[XSL-LIST Mailing List Archive Home] [By Thread] [By Date] [Recent Entries] [Reply To This Message]

Apply <xsl:number level="any"/> across a collection?

Subject: Apply <xsl:number level="any"/> across a collection?
From: David Sewell <dsewell@xxxxxxxxxxxx>
Date: Mon, 8 Oct 2007 16:52:44 -0400 (EDT)
 Apply <xsl:number level="any"/> across a collection?
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.)

DS

-- 
David Sewell, Editorial and Technical Manager
ROTUNDA, The University of Virginia Press
PO Box 801079, Charlottesville, VA 22904-4318 USA
Courier: 310 Old Ivy Way, Suite 302, Charlottesville VA 22903
Email: dsewell@xxxxxxxxxxxx   Tel: +1 434 924 9973
Web: http://rotunda.upress.virginia.edu/

Current Thread

PURCHASE STYLUS STUDIO ONLINE TODAY!

Purchasing Stylus Studio from our online shop is Easy, Secure and Value Priced!

Buy Stylus Studio Now

Download The World's Best XML IDE!

Accelerate XML development with our award-winning XML IDE - Download a free trial today!

Don't miss another message! Subscribe to this list today.
Email
First Name
Last Name
Company
Subscribe in XML format
RSS 2.0
Atom 0.3
Site Map | Privacy Policy | Terms of Use | Trademarks
Free Stylus Studio XML Training:
W3C Member
Stylus Studio® and DataDirect XQuery™are products from DataDirect Technologies, is a registered trademark of Progress Software Corporation, in the U.S. and other countries. © 2004-2007 All Rights Reserved.