我的XML DTD如下:
<!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)>
]>
我想运行以下查询:
Title Book whose title is the same as title of a magazine.
我无法想办法运行这个查询。任何人请帮助我,我会感激不尽。
答案 0 :(得分:2)
您可以尝试这样的事情:
add $5,$2,$3
addi $5,$5,20
sub $5,$1,$5
sub $5,$5, $4
sw $5,0($5)
在xpath之上返回//Bookstore/Book/Title[. = //Magazine/Title]
子项的所有<Title>
元素,其值等于<Book>
的至少一个<Title>
。
答案 1 :(得分:1)
您可以尝试以下方法:
//Bookstore/Book[Title = ../Magazine/Title]/Title