XML : How to get parent node and all it's child node if a condition is true

I have got the following XML

             <?xml version="1.0" encoding="utf-8"?>          <Students>            <Student>              <StdId value="1" />              <Name>a</Name>              <Courses>                  <Course value="c1" />                  <Course value="c2" />                  <Course value="c3" />              </Courses>          </Student>          <Student>              <StdId value="2" InActive="True" />              <Name>b</Name>              <Courses>                  <Course value="c1" />                  <Course value="c4" />                  <Course value="c6" />              </Courses>            </Student>      </Students>    

and my XSLT code is

        <xsl:stylesheet xmlns:xsl="http://www.w3.org/1999/XSL/Transform" version="2.0" >  <xsl:output method="xml" indent="yes"/>  <xsl:strip-space elements="*" />      <xsl:template match="/">      <xsl:result-document method="xml" href="file:///C:/Student_details.xml">                       <xsl:for-each select="Students/Student">              <xsl:if test="(StdId[@InActive != 'True'])">                  <xsl:copy-of select="Student" />                                  </xsl:if>          </xsl:for-each>      </xsl:result-document>  </xsl:template>    

I want to get stdent element with its child nodes apart from where the StdId InActive="True". My code does not copy any of the student element.

No comments:

Post a Comment