I've been trying to find a way to match parent elements that match one or more conditions while only returning unique results. As an example (listed below), how would I write a template match to match all the bookstore elements that contain either 'Harry Potter' or 'Learning XML' and are written in English?
Code:
<?xml version="1.0" encoding="ISO-8859-1"?>
<bookstore>
<book
<title lang="eng">Harry Potter</title>
<price>29.99</price>
</book>
<book>
<title lang="eng">Learning XML</title>
<price>39.95</price>
</book>
</bookstore>
The best I have been able to do is match the titles via the following:
Code:
<xsl:template match="//bookstore/book/title[@lang='eng'][text() = 'Harry Potter'] | //bookstore/book/title[@lang='eng'][text() = 'Learning XML']">
While I can traverse this to get to the bookstore, I'll get multiple hits resulting in the same bookstore. What I want to do is match the bookstore. However, it seems beyond me.