Xslt 剥去标签,但保留它';内容
如何使用XSLT1.0剥离标记Xslt 剥去标签,但保留它';内容,xslt,xslt-1.0,Xslt,Xslt 1.0,如何使用XSLT1.0剥离标记名称(如果存在)以保留其所有内容 input.xml: <authors> <author> Author 1 </author> <author> <sup>*</sup>Author 2 </author> <author> <name>Author 3</nam
名称(如果存在)以保留其所有内容
input.xml:
<authors>
<author>
Author 1
</author>
<author>
<sup>*</sup>Author 2
</author>
<author>
<name>Author 3</name><sup>1</sup>
</author>
<author>
<sup>**</sup><name>Author 4</name><sup>2</sup>
</author>
</authors>
作者1
*作者2
作者31
**作者42
所需的_output.xml:
<authors>
<author>
Author 1
</author>
<author>
<sup>*</sup>Author 2
</author>
<author>
Author 3<sup>1</sup>
</author>
<author>
<sup>**</sup>Author 4<sup>2</sup>
</author>
</authors>
作者1
*作者2
作者31
**作者42
仅用于跳过元素名称:
<xsl:template match="name">
<xsl:apply-templates/>
</xsl:template>
<?xml version="1.0" encoding="UTF-8"?>
<xsl:stylesheet xmlns:xsl="http://www.w3.org/1999/XSL/Transform"
xmlns:xs="http://www.w3.org/2001/XMLSchema"
exclude-result-prefixes="xs"
version="1.0">
<xsl:output indent="yes"/>
<xsl:template match="@* | node()">
<xsl:copy>
<xsl:apply-templates select="@* | node()"/>
</xsl:copy>
</xsl:template>
<xsl:template match="name">
<xsl:apply-templates/>
</xsl:template>
</xsl:stylesheet>
下面是完整的XSLT:
<xsl:template match="name">
<xsl:apply-templates/>
</xsl:template>
<?xml version="1.0" encoding="UTF-8"?>
<xsl:stylesheet xmlns:xsl="http://www.w3.org/1999/XSL/Transform"
xmlns:xs="http://www.w3.org/2001/XMLSchema"
exclude-result-prefixes="xs"
version="1.0">
<xsl:output indent="yes"/>
<xsl:template match="@* | node()">
<xsl:copy>
<xsl:apply-templates select="@* | node()"/>
</xsl:copy>
</xsl:template>
<xsl:template match="name">
<xsl:apply-templates/>
</xsl:template>
</xsl:stylesheet>
谢谢您的回答!我只是需要一些时间来弄清楚它是如何工作的。