I am converting a SAP IDOC into a more human readable XML format.
I have the below XSLT which hides empty values (CHARG, VFDAT)
<Product>
<OrderLineNo><xsl:value-of select="VGPOS"/></OrderLineNo>
<ProductDescription><xsl:value-of select="ARKTX"/></ProductDescription>
<ProductCode><xsl:value-of select="MATNR"/></ProductCode>
<xsl:if test="EAN11">
<Barcode><xsl:value-of select="EAN11"/></Barcode>
</xsl:if>
<QuantityDelivered><xsl:value-of select="LFIMG"/></QuantityDelivered>
<SalesUnit><xsl:value-of select="VRKME"/></SalesUnit>
<xsl:if test="CHARG">
<Batch><xsl:value-of select="CHARG"/></Batch>
</xsl:if>
<xsl:if test="VFDAT">
<ExpiryDate><xsl:value-of select="VFDAT"/></ExpiryDate>
</xsl:if>
</Product>
This gets the below XML output, which hides VFDAT and EAN11 where it doesn't exist in the source XML document.
I also want to hide VFDAT when the value < 1.
How would I do this?
<Product>
<OrderLineNo>000010</OrderLineNo>
<ProductDescription>BARBER'S CATALOGUE</ProductDescription>
<ProductCode>000000000030199850</ProductCode>
<QuantityDelivered>20.000</QuantityDelivered>
<SalesUnit>EA</SalesUnit>
<ExpiryDate>00000000</ExpiryDate>
</Product>
Thank you.
Try doing it as,
If you are using XSLT 2.0 then following should work,
<xsl:if test="VFDAT gt 0">
<ExpiryDate><xsl:value-of select="VFDAT"/></ExpiryDate>
</xsl:if>
If XSLT 1.0,
<xsl:if test="VFDAT > 0">
<ExpiryDate><xsl:value-of select="VFDAT"/></ExpiryDate>
</xsl:if>
or
<xsl:if test="VFDAT > 0">
<ExpiryDate><xsl:value-of select="VFDAT"/></ExpiryDate>
</xsl:if>