次の質問:他の「OutputDoc」xmlドキュメントに変換するための「InputDoc」xmlドキュメントとxsltファイルがあります。以下にxsltおよびxmlドキュメントの例を示します。
<?xml version="1.0" encoding="UTF-8"?>
<InputDoc>
<InputCollection>
<InputItem>
<InputValue>Value_1</InputValue>
</InputItem>
</InputCollection>
</InputDoc>
<?xml version="1.0" encoding="utf-16"?>
<OutputDoc>
<OutputElement>
<OutputItem>
<OutputValue>Value_1</OutputValue>
</OutputItem>
<OutputDescription>Description_1</OutputDescription>
</OutputElement>
</OutputDoc>
<?xml version="1.0" encoding="utf-8"?>
<xsl:stylesheet version="1.0" xmlns:xsl="http://www.w3.org/1999/XSL/Transform" xmlns:msxsl="urn:schemas-microsoft-com:xslt" exclude-result-prefixes="msxsl">
<xsl:output method="xml" indent="yes"/>
<xsl:template match="//InputCollection">
<OutputDoc>
<xsl:for-each select="InputItem">
<OutputElement>
<OutputItem>
<OutputValue><xsl:value-of select="InputValue" /></OutputValue>
</OutputItem>
<OutputDescription>
<xsl:call-template name="InputValue2OutputDescriptionMappings">
<xsl:with-param name="InputValueParam" select="InputValue" />
</xsl:call-template>
</OutputDescription>
</OutputElement>
</xsl:for-each>
</OutputDoc>
</xsl:template>
<xsl:template name="InputValue2OutputDescriptionMappings">
<xsl:param name="InputValueParam" />
<xsl:choose>
<xsl:when test="$InputValueParam='Value_1'">Description_1</xsl:when>
<xsl:when test="$InputValueParam='Value_2'">Description_2</xsl:when>
<xsl:otherwise></xsl:otherwise>
</xsl:choose>
</xsl:template>
</xsl:stylesheet>
できます。ただし、出力xmlドキュメントに「InputValue2OutputDescriptionMappings」への値を含む「OutputElement」ノードのみが含まれていると便利です。つまり、「OutputDescription」ノードの値が空の場合、「OutputElement」ノードは「OutputDoc」に含まれません。
上記のXSL変換を使用してそれを行うにはどうすればよいですか?