Hmm! I looked into this and see what is happening, but I unfortunately
don't have an explanation. Maybe someone else on the list can help us?
In the Variable.execute code if m_fixUpWasCalled is false, we will go to
the stylesheet root and look for variables on that stylesheetRoot's list of
variables. $DocRoot however is in the context's stack of variables (which
we don't look at). I'm not sure whether there is a bug here or if it's
working as designed. Scott, if you see this can you please comment??
Thanks,
Myriam
"Rick Bullotta"
<rick.bullotta@lighth To: <[EMAIL PROTECTED]>
ammer.com> cc: (bcc: Myriam Midy/CAM/Lotus)
Subject: RE: Xalan 2.2 D11 -
Change
10/03/01 09:26 AM in xalan:evaluate - Bug?
Please respond to
xalan-dev
A strange side effect related to variable name resolution has been
identified resulting from the use of a variable to hold the document
node...I suspect there is some type of scoping/resolution weirdness going
on
here.
Case 1 works fine:
====================
<xsl:variable name="DocRoot" select="/"/>
<xsl:variable name="SubtotalColumn">TotalSales</xsl:variable>
<xsl:for-each select="Rowsets">
<!-- Build an grouping expression that can be evaluated
dynamically based
on the request subtotal column -->
<xsl:variable name
="GroupExpr">$DocRoot/Rowsets/Rowset/Row/<xsl:value-of
select="$SubtotalColumn"/></xsl:variable>
<xsl:variable name="GroupList"
select="xalan:distinct(xalan:evaluate($GroupExpr))"/>
<xsl:for-each select="$GroupList">
====================
Case 2, which does not use the intermediate "GroupList" variable, does not
work properly.
====================
<xsl:variable name="DocRoot" select="/"/>
<xsl:variable name="SubtotalColumn">TotalSales</xsl:variable>
<xsl:for-each select="Rowsets">
<!-- Build an grouping expression that can be evaluated
dynamically based
on the request subtotal column -->
<xsl:variable name
="GroupExpr">$DocRoot/Rowsets/Rowset/Row/<xsl:value-of
select="$SubtotalColumn"/></xsl:variable>
<xsl:for-each select="xalan:distinct(xalan:evaluate($GroupExpr))">
====================
The latter generates an exception,
javax.xml.transform.TransformerException:
Variable not resolvable: DocRoot
Best regards,
Rick Bullotta
Lighthammer
-----Original Message-----
From: [EMAIL PROTECTED] [mailto:[EMAIL PROTECTED]]
Sent: Tuesday, October 02, 2001 8:11 PM
To: [EMAIL PROTECTED]
Subject: RE: Xalan 2.2 D11 - Change in xalan:evaluate - Bug?
Can't you just bind the document node to a variable before you enter the
for-each loop?
-scott
"Rick Bullotta"
<rick.bullotta@lighth To:
<[EMAIL PROTECTED]>
ammer.com> cc: (bcc: Scott
Boag/CAM/Lotus)
Subject: RE: Xalan 2.2
D11 - Change in xalan:evaluate - Bug?
10/02/2001 05:53 PM
Please respond to
xalan-dev
Understood. Now the million dollar question, how can one go about
referencing the "real" original document inside the loop? There doesn't
seem to be an obvious way to do so...but for obvious reasons, this would be
essential to be able to do so. Since tokenize only returns a list of text
nodes, is the "document context" really changed? Or should it?
This is obviously be an essential feature to have (reference "original"
document inside the loop), without which the ability to use the
tokenize/evaluate/etc extension functions would be of dramatically reduced
value. Does a node/nodeset returned from the xalan:evaluate function share
this behavior?
It worked "as expected" in 2.1. Welcoming any suggestions!
Many thanks.
- Rick
-----Original Message-----
From: [EMAIL PROTECTED] [mailto:[EMAIL PROTECTED]]
Sent: Tuesday, October 02, 2001 5:39 PM
To: [EMAIL PROTECTED]
Subject: RE: Xalan 2.2 D11 - Change in xalan:evaluate - Bug?
Ok, let me try to explain what I think the problem is. The xsl:for-each is
changing your context node to whatever node is returned by the tokenize
function. Remember that that node was build from a factory and does not
belong to the original document. So, when you try to select a node for the
xsl:value-of, we try to go back to the root of the current document pointed
to by the context node. Obviously, it is not the original document, so
there is no match. That's why we're getting empty results. I'm not sure
what exactly you're trying to do, but you have to make sure that your
context node is the original document.
Myriam
"Rick Bullotta"
<rick.bullotta@lighth To:
<[EMAIL PROTECTED]>
ammer.com> cc: (bcc: Myriam
Midy/CAM/Lotus)
Subject: RE: Xalan 2.2
D11 - Change
10/02/01 05:24 PM in xalan:evaluate - Bug?
Please respond to
xalan-dev
I didn't see the null pointer, but I did get the empty results inside the
loop. FYI, we're using the Transformer object with a DOMSource for the XML
and a DOMSource for the XSL, outputting to a StreamOutput. Another side
note, not that it may matter, but in Xalan 2.1, the xalan:tokenizer
extension function would not work when there was no "context node" yet.
For
example, trying to assign the results of the xalan:tokenizer function to a
variable, right inside the start of a template as in:
<xsl:param name="ColumnHeadings">A,B,C</xsl:param>
<xsl:template match="/">
<xsl:variable name="mylist" select="xalan:tokenize
($ColumnHeadings,',')"/>
<xsl:for-each select="blah blah"
...would not work in Xalan 2.1. Moving it inside the for-each did,
however.
Weird and wacky. But seemingly addressed in 2.2D11.
Curious to see what you sleuth out...
- Rick
-----Original Message-----
From: [EMAIL PROTECTED] [mailto:[EMAIL PROTECTED]]
Sent: Tuesday, October 02, 2001 5:02 PM
To: [EMAIL PROTECTED]
Subject: RE: Xalan 2.2 D11 - Change in xalan:evaluate - Bug?
Rick, were you getting a NullPointerException? That's what I got at first,
and once I fixed that, than I was not getting anything for the results
inside the for-each loop.
Myriam
"Rick Bullotta"
<rick.bullotta@lighth To:
<[EMAIL PROTECTED]>
ammer.com> cc: (bcc: Myriam
Midy/CAM/Lotus)
Subject: RE: Xalan 2.2
D11 - Change
10/02/01 03:26 PM in xalan:evaluate - Bug?
Please respond to
xalan-dev
Here's what I think is going on:
It appears not to be specific to "xalan:evaluate", but rather, there
appears
to be a more general problem evaluating an XPath expression on the source
XML document of a transformation from within a for-each loop on the results
of a xalan:tokenize extension function call. The attached files
demonstrate
the error.
Regards,
Rick Bullotta
Lighthammer
-----Original Message-----
From: [EMAIL PROTECTED] [mailto:[EMAIL PROTECTED]]
Sent: Tuesday, October 02, 2001 2:50 PM
To: [EMAIL PROTECTED]
Subject: RE: Xalan 2.2 D11 - Change in xalan:evaluate - Bug?
Rick,
What exactly is the problem? Can you include a zip file with the xsl and
xml files?
Thanks,
Myriam
"Rick Bullotta"
<rick.bullotta@lighth To:
<[EMAIL PROTECTED]>
ammer.com> cc: (bcc: Myriam
Midy/CAM/Lotus)
Subject: RE: Xalan 2.2
D11 - Change
10/02/01 02:45 PM in xalan:evaluate - Bug?
Please respond to
xalan-dev
Ignore last posting! You can already tell why...<g> Cut and paste strikes
again...the evaluate issue still exists, though.
-----Original Message-----
From: Rick Bullotta [mailto:[EMAIL PROTECTED]]
Sent: Tuesday, October 02, 2001 2:27 PM
To: [EMAIL PROTECTED]
Subject: RE: Xalan 2.2 D11 - Change in xalan:evaluate - Bug?
As a followup, the issue appears elsewhere, for example, given the
following
XML document:
<?xml version="1.0" encoding="UTF-8" standalone="no"?>
<Rowsets DateCreated="2001-10-02 12:59:13" EndDate="2001-10-02 12:59:13"
StartDate="2001-10-02 11:59:13" Version="9.0">
<Rowset>
.....
(See attached file: Samples.zip)