XML : xslt remove node using multiple condition

I got following xml

  <root>      <product>          <someVal>123</someVal>          <ProductIdentifier>              <ProductIDType>01</ProductIDType>              <IDTypeName>OK</IDTypeName>              <IDValue>25</IDValue>          </ProductIdentifier>      </product>      <product>          <someVal>123</someVal>          <ProductIdentifier>              <ProductIDType>01</ProductIDType>              <IDTypeName>Another</IDTypeName>              <IDValue>25</IDValue>          </ProductIdentifier>      </product>      <product>          <someVal>123</someVal>          <ProductIdentifier>              <ProductIDType>01</ProductIDType>              <IDTypeName>Good</IDTypeName>              <IDValue>25</IDValue>          </ProductIdentifier>      </product>      <product>          <someVal>123</someVal>          <ProductIdentifier>              <ProductIDType>01</ProductIDType>              <IDTypeName>Good</IDTypeName>              <IDValue>25</IDValue>          </ProductIdentifier>      </product>      <product>          <someVal>123</someVal>          <ProductIdentifier>              <ProductIDType>01</ProductIDType>              <IDTypeName>Bad</IDTypeName>              <IDValue>25</IDValue>          </ProductIdentifier>      </product>  </root>    

I want to copy all nodes that contains 'Good' value under /product/ProductIdentifierIDTypeName

Here my transform

  <?xml version="1.0"?>  <xsl:stylesheet version="1.0" xmlns:xsl="http://www.w3.org/1999/XSL/Transform">      <xsl:output method="xml" encoding="utf-8" indent="yes"/>        <xsl:template match="@*|node()">          <xsl:copy>              <xsl:apply-templates select="@*|node()"/>          </xsl:copy>      </xsl:template>        <xsl:template match="product[ProductIdentifier[IDTypeName != 'Good']]"/>  </xsl:stylesheet>    

This works fine however now I want to copy also product nodes that have OK value under /product/ProductIdentifierIDTypeName. How can I write this complex condition?

Thanks

No comments:

Post a Comment