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

RE: numbering and document()

Subject: RE: numbering and document()
From: "Michael Kay" <mhk@xxxxxxxxx>
Date: Fri, 22 Aug 2003 18:54:58 +0100
numbering a document
I think this needs a two-pass solution. Assemble the combined document
first, then number the nodes.

You can do a two-pass transformation either using two separate
stylesheets, or with a single stylesheet that writes the result of the
first pass to a result-tree-fragment and then uses xx:node-set() to open
it as a new source document.

Michael Kay

> -----Original Message-----
> From: owner-xsl-list@xxxxxxxxxxxxxxxxxxxxxx 
> [mailto:owner-xsl-list@xxxxxxxxxxxxxxxxxxxxxx] On Behalf Of 
> Felix Breuer
> Sent: 22 August 2003 17:20
> To: XSL-List@xxxxxxxxxxxxxxxxxxxxxx
> Subject:  numbering and document()
> 
> 
> Hello!
> 
> The XML DT I am creating a stylesheet for has an
> 
> <include file="sub.xml"/>
> 
> element, which can be used to include sub.xml seamlessly in 
> the main document. Now, suppose the documents look like this
> 
> main.xml:
> -----------------------------
> <doc>
>     <section/>
>     <section/>
>     <include file="sub.xml"/>
>     <section/>
> </doc>
> -----------------------------
> 
> sub.xml:
> -----------------------------
> <doc>
>     <section/>
>     <section/>
> </doc>
> -----------------------------
> 
> and my stylesheet is supposed to number the sections in these 
> documents in the following way:
> 
> 1 Section
> 2 Section
> 3 Section     <--- from sub.xml
> 4 Section     <--- from sub.xml
> 5 Section
> 
> whereas 4 and 5 are from sub.xml. I tried to achieve this 
> using the following templates:
> 
> <xsl:template match="section>
>     <xsl:number/> Section
> </xsl:template>
> 
> <xsl:template match="include">
>     <xsl:for-each select="document(@file)/doc/*">
>         <xsl:apply-templates select="self::section"/>
>     </xsl:for-each>
> </xsl:template>
> 
> but the numbering I get, is
> 
> 1 Section
> 2 Section
> 1 Section     <--- from sub.xml
> 2 Section     <--- from sub.xml
> 3 Section
> 
> I am at a loss as to how to solve this problem. If anybody 
> has an idea, please tell me.
> 
> Thanks in advance,
> Felix Breuer
> 
> 
>  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

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-2013 All Rights Reserved.