I want to write an HTML link in my .xml file. I have tried with <![CDATA[<a href=...>LINK</a>]]> but I keep getting & (amp)lt; so it just write the whole link including the <> to the screen. I want it to be a link - how do I do that? Nils
Simply put <a href=...>LINK</a> in your XML (make sure it is a valid XML: all attribute values are enclosed in quotes and so on...) Then in your XSL stylesheet you can write something like <xsl:template match="a"> <xsl:copy-of select="."/> </xsl:template> and you should have a perfect HTML link
i had the same problem a time ago because i save unser input from a htlm Form into an xml File.I display this text lateron with xslt and cocoon.
Saving the links explicitly as CDATA is the right way. the just get the value with xslt <xsl:value-of select="//NewsText" disable-output-escaping="yes"/> the attribute disable-output-escaping="yes" is very important because i tells the xslt Processor not to convert <> into &lt&gt Bye, Holger
Leverager of our synergies
Joined: Aug 26, 2000
Both variants will work. CDATA looks not quite elegant for me, since its content implies something that is not XML, but this solution has its advantages. CDATA section will not be parsed = less overhead during transformation. On the other hand, if you include �pure HTML� in your XML document, its well-formedness will be nicely checked for you. But for most practical applications, there is no huge difference, really.
Say in .xml you have: <profile> <fname>My name</fname> <homepage>www.somewebsite.com.au</homepage> </profile> In .xsl, simply put: <xsl:for-each select="profile"> <a> <xsl:attribute name="href"> <xsl:value-of select="homepage" /> </xsl:attribute> <xsl:value-of select="homepage" /> </a> </xsl:for-each> It's a bit long but it works and easy to understand.
Joined: May 25, 2001
I used the disable-output-escaping="yes" and it works fine. Thanks to all. Nils