Re: Can XSLT render the content: <p> as html <p> rather than text?
- From: Martin Honnen <mahotrash@xxxxxxxx>
- Date: Thu, 13 Mar 2008 14:38:28 +0100
mark4asp wrote:
I have an element, report which contains tags which have been
transformed. E.g. <p> is <p>
<myXml>
<report>This text has html tags in it.<p> which but <> has been
changed to <></report>
</myXml>
I there a way that the XSLT transformation can render the content as
html rather than text?
Well the proper way to solve that is at the source, instead of escaping the HTML markup you should insert well-formed XHTML markup, then your XSLT style*** can easily copy it to the output or transform it to HTML if needed.
If you can't do that then one approach is disable-output-escaping e.g.
<xsl:template match="report">
<div>
<xsl:value-of select="." disable-output-escaping="yes"/>
</div>
</xsl:template>
However disable-output-escaping is an optional feature that is not supported by all XSLT processors respectively is not supported with all XSLT uses (for instance when chaining XSLT tranformations). So you will have to check whether it works with your XSLT processor in the setting you use it with.
Other than that you are left with processing and parsing the text with the escaped markup and create elements as needed, a task that is rather difficult with the restricted string processing that XSLT/XPath 1.0 offer.
--
Martin Honnen
http://JavaScript.FAQTs.com/
.
- Follow-Ups:
- References:
- Prev by Date: Can XSLT render the content: <p> as html <p> rather than text?
- Next by Date: Re: XML Schemas: Advanced Validation
- Previous by thread: Can XSLT render the content: <p> as html <p> rather than text?
- Next by thread: Re: Can XSLT render the content: <p> as html <p> rather thantext?
- Index(es):
Loading