Lists Home |
Date Index |
> I have a question about view construction in xml.
> Problem Setting
> Given a XML database DB, and a query Q1, either XQuery or
> XSLT, we refer
> to the result of Q1(DB) (the result of running query Q1
> against database
> DB) as a view, say V, whose schema is Sv.
In XQuery, the result of a query is not an XML document, it is a sequence of
items, where each item may be either an atomic value or a node. It's
meaningful to talk about the type of the result, but not about its schema.
In XSLT, the result of a transformation is indeed an XML document. In
general, though, the result document has no schema.
> Suppose we have another query Q2 (either XQuery or XSLT) which is
> formulated against schema Sv (the schema of the view V) and the
> size of view V too big to fit in memory, my questions are:
> 1) Is it possible that we evaluate Q2(V), (that is running Q2
> against the
> result of Q1(DB)), without materializing (or write back to
> hard disk) the
> result of Q1(DB)?
In XSLT this is normal practice: see the JAXP interfaces, which allows a
pipeline of transformations to be run as filters. However, although the
intermediate result does not need to be written to disk, all existing
processors require that it exists as a tree in memory.
For XQuery the same notion is likely to be supported - that the result of
one query can be used as input to another - but the implementations and APIs
aren't yet as advanced.
> As we know, in relational database, Q2(V) can be evaluated without
> materializing the view V. However, I am not sure if it is
> still hold in
> XML database.
Actually, SQL has another interesting property, which as that Q1 and Q2 can
be combined statically into a single query and optimized as a unit. I think
XQuery will also have that property, because it is a fully compositional
language. You can't to the same thing with XSLT, because template rules
aren't fully compositional expressions in the same way.