homepage Welcome to WebmasterWorld Guest from 54.226.180.223
register, free tools, login, search, subscribe, help, library, announcements, recent posts, open posts,
Subscribe to WebmasterWorld
Home / Forums Index / Code, Content, and Presentation / XML Development
Forum Library, Charter, Moderators: httpwebwitch

XML Development Forum

    
Links, For Each, and xml
travel618




msg:3915787
 2:18 pm on May 18, 2009 (gmt 0)

I am new to xml and having trouble with the code below. The rest of my page works perfectly. I am trying to pull in an external link and an internal link and nothing shows. The internal link text is the NavName attribute and the external link text is the Link attribute.

Does anyone see what I am doing wrong?

Here's the xsl.
____________________
<p>
<xsl:for-each select="Page">
<choose>
<when>
<a href="@URL"><value-of select="@Link" /></a>
</when>
<otherwise>
<a href="@URL"><value-of select="@NavName" /></a>
</otherwise>
</choose>
</xsl:for-each>
</p>
Here's the xml
________________
<Page Name="LinkList" Link="Test" URL="http://www.google.com" />
<Page ID="x1092" Name="LinkList" Link="People & Communities" URL="x1092.xml?Preview=true&Site=&UserAgent=&IncludeAllPages=true&tfrm=4" Title="People & Communities" Abstract="People & Communities" NavName="People & Communities" CreationDate="20090513T14:32:00" Changed="20090513T18:33:10" CategoryIds="" Schema="SectionFront" />

 

httpwebwitch




msg:3916148
 1:25 am on May 19, 2009 (gmt 0)

1) you need to prepend all XSLT entities with the XSL namespace.

<xsl:choose>
<xsl:when>

2) invalid XSLT syntax:
<a href="@URL">

should be

<a>
<xsl:attribute name="href" value="@URL"/>
<value-of select="@NavName" />
</a>

3) <xsl:choose> and <xsl:when> requires a conditional statement (it's analogous to an "if" statement...

W3Schools has some wicked tutorials on XSLT.
[w3schools.com...]

httpwebwitch




msg:3916428
 1:30 pm on May 19, 2009 (gmt 0)

welcome to WebmasterWorld!

Take a moment to peruse the Terms of Service [webmasterworld.com], then introduce yourself [webmasterworld.com] to the community.

Global Options:
 top home search open messages active posts  
 

Home / Forums Index / Code, Content, and Presentation / XML Development
rss feed

All trademarks and copyrights held by respective owners. Member comments are owned by the poster.
Home ¦ Free Tools ¦ Terms of Service ¦ Privacy Policy ¦ Report Problem ¦ About ¦ Library ¦ Newsletter
WebmasterWorld is a Developer Shed Community owned by Jim Boykin.
© Webmaster World 1996-2014 all rights reserved