cocoon-dev mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From Colin Paul Adams <co...@colina.demon.co.uk>
Subject CForms stylesheets - use of xsl:param and xhtml
Date Tue, 29 Jun 2004 15:39:20 GMT
The stylesheets in $COCOON_ROOT/src/blocks/samples/resources only
handle html input/output. 
I use xhtml exclusively. Whilst I can easily copy the stylesheets to a
private directory, and change them to work with xhtml instead, I would
then have to re-work them every time changes were made to the
distrbuted versions. Also other people would not benefit.

So I thought it would be pretty easy to
change the stylesheets so they could cope with either html or xhtml
input (generating output as html for html input and xhtml as xhtml
output).

In principle, it IS easy, but I have come across two problems.

The first is how to indicate to the stylsheets which format to use.
No problem - just provide a global boolean xsl:param in the driver stylesheet
(forms-samples-styling.xsl), defaulting to false, which can be set in
the sitemap to true, if you want XHTML.

The only problem with this is that is people have created their own
driver stylesheet, then it will lack the parameter, and the
stylesheets won't compile.
But I guess as CForms is not yet stable, this could be acceptable.

Then there is a related problem - basically a bug in the current
stylesheets (but it may be intentional, if their is instead a bug in
Xalan-J - I don't know - I'm guessing).

The problem is that according to the XSLT specification (both 1.0 and
2.0), it is an error to have two global parameters with the same name
in a stylesheet with the same import precedence, unless there is one
with a higher import precedence.

Now, in forms-advanced-field-styling.xsl, there is a global parameter
named resources-uri.
This module xsl:includes forms-calendar-styling.xsl and
forms-htmlarea-styling.xsl both of which re-declare (identically) the
same global parameter. As they are included rather than imported, they
all have the same import precedence.
A possible fix is to include rather than import these two modules -
but maybe there is a good reason why this can't be done (I haven't
looked at them closely enough to determine if include is necessary).
A simpler fix is to remove the declarations from the included
stylesheets - both of them state that they are designed to be included
from forms-advanced-field-styling.xsl, so the global param is
guarenteed to be present.
My only worry about this is that there might be some bug in Xalan-C
that has caused them to be written like this.
presumably there is already a bug in this area with Xalan-C as the
spec indicates that the current stylesheets are in error, and so
should be rejected. Saxon 8 rejects them. Interestingly, xsltproc does
not reject them.

So after all that, if I were to provide patches that:
a) Remove the offending global parameter from the two stylesheets,
b) add a global parameter to the driver stylesheet
c) Add code to all the stylesheets to read either html or xhtml input,
and write output as html or xhtml according to the value of the new
parameter

would these pathces be accepted? (If not, then I don't want to bother,
as it is then easier for me to do a copy-paste-edit cycle)
-- 
Colin Paul Adams
Preston Lancashire

Mime
View raw message