How do I embed a link into the text of an xml element's value?

Thomas P. Fuller

Usenet Archive
Joined
Sep 8, 2003
Messages
2
Reaction score
0
Hi,

Thanks in advance for any help in this matter.

I need to embed a link in the text portion of an xml element's value.

For example,

<some_element>
Hi, my name is Tom, and you can find my webpage <URL
link="www.xyz.net/~tom">here</URL> </some_element>

so when this element is transformed into xhtml (using xsl, of course) we will see the link properly.

If anyone can offer me a suggestion regarding how to tackle this issue, I would much appreciate it.

Tom
 

Ted (3)

Usenet Archive
Joined
Apr 11, 2002
Messages
31
Reaction score
0
If you include the protocol in your link attribute (eg, http://www.xyz.net/~tom) then you can use this:

<xsl:template match="URL">
<a href="{@link}"><xsl:apply-templates/></a>
</xsl:template>

Otherwise, you'll need to add the "http://" part like this:

<xsl:template match="URL">
<xsl:variable name="myUrl" select="concat('http://', @link)"/> <a href="{$myUrl}"><xsl:apply-templates/></a> </xsl:template>
 

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
548,042
Messages
3,104,224
Members
248,132
Latest member
henrywalsh

Latest Threads

Top