I am working on the following XML:
<digiprovMD ID="digiprov-3">
<mdWrap MDTYPE="PREMIS">
<xmlData>
<agent>
<agentIdentifier>
<agentIdentifierType>URI</agentIdentifierType
<agentIdentifierValue>info:fda/system-v0.16.2</agentIdentifierValue>
<agentIdentifierResult>outcome</agentIdentifierResult>
</agentIdentifier>
<agentName>DAITSS Account: UF</agentName>
<agentType>Affiliate</agentType>
</agent>
</xmlData>
</mdWrap>
</digiprovMD>
<digiprovMD ID="digiprov-4">
<mdWrap MDTYPE="PREMIS">
<xmlData>
<agent>
<agentIdentifier>
<agentIdentifierType>URI</agentIdentifierType>
<agentIdentifierValue>info:fda/system-v0.16.2</agentIdentifierValue>
</agentIdentifier>
<agentName>daitss system (v0.16.2)</agentName>
<agentType>software</agentType>
</agent>
</xmlData>
</mdWrap>
</digiprovMD>
<digiprovMD ID="digiprov-5">
<mdWrap MDTYPE="PREMIS">
<xmlData>
<agent>
<agentIdentifier>
<agentIdentifierType>URI</agentIdentifierType>
<agentIdentifierValue>info:fda/system-v0.16.2</agentIdentifierValue>
<agentIdentifierResult>source</agentIdentifierResult>
</agentIdentifier>
<agentIdentifier>
<agentIdentifierType>URI</agentIdentifierType>
<agentIdentifierValue>someotheruri</agentIdentifierValue>
<agentIdentifierResult>outcome</agentIdentifierResult>
</agentIdentifier>
<agentName>daitss system (v0.16.2)</agentName>
<agentType>software</agentType>
</agent>
</xmlData>
</mdWrap>
</digiprovMD>
I want to select all agents with a specific value of agentIdentifierValue say info:fda/system-v0.16.2, only if 1. it has no agentIdentifierResult tag associated with it and 2. if there is an agentIdentifierResult assocaited with it its value should be 'outcome'
So in this case both agents, digiprov-3 and digiprov-4 should be selected. How do I write an xpath for this?
I tried this (pseudo-code): (result = outcome and value = '#{uri.content}') or (value = '#{uri.content}') but this selects the 3rd agent digiprov-5 too!
This should work:
'//digiprovMD[.//agentIdentifier[./agentIdentifierValue="info:fda/system-v0.16.2"][not(./agentIdentifierResult) or ./agentIdentifierResult = "outcome"]]'
Basically this is returning any digiprovMD nodes that include an agentIdentifier node with the specified agentIdentifierValue value, as well either no agentIdentifierResult or a agentIdentifierResult of "outcome".