I am looking for a way to compare two XPath (version 1.0) values from two different XML's even when one does not exist.
One of the generated XML's always return an XML element either with value or an empty tag, i.e.
<Product>
<Name>ProdName</Name>
<Id>3388</Id>
</Product>
or
<Product>
<Name/>
<Id>3388</Id>
</Product>
However, the other generated XML document, when there is no value for an element, it does not provide it at all, i.e. (I might receive it like following if there is a value for ProductName),
<ProductDetail>
<ProductName>ProdName</ProductName>
<ProductPrice>4820.99</ProductPrice>
...
</ProductDetail>
And receive it when there is no value for ProductName,
<ProductDetail>
<ProductPrice>4820.99</ProductPrice>
...
</ProductDetail>
In case where the nodes exist, the comparison is straightforward,
//interested_node/Product/Name/text()
and
//interested_node/ProductDetail/ProductName/text()
Is there a way to have two XPath expressions, one that gets a value of node from the first XML document and compares it with the value of node from the second XML document even in cases when there is no such node in the second expression? Is there any XPath 1.0 function that returns a value if a condition is met, otherwise another value (like Oracle's decode())?
No comments:
Post a Comment