F
FrankIsHere
Hi!
I cannot figure out how to remove XHTML tags from an XML source file
using XSLT.
Here's what I have:
source XML file:
<?xml version='1.0'?>
<Offer ID="S0173" xmlns:msxsl="urn:schemas-microsoft-com:xslt"
xmlns:msdata="urn:schemas-microsoft-com:xml-msdata"
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xmlns:xhtml="http://www.w3.org/1999/xhtml" >
<GroupInfo>
<Abstract>
<br xmlns="http://www.w3.org/1999/xhtml" />
<i><br/></i><br/><p>test</p>
<br xmlns="http://www.w3.org/1999/xhtml" />
</Abstract>
<Name>Overview</Name>
</GroupInfo>
</Offer>
And this is transformed using this stylesheet:
<xsl:stylesheet
xmlns:xsl='http://www.w3.org/1999/XSL/Transform'
version='1.0' >
<xslutput method="html" encoding="utf-8" />
<xsl:template match="*|@*|text()">
<xsl:copy>
<xsl:apply-templates />
</xsl:copy>
</xsl:template>
<xsl:template match="Abstract//p|Abstract//br">
<xsl:value-of
select="." />
</xsl:template>
</xsl:stylesheet>
This is the result of the transformation:
<Offer xmlns:msxsl="urn:schemas-microsoft-com:xslt"
xmlns:msdata="urn:schemas-microsoft-com:xml-msdata"
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xmlns:xhtml="http://www.w3.org/1999/xhtml">
<GroupInfo>
<Abstract>
<br xmlns="http://www.w3.org/1999/xhtml"></br>
<i></i>test
<br xmlns="http://www.w3.org/1999/xhtml"></br>
</Abstract>
<Name>Overview</Name>
</GroupInfo>
</Offer>
What I want to get is eliminate all XHTML tags from the source XML
file. So for instance the <br
xmlns="http://www.w3.org/1999/xhtml"></br> should not be there. I
figured out how to remove the regular HTML but not when it's XHTML
format.
I appreciated any help!
Frank
I cannot figure out how to remove XHTML tags from an XML source file
using XSLT.
Here's what I have:
source XML file:
<?xml version='1.0'?>
<Offer ID="S0173" xmlns:msxsl="urn:schemas-microsoft-com:xslt"
xmlns:msdata="urn:schemas-microsoft-com:xml-msdata"
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xmlns:xhtml="http://www.w3.org/1999/xhtml" >
<GroupInfo>
<Abstract>
<br xmlns="http://www.w3.org/1999/xhtml" />
<i><br/></i><br/><p>test</p>
<br xmlns="http://www.w3.org/1999/xhtml" />
</Abstract>
<Name>Overview</Name>
</GroupInfo>
</Offer>
And this is transformed using this stylesheet:
<xsl:stylesheet
xmlns:xsl='http://www.w3.org/1999/XSL/Transform'
version='1.0' >
<xslutput method="html" encoding="utf-8" />
<xsl:template match="*|@*|text()">
<xsl:copy>
<xsl:apply-templates />
</xsl:copy>
</xsl:template>
<xsl:template match="Abstract//p|Abstract//br">
<xsl:value-of
select="." />
</xsl:template>
</xsl:stylesheet>
This is the result of the transformation:
<Offer xmlns:msxsl="urn:schemas-microsoft-com:xslt"
xmlns:msdata="urn:schemas-microsoft-com:xml-msdata"
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xmlns:xhtml="http://www.w3.org/1999/xhtml">
<GroupInfo>
<Abstract>
<br xmlns="http://www.w3.org/1999/xhtml"></br>
<i></i>test
<br xmlns="http://www.w3.org/1999/xhtml"></br>
</Abstract>
<Name>Overview</Name>
</GroupInfo>
</Offer>
What I want to get is eliminate all XHTML tags from the source XML
file. So for instance the <br
xmlns="http://www.w3.org/1999/xhtml"></br> should not be there. I
figured out how to remove the regular HTML but not when it's XHTML
format.
I appreciated any help!
Frank