homepage Welcome to WebmasterWorld Guest from
register, free tools, login, search, pro membership, help, library, announcements, recent posts, open posts,
Become a Pro Member
Home / Forums Index / Code, Content, and Presentation / XML Development
Forum Library, Charter, Moderators: httpwebwitch

XML Development Forum

Transforming URL in XML data to hyperlink with XSL

 3:12 pm on Dec 1, 2004 (gmt 0)

Hi all,

I am using an XML document as a source of a list of URLs and their descriptions and wish to transform these to a series of hyperlinks using XSL along the lines of that below.

In XML Doc:
<url desc="A description" address="www.widget.com" />
<url desc="Blah" address="www.bluewidgets.com" />

In XSL Doc:
<xsl:for-each select="urls/url">
<a href=" <xsl:value-of select="@address" /> ">
<xsl:value-of select="@desc" />

Obviously the above XSL is not valid, but I don't know how to insert the URL into the href value. Any ideas how to get around this? It seems such a simple thing to want to do, but is proving problematic!

Thanks in advance.


Alternative Future

 3:22 pm on Dec 1, 2004 (gmt 0)

Hi mcfly,

If your using FOP then this is the code:

<fo:basic-link external-destination="{url}">
<xsl:value-of select="title"/>


<a href="{@address}"> in the context you are using



 3:42 pm on Dec 1, 2004 (gmt 0)

Thanks for your suggestion Alternative Future.

I'm not familar with FOP but will look into it. I take it this can be used with ASP/IIS?

Alternative Future

 3:51 pm on Dec 1, 2004 (gmt 0)

If you are printing out in PDF format then it would be worth looking into otherwise it might be best sticking with the xsl suggestion which should work.



 4:01 pm on Dec 1, 2004 (gmt 0)

Cheers George, the simple <a href="{@url}"> does the job nicely.


 1:58 pm on Dec 7, 2004 (gmt 0)

The solution is to use xsl element and attribute tags:

<xsl:for-each select="urls/url">
<xsl:element name="a">
<xsl:attribute name="href">
<xsl:value-of select="@address" />
<xsl:value-of select="@desc" />



 9:50 pm on Dec 14, 2004 (gmt 0)

Is it possible to turn an XML element image path into an HTML image tag with XSL? If you can create a link (href), I'd bet you could do an image tag (img src), but I wasn't sure...

Alternative Future

 8:50 am on Dec 15, 2004 (gmt 0)

You are correct it is possible:

<xsl:element name="img">
<xsl:attribute name="src">
<xsl:attribute name='border'>0</xsl:attribute>


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