1
 <DETAILS>
     <PUT>
        <RECORD>ABC_PQRST0123456-001_1</RECORD> 
        <NUMBER>4</NUMBER>
        <INST>1,2</INST>
      </PUT>
      <PUT>
        <RECORD>ABC_PQRST0123456-001_2</RECORD>
        <NUMBER>1</NUMBER>
     </PUT>
   </DETAILS>

How to remove the other loop elements from where INST don't have values.Can someone help me with xslt Transformation code to sort this

<PUT>
    <RECORD>ABC_PQRST0123456-001_2</RECORD>
    <NUMBER>1</NUMBER>
  </PUT>
Harsha
  • 11
  • 2

1 Answers1

0

This does what you describe:

<?xml version="1.0" encoding="UTF-8" ?>

<xsl:stylesheet xmlns:xsl="http://www.w3.org/1999/XSL/Transform" version="1.0">

    <xsl:template match="/">
        <xsl:apply-templates select="*" />
    </xsl:template>

    <xsl:template match="PUT[not(INST)]">
        <xsl:copy>
            <xsl:apply-templates select="@*|node()" />
        </xsl:copy>
    </xsl:template>

<!-- match but dont do anything -->
    <xsl:template match="PUT">
    </xsl:template>

    <xsl:template match="@*|node()">
        <xsl:copy>
            <xsl:apply-templates select="@*|node()" />
        </xsl:copy>
    </xsl:template>

</xsl:stylesheet>
Bryn Lewis
  • 580
  • 1
  • 5
  • 14