Wrox Programmer Forums
Go Back   Wrox Programmer Forums > XML > XSLT
|
XSLT General questions and answers about XSLT. For issues strictly specific to the book XSLT 1.1 Programmers Reference, please post to that forum instead.
Welcome to the p2p.wrox.com Forums.

You are currently viewing the XSLT section of the Wrox Programmer to Programmer discussions. This is a community of software programmers and website developers including Wrox book authors and readers. New member registration was closed in 2019. New posts were shut off and the site was archived into this static format as of October 1, 2020. If you require technical support for a Wrox book please contact http://hub.wiley.com
 
Old May 10th, 2004, 09:09 AM
Registered User
 
Join Date: May 2004
Posts: 2
Thanks: 0
Thanked 0 Times in 0 Posts
Default convert elements based on place in document

hi all,

i have a document with 7 recurring elements, the problem is they all have the same name/attributes.
is there a possibility to 'rename' them according to their place in the document ?
the first element of the recurring cyclus always has the same text. e.g. "start"
sourcefile :
<par>start</par>
<par>random text1</par>
<par>random text2</par>
<par>random text3</par>
<par>random text4</par>
<par>start</par>
<par>random text5</par>
...
endfile :
<element1>start</element1>
<element2>random text1</element2>
<element3>random text2</element3>
<element4>random text3</element4>
<element5>random text4</element5>
<element1>start</element1>
<element2>random text5</element2>

can this be done in xslt ?
thanx in advance

 
Old May 12th, 2004, 08:22 PM
Registered User
 
Join Date: Apr 2004
Posts: 4
Thanks: 0
Thanked 0 Times in 0 Posts
Default

The short answer is - yes.

 
Old May 17th, 2004, 05:32 AM
Registered User
 
Join Date: May 2004
Posts: 7
Thanks: 0
Thanked 0 Times in 0 Posts
Default

Have a look at the generate-id() and key() fumctions.
Then use the xsl:element with parameters generated from the above functions.






Similar Threads
Thread Thread Starter Forum Replies Last Post
accessing elements using document() function geoGregory3 XSLT 2 February 28th, 2008 07:39 PM
Excluding Elements based on a Predicate Condition tasmisr XSLT 3 February 27th, 2008 01:00 PM
Comparing elements in an XML document dlorenz XSLT 0 August 7th, 2007 05:28 PM
convert list of ';' separated values --> elements Condor76 XSLT 1 June 11th, 2007 02:56 PM





Powered by vBulletin®
Copyright ©2000 - 2020, Jelsoft Enterprises Ltd.
Copyright (c) 2020 John Wiley & Sons, Inc.