Hi, All,
Next question: I have "InputDoc" xml document and xslt file in order to transform into other "OutputDoc" xml document. You can find examples xslt and xml documents below.
<?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>
It works. But It would be nice if output xml document contained just "OutputElement" nodes which contains values into "InputValue2OutputDescriptionMappings", i.e. if value of "OutputDescription" node is empty then "OutputElement" node won't be included into "OutputDoc".
How I can do it using XSL transformation above?