[xquery-talk] when to use document { }?

Michael Kay mhk at mhk.me.uk
Tue Jul 26 11:02:19 PDT 2005


I can try two answers.

(a) it depends what happens to the result next. There's lots of XML software
that expects to handle documents, rather than parentless elements.
Parentless elements are rather a peculiarity of XQuery, in fact, and to me
they they have a feel of being "under construction". Perhaps the document
node will be added implicitly by the XQuery processor when the results are
passed on to someone else, but who knows?

(b) there's a difference if you're validating. Integrity constraints such as
uniqueness and referential integrity are checked only if you validate at
document level, not if you validate at element level.

Michael Kay
http://www.saxonica.com/
 

> -----Original Message-----
> From: talk-bounces at xquery.com 
> [mailto:talk-bounces at xquery.com] On Behalf Of Howard Katz
> Sent: 26 July 2005 01:34
> To: talk at xquery.com
> Subject: [xquery-talk] when to use document { }?
> 
> I just came across an example of a query being used to 
> generate an xhtml
> document where the query is wrapped in a document constructor  :
> 
> document {
>  
> <html xmlns="http://www.w3.org/1999/xhtml">
> 
> ...
> 
> </html>
> }
> 
> What is the document constructor doing in this case? The query would
> generate perfectly good xhtml without it, would it not? I 
> know that Saxon
> automatically applies document construction to any document 
> being serialized
> (unless you turn it off), but I've seen lots of perfectly 
> valid xml/xhtml
> generated without its use in other environments. What's the difference
> between the two cases?
> 
> TIA,
> Howard
> 
> _______________________________________________
> talk at xquery.com
> http://xquery.com/mailman/listinfo/talk
> 




More information about the talk mailing list