Please help on this issue.
I want to check an XML contains a node or not [OR] it is an empty file using XSLT.
My XML is:
<mynode>
<node1>testing</node1>
</mynode>
I want to write XSLT code something like this:
<xsl:choose>
<xsl:when test="document('')/mynode">
file is empty
</xsl:when>
&开发者_运维问答lt;xsl:otherwise>
file has nodes
</xsl:otherwise>
</xsl:choose>
Please any one can help me on this.....
If the file doesn't contain an element, then it is not an XML file, and XML parsing will therefore fail. Different XSLT 1.0 processors react differently to this (as permitted by the spec). In XSLT 2.0 you can use doc-available() to protect yourself, but this is not available in 1.0. In fact, there's nothing you can do about this in 1.0 without knowing details of your particular XSLT processor.
精彩评论