0

この 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>

このXPathで要素を選択できます

//well[@bulkShift=0 and @diameter=5 and @hidden='false' and @name='67-1-TpX-10' and @filename='67-1-TpX-10.well']

ただし、子要素 (メタデータ、ユニット、色など) が要素内に任意の順序で表示される場合、これらの特定の子ノードを持つ要素を見つける必要があるという点で、より具体的にする必要があります。

理想的には、1 つの XPath クエリだけでこのノードを選択できるようにしたいと考えています。

誰でも助けることができますか?

4

2 に答える 2

3

このテンプレートは、チャイルドにも一致し、チャイルドに起因します

<xsl:template match="well[@hidden='false'][./unit='ftUS' or ./tvd/@clip='false']">
    well found!
</xsl:template>

または一度に:

<xsl:template match="well[@hidden='false' and (./unit='ftUS' or ./tvd/@clip='false')]">
    well found!
</xsl:template>
于 2013-07-15T11:05:28.447 に答える
1

属性のテストのような子のテストを述語に追加できます。

//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]

述語からリストを作成すること[ predicate1 ][ predicate2 ]は、and 操作を使用してリストを作成することと同じです。

于 2013-07-15T11:09:18.447 に答える