Subject: [xsl] Re: Subject: One-based indexes in XPath From: "John Cavalieri" <john.cavalieri@xxxxxxxxx> Date: Wed, 21 May 2008 12:55:35 -0500 |
For processing content, one-based makes a lot of sense. <book> <chapter/> <chapter/> <chapter/> </book> Do I select the zero chapter or the first chapter? For arrays it is neither here nor there. Javascript, Java, C++, CSharp use zero-base notation because they all borrow their syntax from C. -- John Cavalieri john.cavalieri@xxxxxxxxx >From: Justin Johansson <procode@xxxxxxxxxxx> >Subject: One-based indexes in XPath > >Trusting this question is relevant to the XSL List. > >Would someone please give me advice as to why "1-based" indexes are used in >XPath, such as para[1] instead of para[0] for the first para item/element? > >Why does the spec for XPath (and its/XQuery operator/function library) go >against the norm for modern programming languages in which zero is the base >for array-like collections? > >The reason for my question is to do with reconciling XPath and XSLT with an >implementation in Javascript in which zero is the base index for arrays. >My users may well be perplexed by having to decide whether an index number >is in XPath/XSLT-world or Javascript-world. > >Thanks for comments, > >Justin Johansson
Current Thread |
---|
|
<- Previous | Index | Next -> |
---|---|---|
RE: [xsl] Variable containing uniqu, Hesselberth, Jan | Thread | [xsl] How to beautify XML source co, Ben Stover |
Re: [xsl] Variable containing uniqu, Mukul Gandhi | Date | RE: [xsl] How to list the internall, Ben Stover |
Month |