I have this XML:
<university>
<departaments>
<departament sl="AA">
<subject>Numbers</subject>
<categories>
<categorie>
<name type="one">Mathematics</name>
</categorie>
<categorie>
<name type="one">Physics</name>
</categorie>
<categorie>
<name type="two">Other</name>
</categorie>
</categories>
</departament>
<departament sl="BB">
<subject>Letters</subject>
<categories>
<categorie>
<name type="one">Philosophy</name>
</categorie>
<categorie>
<name type="two">Language</name>
</categorie>
<categorie>
<name type="two">Other</name>
</categorie>
</categories>
</departament>
</departaments>
</university>
And I need to obtain the names with his attributes, ordered by length and without duplicates names. I.e.this xml:
<name type="two">Other</name>
<name type="one">Physics</name>
<name type="two">Language</name>
<name type="one">Philosophy</name>
<name type="one">Mathematics</name>
I have this code, but don't work.
for $name in distinct-values(doc ("uni.xml")//categorie/name)
order by string-length($name)
return $name
Somebody could help me?
Thanks in advance.