Subject: Re: [xsl] Apply <xsl:number level="any"/> across a collection? From: "G. Ken Holman" <gkholman@xxxxxxxxxxxxxxxxxxxx> Date: Mon, 08 Oct 2007 17:05:08 -0400 |
Suppose I am operating on a collection of XML documents returned by collection("docs.xml"). Further suppose that each document node returned by collection() contains <p> elements that I want to number sequentially across the collection in my output. (And assume XSLT 2.0.)
My first stab at this was along these lines:
<xsl:apply-templates select="collection('docs.xml')"/>
... intermediate templates ...
<xsl:template match="p"> <xsl:copy> <xsl:attribute name="number"> <xsl:number level="any"/> </xsl:attribute> <xsl:apply-templates/> </xsl:copy> </xsl:template>
Output is all as desired except that the numbering is reset to 1 at each document node. Is it a built-in limitation of xsl:number that operates within single document nodes only
, or am I missing some way to accomplish what I want other than putting the whole collection into a variable like so:
<xsl:variable name="wrapper"> <wrapper> <xsl:sequence select="collection('docs.xml')"/> </wrapper> </xsl:variable>
and then applying templates to $wrapper? (This works fine, I'm just wondering if it's the optimal solution.)
-- World-wide corporate, govt. & user group XML, XSL and UBL training RSS feeds: publicly-available developer resources and training G. Ken Holman mailto:gkholman@xxxxxxxxxxxxxxxxxxxx Crane Softwrights Ltd. http://www.CraneSoftwrights.com/s/ Box 266, Kars, Ontario CANADA K0A-2E0 +1(613)489-0999 (F:-0995) Male Cancer Awareness Jul'07 http://www.CraneSoftwrights.com/s/bc Legal business disclaimers: http://www.CraneSoftwrights.com/legal
Current Thread |
---|
|
<- Previous | Index | Next -> |
---|---|---|
[xsl] Apply <xsl:number level="any", David Sewell | Thread | [xsl] Add numbers, Chaudhary, Harsh |
[xsl] Apply <xsl:number level="any", David Sewell | Date | RE: [xsl] XML/XSLT for web templati, Michael Kay |
Month |