2
鑑於此xml:的Xpath如何通過指數得到的元素和屬性
<mets:techMD ID="techMD014">
<mets:mdWrap MDTYPE="PREMIS:OBJECT">
<mets:xmlData>
<premis:object
xsi:type="premis:file"
xsi:schemaLocation="info:lc/xmlns/premis-v2
http://www.loc.gov/standards/premis/v2/premis-v2-0.xsd">
<premis:objectIdentifier>
<premis:objectIdentifierType
>filepath</premis:objectIdentifierType>
<premis:objectIdentifierValue
>bib1234_yyyymmdd_99_x_performance.xml</premis:objectIdentifierValue>
</premis:objectIdentifier>
</premis:object>
</mets:xmlData>
</mets:mdWrap>
</mets:techMD>
<mets:techMD ID="techMD015">
<mets:mdWrap MDTYPE="PREMIS:OBJECT">
<mets:xmlData>
<premis:object
xsi:type="premis:representation"
xsi:schemaLocation="info:lc/xmlns/premis-v2
http://www.loc.gov/standards/premis/v2/premis-v2-0.xsd">
<premis:objectIdentifier>
<premis:objectIdentifierType
>local</premis:objectIdentifierType>
<premis:objectIdentifierValue
>bib1234_yyyymmdd_99_x</premis:objectIdentifierValue>
</premis:objectIdentifier>
</premis:object>
</mets:xmlData>
</mets:mdWrap>
</mets:techMD>
我想作一個XPath查詢一個同時索引和屬性考慮在內。 I.e我可以將這兩個組合成一個查詢嗎? (它圍繞「對象」元素Im的東西感興趣):
//techMD/mdWrap[
@MDTYPE=\'PREMIS:OBJECT\'
]/xmlData//object[1]/objectIdentifier/objectIdentifierValue
//techMD/mdWrap[
@MDTYPE=\'PREMIS:OBJECT\'
]/xmlData//object[
@xsi:type=\'premis:file\'
]/objectIdentifier/objectIdentifierValue
謝謝!
+1正確答案。最後的謂詞將等於'[position()= 1和@xsi:type ='premis:file']' – 2011-03-14 16:00:57
@Ajjandro。是。實際上在某些實現中會更快。 – Flack 2011-03-14 16:17:36
謝謝你們,看起來我有我需要的東西:) – Jojje 2011-03-15 08:56:27