删除xslt中的子节点

问题描述 投票:0回答:1
xml xslt xslt-1.0
1个回答
0
投票

试试这个:

<?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:template match="@*|node()" >
    <xsl:copy>
      <xsl:apply-templates select="@*|node()" />
    </xsl:copy>
  </xsl:template>
  
  <xsl:template match="credit">
    <xsl:text>&#xa;</xsl:text>
    <!-- 
      If you want to get rit of the line-break inside credit, i.e. do a normalize-space like this
        <xsl:value-of select="normalize-space(text())"/>
    -->
    <xsl:apply-templates select="node()" />
    <xsl:text>&#xa;</xsl:text>
  </xsl:template>

</xsl:stylesheet>
© www.soinside.com 2019 - 2024. All rights reserved.