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 February 15th, 2010, 10:48 AM
Registered User
 
Join Date: Nov 2008
Posts: 4
Thanks: 1
Thanked 0 Times in 0 Posts
Default processing element within element

Hi,
I have a problem with processing a list within list:

Source snippet:
Code:
<Paragraph process="False">
   <ParagraphContent>Blah Blah Blah</ParagraphContent>
</Paragraph>

<Paragraph process="True">
   <ParagraphContent>
         <List>
             <ListItem>A List entry</ListItem>
             <ListItem>
                   <List>
                      <ListItem>Another List entry</ListItem>
                  </List>
          <List>
     </ParagraphContent>
</Paragraph>
The transform :
Code:
<xsl:template match="Paragraph[@Process='True']">
   <div><xsl:apply-templates/><div>
</xsl:template>

<xsl:template match="List">
  <list><xsl:apply-templates/></list>
</xsl:template>

<xsl:template match="ListItem>
   <li><xsl:value-of select="."/></li>
</template>
What I get as an output:
Code:
<div>
  <list>
   <li>A list entryAnother List entry</li>
  </list>
</div>

What I would like to see as an output:
Code:
<div>
   <list>
      <li>A list entry</li>
       <li>
          <list>
              <li>Another List entry</li>
          </list>
        </li>
     </list>
I can see where I am going wrong in that xsl:value-of probably isnt the way forward. Has anyone got any ideas?

Many thanks

Last edited by Krippers; February 15th, 2010 at 10:50 AM..
 
Old February 15th, 2010, 10:54 AM
Friend of Wrox
 
Join Date: Nov 2007
Posts: 1,243
Thanks: 0
Thanked 245 Times in 244 Posts
Default

Don't use xsl:value-of, instead use xsl:apply-templates:
Code:
<xsl:template match="ListItem>
   <li><xsl:apply-templates/></li>
</template>
__________________
Martin Honnen
Microsoft MVP (XML, Data Platform Development) 2005/04 - 2013/03
My blog
The Following User Says Thank You to Martin Honnen For This Useful Post:
Krippers (February 15th, 2010)
 
Old February 15th, 2010, 11:06 AM
Registered User
 
Join Date: Nov 2008
Posts: 4
Thanks: 1
Thanked 0 Times in 0 Posts
Default

Quote:
Originally Posted by Martin Honnen View Post
Don't use xsl:value-of, instead use xsl:apply-templates:
Code:
<xsl:template match="ListItem>
   <li><xsl:apply-templates/></li>
</template>

thats the one thanks.

Thats the problem with learning c#, citrix, xml, xslt, CMS, html, UNIX, LINUX, and Network engineering all at the same time, one forgets the basics, like eating and sleeping. Cheers for the help





Similar Threads
Thread Thread Starter Forum Replies Last Post
Chapter 9: Element[user control] is not a known element Arya BOOK: Beginning ASP.NET 3.5 : in C# and VB BOOK ISBN: 978-0-470-18759-3 2 December 20th, 2009 07:31 AM
Problem adding element to the previous element dani1 XSLT 5 September 10th, 2008 01:38 AM
processing instruction vs. element bcogney XML 6 April 10th, 2007 03:46 PM
translate element name to element name lexzeus XSLT 3 September 4th, 2006 09:04 AM
adding of element and assigning to one element sushovandatta XSLT 2 November 16th, 2004 07:04 PM





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