Wrox Programmer Forums

Need to download code?

View our list of code downloads.

Go Back   Wrox Programmer Forums > XML > XSLT
Password Reminder
Register
| FAQ | Members List | Calendar | Search | Today's Posts | Mark Forums Read
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 tens of thousands of software programmers and website developers including Wrox book authors and readers. As a guest, you can read any forum posting. By joining today you can post your own programming questions, respond to other developers’ questions, and eliminate the ads that are displayed to guests. Registration is fast, simple and absolutely free .
DRM-free e-books 300x50
Reply
 
Thread Tools Search this Thread Display Modes
  #1 (permalink)  
Old October 4th, 2010, 10:54 AM
Authorized User
 
Join Date: Sep 2008
Location: , , .
Posts: 56
Thanks: 0
Thanked 1 Time in 1 Post
Default Display all nodes of an XML

<?xml version="1.0" encoding="UTF-8"?>
<root>
<node category="A" name="levelOne" title="Home" link="/index.jsp">
<node category="B" name="levelTwo" title="Residential" link="/levelTwo/index.jsp">
<node category="A" name="levelThree" title="Food Waste" link="/levelThree/food/food-waste.jsp">
<node category="A" name="levelFour" title="junk Waste" link="/levelFour/food/junk.jsp"/>
<node category="A" name="levelFour" title="PC Waste" link="/levelFour/food/pcwaste.jsp"/>
</node>
</node>
<node category="A" name="levelTwo" title="Residential II" link="/levelTwo/index.jsp">
<node category="B" name="levelThree" title="Health Care" link="/levelThree/health/index.jsp">
<node category="A" name="levelFour" title="med Disposal" link="/levelFour/health/test.jsp"/>
</node>
</node>
<node category="C" name="levelTwo" title="Residential III" link="/levelTwo/index.jsp">
<node category="B" name="levelThree" title="Curb" link="/levelThree/health/index.jsp">
<node category="B" name="levelFour" title="Site Disposal" link="/levelFour/health/testing.jsp"/>
<node category="B" name="levelFour" title="car Disposal" link="/levelFour/health/car.jsp"/>
</node>
</node>
</node>

</root>

Based on the XML above how do I get this output.



(Residential)
Food Waste
(1)junk Waste
(2)PC waste

(Residential II)
Health Care
(1)med Disposal

(Residential III)
Curb
(1)Site Disposal
Reply With Quote
  #2 (permalink)  
Old October 4th, 2010, 11:54 AM
samjudson's Avatar
Friend of Wrox
Points: 8,687, Level: 40
Points: 8,687, Level: 40 Points: 8,687, Level: 40 Points: 8,687, Level: 40
Activity: 0%
Activity: 0% Activity: 0% Activity: 0%
 
Join Date: Aug 2007
Location: Newcastle, , United Kingdom.
Posts: 2,128
Thanks: 1
Thanked 189 Times in 188 Posts
Default

Code:
   <xsl:template match="node[@name='levelTwo']">
	     (<xsl:value-of select="@title"/>)
	     <xsl:apply-templates/>
	     <xsl:text>
</xsl:text>
   </xsl:template>

   <xsl:template match="node[@name='levelThree']">
	     <xsl:value-of select="@title"/>
	     <xsl:apply-templates/>
   </xsl:template>

   <xsl:template match="node[@name='levelFour']">
	     (<xsl:value-of select="position()"/>) <xsl:value-of select="@title"/>
	     <xsl:apply-templates/>
   </xsl:template>
   
	  <xsl:template match="text()"/>
__________________
/- Sam Judson : Wrox Technical Editor -/

Think before you post: What have you tried?
Reply With Quote
Reply


Thread Tools Search this Thread
Search this Thread:

Advanced Search
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is Off
HTML code is Off
Trackbacks are Off
Pingbacks are On
Refbacks are Off


Similar Threads
Thread Thread Starter Forum Replies Last Post
Display only unique Nodes kylektran XSLT 1 July 17th, 2009 08:41 AM
How can I display parent & child nodes if XML .... vishnu108mishra ASP.NET 2.0 Basics 0 November 17th, 2007 07:45 AM
HOW TO: Display specified # of nodes kwilliams XSLT 2 October 5th, 2005 11:04 AM
Display nodes from xml nambati XSLT 2 September 17th, 2004 07:57 AM
How to display all nodes in my Network using VB 6 harini19 VB How-To 1 January 16th, 2004 10:10 AM



All times are GMT -4. The time now is 09:00 PM.


Powered by vBulletin®
Copyright ©2000 - 2019, Jelsoft Enterprises Ltd.
© 2013 John Wiley & Sons, Inc.