Altova Mailing List Archives>Archive Index >microsoft.public.xsl Archive Home >Recent entries >Thread Prev - XSLT and displaying hyperlinks in XML >Thread Next - Re: XSLT and displaying hyperlinks in XML Re: XSLT and displaying hyperlinks in XMLTo: NULL Date: 3/8/2005 12:48:00 PM Xero wrote: > I know the solution to the issue I'm having is very simple but I can't > seem to find it. I have to say I'm a total newbie when it comes to > xml/xslt. Here are my xml and xslt files: > > <Body>Some text some text some text some text some text some > http://www.msn.com text</Body> > <xsl:value-of select="Body"/> > Question: How do I make those hyperlinks in the Body show as actual > hyperlinks? If I simply turn it into > > <Body>Some text some text some text <a > href="http://www.google.com">http://www.google.com</a> text some text > some text some text</Body> > > it won't work. it still shows as text. How do I do this? If you are able to change the input XML before you apply the XSLT e.g. you have <Body> Some text some text some text <a href="http://www.google.com">http://www.google.com</a> text some text some text some text</Body> in the input XML then it is rather easy, simply do <xsl:template match="Body"> <p> <xsl:apply-templates /> </p> </xsl:template> <xsl:template match="a"> <xsl:copy> <xsl:apply-templates select="@* | node()" /> <xsl:copy> </xsl:template> <xsl:template match="@*"> <xsl:copy /> </xsl:template> and then where you have <xsl:value-of select="Body"/> use <xsl:apply-templates select="Body" /> instead, that way the content of <Body> is recursively processed, text nodes are copied and elements like <a> are copied too. If you are not able to change the input XML then it is difficult with XSLT 1.0 as then you have to write a recursive template processing the text content of <Body> and finding the URL to transform it into a HTML link. -- Martin Honnen http://JavaScript.FAQTs.com/ | ||||||
| Company | Legal | Press | Partners | Careers | Sitemap | Contact Us | Altova Blog | Mobile | Full Site | |||
|
