You are viewing a plain text version of this content. The canonical link for it is here.
Posted to dev@xalan.apache.org by Sc...@lotus.com on 2001/04/04 23:28:13 UTC

Re: Not sure if this is a bug, feature, or user error - can you help?

> I've been using Xerces-J 2.0.0

You mean XalanJ2?  First, I would upgrade to XalanJ 2.0.1.

To tell you the truth, I'm in the middle of some deep work right now and
can't spend a lot of time on this... and I don't want to give you the wrong
answer off the top of my head.  I took the liberty of cc'ing to xalan-dev,
since I didn't see anything sensitive in your note (you should really send
this kind of thing to xalan-dev and not to me).

Off the top of my head: I think this is by design, though maybe the wrong
design.  I think the idea was that you didn't want to force the caller to
repush all their params each time.  It seems silly now, but I think made
sense at the time.  Probably clearParameters() should be called in the
reset() method.

-scott




                                                                                                                    
                    Alex Blewitt                                                                                    
                    <Alex.Blewitt@        To:     sboag@apache.org                                                  
                    ioshq.com>            cc:     (bcc: Scott Boag/CAM/Lotus)                                       
                                          Subject:     Not sure if this is a bug, feature, or user error - can you  
                    04/04/2001            help?                                                                     
                    01:05 PM                                                                                        
                                                                                                                    
                                                                                                                    




Scott,

I've been using Xerces-J 2.0.0 with Ant 1.3, and I've uncovered what I am
not sure is a bug, feature, or merely misunderstanding. I've not filed it
as a bug since I don't know if it is a bug, but if it is, I'll do so.

When using <xsl:param/> and the TraX API, the 'parameter' values are saved
between transforms (as per API); presumably, this is a feature designed
for faster processing:

trax.setParam(...)
trax.transform(docOne)
trax.transform(docTwo)

In this case, '...' is available in both docOne and docTwo.

However, in my stylesheet I have:
<xsl:param name="title" select="/Page/Title/node()"/>

In the output, I get:
docOne.out: ... Title is 'TitleOne' ...
docTwo.out: ... Title is 'TitleOne' ...

It seems that the 'trax' is not only saving user-supplied parameters
(which I'd expect), but also parameters calculated on-the-fly with the
first transform. I was expecting that the 'title', given that it contained
document-specific data (in this case, the title of the document) that it
would be re-evaluated for the second one.

So, the biggie is: is this expected behaviour? I'd think not, but I'm not
sure whether my answer is the right one or not.

I had to hack Ant so that after each 'transform' it did a
'clearParameters' instead; whilst it solved the problem, it's neither
elegant, nor takes advantage of the stored parameters.

If this is a bug, let me know, and I'll file this as a bug report.

Thanks for your time,

Alex.

/***************************************************************\
|*       Alex Blewitt       * Hug, and the world hugs with you *|
|*  Alex.Blewitt@ioshq.com  *                                  *|
|* Mobile: +44 7966 158 647 *    Spread a little happiness     *|
\***************************************************************/







Re: Not sure if this is a bug, feature, or user error - can you help?

Posted by Alex Blewitt <Al...@ioshq.com>.
On Wed, 4 Apr 2001 Scott_Boag@lotus.com wrote:

> > I've been using Xerces-J 2.0.0
> 
> You mean XalanJ2?  First, I would upgrade to XalanJ 2.0.1.

D'oh! Yes, I do mena XalanJ2.

> Off the top of my head: I think this is by design, though maybe the wrong
> design.  I think the idea was that you didn't want to force the caller to
> repush all their params each time.

IMHO it is a nice feature to allow the user to not re-send their
parameters each time a transform() is called. However, the
transformer() should (IMHO) only cache the user-supplied parameters, and
not all the parameters that are generated during the transform process.

You could fix this pseduo trivially using:

public UserParamKeeperTransform extends Transformer {
  private Map userParms = new HashMap();
  public void setParameter(String name, Object value) {
    userParms.put(name,value);
  }
  public void transform(Source src, Result res) {
    super.clearParameters();
    Iterator i = userParms.keySet().iterator();
    while(i.hasNext()) { 
      String name = i.next().toString();
      super.setParameter(name,userParms.get(name));
    }
    super.transform(src,res);
  }
}

> It seems silly now, but I think made
> sense at the time.  Probably clearParameters() should be called in the
> reset() method.

Actually, I think there is benefit in caching the parameters - at least
the ones the user sends, if not the ones that are set from an XSL/document
pair.

In any case, the fix above demonstrates this w/o loosing this flexibility.

Alex.

--- 8< ---
> Scott,
> 
> I've been using Xerces-J 2.0.0 with Ant 1.3, and I've uncovered what I am
> not sure is a bug, feature, or merely misunderstanding. I've not filed it
> as a bug since I don't know if it is a bug, but if it is, I'll do so.
> 
> When using <xsl:param/> and the TraX API, the 'parameter' values are saved
> between transforms (as per API); presumably, this is a feature designed
> for faster processing:
> 
> trax.setParam(...)
> trax.transform(docOne)
> trax.transform(docTwo)
> 
> In this case, '...' is available in both docOne and docTwo.
> 
> However, in my stylesheet I have:
> <xsl:param name="title" select="/Page/Title/node()"/>
> 
> In the output, I get:
> docOne.out: ... Title is 'TitleOne' ...
> docTwo.out: ... Title is 'TitleOne' ...
> 
> It seems that the 'trax' is not only saving user-supplied parameters
> (which I'd expect), but also parameters calculated on-the-fly with the
> first transform. I was expecting that the 'title', given that it contained
> document-specific data (in this case, the title of the document) that it
> would be re-evaluated for the second one.
> 
> So, the biggie is: is this expected behaviour? I'd think not, but I'm not
> sure whether my answer is the right one or not.
> 
> I had to hack Ant so that after each 'transform' it did a
> 'clearParameters' instead; whilst it solved the problem, it's neither
> elegant, nor takes advantage of the stored parameters.
> 
> If this is a bug, let me know, and I'll file this as a bug report.
> 
> Thanks for your time,
> 
> Alex.

/***************************************************************\
|*       Alex Blewitt       * Hug, and the world hugs with you *|
|*  Alex.Blewitt@ioshq.com  *                                  *|
|* Mobile: +44 7966 158 647 *    Spread a little happiness     *|
\***************************************************************/