At 4:46 PM -0600 4/29/02, Uche Ogbuji wrote:
>> You can XInclude anywhere you want to. You just can't do it as part
>> of an XSLT transformation.
>
>So you claim, but you still haven't been able to back this assertion
>up with concrete citations, or even compelling examples.
>
OK. Here's a concrete citation:
A transformation expressed in XSLT describes rules for transforming a
source tree into a result tree. The transformation is achieved by
associating patterns with templates. A pattern is matched against
elements in the source tree. A template is instantiated to create
part of the result tree. The result tree is separate from the source
tree. The structure of the result tree can be completely different
from the structure of the source tree. In constructing the result
tree, elements from the source tree can be filtered and reordered,
and arbitrary structure can be added.
Source: http://www.w3.org/TR/xslt#section-Introduction
From XPath 1.0 which XSLT 1.0 normatively references
http://www.w3.org/TR/xpath#data-model we discover,
XPath operates on an XML document as a tree. This section describes
how XPath models an XML document as a tree. This model is conceptual
only and does not mandate any particular implementation.
And finally from XML 1.0, 2nd edition, we find:
A data object is an XML document if it is well-formed, as defined in
this specification.
I could copy and paste the rest of the relevant specs, but you get
the idea. There's a clear path from the character representation of
the XML document to the source tree on which XSLT operates. There's
no wiggle-room for performing other processes on the document before
XSLT gets ahold of it. XSLT/XPath/XML state quite clearly how the
input document is to be represented and modeled and how the
transformation is applied. At no point is there any room for saying
"Gee, let's throw away some elements from the input tree and replace
them with others before we do the transformation."
Now if you do want to apply a different process to Document A and
produce Document B before you transform, that's your right. This
process can be XInclusion, a SAX filter, another XSLT transform, or
just about anything else that produces a well-formed XML document.
However, what you end up with is the transformation of document B,
not the transformation of document A. And if you're shipping a tool
that automatically transforms A into B before applying the
stylesheet, then that is simply not a conformant XSLT processor.
As to practical uses, here's one: I have a document full of
XInclusions that point to text files on my hard drive. Tomorrow I
decide to migrate all the examples to an equivalent directory
structure on my server. Thus I write an XSLT stylesheet that
transforms all attributes of the form
xinclude:href="examples/XX/filename.xml" to the form
xinclude:href="http://www.cafeconleche.org/examples/XX/filename.xml"
while leaving all other content intact. If the processor is resolving
XIncludes behind my back, that transform is not going to do what I
want and what the sp0ec says it should do.
Here's another example: The namespace URI or some other aspect of the
syntax for XInclude changes between working drafts so I write an
XSLT stylesheet to migrate my documents forward; e.g. by adding a
standard fallback element. Again, this should work but it fails if
the XSLT processor takes it upon itself to process XIncludes.
XInclusion is a separate layer of processing which I can choose to
perform or not, before or after an XSLT process. However I cannot
choose to perform it *during* an XSLT process or as an inseparable
part of an XSLT process.
To say that it is somehow OK for an XSLT processor to perform
XInclusions, is as silly as saying it's OK for an XSLT processor to
throw delete all elements with the name rectangle or to replace all
attributes in the namespace http://www.w3.org/1999/xlink with
elements. Anything can be done in a preprocess, not just XInclusions,
but any such preprocesses produce different documents and
transforming the processed documents is not the same as transforming
the original documents.
--
+-----------------------+------------------------+-------------------+
| Elliotte Rusty Harold | | Writer/Programmer |
+-----------------------+------------------------+-------------------+
| The XML Bible, 2nd Edition (Hungry Minds, 2001) |
| http://www.cafeconleche.org/books/bible2/ |
| http://www.amazon.com/exec/obidos/ISBN=0764547607/cafeaulaitA/ |
+----------------------------------+---------------------------------+
| Read Cafe au Lait for Java News: http://www.cafeaulait.org/ |
| Read Cafe con Leche for XML News: http://www.cafeconleche.org/ |
+----------------------------------+---------------------------------+