[xquery-talk] when to use document { }?
Howard Katz
howardk at fatdog.com
Tue Jul 26 07:30:34 PDT 2005
> Does this make the document {} constructor clearer?
It does. I understand the difference; I was so focused on the serialized
result that I wasn't thinking about any further downstream processing.
Thanks to yourself, Mike, and Martin for reminding me that other clients
might be consuming the product of an XQuery transformation.
Howard
> -----Original Message-----
> From: talk-bounces at xquery.com
> [mailto:talk-bounces at xquery.com] On Behalf Of Jens Teubner
> Sent: Tuesday, July 26, 2005 3:42 AM
> To: talk at xquery.com
> Subject: Re: [xquery-talk] when to use document { }?
>
> On Mon, Jul 25, 2005 at 05:33:52PM -0700, Howard Katz wrote:
>
> > 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 :
> >
> > [...]
> >
> > 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?
>
> Well, the *serialized output* of that query may be the same
> with or without the document constructor, depending on your
> query engine.
>
> However, in the XQuery data model, the application of the
> document {} constructor makes a big difference. Consider,
> e.g. the queries
>
> let $a := <a/>
> return $a/a
>
> and
>
> let $a := document { <a/> }
> return $a/a
>
> In the former case, $a is bound to the element a. If you do
> a child step on that (empty) element, you will get an empty result.
>
> In the latter case, $a will be bound to a document node that
> sits on top of the (empty) element <a/>. If you now do a
> child step from $a, you will happliy get the <a/> element.
>
> Does this make the document {} constructor clearer?
>
> Jens
>
> --
> Jens Teubner
> Technische Universitaet Muenchen, Department of Informatics
> D-85748 Garching, Germany
> Tel: +49 89 289-17259 Fax: +49 89 289-17263
>
> Unix is user friendly - it's just picky about it's friends.
> _______________________________________________
> talk at xquery.com
> http://xquery.com/mailman/listinfo/talk
>
More information about the talk
mailing list