[EMAIL PROTECTED] wrote:
> Gary,
> I thought this was a valid bug because when I looked at the code for the
> document() function, it seemed to me that if there was only one argument
> (nodeset or not) we were always getting the base id from the context node,
> which may not necessarily be the same as the base from the nodes in the
> nodeset. I think I'm missing something because I don't see us ever getting
> the base from the nodes in the nodeset. If the value of the node from the
> nodeset is absolute, all is well, but if not, we resolve it with the base
> id of the context node from what I can see. I thought this may be wrong??
> What do you think? I'm confused!
Okay. I just looked at the code:) I've got it. You said "... we were
always getting the base id from the context node, ..." but I think you
meant that "... we were always getting the base id from the stylesheet
node containing the document() function, ...".
The PrefixResolver pushed by XalanJ is the PrefixResolver used to
evaluate the XPath expression which is generally (except for XPathAPI
but that's another story), the node in the stylesheet where the
document() function appears. So, as Evan reports, we are always using
the Base URI of that node (in the stylesheet) as the Base URI.
This stems from a statement in the XSLT Recommendation section 12.1 that
is somewhat misleading when taken out of context. It is in the ninth
paragraph of that section, the one after the "NOTE:". It starts "The
URI reference may be relative." Then, it says "If the second argument
is omitted, then it defaults to the node in the stylesheet that contains
the expression that includes the call to the document function." This
is exactly what XalanJ is doing.
However, this is wrong.
The document function can be called in four ways:
1. document(node-set)
2. document(node-set, node-set)
3. document(non-node-set)
4. document(non-node-set, node-set)
The second paragraph of section 12.1 makes it clear that, when called
with a "type 1" call, that is treated as the union of a series of "type
4" calls. For each node N in the first argument node-set, a "type 4"
call is made using as the first argument the string-value of N and,
using as the second argument a node-set with N as its only memeber.
Thus, if the stylesheet is making a "type 1" call, this is converted
into a series of "type 4" calls in which, obviously, the second argument
can never be omitted.
The second paragraph of section 12.1 disposes completely of how to
handle "type 1" and "type 2" calls. It is clear that the rest of
section 12.1 is addressing "type 3" and "type 4" calls. Thus, the
sentence that I quoted above ("If the second argument is omitted, then
it defaults to the node in the stylesheet that contains the expression
that includes the call to the document function.") applies only to "type
3" calls. However, XalanJ is applying it, incorrectly, to "type 1"
calls as well.
So Myriam, your analysis was correct and this is a bug and Evan should
enter it into Bugzilla, please.
As a workaround, Evan, if all of the nodes in the node-set have the same
Base URI, you can specify that node-set as the second argument to the
document function and all should work okay. If the nodes in the first
argument node-set have different Base URIs, you're basically screwed
until we fix the bug.
Gary