I'm making different selection on this XML, but for most of them i'm not sure that i done the simplest solution, and for 2 of them i'm not able to provide a working solution.
<?xml version="1.0" ?>
<!DOCTYPE list[
<!ELEMENT list(man|woman)*>
<!ELEMENT man(sons,daughters)>
<!ATTLIST man name CDATA #REQUIRED>
<!ELEMENT man(sons,daughters)>
<!ATTLIST woman name CDATA #REQUIRED>
<!ELEMENT sons(man)*>
<!ELEMENT daughters(woman)*>
<list>
<man name="Jean-Bernard">
<sons>
<man name="Marc-Antoine"/>
</sons>
<daughters>
<woman name="Marie-Jeanne">
<sons/>
<daughters>
<woman name="Anne-Sophie"/>
</daughters>
</woman>
<woman name="Rose-Marie">
<daughters>
<woman name="Marie-Cécile"/>
</daughters>
</woman>
</daughters>
</man>
<woman name="Marie-Jeanne">
<sons>
<man name="Ghislain-Auguste">
<sons/>
</man>
</sons>
<daughters>
<woman name="Rita-Lise">
<sons>
<man name="Alain-Luc"/>
<man name="Jules-Edouard"/>
</sons>
</woman>
</daughters>
</woman>
</list>
What i have done :
- Selecting all women :
//woman
- Selecting all women with the name "Marie Jeanne" :
//woman[@name='Marie-Jeanne']
- Selecting all woman with a name which contains "Marie" :
//woman[contains(@name,Marie)]
What i have done but this is not exact or i think it can be better :
- Selecting all women or men who have at least 2 children :
//*[sum(count(sons/man), count(daughters/woman)) >= 2]
- Selecting all women or men who are grandparents : i'm totally stuck for this one i can't see how i can select with so much unknown. In my mind this is like that :
//*/*/*/*
. . . i don't understand how to start.