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 December 14th, 2006, 07:07 AM
Authorized User
 
Join Date: Jun 2005
Posts: 36
Thanks: 0
Thanked 0 Times in 0 Posts
Send a message via MSN to rajatake
Default To select infinite nested element in XSLT1.0

<root>
<ol>
<li>first</li>
<li>second</li>
<ol>
<li>list2 item3</li>
<li>list2 item2</li>
<ol>
<li>list3 item1</li>
<li>list3 item2</li>
</ol>
</ol>
<li>third></li>
</ol>
</root>

The above is the part of my input file. The nested level of the <ol> is infinitive. I have to apply a template for each <ol> to convert to as <orderedlist>. ie. my output should come like the following


<root>
<orderlist>
<listitem>first</listitem>
<listitem>second</listitem>
<orderlist>
<listitem>list2 item3</listitem>
<listitem>list2 item2</listitem>
<orderlist>
<listitem>list3 item1</listitem>
<listitem>list3 item2</listitem>
</orderlist>
</orderlist>
<listitem>third></listitem>
</orderlist>
</root>


How can write xsl for this. i have just now started to write XSl.

Thanks
Raja

 
Old December 14th, 2006, 07:28 AM
mhkay's Avatar
Wrox Author
 
Join Date: Apr 2004
Posts: 4,962
Thanks: 0
Thanked 292 Times in 287 Posts
Default

A straightforward recursive descent does the job:

<xsl:template match="ol">
 <orderlist>
  <xsl:apply-templates/>
 </orderlist>
</xsl:template>

<xsl:template match="li">
 <listitem>
  <xsl:apply-templates/>
 </listitem>
</xsl:template>

Michael Kay
http://www.saxonica.com/
Author, XSLT Programmer's Reference and XPath 2.0 Programmer's Reference
 
Old December 14th, 2006, 09:32 AM
Authorized User
 
Join Date: Jun 2005
Posts: 36
Thanks: 0
Thanked 0 Times in 0 Posts
Send a message via MSN to rajatake
Default

Kay,
Thank you very much. Its working fine.






Similar Threads
Thread Thread Starter Forum Replies Last Post
Update with nested select darkhalf Access 3 February 1st, 2008 09:30 AM
NESTED GROUPING USING XSLT1.0 jhansib4u Classic ASP XML 0 November 19th, 2007 09:12 AM
XSL select by child element value vivhost XSLT 3 May 21st, 2005 02:58 AM
select wildcard element names groovepapa XSLT 4 September 1st, 2004 08:12 AM
Nested Loop Select Box Issue mat41 Classic ASP Basics 5 August 24th, 2004 11:02 PM





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