lundi 9 novembre 2015

Check if there is a node in XML

As I searched over questions and answers I could not find any exact answers, then I am sending here as a question.

I have an XSLT file including two tables and lots of XML files. For some XML files, I struct two tables and for some others only one table. It depends on parent node. If there is such a node(here <exam>) then draw a second table otherwise do not.

A part of XML file:

<?xml version="1.0" encoding="utf-8"?>
<?xml-stylesheet type="text/xsl" href="test.xslt"?>
<Summary>
    <test name="dfsdf">
      <test name="test">
        <result state="OK">
            <description href="Stest.xml"> dsfdfsf </description>
        </result>
      </test>
      <exam>
        <description>  test2.xml    </description>
      <exam>
    </test>
</Summary>

I followed the accepted answer of this question but it does not work. Also I used the when instruction, but could not succeed. Could you please let me how could I come over?

<xsl:choose>
   <xsl:when test="/exam/node()">body node exists</xsl:when>
   <xsl:otherwise> something else </xsl:otherwise>
</xsl:choose>

Aucun commentaire:

Enregistrer un commentaire