XPATH construction from an attributes value
Posted: Tue May 16, 2006 1:19 pm
pjl
I should start with I'm new to XSLT/XPATH.
I'm trying to use an attribute value in an input XML file as an XPATH expression to query whether an element with a named attribute exists in a second XML file. Basically I have the following:
Input XML file:
<Feature expression="/root/feature/option[name="dog"]"/>
Referenced XML file:
<root><feature><option name="cat"/></feature></root>
In the xsl file I've tried various things such as the following to look up whether the the expression evaluates to a location/element in the reference file:
<xsl:if test="document('input.xml')@expression"/>
which is invalid
or
<xsl:if test="document('input.xml', @expression)">
whcih returns true.
Any ideas as to how construct the XPATH expression or otherwise so as to be able to achieve this test?
Many thanks. Peter.
I should start with I'm new to XSLT/XPATH.
I'm trying to use an attribute value in an input XML file as an XPATH expression to query whether an element with a named attribute exists in a second XML file. Basically I have the following:
Input XML file:
<Feature expression="/root/feature/option[name="dog"]"/>
Referenced XML file:
<root><feature><option name="cat"/></feature></root>
In the xsl file I've tried various things such as the following to look up whether the the expression evaluates to a location/element in the reference file:
<xsl:if test="document('input.xml')@expression"/>
which is invalid
or
<xsl:if test="document('input.xml', @expression)">
whcih returns true.
Any ideas as to how construct the XPATH expression or otherwise so as to be able to achieve this test?
Many thanks. Peter.