Question

Currently I'm using Eclipses XQuery plugin xqdt with the XQuery engine Zorba.

I would like the XQuery engine to "type check" the correctness of my XPath expressions, e.g. if the schema defines videos/video is allowed, but videos/pictures isn't, the interpreter should warn that the latter XPath expression is invalid.

I've tried to follow the Schema-Aware Queries and Stylesheets tutorial, but I can't get it to work. My code examples use the sample video.xml and the sample video.xsd from the tutorial.

My first, stripped down example of theirs results in an type error: import schema default element namespace "" at "videos.xsd";

1   import schema default element namespace "" at "videos.xsd";
2
3   declare variable $input as schema-element(result) := doc('videos.xml')/*;
4   for $v in $input/videos/video
5   return $v
 ...\XQqueryProject\videos.xq>:3,1: type error [err:XPTY0004]: 
element(result, xs:untyped) can not be treated as type schema-element(result)

Playing with types, using element instead of schema-element doesn't warn me about my misspelled video2 path and doesn't print anything:

import schema default element namespace "" at "videos.xsd";

declare variable $input as element(result) := doc('videos.xml')/*;
for $v in $input/videos/video2
return $v

Q: Could someone provide me with a minimal working example where $input/videos/video2 fails?

Update: I've added namespaces to the videos.xsd, the videos.xml and changed the import schema to

import schema default element namespace "myVideos" at "videos.xsd";

, but without success.

Was it helpful?

Solution

Neither XQDT nor Zorba support static validation of XPath expressions wrt. schemas. There is/was quite some research happening around that topic but (afaik) non of them have made it into a product, yet.

For example, you could get in touch with the guys over at http://wam.inrialpes.fr/websolver/ to see what the status of this project is.

Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top