I have an Xml fragment where I need to verify that there is only a single ocurrence of each node on the first level (0-based).
An example of bad Xml is this:
<library>
<book1>
<title>My first book</title>
<PageNum>101</PageNum>
</book1>
<book2>
<title>My second book</title>
</book2>
<book1>
<title>Another of my first book</title>
</book1>
<book3>
<title>My third book</title>
<PageNum>101</PageNum>
</book3>
</library>
... since there are two ocurrences of elements with element name "book1" at the first level.
The structure of the child-nodes is not important - just that there are no nodes with the same "top-level" element name. I also do not know the names of the child nodes.
How do I do this - using RelaxNg, XSD or XQuery?
Thanks, Jesper