Monday, 8 December 2014

Parsing a string to xml and load into document variable



I am writing a stylesheet to convert un-parsed HTML to XSl-FO. I will get a element that has un-parsed html. I want to load the contents of Comment into a document variable:



<Comment>&lt;div align="left"&gt;&lt;font size="4" color="#FF0000"&gt;This is &lt;i&gt;&lt;b&gt;&lt;u&gt;some &lt;/u&gt;&lt;/b&gt;&lt;/i&gt;sample html again&lt;/font&gt;&lt;br&gt;&lt;/div&gt;</Comment>


Which will look like this



<div align="left"><font size="4" color="#FF0000">This is <i><b><u>some </u></b></i>sample html again</font></div>


or formatted:



<div align="left">
<font size="4" color="#FF0000">This is <i>
<b>
<u>some </u>
</b>
</i>sample html again</font>
</div>


And try to access the elements with:



<xsl:variable name="html">
<xsl:value-of select="Comment" disable-output-escaping="yes"/>
</xsl:variable>
<xsl:value-of select="$html//b"/>


But this of course is not working. Is this possible with xslt 1.0?


No comments:

Post a Comment