OK this bug is now fixed - thanks once again for both finding it and
replicating it in a JellyUnit test case. This made fixing it considerably
easier.

It was a strange, hard to explain bug caused by the current TagScript
implementation (in the impl package). The bug is due to the body of a
<jsl:template> actually being invoked from outside of the TemplateTag's
doTag() method (as its invoked from inside the stylesheet) and so the parent
of the nested tags could get stale when the stylesheet is redefined in a
loop. This is now fixed in CVS.

James
-------
http://radio.weblogs.com/0112098/
----- Original Message -----
From: <[EMAIL PROTECTED]>
To: <[EMAIL PROTECTED]>
Sent: Sunday, November 17, 2002 3:52 AM
Subject: [jelly] [jsl] XPath context for templates and looping


> I have what appears to be a bug in the jsl tag library wrt relative select
> attributes.
>
> In a script (actually the conversion of Maven's site.dvsl to jelly's jsl),
> I
> 1)loop through a set of files using core:forEach.
> 2) Within the loop each file is then parsed using xml:parse.
> 3) The parsed doc is then used as the source of the jsl:stylesheet
> 4) Within a template an xml:expr is used to retrieve nodes with a select
> relative to the template (or so I thought), e.g.
> select="./properties/author"
>
> First  time through all gets extracted as expected. For every other
> iteration though, it appears the xpath context has 'remembered' the
> original document.
>
> Here's a snippet:
> ---------- Start Snippet ---------
> Step 1:    <j:forEach var="file" items="${docFiles.iterator()}">
> Step 2:      <x:parse var="doc" xml="${file.toURL()}" />
> Step 3:      <jsl:stylesheet select="$doc">
>              <jsl:template match="document" trim="no">
>               <x:doctype name="html"
>                 publicId="-//CollabNet//DTD XHTML 1.0 Transitional//EN"
>                 systemId=
> "http://www.collabnet.com/dtds/collabnet_transitional_10.dtd"; />
>               <html>
>                 <head>
> Step 4:           <j:set var="docTitle"><x:expr select=
> "./properties/title" /></j:set>
>                   Test <x:expr select="./properties/title" /> - <x:expr
> select="$doc/document/properties/title" />
>
> ---------- End Snippet -----------
>
> On the Test line above, just after Step 4, the first expr stays the same
> all the way through the loop.
> The second expr changes as I would expect.
>
> Anything I can do to work around this, short of specifying the full select
> attribute each time?
>
> I've tried to find out where the bad code is, but so far no luck :)
> --
> dIon Gillard, Multitask Consulting
> Work:      http://www.multitask.com.au
> Developers: http://adslgateway.multitask.com.au/developers
>
>
> --
> To unsubscribe, e-mail:
<mailto:[EMAIL PROTECTED]>
> For additional commands, e-mail:
<mailto:[EMAIL PROTECTED]>
>


--
To unsubscribe, e-mail:   <mailto:[EMAIL PROTECTED]>
For additional commands, e-mail: <mailto:[EMAIL PROTECTED]>

Reply via email to