I have a series of documents output by a Java application that exports XML with html tags not bound, like for example
<b>some text</b>
(I cannot change this behavior).
An application that then uses this output should have all the html tags that have been escaped in
<b>some text </b>
I use xslt below to avoid tags, but it is not surprising that it does not work for nested html tags , for example where
<u><b>A string of html</b></u>
When converting XSLT I get
<u>a string of html</u>
where nested <b> and </b> tags get removed altogether.
I am looking to achieve
<u><b>A string of html</b></u>
I am sure there is a simple answer to this by setting the select value or template, but I tried and failed
Any help would be greatly appreciated!
Sample document with embedded html tags
<?xml version="1.0" encoding="UTF-8"?>
<Main>
<Text><u><b>A string of html</b></u></Text>
</Main>
This is XSLT
<xsl:stylesheet version="1.0" xmlns:xsl="http://www.w3.org/1999/XSL/Transform">
<xsl:output method="xml" indent="yes" omit-xml-declaration="no" encoding="UTF-8"/>
<xsl:strip-space elements="*" />
<xsl:template match="@*|node()">
<xsl:copy>
<xsl:apply-templates select="@*|node()"/>
</xsl:copy>
</xsl:template>
<xsl:template match="Text/*">
<xsl:value-of select="concat('<',name(),'>',.,'</',name(),'>')" />
</xsl:template>
</xsl:stylesheet>
What produces
<?xml version="1.0" encoding="UTF-8"?>
<Main>
<Text><u>A string of html</u></Text>
</Main>
Internal bold tags were dropped as you can see.
- xslt?
: -)