TRAX: Passing parameters to a "pull" transformer

The TRAX API for performing XSL transformations includes a factory extension, SAXTransformerFactory, which can return a transformer hidden behind a SAX XML Filter. This allows multiple transformations to be easily chained together, as per the Filter design pattern. Moreover, it allows filters backed by transformations to be intermixed with other types of filter implementations, which can simplify the code for iterative XML processing.

Unfortunately, returning the transformer as a class that implements only XMLFilter effectively hides the methods defined by javax.xml.transform.Transformer, including those used to pass global parameters to the transformation process. This is unfortunate.

I think a better solution would have been to return an interface that extends both XMLFilter and Transformer, allowing the caller to set up the filter chain, and then pass parameters to some or all of the filters before processing. This is one of the things that I liked about James Clark's XT: his XSLProcessor class extended XMLParser (the SAX 1.0 predecessor of XMLReader), so they could be made easily into filters. Of course, having to wrap processors in XMLReaderAdapators (to allow the SAX 1.0 parser to read from a SAX 2.0 reader) makes for its own headaches.

Comments:

Post a Comment:
Comments are closed for this entry.
About

gjmurphy

Search

Top Tags
Archives
« April 2014
SunMonTueWedThuFriSat
  
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
   
       
Today