Project

Profile

Help

Constructing Result Documents with XQuery

Added by Anonymous over 17 years ago

Legacy ID: #4538317 Legacy Poster: W. Eliot Kimber (drmacro)

I didn't see this in the Saxon8B documentation but I was looking for the equivalent of result-document() as an extension to Saxon's XQuery support. I realize that the document{} constructor per the spec has an empty document-uri property but it seems reasonable for Saxon to allow you to set one. Anyway, I'm finding I'm using XQuery to do more easily what before I would have used XSLT to do, for example, convert a single source document to multiple result documents. So I'm thinking that something like this would make sense: for $e in doc("mydoc.xml")/*/chapter let $doc := document{$e} return saxon:result-document(concat($e/@id, '.xml'), $doc) Thanks, Eliot


Replies (4)

Please register to reply

RE: Constructing Result Documents with XQuery - Added by Anonymous over 17 years ago

Legacy ID: #4538392 Legacy Poster: Michael Kay (mhkay)

I agree, in principle it would be nice to offer something like this. It's difficult to come up with a satisfactory specification, however. xsl:result-document is very carefully designed to avoid problems with side-effects; essentially, you're only allowed to call it at a point where other instructions would be writing to the final result tree, and that makes it pretty certain that they're not going to be optimized away. I wouldn't want saxon:result-document() as you show it to actually return the constructed document, because that would mean it has to be materialized in memory. Perhaps it would work to return the value of the first argument (that is, the URI). It would also be nice to offer some control over serialization, perhaps along the lines of saxon:serialize(). Michael Kay

RE: Constructing Result Documents with XQuery - Added by Anonymous about 17 years ago

Legacy ID: #4539360 Legacy Poster: W. Eliot Kimber (drmacro)

I can't claim to understand the implementation challenges with generating result docs, but I do appreciate that there might subtle problems there. For serialization it would be nice to have the same soft of control you have with xsl:output. My reading of the spec indicates that implementations are certainly allowed, if not encouraged, to have that sort of control. There are definitely use cases for having a query generate HTML or plain text, rather than XML. Cheers, Eliot

RE: Constructing Result Documents with XQuery - Added by Anonymous about 17 years ago

Legacy ID: #4539660 Legacy Poster: Michael Kay (mhkay)

Saxon already provides options in the prolog to control serialization of the primary query output (e.g. declare option saxon:output "method=html";) - the question is how to do it for secondary outputs. The mechanism used for saxon:serialize http://www.saxonica.com/documentation/extensions/functions/serialize.html is somewhat exotic, but it seems to do the job and could be brought into play for this case too.

RE: Constructing Result Documents with XQuery - Added by Anonymous about 17 years ago

Legacy ID: #4544491 Legacy Poster: W. Eliot Kimber (drmacro)

OK, I didn't see the options when I was going through the docs (which surprised me because it seemed like something you would have done as a matter of course :-)). Thanks for considering the feature request. Cheers, E.

    (1-4/4)

    Please register to reply