Subject: RE: [xsl] more xsl:number confusion! From: "Michael Kay" <mike@xxxxxxxxxxxx> Date: Wed, 28 Sep 2005 10:16:54 +0100 |
You need to assess the behavior of an XSLT 1.0 processor against the 1.0 spec, and a 2.0 processor against the 2.0 spec. The 2.0 spec was intended to get as close as we could to a formalization of the 1.0 rules, but there are so many ambiguities and strange corner cases in the 1.0 spec that this can't be guaranteed in all cases. In most cases if the two are different, it's because 1.0 was unclear. This seems to be an exception. The main area where 1.0 is unclear is what happens if there's no ancestor that matches the from pattern. But there are a few other difficulties as well: with level="single", for example, it says "it goes up to the first node in the ancestor-or-self axis" and then says "if there is no such ancestor": this can only really mean "if there is no such ancestor-or-self". This leads one to suspect that "ancestor" in the next sentence "the only ancestors that are searched" should also read ancestors-or-self; which in turn leads one to adopt the same meaning for this phrase under level="multiple". We felt that it was worth formalizing the definition in 2.0 to remove ambiguities, even though this creates the risk of incompatibilities in edge cases. Michael Kay http://www.saxonica.com/ > -----Original Message----- > From: Jack Matheson [mailto:jack@xxxxxxxxxxxxxx] > Sent: 27 September 2005 21:50 > To: xsl-list@xxxxxxxxxxxxxxxxxxxxxx > Subject: [xsl] more xsl:number confusion! > > I have the following input document: > > <?xml version="1.0"?> > <a> > <b/> > </a> > > ...and I am trying to determine why this stylesheet is not behaving > as I would expect: > > <?xml version="1.0"?> > <xsl:stylesheet xmlns:xsl="http://www.w3.org/1999/XSL/Transform" > version="1.0"> > <xsl:output omit-xml-declaration="yes"/> > <xsl:template match="a/b"> > xsl:number result: (<xsl:number level="multiple" count="a" > from="a"/>) > <xsl:variable name="S" select="."/> > <xsl:variable name="A" > select="$S/ancestor-or-self::node()[local- > name() = 'a']"/> > <xsl:variable name="F" > select="$S/ancestor-or-self::node()[local- > name() = 'a'][1]"/> > <xsl:variable name="AF" select="$A[count(.|$F) = count($F)]"/> > sequence number should contain: (<xsl:for-each select="$AF"> > <xsl:value-of select="1 + count($AF/preceding-sibling::node() > [local-name() = 'a'])"/> > <xsl:text> </xsl:text> > </xsl:for-each>) > </xsl:template> > </xsl:stylesheet> > > > I emit the result of an xsl:number when both the from and count > patterns are the parent of the context node. The result is empty. > However, if I follow the explicit instructions on how to determine a > sequence number, it seems like this should contain a single > integer of value 1. > > The output I get from Xalan and Saxon both is: > > xsl:number result: () > > sequence number should contain: (1 ) > > Can anyone help explain why the xsl:number value is not the same as > the hand-computed value? > > NOTE: I used a very simple local-name() test in place of a node-type > and node-name test. I realize > this is not the same as matching the pattern "a", but it should > suffice for this example.
Current Thread |
---|
|
<- Previous | Index | Next -> |
---|---|---|
Re: [xsl] more xsl:number confusion, Jack Matheson | Thread | [xsl] Ignore Namespace while transf, jaya vardhani |
Re: [xsl] XSLT recursion problem, Ragulf Pickaxe | Date | Re: [xsl] XSLT recursion problem, M. David Peterson |
Month |