Need XSL list of XML links

D

Donald Firesmith

How do I use XSL to generate and XHTML list of hyperlinks stored in XML?

My XML contains links of examples of the form:

<examples>
<example>
<link url="aURL">some text</link>
<info>some more text</info>
</example>
<example>
<link url="aURL">some text</link>
<info>some more text</info>
</example>
</examples>

My XSL looks like this:

<ul>
<xsl:for-each select="examples/example">
<li><a href="<xsl:value-of select="@url"/>">
<xsl:value-of select="." disable-output-escaping="yes"/>
<xsl:value-of select="info"/>
</a></li>
</xsl:for-each>
</ul>

I can't seem to get this to work. The url parameter won't fit in the
link. Can anyone show me the proper XSL code for this? Also what
should the XSL code look like if info is optional?

Thanks.

Don
 
J

Joris Gillis

<li><a href="<xsl:value-of select="@url"/>">
Make that <li<a href="{@url}">


regards,
 
A

anonymous

Donald said:
How do I use XSL to generate and XHTML list of hyperlinks stored in XML?

My XML contains links of examples of the form:

<examples>
<example>
<link url="aURL">some text</link>
<info>some more text</info>
</example>
<example>
<link url="aURL">some text</link>
<info>some more text</info>
</example>
</examples>

My XSL looks like this:

<ul>
<xsl:for-each select="examples/example">
<li><a href="<xsl:value-of select="@url"/>">
<xsl:value-of select="." disable-output-escaping="yes"/>
<xsl:value-of select="info"/>
</a></li>
</xsl:for-each>
</ul>

I can't seem to get this to work. The url parameter won't fit in the
link. Can anyone show me the proper XSL code for this? Also what
should the XSL code look like if info is optional?

Thanks.

Don

Look into a construct like this:

<a>
<xsl:attribute name="href">
<xsl:value-of select =....../>
</xsl:attribute>
Link text goes here
</a>

Where your @url stuff goes in the value-of section of the attribute.
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Members online

No members online now.

Forum statistics

Threads
473,999
Messages
2,570,243
Members
46,836
Latest member
login dogas

Latest Threads

Top