tomcat-taglibs-user mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From Marius Scurtescu <>
Subject param tag and other suggestions
Date Thu, 02 Nov 2000 00:37:05 GMT

I run into a problem with the 'apply' tag: there is no way
specify a stylesheet parameter.

By looking at the source code I realized that it would be 
quite easy to add this functionality, and since I needed
it I decided to implement it.

The way I solved the problem is by adding an extra tag,
called 'param', which is supposed to be used only directly
inside an 'apply' tag. This 'param' tag will get the stylesheet
parameter name and value and pass them to the 'apply' tag.
The 'apply' tag will set these parameters, if any, to the
XSLT processor just before doing the processing.

An example:
<xsl:apply xml="some.xml" xsl="some.xsl">
  <xsl:param name="name1" value="value1"/>
  <xsl:param name="name2" param="reqname"/>

The parameter value can be specified in two ways: directly
with the 'value' attribute or by referencing a request
parameter with the 'param' attribute.

I added tow classes to the package: ParamTag and ParamTEI.
ApplyTag was slightly modified. It has a method, setParam,
through which one can add parameters and these parameters
are applied before processing. I added a comment starting
with "// marius:" where I modified ApplyTag.

Is there a process in place through which I could get
commit rights?

The attached zip files contains the added and modified
source code and tld and also the compiled code if you
want to try this out.

A few other suggestions and comments:

- the "xml" attribute of the apply tag is not very useful,
it will try to locate an xml file in the folder where the
application is installed but any realistic xml file will not
reside there

- the body of the 'apply' tag can contain the actual xml file
and this does not make much sense; the xml part of the
transformation is the most likely to be the dynamic one and
you would not hard code it into your jsp file; it would make
all the sense in the world to hardcode the xsl file since
this represent style just as jsp does

- I suggest adding two new tags: xml and xsl; these tags
would be used inside the apply tag and will offer an
alternative to hardcode the xml and xsl content

An example using the xsl:
<xsl:apply xml="some.xml">
  <xsl:param name="name" value="xxx"/>
    <?xml version="1.0" encoding="UTF-8"?>
    <xsl:stylesheet version="1.0" xmlns:xsl="...">
      <xsl:output method="html" indent="yes"/>

If these tags are used then the body of 'apply' can be always
ignored and the xml and xsl data would be set by these
inner tags.

It would also make sense to create an ApplyTEI class to deal 
with the arguments instead of doing this in the ApplyTag itself.

I apologies if some of my observations are stupid due
to ignorance, I am new to this list and to xsl.


Marius Scurtescu, Software Engineer
Tel: (604) 899-2835 Fax: (604) 899-2899
Multiactive Software Inc.
Attract and retain customers with Multiactive Software --
proud winners of PC WEEK's "Best of COMDEX" award.
View raw message