[XSL-LIST Mailing List Archive Home] [By Thread] [By Date] [Recent Entries] [Reply To This Message]

Re: One-based indexes in XPath

Subject: Re: One-based indexes in XPath
From: "Colin Adams" <colinpauladams@xxxxxxxxxxxxxx>
Date: Tue, 20 May 2008 17:48:46 +0100
Re:  One-based indexes in XPath
Zero is NOT the norm for modern programming languages. It might well
be for ancient ones. It is a very poor choice, justifiable only when
trying to squeeze the last ounce of speed in a highly
numerically-intensive application.

And even there it is not justified - you simply use data structures
that have an unused first element, and so avoid the subtract one
operation in that way.

2008/5/20 Justin Johansson <procode@xxxxxxxxxxx>:
> 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

PURCHASE STYLUS STUDIO ONLINE TODAY!

Purchasing Stylus Studio from our online shop is Easy, Secure and Value Priced!

Buy Stylus Studio Now

Download The World's Best XML IDE!

Accelerate XML development with our award-winning XML IDE - Download a free trial today!

Don't miss another message! Subscribe to this list today.
Email
First Name
Last Name
Company
Subscribe in XML format
RSS 2.0
Atom 0.3
Site Map | Privacy Policy | Terms of Use | Trademarks
Free Stylus Studio XML Training:
W3C Member
Stylus Studio® and DataDirect XQuery ™are products from DataDirect Technologies, is a registered trademark of Progress Software Corporation, in the U.S. and other countries. © 2004-2013 All Rights Reserved.