PDA

View Full Version : Converting text to tags


Tolstoy
02-17-2005, 11:48 AM
I have some XML that contains things like
<value>
10&lt;sup&gt;9&lt;/sup&gl;
<value>

I'd like &lt;sup&gt; to be interpretted as <sup> in the HTML output (and the same for the closing tag). I'm having a surprising amount of trouble getting it to work (surprising to my, anyway) and would be very grateful of any pointers.

Many thanks,
Tolstoy.

mpjbrennan
02-17-2005, 10:52 PM
Is this what you want?

Patrick

XML fle
------------
<?xml version="1.0" encoding="ISO-8859-1"?>
<?xml-stylesheet type="text/xsl" href="test_xsl.xml"?>
<root>
<value>
<base>10</base>
<exponent>9</exponent>
</value>
</root>

XSL file
------------
<?xml version="1.0" encoding="ISO-8859-1"?>
<xsl:stylesheet version="1.0" xmlns:xsl="http://www.w3.org/1999/XSL/Transform"
xmlns:xforms="http://localhost/xsl/xforms">

<xsl:template match="/">
<html>
<body>
<xsl:apply-templates />
</body>
</html>
</xsl:template>
<xsl:template match="value">
<p>
<xsl:value-of select="base"/>
<sup>
<xsl:value-of select="exponent" />
</sup>
</p>
</xsl:template>
</xsl:stylesheet>

Tolstoy
02-18-2005, 04:58 PM
Thats for your response. My problem was converting &lt;blah&gt; to <blah>
I found a possible solution (http://www.stylusstudio.com/xsllist/200307/post51160.html) elsewhere, and it's pretty complicated for what I'm trying to achieve.
I've given up and am now changing the way in which the XML is written in the first place so that the problem doesn't arise.

Thanks again,
Tolstoy.

Alex Vincent
02-19-2005, 05:23 AM
Why can't you use a character data section?
<value><![CDATA[
<tag><othertag><innertag/></othertag></tag>
]]></value>