Reputation: 2955
Given this XML
<well bulkShift="0.000000" diameter="5.000000" hidden="false" name="67-1-TpX-10" filename="67-1-TpX-10.well">
<metadata/>
<unit>ftUS</unit>
<colour blue="1.000000" green="1.000000" hue="" red="1.000000"/>
<tvd clip="false"/>
<associatedcheckshot>25-1-X-14</associatedcheckshot>
<associatedwelllog>HDRA_67-1-TpX-10</associatedwelllog>
<associatedwelllog>NPHI_67-1-TpX-10</associatedwelllog>
</well>
I can select the element with this XPath
//well[@bulkShift=0 and @diameter=5 and @hidden='false' and @name='67-1-TpX-10' and @filename='67-1-TpX-10.well']
However I need to be much more specific in that I need to find the element with these specific child nodes given that the child elements (metadata,unit,colour, etc) can appear in any order inside the element.
Ideally I'd like to be able to select this node with only a single XPath query.
Can anyone help?
Upvotes: 0
Views: 541
Reputation: 42444
This template match also childs and attributed on childs
<xsl:template match="well[@hidden='false'][./unit='ftUS' or ./tvd/@clip='false']">
well found!
</xsl:template>
or in one go:
<xsl:template match="well[@hidden='false' and (./unit='ftUS' or ./tvd/@clip='false')]">
well found!
</xsl:template>
Upvotes: 3
Reputation: 9627
You can add the test for children like the test for attributes to your predicate e.g.:
//well[@bulkShift=0 and @diameter=5 and @hidden='false' and @name='67-1-TpX-10' and @filename='67-1-TpX-10.well']
[metadata and unit and colour]
Having a list off predicates [ predicate1 ][ predicate2 ]
is the same as have one with and operation.
Upvotes: 1