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

RE: Identifier attribute (was: Re: Creating Hie

Subject: RE: Identifier attribute (was: Re: Creating Hierarchy)
From: "Michael Kay" <mike@xxxxxxxxxxxx>
Date: Mon, 20 Oct 2008 23:03:19 +0100
RE:  Identifier attribute (was: Re:  Creating  Hie
> How would I generate these id/sequence values, either as a 
> second pass, or as part of the first pass which generates 
> this structure from the non-hierarchical source file?

> <root>
>     <a id="1">
>         <b id="2">
>             <e/>
>         </b>
>         <b id="3">
>             <c id="4"/>
>         </b>

I think the only way to do this is in a second pass. It then becomes fairly
easy:

Assuming you give the elements a blank id attribute in the first pass
(id=""), then in the second pass do

<xsl:template match="*[@id]" mode="pass2">
  <xsl:copy>
    <xsl:attribute name="id">
      <xsl:number level="any" count="*[@id]"/>
    </xsl:attribute>
    <xsl:apply-templates mode="pass2"/>
  </xsl:copy>
</xsl:template>

plus an identity template.

Michael Kay
http://www.saxonica.com/

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.