cocoon-dev mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From "Scott Boag/CAM/Lotus" <>
Subject RE: XSLT API Proposal (Draft 2)
Date Tue, 08 Feb 2000 03:29:00 GMT

Kay Michael <> wrote:
> How about Processor, Transformer, and Transformation? That gets across
> idea that one transformer can do many transformations.

Frankly I like TransformContext a bit better than Transformation.  It gets
the idea across that this is a one-per-thread object, for the purpose of
non-static data during the transform.  I'm not sure if a Transformer is the
stylesheet, or if the Transformation is the stylesheet.

Processor or TransformFactory?  I kind of like TransformFactory better.
And then I was thinking...

Maybe we could back out of having a SourceTree object, which introduces
certain problems, and just have:

public interface TransformFactory
Transform createTransform(XSLTInputSource source);
XSLTInputSource getAssociatedStylesheet(XSLTInputSource source, String
media, String title, String charset);
// TransformSourceHandler just extends DocumentHandler with a getTransform
() method.
TransformSourceHandler getTransformSourceHandler(Parser parser, String

Which would replace the Processor/ExecContext.  If the processor has to
load the XML for getAssociatedStylesheet, it can easily remember that it
has done so.  This would make the TransformFactory have pretty much the
sole responsibility of creating stylesheets.  getTransformSourceHandler
would flatten the issue of the DocumentHandler, though I can see that
people will still think it ought to be part of the XSLTInputSource.

> Transformer transformer = processor.makeTransformer(new
> XSLTInputSource("style.xsl"));
> transformation.setParameter("name", "value");
> transformation.process(new XSLTInputSource(uri[i]), oprop);

Transformer and Transformation just seem too close to me... I think people
would mix them up.  What do other's think?

Bottom line: names are important.  This is a good discussion.

> DocumentInfo sourceDoc = (new Builder()).build(inputSource);
> String styleURI = sourceDoc.getAssociatedStylesheet();
> if (styleURI.startsWith('#')) {
>          transformer =
> sourceDoc.getEmbeddedStylesheet(styleURI.substring(1));
> } else {
>          transformer = processor.makeTransformer(new
> XSLTInputSource(styleURI));
> }
> (transformer.makeTransformation()).process(sourceDoc, oprop);

OK, let me try this as a close-to equivalent:

TransformFactory tfactory = XSLTFactory.newTransformFactory(...);
XSLTInputSource transformSource = tfactory.getAssociatedStylesheet(
inputSource, null, null, null);
// I'm going to assume the processor should be able to handle an embedded
Transform transform = (null != transformSource) ? tfactory.createTransform(
          : tfactory.createTransform(new XSLTInputSource("default.xsl");
transform.process(transform.getContext(), sourceDoc, oprop);


View raw message