Joan Xiao wrote:
But if I replace * by a node name, i.e., //element(test.txt, my:file),
it doesn't return anything even though the file exists and is returned
from the previous query.
I'm not able to reproduce this. could you please file a jira issue on
http://issues.apache.org/jira/browse/JCR and provide a code fragment
that reproduces the problem you described?
I've also tried the following queries:
/Documents//element(*, my.file): returns nothing
/Documents//element(test.txt, my.file): returns nothing
/jcr:root//element(*, my.file): returns nothing
/jcr:root/Documents//element(*, my.file): returns nothing
/jcr:root/Documents//element(test.txt, my.file): returns nothing
there are two issues with the above queries:
1) /Documents will never return any nodes because absolute XPath queries
must always begin with /jcr:root (see spec section 6.6.4.3 for details)
you may also use a relative path:
Documents//elements(*, my:file)
2) my.file ? I guess this should be my:file. Unless you have a node type
without a namespace prefix and a local name 'my.file' this will of
course never match.
regards
marcel