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

  • Thread starter Thomas P. Fuller
  • Start date
T

Thomas P. Fuller

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
 
T

ted

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

Forum statistics

Threads
473,994
Messages
2,570,223
Members
46,813
Latest member
lawrwtwinkle111

Latest Threads

Top