出力 xml は、変数フラグに基づいていくつかの要素でマスクする必要があります。フラグの値が '1' の場合、出力 xml には要素 'a' (すべての属性と子要素を含む) のみが含まれる必要があります。フラグが 2 の場合、出力 xml には要素 a と b が必要です。3 の場合、入力に存在するすべての要素と属性が出力に存在する必要があります。
私の入力xml
<Root>
<a ref="t">
<s id="2">value</s>
</a>
<b ref="t">
<s id="2">value</s>
</b>
<c ref="t">
<s id="2">value</s>
</c>
</Root>
私の希望する出力(フラグが1の場合)
<Root>
<a ref="t">
<s id="2">value</s>
</a>
</Root>
私が試したxslt
<xsl:stylesheet version="1.0"
xmlns:xsl="http://www.w3.org/1999/XSL/Transform">
<xsl:output omit-xml-declaration="yes" indent="yes"/>
<xsl:variable name="flag" select="'1'"/>
<xsl:strip-space elements="*"/>
<xsl:template match="node()|@*">
<xsl:copy>
<xsl:apply-templates select="node()|@*"/>
</xsl:copy>
</xsl:template>
<xsl:if test ="$flag ='1'">
<xsl:template match="b"></xsl:template>
<xsl:template match="c"></xsl:template>
</xsl:if>
</xsl:stylesheet>