我正在使用XSLT2.0从XHTML文件中提取数据。我想去掉除href之外的所有属性。此版本的标识转换将删除所有属性。请注意,它不复制任何属性,因为没有使用@*。
<xsl:template match="node()">
<xsl:copy>
<xsl:apply-templates select="node()"/>
</xsl:copy>
</xsl:template>我尝试使用@*和对href进行过滤,但不起作用。
<xsl:template match="node()|@*[href]">
<xsl:copy>
<xsl:apply-templates select="node()|@*"/>
</xsl:copy>
</xsl:template>我得到了消息,我也尝试过使用其他构造,比如@*[@href]和@*[href=@*],我也得到了同样的消息。我使用的是Saxon HE 9.5.1.4。
是否可以使用标识转换选择性地仅复制特定属性(及其值),或者必须以另一种方式进行复制?
发布于 2015-07-21 10:16:09
尝试:
<xsl:template match="node()|@href">
<xsl:copy>
<xsl:apply-templates select="node()|@href"/>
</xsl:copy>
</xsl:template>https://stackoverflow.com/questions/31529251
复制相似问题