XSLT Copy all Nodes except 1 element

前端 未结 1 1566
天涯浪人
天涯浪人 2021-02-20 06:25

    
modification weights
&l
相关标签:
1条回答
  • 2021-02-20 06:47

    You just have to use the identity template (as you were using) and then use a template matching DataSeriesBodyType which does nothing.

    The code would be:

    <xsl:stylesheet version="1.0" xmlns:xsl="http://www.w3.org/1999/XSL/Transform">
    
    
        <xsl:output method="xml" encoding="utf-8" indent="yes"/>
    
        <!-- Identity template : copy all text nodes, elements and attributes -->   
        <xsl:template match="@*|node()">
            <xsl:copy>
                <xsl:apply-templates select="@*|node()" />
            </xsl:copy>
        </xsl:template>
    
        <!-- When matching DataSeriesBodyType: do nothing -->
        <xsl:template match="DataSeriesBodyType" />
    
    </xsl:stylesheet>
    

    If you want to normalize the output to remove empty data text nodes, then add to the previous stylesheet the following template:

    <xsl:template match="text()">
        <xsl:value-of select="normalize-space()" />
    </xsl:template>
    
    0 讨论(0)
提交回复
热议问题