Hi Folks,
I am modeling a file system. Below is a sample instance. D1 means Directory 1,
F1 means File 1, etc. The instance says this: the content of directory 1 is
directory 2 and file 1. The content of directory 2 is file 2. Stated another
way, directory 2 and file 1 are contained in directory 1, and file 2 is
contained in directory 2.
<Root>
<D1>
<D2/>
<F1/>
</D1>
<D2>
<F2/>
</D2>
</Root>
I want an XPath 2.0 expression which returns true if each object has one
parent. An "object" is a directory or a file. In the example above each object
has one parent, so the XPath should return true. Below is an illegal file
system because F1 has two parents: D1 and D2.
<Root>
<D1>
<D2/>
<F1/>
</D1>
<D2>
<F2/>
<F1/>
</D2>
</Root>
The XPath should return false.
This XPath is almost correct:
for $i in /Root/* return for $j in $i/* return not(name($j) =
$i/following-sibling::*/*/name())
I say it is "almost" correct because it returns multiple Booleans, not a single
Boolean result.
Two Questions:
1. What is the correct XPath expression?
2. Is there a different way to model in XML a file system that would enable a
simple XPath expression?
/Roger
--~----------------------------------------------------------------
XSL-List info and archive: http://www.mulberrytech.com/xsl/xsl-list
EasyUnsubscribe: http://lists.mulberrytech.com/unsub/xsl-list/1167547
or by email: xsl-list-unsub(_at_)lists(_dot_)mulberrytech(_dot_)com
--~--