[XML-DEV Mailing List Archive Home] [By Thread] [By Date] [Recent Entries] [Reply To This Message]

SAX XPath Filter


sax xpath
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



PURCHASE STYLUS STUDIO ONLINE TODAY!

Purchasing Stylus Studio from our online shop is Easy, Secure and Value Priced!

Buy Stylus Studio Now

Download The World's Best XML IDE!

Accelerate XML development with our award-winning XML IDE - Download a free trial today!

Don't miss another message! Subscribe to this list today.
Email
First Name
Last Name
Company
Subscribe in XML format
RSS 2.0
Atom 0.3
 

Stylus Studio has published XML-DEV in RSS and ATOM formats, enabling users to easily subcribe to the list from their preferred news reader application.


Stylus Studio Sponsored Links are added links designed to provide related and additional information to the visitors of this website. they were not included by the author in the initial post. To view the content without the Sponsor Links please click here.

Site Map | Privacy Policy | Terms of Use | Trademarks
Free Stylus Studio XML Training:
W3C Member
Stylus Studio® and DataDirect XQuery ™are products from DataDirect Technologies, is a registered trademark of Progress Software Corporation, in the U.S. and other countries. © 2004-2013 All Rights Reserved.