how to write such xquery?

"Chen Yabing" <[email protected]>
Newsgroups gmane.comp.web.query-languages
Message-ID <[email protected]>
Suppose I have a document as follows:

 

<a ano="a001">

   <b bno="b001">

       <c cno="c001"/>

       <d dno="d001"/>

       <d dno="d002"/>

   </b>

   <b bno="b002">

       <c cno="c002"/>

       <d dno="d002"/>

   </b>

</a>

 

I would like to write a query to retrieve those elements from top to
down that has sub element <d> whose dno = "d002". That is, I want the
result like this:

 

<a ano="a001">

   <b bno="b001">

       <c cno="c001"/>

       <d dno="d002"/>

   </b>

   <b bno="b002">

       <c cno="c002"/>

       <d dno="d002"/>

   </b>

</a>

 

How to write such a query in a simple XQuery? Can I use filter function?

Thanks in advance.
lmpx.com only provides a reader for public news (NNTP) servers. It is not affiliated with the servers or forums shown here and is not responsible for the content of articles, which is written by their respective authors.