Re: [xsl] collapsing number ranges

Subject: Re: [xsl] collapsing number ranges
From: J-P S <jps@xxxxxxxxxxxxxxxxxxxx>
Date: Mon, 30 Aug 2004 10:53:20 +0100 (BST)
On Mon, 30 Aug 2004, Jeni Tennison wrote:

) There are type-related implications: some people would say that since
) the values of $begin and $end are integers, you should process them as
) integers rather than pretending that they're strings.

You'd have to look to the schema for a declaration of their integral
nature, though, wouldn't you? So unless you're specifically typing (and
worrying about that later on) then they might as well be strings.

There's also the argument that idiv and mod are general functions which
don't depend on the base, whereas any string function assumes base 10.
Hence if you really wanted to then you could adapt these functions to
count pages in base 8, or base 13. Again, so long as your code is
watertight and won't need extending then that's probably moot.

(Incidentally, Bruce: I can't remember whether it was answered here, or
whether this was the level you wanted the answer pitched at, but "a mod b"
yields the remainder when a is divided by b, and "a idiv b"  gives you the
number of times b is divisible into a, not including the remainder. Thus

	a = (a idiv b) * b + (a mod b)

I think. The other numerical operators are more obvious and their usage is
explained in W3Schools' tutorials, although I can't immediately see idiv
as a function - is that new XPathery? Off the top of my Google there's a
brief tutorial at http://saxon.sourceforge.net/saxon7.9.1/expressions.html
that covers XPath 2.0)

Cheers,
J-P
-- 
Some pigs lead a revolt against people, act like jerks, and play poker.

Current Thread