XPath query in a recursive DTD

115 Views Asked by At

I'm using XPath 3.0 and I've the following problem. I need to write a function that returns true/false, checking whether the names of the resources (files and folders) are such that all resources have a distinct pathname.

This is my Document Type Definition

I am able to retrieve the name of the ancestor nodes folders of a specific folder but then I cannot think of how to build a "path name" from that to then perform the comparison. Any idea?

1

There are 1 best solutions below

0
On

The following expression checks whether there are any duplicate file/folder names in any folder. That should be sufficient to check whether there are no duplicate path names.

//*[self::RootFolder|self::Folder][count(distinct-values(*/Name))!=count(File|Folder)]

Additional checks to make sure the path separator is not used in any file/folder names would be required.