Subject: RE: [xsl] xsl:number question (XSLT 1.0)|
From: "Michael Kay" <mike@xxxxxxxxxxxx>
Date: Fri, 15 Apr 2005 16:19:36 +0100
I thought the spec was quite clear: (a) If there are more numbers than format tokens, then the last format token will be used to format remaining numbers (b) Each number after the first will be separated from the preceding number by the separator token preceding the format token used to format that number So if there is one format token, then it is used to format all the numbers, and each one is separated from the preceding number by the separator token that precedes that format token. (In reading the XSLT 1.0 spec it helps to know that it was written by James Clark; I asked him many questions similar to yours, and would always get replies that suggested I should take the text as written at face value. He never wasted words, and the text invariably means what it says, even when you think it might not. The fact that the same phrase is used in the two sentences above "the token.. used to format [the number]" is pretty clear evidence of the intention.) Michael Kay http://www.saxonica.com/ > -----Original Message----- > From: Jack Matheson [mailto:jack@xxxxxxxxxxxxxx] > Sent: 15 April 2005 15:31 > To: xsl-list@xxxxxxxxxxxxxxxxxxxxxx > Subject: [xsl] xsl:number question (XSLT 1.0) > > According to the spec, when a sequence number contains more > values than > there are formatting tokens, the last formatting token is > used for the > excess values. Unfortunately, it is a little vague on which separator > token to use with the excess values. > > It says that a '.' is to be used if no separator token > exists, but does > this also apply to the case where the final formatting token > is re-used > with excess sequence values? > > Here is a quick test I did to try and see how different > processors are > handling this: > > <xsl:stylesheet xmlns:xsl="http://www.w3.org/1999/XSL/Transform" > version="1.0"> > <xsl:template match="a/b/c/d"> > <xsl:number level="multiple" count="*" format="(1)"/> > </xsl:template> > </xsl:stylesheet> > > If my input document is... > > <?xml version="1.0"?> > <a><b><c><d/></c></b></a> > > > ...then Saxon produces this: > (1(2(1(1) > > ...while Xalan produces this: > (188.8.131.52) > > Both answers seem perfectly reasonable to me, given the lack > of clarity > in the 1.0 spec. > Can anyone help me figure out which is (more) correct?