using Apache URI resolver with xquery
Added by Anonymous about 17 years ago
Legacy ID: #4527173 Legacy Poster: nan00k (nan00k)
Hi: I'm using a collection function in xQuery 1.0 to traverse a directory tree of target xml docs, as in ... collection('/directory/sub-directory?recurse=yes;select=*.xml')/root but my xml files have Doctype declarations with public identifiers, so I figure I need to add a uri resolver to my command line to reference a catalog file. I've successfully done this with xslt transforms by following instructions that come with resolver.jar, and also at http://www.sagehill.net/docbookxsl/UseCatalog.html, but I'm not having as much success invoking the xquery command. Can someone give me a hand? Thanks. Matt Stoeffler.
Replies (5)
Please register to reply
RE: using Apache URI resolver with xquery - Added by Anonymous about 17 years ago
Legacy ID: #4529498 Legacy Poster: Michael Kay (mhkay)
Unfortunately the XQuery command line doesn't have any equivalent to the -x flag on the Transform command line, so I don't think this can be done from the command line. You can do it from the Java API, of course - and you could create yourself an extended command line by modifying the net.sf.saxon.Query module, because it's just an interface built over the Java API. Michael Kay http://www.saxonica.com/
RE: using Apache URI resolver with xquery - Added by Anonymous about 17 years ago
Legacy ID: #4530662 Legacy Poster: nan00k (nan00k)
Hmmm. Ok. I can work on getting the resolver in place. In the mean time, testing the query itself over a fairly large sample of about 1000 documents, my query throws a out of memory exception ... Exception in thread "main" java.lang.OutOfMemoryError: Java heap space Can one incorporate saxon:discard-document() into the query to help recover memory? m./
RE: using Apache URI resolver with xquery - Added by Anonymous about 17 years ago
Legacy ID: #4531342 Legacy Poster: Michael Kay (mhkay)
>Can one incorporate saxon:discard-document() into the query to help recover memory? Yes, you can.
RE: using Apache URI resolver with xquery - Added by Anonymous about 17 years ago
Legacy ID: #4536761 Legacy Poster: nan00k (nan00k)
Still not getting there. Maybe you can help flesh out the problem a little. I have a directory structure of documents. I use collection('/directory/sub-directory?recurse=yes;select=.xml') to gain access to the document collection. I've tried two approaches, neither of which work. Approach 1 is: let $uris := collection('/directory/sub-directory?recurse=yes;select=.xml')/saxon:discard-document(.) for $uri in $uris ... return ... This does not resolve the memory problem. Approach 2 is: let $uris := collection('/directory/sub-directory?recurse=yes;select=*.xml') for $u in $uris let $uri := saxon:discard-document(doc($u)) .... return ... This doesn't work because the collection function returns document nodes, and what doc wants is a URI. What is the work around, or is there none in this situation?
RE: using Apache URI resolver with xquery - Added by Anonymous about 17 years ago
Legacy ID: #4536790 Legacy Poster: nan00k (nan00k)
Here is a third approach that appears to work: let $uris := collection('/directory/sub-directory?recurse=yes;select=*.xml') for $u in $uris let $uri := saxon:discard-document(doc(document-uri($u))) is that the best way to do this?
Please register to reply