samedi 26 avril 2014

Compare two sibling nodes' child nodes


Vote count:

0




I am very new to Xml and Xquery so I am sorry if this is a stupid question. I have xml code in this format



<myDB>
<book>
<title>ebXML : Concepts and Application</title>
<author>
<last_name>Smith</last_name>
<first_name>John</first_name>
</author>
<year>2003</year>
<publisher>Wiley</publisher>
</book>
<article>
<title>test title</title>
<author>
<last_name>Smith</last_name>
<first_name>John</first_name>
</author>
<year>2003</year>
<publisher>test Wiley</publisher>
</article>
</myDB>


So there are two siblings, 'book' and 'article' They both have children 'author' and 'year' I want to find all authors who have written at least one article and one book in the same year. I thought it would work if I used this as a predicate



//author[//book/(author|year)=//article/(author|year)]


but it did not, instead it returned all of the authors. Evidently my predicate is not acting as a filter/qualifier for each element but more of an absolute statement, an evaluation on the entire code. I think that's what is happening anyway. So my question is how can I select an element based on the value of its sibling's child?



asked 44 secs ago






Aucun commentaire:

Enregistrer un commentaire