I try replacing the tags like this:
<node><br></node> -- > <node><br></node>
unfortunately when the xsl parses the xml file i actually get
<br>
displayed on the page instead of having it displayed as markup.
HTML isn't XML, although they do look very similar; there's four things that are valid in HTML that you can't do with XML, all of which can be modified to be XML compliant:
<br> to <br/> etc.<input type="checkbox" checked>. Just assign them a value with the same name as the attribute, i.e. <input type="checkbox" checked="checked" />.<b>A<i>B</b>C</i>, which would make A bold, C italic, and B both bold and italic. You can make this XML compliant by doing <b>A<i>B</i></b><i>C</i> or <b>A</b><i><b>B</b>C</i>.<, >, &, ", ' and unicode values (e.g.  / ) are valid entities in XML. You can't use or ø or anything like that by default. To fix this, you need to include an entity declaration at the top of the sheet, such as <!ENTITY nbsp " ">.XSLT is incapable of processing an HTML file unless it's also valid XML.
As a rule, I always write HTML to be XML compliant simply because it makes the whole range of XML tools available, and there's really no reason not to.
Replacing <br> with <br> actually replaces the tag with TEXT that happens to resemble html, not an xml compliant tag.
If you want to insert a non well-formed html, this is a possible work-around. Put your not well-formed html in a comment inside the xml, then extract it from xsl.
example of XML:
<Data>
<!--
<div>
not well-formed xml<br>
</div>
-->
</Data>
example of XSL:
<xsl:stylesheet version="1.0" xmlns:xsl="http://www.w3.org/1999/XSL/Transform"
xmlns:msxsl="urn:schemas-microsoft-com:xslt" exclude-result-prefixes="msxsl">
<xsl:template match="Data">
<html>
<body>
<xsl:value-of disable-output-escaping="yes" select="comment()"/>
</body>
</html>
</xsl:template>
<xsl:template match="text() | @*">
</xsl:template>
</xsl:stylesheet>
output
<html>
<body>
<div>
not well-formed xml<br>
</div>
</body>
</html>
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With