1
我想删除XSLT中的标记,但将所有内容都留在原地。XSLT删除标记但保留内容
我有这个源:
<?xml version="1.0" encoding="UTF-8"?>
<DOCUMENT>
<div>
<p>foo</p>
<div>we want any divs found in here</div>
<p>we want to keep everything</p>
<p>except the div that follows DOCUMENT</p>
</div>
</DOCUMENT>
,并希望这样的输出:
<?xml version="1.0" encoding="UTF-8"?>
<DOCUMENT>
<p>foo</p>
<div>we want any divs found in here</div>
<p>we want to keep everything</p>
<p>except the div that follows DOCUMENT</p>
</DOCUMENT>
不需要的<div>
始终遵循<DOCUMENT>
,它是唯一<div>
我想删除。
我能与此XSLT
<xsl:stylesheet version="1.0" xmlns:xsl="http://www.w3.org/1999/XSL/Transform">
<xsl:template match="@*|node()">
<xsl:copy>
<xsl:apply-templates select="@*|node()"/>
</xsl:copy>
</xsl:template>
<xsl:template match="/DOCUMENT/div">
<xsl:apply-templates select="@*|node()"/>
</xsl:template>
</xsl:stylesheet>
问题要做到这一点:我不想与身份变换模板,要做到这一点,因为我工作的一个“拉”转变,不推。但我很难找到另一种选择。
感谢。你的回复给了我需要的微调。有时你长期看问题,你不知道答案在你面前是正确的。 – Paulb 2013-05-08 14:03:09