Skip to Content
0
Former Member
Jan 29, 2009 at 11:06 AM

How to Supress null target Elements in XSLT Mapping

66 Views

Hi Experts,

I need to Strip off (remove) Null tags from my ouput XML document.

My XSLT Mapping file

<?xml version='1.0' ?>

http://www.w3.org/1999/XSL/Transform">

<xsl:template match="/">

<a:A2ACU>

<a:PartNo>

<xsl:value-of select="Specifications/Specification/PARTNO"/>

</a:PartNo>

<a:Revision>

<xsl:value-of select="Specifications/Specification/REVISION"/>

</a:Revision>

<a:ENERGY>

<xsl:for-each select="Specifications/Specification/Section">

<xsl:variable name="Sec_ID">

<xsl:value-of select="SECTIONID"/>

</xsl:variable>

<xsl:if test="$Sec_ID = '700015'">

<xsl:for-each select="Item">

<xsl:variable name="Item_ID">

<xsl:value-of select="ITEMID"/>

</xsl:variable>

<xsl:if test="$Item_ID = '701134'">

<xsl:for-each select="PropertyGroup/Property">

<xsl:variable name="Pro_ID">

<xsl:value-of select="PROPERTYID"/>

</xsl:variable>

<xsl:if test="$Pro_ID = '700232'">

<xsl:variable name="Atr_ID">

<xsl:value-of select="ATTRIBUTEID"/>

</xsl:variable>

<xsl:if test="$Atr_ID = '700064'">

<xsl:value-of select="STRING2"/>

</xsl:if>

</xsl:if>

</xsl:for-each>

</xsl:if>

</xsl:for-each>

</xsl:if>

</xsl:for-each>

</a:ENERGY>

</a:A2ACU>

</xsl:template>

</xsl:stylesheet>

If any one of the condition in ENRGY TAG FAILS it is giving a output as

- <A2ACU>

<PartNo>123456789</PartNo>

<Revision>2</Revision>

<ENERGY></ENERGY>

- </A2ACU>

But as per my new requirement I need to check the Empty value in all the tags and need to strip of them form final output ...like..

- <A2ACU>

<PartNo>123456789</PartNo>

<Revision>2</Revision>

- </A2ACU>

Can any one please suggest me whether any function is availble to this stripping

Thanks in Advance

Ram