Welcome to WebmasterWorld Guest from 54.167.129.169

Forum Moderators: httpwebwitch

Message Too Old, No Replies

Links, For Each, and xml

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

New User

5+ Year Member

joined:May 18, 2009
posts: 1
votes: 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" />

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

Moderator This Forum from CA 

WebmasterWorld Administrator httpwebwitch is a WebmasterWorld Top Contributor of All Time 10+ Year Member

joined:Aug 29, 2003
posts:4059
votes: 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...]

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

Moderator This Forum from CA 

WebmasterWorld Administrator httpwebwitch is a WebmasterWorld Top Contributor of All Time 10+ Year Member

joined:Aug 29, 2003
posts:4059
votes: 0


welcome to WebmasterWorld!

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

 

Join The Conversation

Moderators and Top Contributors

Hot Threads This Week

Featured Threads

Free SEO Tools

Hire Expert Members