[XSL-LIST Mailing List Archive Home] [By Thread] [By Date]

Re: [xsl] XALAN does not handle document('') as expected to carry out an in-stylesheet look-up


Subject: Re: [xsl] XALAN does not handle document('') as expected to carry out an in-stylesheet look-up
From: David_N_Bertoni@xxxxxxxxx
Date: Thu, 1 Nov 2001 19:38:14 -0500

> Seems to me that this is very clear - document('') should give you the
root
> of the stylesheet, which is what Mark wanted.  Instead, it seems that
Xalan
> is trying to get a document at the base url of the xml document.  This
would
> give the same result if it had in fact been in the same directory as the
> stylesheet, but here there never was a physical xml document.
>
> Sounds like a bug to me.
>
> Cheers,
>
> Tom P

Not true.  Xalan knows the fully-qualified URI of the stylesheet when it's
built from a source that specifies a URI.  The problem is that XSLT
interprets the XML for a stylesheet in different ways than the XML for a
source document.  For example, the whitespace stripping rules are
different.  If document('') returned the root of the stylesheet as
processed using the rules for stylesheets, it would not have the same form
as if it were processed as a source document.  The recommendation is clear
that the tree returned _must_ respect the data model:

   "Note that a zero-length URI reference is a reference to the document
   relative to which the URI reference is being resolved; thus document("")
   refers to the root node of the stylesheet; the tree representation of
   the stylesheet is exactly the same as if the XML document containing the
   stylesheet was the initial source document."

It also implies that the stylesheet must be stored as a tree, and I don't
believe the recommendation says any such thing.

This:

   "However my application applies the template after reading the XSL
   transform from a
   database and then applying it to a document."

leads me to believe that the XML for the stylesheet is being read from a
database, so there's no URI available.  If a stylesheet has no URI
associated with it, how is a processor supposed to find it relative to
anything?  If this is expected to work properly in every case, it would
require the processor to keep the XPath tree representation of the
stylesheet available in the off chance the user asks for it through the
document() function.  I don't think anyone really wants or expects that,
and I don't think the recommendation requires it.

Mark, if you believe this to be a bug, I encourage you to post a message on
the Xalan developer list, or post a bug in the Bugzilla database on the
Apache web site.  If you're interested in the details of implementing an
EntityResolver, I'd suggest the Xalan developer list.

Dave


 XSL-List info and archive:  http://www.mulberrytech.com/xsl/xsl-list



Current Thread
Keywords