Subject: RE: number for attributes vs elements From: Andrew Kimball <akimball@xxxxxxxxxxxxx> Date: Mon, 15 May 2000 18:58:01 -0700 |
>From section 7.7 of the spec: When level="any", it constructs a list of length one containing the number of nodes that match the count pattern and belong to the set containing the current node and all nodes at any level of the document that are before the current node in document order, <MY-EMPHASIS>excluding any namespace and attribute nodes</MY-EMPHASIS>. This is why your "xsl:template" example works and your "match" doesn't. Only the "match" attribute itself is counted--other match attributes on previous elements are never even considered. I think Saxon is correct and XT has a bug. ~Andy Kimball MSXSL Dev -----Original Message----- From: Mike Brown [mailto:mike@xxxxxxxx] Sent: Monday, May 15, 2000 5:52 PM To: xsl-list@xxxxxxxxxxxxxxxx Subject: xsl:number for attributes vs elements This stylesheet, when applied to itself or any other stylesheet, does the simple identity transformation, with a couple of additions: Elements that have an attribute named 'match' will have an extra attribute added: 'matchCount1'. The value of this attribute will be the the result of <xsl:number level="any"/>, with the current node being the 'match' attribute. In this context I would predict that the number inserted would be the position of the attribute relative to all preceding 'match' attributes. So I would expect that the first 'match' would be number 1, the second would be number 2, and so on. However, SAXON says they're all number 1, and XT, once the requisite adjustments are made for the lack of match="node()" implementation, doesn't insert any number at all. I also have elements named 'template' in the namespace assigned to the prefix 'xsl' by this stylesheet (i.e., xsl:template elements) having a 'matchCount2' attribute added. The value of this attribute will be the result of <xsl:number level="any"/>, with the current node being the xsl:template element. In this context, I would predict the same results -- the number inserted should be the position of the xsl:template element relative to all preceding xsl:template elements. This works as expected in SAXON, with the numbers being 1, 2 and 3 in order. Am I misunderstanding what xsl:number should do here? I don't see why attributes are treated differently than elements for counting purposes. The stylesheet: <?xml version="1.0" encoding="utf-8"?> <xsl:stylesheet xmlns:xsl="http://www.w3.org/1999/XSL/Transform" version="1.0"> <xsl:output method="xml" version="1.0" indent="no"/> <xsl:template match="node()|@*"> <xsl:copy> <xsl:apply-templates select="node()|@*"/> </xsl:copy> </xsl:template> <xsl:template match="@match"> <xsl:copy/> <xsl:attribute name="matchCount1"> <xsl:number level="any"/> </xsl:attribute> </xsl:template> <xsl:template match="xsl:template"> <xsl:copy> <xsl:attribute name="matchCount2"> <xsl:number level="any"/> </xsl:attribute> <xsl:apply-templates select="node()|@*"/> </xsl:copy> </xsl:template> </xsl:stylesheet> Result of applying the stylesheet to itself with SAXON 5.3.1: <?xml version="1.0" encoding="utf-8" ?><xsl:stylesheet xmlns:xsl="http://www.w3.org/1999/XSL/Transform" version="1.0"> <xsl:output method="xml" version="1.0" indent="no"/> <xsl:template matchCount2="1" match="node()|@*" matchCount1="1"> <xsl:copy> <xsl:apply-templates select="node()|@*"/> </xsl:copy> </xsl:template> <xsl:template matchCount2="2" match="@match" matchCount1="1"> <xsl:copy/> <xsl:attribute name="matchCount1"> <xsl:number level="any"/> </xsl:attribute> </xsl:template> <xsl:template matchCount2="3" match="xsl:template" matchCount1="1"> <xsl:copy> <xsl:attribute name="matchCount2"> <xsl:number level="any"/> </xsl:attribute> <xsl:apply-templates select="node()|@*"/> </xsl:copy> </xsl:template> </xsl:stylesheet> XSL-List info and archive: http://www.mulberrytech.com/xsl/xsl-list XSL-List info and archive: http://www.mulberrytech.com/xsl/xsl-list
Current Thread |
---|
|
<- Previous | Index | Next -> |
---|---|---|
RE: Fwds Compat/Fallback Conformanc, Kay Michael | Thread | RE: number for attributes vs elemen, Kay Michael |
Fwds Compat/Fallback Conformance Pu, Andrew Kimball | Date | Re: apos output problems, Scott Boag/CAM/Lotus |
Month |