GIDForums  

Go Back   GIDForums > Webmaster Forums > Web Design Forum
User Name
Password
Register FAQ Members List Calendar Search Today's Posts Mark Forums Read

 
 
Thread Tools Search this Thread Rate Thread
  #1  
Old 09-Oct-2009, 01:39
blakekl's Avatar
blakekl blakekl is offline
Junior Member
 
Join Date: Nov 2007
Posts: 33
blakekl will become famous soon enough

XML and XSLT nesting elements


I was wondering if it's possible to have an xml document that nests tags, it nests the same tags within itself, actually.
so for instance, it has a <feature> tag that is allowed to hold other <feature> tags inside of it. I tried writing an XSLT for this, but I'm having trouble getting it to parse properly. Here is the code for it.
HTML Code:
<xsl:template match="section"> <div class="section"> <h2>Section Title: <xsl:value-of select="@title"/></h2> <xsl:for-each select="feature"> <div class="feature"> <h2>Feature Title: <xsl:value-of select="@title"/></h2> <h3>Purpose: <xsl:value-of select="./purpose"/></h3> <h3>Users:</h3> <ul> <xsl:for-each select="user"> <li><xsl:value-of select="."/></li> </xsl:for-each> </ul> <xsl:for-each select="./feature"> <xsl:apply-template select="."/> </xsl:for-each> </div> </xsl:for-each> </div> </xsl:template> <xsl:template match="feature"> <xsl:value-of select="title"/> </xsl:template>

I get this error when I try to view the xml document in firefox:
Error loading stylesheet: Parsing an XSLT stylesheet failed. Any help?
  #2  
Old 09-Oct-2009, 15:19
blakekl's Avatar
blakekl blakekl is offline
Junior Member
 
Join Date: Nov 2007
Posts: 33
blakekl will become famous soon enough

Re: XML and XSLT nesting elements


Well, I figured it out on my own. You can definitely accomplish what I was trying to do. Here's the code, just so everyone else can see how it's done.
HTML Code:
<xsl:template match="section"> <div class="section"> <h2><xsl:value-of select="@title"/></h2> <xsl:for-each select="feature"> <xsl:apply-templates select="."/> </xsl:for-each> <xsl:apply-templates select="section"/> </div> </xsl:template>
As you can see, <section> is allowed to be nested under <section>. This displays properly.
 
 

Recent GIDBlogProblems with the Navy (Chiefs) by crystalattice

Thread Tools Search this Thread
Search this Thread:

Advanced Search
Rate This Thread
Rate This Thread:

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

vB code is On
Smilies are On
[IMG] code is Off
HTML code is Off
Forum Jump

Network Sites: GIDNetwork · GIDWebHosts · GIDSearch · Learning Journal by J de Silva, The

All times are GMT -6. The time now is 15:35.


vBulletin, Copyright © 2000 - 2009, Jelsoft Enterprises Ltd.