OASIS Mailing List ArchivesView the OASIS mailing list archive below
or browse/search using MarkMail.

 


Help: OASIS Mailing Lists Help | MarkMail Help

 


 

   SAX XPath Filter

[ Lists Home | Date Index | Thread Index ]

I am building some components that I can use in a SAX process chain.
One of them is the 'QueryURIResolver' that is used from an XSLT
transformation. It enables you to execute an SQL Statement,
and import the results directly into the transformation,
for example through the XPath document() function.
I used Michael Kay's (thanks for the reply in saxon-help) saxon Java
project to implement it.
This is roughly how it works:

---> = uses    - - -[> = implements

QueryTransformerHandler - - -[> javax.xml.transform.sax.TransformerHandler
   |
   +--> Transformer
         |
         +--> QueryURIResolver - - -[> javax.xml.transform.URIResolver
                  |
                  +--> QueryXMLReader - - -[> org.xml.sax.XMLReader

I prepare the QueryURIResolver by setting a
java.sql.PreparedStatement on it.

The QueryTransformerHandler behaves like an org.xml.sax.ContentHandler.
I feed it some very simple XPath-like expressions, for example '/root/sub'
or '/root/*/sub/'. During the xml-processing it filters out the data
indicated by the XPath-like expressions. The data is passed to the
QueryURIResolver, which then prepares the SQL Statement by setting its
parameters.

When the endDocument() method is called the TransformerHandler triggers
the XSLT transformation. During the transformation, when an external
document is requested, the QueryURIResolver catches the 'query-uri',
and then triggers the execution of the SQL Statement.

A QueryXMLReader actually executes the statement. And the results are then
made available in the transformation process, as the result node-set of
the document() funcion.

1. Is this a good idea or a bad idea? Any comments are welcome.
2. Of course I would like to improve the XPath support in the
   QueryTransformerHandler. But it is very tricky to write this component.
   I cannot find any code that I can use, but it is very unlikely that this
   idea is new.
   So I am looking for an org.xml.sax.ContentHandler that filters data from
   a SAX stream, using XPath expressions.
   
I hope this makes sense...

bye bye,

Bart Swennenhuis






 

News | XML in Industry | Calendar | XML Registry
Marketplace | Resources | MyXML.org | Sponsors | Privacy Statement

Copyright 2001 XML.org. This site is hosted by OASIS