How to get XPath node using XSLT
I need to get the XPath node using XSLT. I need to check if a particular node exists within a block of xml. The only way i klnow how to do it is using the XPath node. Let me know if you know of another way to check if a certain node exists within a block o开发者_如何学编程f XML using XSLT.
Yep, XPath is the way.
Assuming you're in an XSLT template and you want to check for the existence of a child element "TestElement", you could do something like:
<xsl:if test="TestElement">
<!-- some-code -->
</xsl:if>
Simply specifying the element/node name in a test checks for the existence of that element/node.
Sounds like I completely misunderstood the question. If you want to generate an "absolute" XPath expression for an given node in a given document from within XSLT, there's a lovely succinct solution described here.
精彩评论