xsl-list
[Top] [All Lists]

RE: [xsl] [Saxon-SA] SAX filter for stylesheet

2007-07-19 05:32:51
he list.

1.  If one wants to implement a SAX filter to intercept 
parsing of a stylesheet (using Saxon -y option) what is the 
best/easiest Java class to inherit from. 

org.xml.sax.helpers.XMLFilterImpl

You also need to implement org.xml.sax.Locator (in the same or a different
class).

Apart from the Locator methods, I think the only things you need to do are

(a) intercept startElement() method that reads the line number information
and saves it somewhere

(b) intercept setDocumentLocator() and pass your ContentHandler (Saxon) a
different Locator.


2. Using Eclipse 3.3 and Ant, my way of doing XSLT has been 
something like this in my Ant build:

  <target name="trax">

    <!-- trax test -->
    <xslt processor="trax"
          basedir="./input/"
          destdir="./output/"
          extension=".xsl"
          style="./xsl/compilers/high-to-low-xsl.xsl">
    </xslt>

  </target>

Since upgrading to Saxon-SA I would like the Ant trax 
processor to recognize specific arguments to be presented to 
Saxon-SA.  How do I do this?  Rationale for question: want to 
use Saxon-SA -y command line option.

The Ant xslt task allows you to specify values for TransformerFactory
properties

<factory name="com.saxonica.SchemaAwareTransformerFactory">
  <attribute name="http://saxon.sf.net/feature/styleParserClass";
             value="your.sax.Filter"/>

Alternatively, there's the beginnings of an Ant task specifically for
Saxon-SA in 8.9, see 

http://www.saxonica.com/documentation/using-xsl/xsltfromant.html

but it's very rudimentary. If you want to make any enhancements, I'll send
you my current version of the code and you can work from that as a baseline.
Although it drives Saxon-SA, the Ant task itself is open-source (largely
because it's built on Apache code as the baseline).  

Regards,

Michael Kay
http://www.saxonica.com/


--~------------------------------------------------------------------
XSL-List info and archive:  http://www.mulberrytech.com/xsl/xsl-list
To unsubscribe, go to: http://lists.mulberrytech.com/xsl-list/
or e-mail: <mailto:xsl-list-unsubscribe(_at_)lists(_dot_)mulberrytech(_dot_)com>
--~--

<Prev in Thread] Current Thread [Next in Thread>