Connecting Tech Pros Worldwide Help | Site Map

Need XSL list of XML links

Donald Firesmith
Guest
 
Posts: n/a
#1: Jul 20 '05
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

Joris Gillis
Guest
 
Posts: n/a
#2: Jul 20 '05

re: Need XSL list of XML links


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


regards,
--
Joris Gillis (http://www.ticalc.org/cgi-bin/acct-v...i?userid=38041)
Gaudiam omnibus traderat W3C, nec vana fides
Donald Firesmith
Guest
 
Posts: n/a
#3: Jul 20 '05

re: Need XSL list of XML links


Joris Gillis wrote:[color=blue][color=green]
>> <li><a href="<xsl:value-of select="@url"/>">[/color]
>
> Make that <li<a href="{@url}">
>
>
> regards,[/color]
Joris
Thanks. That works.
Don

anonymous
Guest
 
Posts: n/a
#4: Jul 20 '05

re: Need XSL list of XML links


Donald Firesmith wrote:[color=blue]
> 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
>[/color]

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.
Closed Thread


Similar .NET Framework bytes