Long-time listener, first-time caller. I'm relatively new to XPath and looked at several other threads here and elsewhere but I can't seem to get a query working, any help would be great.
I have XML as follows:
<catalog>
<book pgid="28054" lang="en">
<title>The Brothers Karamazov</title>
<author>Dostoyevsky, Fyodor</author>
<friendly_title>The Brothers Karamazov by Fyodor Dostoyevsky</friendly_title>
<file>
<type>ePub</type>
<path>cache/generated/28054/</path>
<name>pg28054.epub</name>
<size>800</size>
</file>
<file>
<type>PDF</type>
<path>2/8/0/5/28054/</path>
<name>28054-pdf.pdf</name>
<size>5829</size>
</file>
<file>
<type compression="zipped">PDF</type>
<path>2/8/0/5/28054/</path>
<name>28054-pdf.zip</name>
<size>1693</size>
</file>
<file>
<type encoding="utf-8" compression="zipped">Text</type>
<path>2/8/0/5/28054/</path>
<name>28054-0.zip</name>
<size>726</size>
</file>
</book>
</catalog>
(catalog is the root element, and in this example there are no <contributor> elements)
I have the query working on author, contributor, title, and language searches, but I am getting hung up on adding a file type condition. This query to find books with author OR contributor containing "Dostoyevsky" and title containing "Brothers" with language "en" is working (i.e. giving expected results), but if there's a better way to write it I'm all ears:
/catalog//book/*[(contains(self::author,'Dostoyevsky') or contains(self::contributor,'Dostoyevsky')) and contains(../title,'Brothers') and ../@lang = 'en']
What I can't get to work is limiting the query results to files of a certain type, i.e. appending and ../file/type='PDF' or something. Didn't have any luck with | unions either.
Thanks in advance.
Oh, and if it matters, the query needs to be built dynamically (from form input), so it needs to retain a universal syntax that would work with any number of user-supplied criteria.