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

RE: Duplicate Nodes in XSL and transform them

Subject: RE: Duplicate Nodes in XSL and transform them
From: "Michael Kay" <mike@xxxxxxxxxxxx>
Date: Tue, 30 Jan 2007 17:56:42 -0000
RE:  Duplicate Nodes in XSL and transform them
> -A template that takes any node and copies it -Each copy has 
> to replace a string "replaceMe" with the string "replaced" + 
> i. ( 'i' being the iteration of the copy)

Generally, it's reasonably easy to generate numbers that are computed by
reference to the position of a node in the source tree. In some special
cases you can also use position() to generate a number that reflects the
position in the result tree. But in the general case, this kind of problem
is best tackled as a two-pass transformation, in which you generate the
numbers in the second pass. For example, rather than inserting a sequential
number, insert <n/>, and then in the second pass do a "modified copy"
transformation with

<xsl:template match="n">
  <xsl:number level="any"/>
</xsl:template>

(You can do a two-pass transform with two stylesheets, or within a single
stylesheet, whichever is most convenient. Using two stylesheets is a bit
harder to set up but gives you more reusable code.)

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.