Reputation: 31
My XML DTD is as follows:
<!DOCTYPE Bookstore [
<!ELEMENT Bookstore (Book | Magazine)*>
<!ELEMENT Book (Title, Authors, Remark?)>
<!ATTLIST Book ISBN CDATA #REQUIRED
Price CDATA #REQUIRED
Edition CDATA #REQUIRED>
<!ELEMENT Magazine (Title)>
<!ATTLIST Magazine Month CDATA #REQUIRED Year CDATA #REQUIRED>
<!ELEMENT Title (#PCDATA)>
<!ELEMENT Authors (Author+)>
<!ELEMENT Remark (#PCDATA)>
<!ELEMENT Author (First_Name, Last_Name)>
<!ELEMENT First_Name (#PCDATA)>
<!ELEMENT Last_Name (#PCDATA)>
]>
I want to run the following query:
Title Book whose title is the same as title of a magazine.
I cant think a way to run this query.Anyone Please help me with this i will b thanksful.
Upvotes: 1
Views: 41
Reputation: 2961
you can try the following:
//Bookstore/Book[Title = ../Magazine/Title]/Title
Upvotes: 1
Reputation: 89305
You could try something like this :
//Bookstore/Book/Title[. = //Magazine/Title]
Above xpath returns all <Title>
elements that is child of <Book>
and has value equals to at least one <Title>
of <Magazine>
.
Upvotes: 2