I want to output an xml based on some conditions.

Here is my input XML

```
<YIORDER01>
    <IDOC>
        <E1ORHDR>
            <E1OROPR>
                <VORNR>0010</VORNR>
                <E1OROPR_MAT>
                    <MATNR>M0003-01</MATNR>
                    <YE1OROPR_MAT>
                        <STTXT>REL</STTXT>
                        <MTART>ZPAR</MTART>
                        <POSTP>L</POSTP>
                    </YE1OROPR_MAT>
                </E1OROPR_MAT>
                <E1OROPR_MAT>
                    <MATNR>M0003-01</MATNR>
                    <YE1OROPR_MAT>
                        <STTXT>REL</STTXT>
                        <MTART>XYZ</MTART>
                        <POSTP>M</POSTP>
                    </YE1OROPR_MAT>
                </E1OROPR_MAT>
            </E1OROPR>
            <E1OROPR>
                <VORNR>0020</VORNR>
                <E1OROPR_MAT>
                    <MATNR>M0003-01</MATNR>
                    <YE1OROPR_MAT>
                        <STTXT>REL</STTXT>
                        <MTART>ZPAR</MTART>
                        <POSTP>L</POSTP>
                    </YE1OROPR_MAT>
                </E1OROPR_MAT>
            </E1OROPR>
        </E1ORHDR>
    </IDOC>
</YIORDER01>

```

And the output is something like this.

```
<PartOrderList>
   <PartOrder>
      <OperationBONumber>0010</OperationBONumber>
      <PartOrderLine>
         <MaterialNumber>M0003-01</MaterialNumber>
         <ShipmentType>REL</ShipmentType>
      </PartOrderLine>
   </PartOrder>
   <PartOrder>
      <OperationBONumber>0020</OperationBONumber>
   </PartOrder>
</PartOrderList>

```

And my XSLT is this

```
<xsl:stylesheet xmlns:xsl="http://www.w3.org/1999/XSL/Transform">
    <xsl:template match="YIORDER01">
        <xsl:element name="PartOrderList">
            <xsl:for-each select="IDOC/E1ORHDR/E1OROPR">
                <xsl:element name="PartOrder">
                    <xsl:element name="OperationBONumber">
                        <xsl:value-of select="VORNR"/>
                    </xsl:element>
                    <xsl:for-each select="E1OROPR_MAT">
                        <xsl:if test="YE1OROPR_MAT/MTART = &apos;ZPAR&apos; and YE1OROPR_MAT/POSTP = &apos;L&apos;">
                            <xsl:element name="PartOrderLine">
                                <xsl:element name="MaterialNumber">
                                    <xsl:value-of select="MATNR"/>
                                </xsl:element>
                                <xsl:element name="ShipmentType">
                                    <xsl:value-of select="YE1OROPR_MAT/STTXT"/>
                                </xsl:element>
                            </xsl:element>
                        </xsl:if>
                    </xsl:for-each>
                </xsl:element>
            </xsl:for-each>
        </xsl:element>
    </xsl:template>
</xsl:stylesheet>

```

Problem here is, i don't want the second "PartOrder" tag in the output as it does not have any "PartOrderLine" child.

Rules used in the xslt:

1. Create a "PartOrder" tag in output for each "E1OROPR" in input
2. Create a "PartOrderLine" tag inside "PartOrder" only if "MTART" = "ZPAR" and "POSTP" = "L"
3. Do not create any "PartOrder" tag if there is no valid "PartOrderLine" tag in the output.

Using my xslt I am able to achieve rules 1 and 2, but don't know how to achieve rule 3.  

Is there any way I can achieve this using xslt??

Please help.