[XSL-LIST Mailing List Archive Home] [By Thread] [By Date]

[xsl] using SAX events in URIResolver


Subject: [xsl] using SAX events in URIResolver
From: Robert Koberg <rob@xxxxxxxxxx>
Date: Sat, 15 Jan 2005 08:34:55 -0800

Hi,

I am working on a cache for XML resolved through an URIResolver. I have been storing byte arrays and providing them as a ByteArrayInputStream to a StreamSource. It is very expensive to convert a file to a byte array and it still has to be parsed every time, so I am trying to provide cached SAX events. Is it possible? I have tried using Saxon653, Xalan and Resin to process the stylesheets (none work, but Saxon gets the closest). I have the following XML Parser system properties set:

org.xml.sax.driver=org.apache.xerces.parsers.XIncludeParserConfiguration
javax.xml.parsers.SAXParserFactory=org.apache.xerces.jaxp.SAXParserFactoryImpl
org.apache.xerces.xni.parser.XMLParserConfiguration=org.apache.xerces.parsers.XIncludeParserConfiguration

I am extending InputSource to be able to use an XMLFilter that stores an ArrayList of SAX events. The SAX events are output using the TransformerHandler from the transformation.

// handler is the current TransformerHandler
// file is the key/source for the cache entry

InputSource in = new SaxEventsInputSource(handler, file);

// entry is the XMLFilter that has the ArrayList of SAXEvents
// in is the extended InputSource

SAXSource source = new SAXSource(entry, in);


The events are stored correctly and when the parse of the XMLFilter occurs the events are output correctly (I believe). The parse calls a method (sendEvents) that iterates over the list of SAX events. See my trace of what is going on below the exception. I get the following exception when running the code:



java.lang.NullPointerException


at com.icl.saxon.output.GeneralOutputter.makeEmitter(GeneralOutputter.java:272)

at com.icl.saxon.output.GeneralOutputter.setOutputDestination(GeneralOutputter.java:66)

at com.icl.saxon.Controller.changeOutputDestination(Controller.java:405)

at com.icl.saxon.Controller.transformDocument(Controller.java:1076)

at com.icl.saxon.TransformerHandlerImpl.endDocument(TransformerHandlerImpl.java:101)

at com.livestoryboard.SaxEventsCacheEntry.sendEvents(Unknown Source)

at com.livestoryboard.SaxEventsCacheEntry.parse(Unknown Source)

at com.icl.saxon.om.Builder.build(Builder.java:265)

at com.icl.saxon.functions.Document.makeDoc(Document.java:228)

at com.icl.saxon.functions.Document.getDocuments(Document.java:134)

at com.icl.saxon.functions.Document.evaluate(Document.java:70)

at com.icl.saxon.functions.Document.reduce(Document.java:299)

at com.icl.saxon.expr.PathExpression.reduce(PathExpression.java:160)

at com.icl.saxon.expr.NodeSetExpression.evaluate(NodeSetExpression.java:39)

at com.icl.saxon.style.XSLGeneralVariable.getSelectValue(XSLGeneralVariable.java:251)

at com.icl.saxon.style.XSLVariable.process(XSLVariable.java:89)

at com.icl.saxon.style.XSLStyleSheet.process(XSLStyleSheet.java:626)

at com.icl.saxon.Controller.transformDocument(Controller.java:1082)

at com.icl.saxon.Controller.transform(Controller.java:953)

at com.livestoryboard.actions.Preview.service(Unknown Source)

at javax.servlet.http.HttpServlet.service(HttpServlet.java:103)

at com.caucho.server.http.FilterChainServlet.doFilter(FilterChainServlet.java:96)

at com.livestoryboard.actions.EntryFilter.doFilter(Unknown Source)

at com.caucho.server.http.FilterChainFilter.doFilter(FilterChainFilter.java:88)

at com.livestoryboard.actions.PermissionsFilter.doFilter(Unknown Source)

at com.caucho.server.http.FilterChainFilter.doFilter(FilterChainFilter.java:88)

at com.livestoryboard.actions.CheckUserFilter.doFilter(Unknown Source)

at com.caucho.server.http.FilterChainFilter.doFilter(FilterChainFilter.java:88)

at com.caucho.server.http.Invocation.service(Invocation.java:315)

at com.caucho.server.http.CacheInvocation.service(CacheInvocation.java:135)

at com.caucho.server.http.RunnerRequest.handleRequest(RunnerRequest.java:346)

at com.caucho.server.http.RunnerRequest.handleConnection(RunnerRequest.java:274)

at com.caucho.server.TcpConnection.run(TcpConnection.java:139)

at java.lang.Thread.run(Thread.java:595)







[Trace]

SaxEventsCache.getSaxSource file: projects\rob-test\lsb\metadata\site\site_root.xml

SaxEventsCache.getSaxSource entry: null

SaxEventsCacheEntry.parse source: org.xml.sax.InputSource@33b121

SaxEventsCacheEntry.startElement namespaceURI: http://livestoryboard.com/schemas/lsb

SaxEventsCacheEntry.startElement localName: md-folder

SaxEventsCacheEntry.startElement qualifiedName: md-folder

SaxEventsCache.getSaxSource entry NEW: com.livestoryboard.SaxEventsCacheEntry@1aa2c23

SaxEventsCacheEntry.parse source (instanceof SaxEventsInputSource): com.livestoryboard.SaxEventsInputSource@7d4a4

SaxEventsCacheEntry.sendEvents saxEvent: START_DOCUMENT

SaxEventsCacheEntry.sendEvents saxEvent: START_PREFIX_MAPPING

SaxEventsCacheEntry.sendEvents saxEvent: START_ELEMENT

SaxEventsCacheEntry.sendEvents saxEvent.getParm(0): http://livestoryboard.com/schemas/lsb

SaxEventsCacheEntry.sendEvents saxEvent.getParm(1): md-folder

SaxEventsCacheEntry.sendEvents saxEvent.getParm(2): md-folder

SaxEventsCacheEntry.sendEvents attParms[0]:

SaxEventsCacheEntry.sendEvents attParms[1]:

SaxEventsCacheEntry.sendEvents attParms[2]: xmlns

SaxEventsCacheEntry.sendEvents attParms[3]: CDATA

SaxEventsCacheEntry.sendEvents attParms[4]: http://livestoryboard.com/schemas/lsb

SaxEventsCacheEntry.sendEvents attParms[0]:

SaxEventsCacheEntry.sendEvents attParms[1]: created

SaxEventsCacheEntry.sendEvents attParms[2]: created

SaxEventsCacheEntry.sendEvents attParms[3]: CDATA

SaxEventsCacheEntry.sendEvents attParms[4]: 2004-03-08T11:25:05

SaxEventsCacheEntry.sendEvents attParms[0]:

SaxEventsCacheEntry.sendEvents attParms[1]: creator

SaxEventsCacheEntry.sendEvents attParms[2]: creator

SaxEventsCacheEntry.sendEvents attParms[3]: CDATA

SaxEventsCacheEntry.sendEvents attParms[4]: Robert Koberg

SaxEventsCacheEntry.sendEvents attParms[0]:

SaxEventsCacheEntry.sendEvents attParms[1]: last_mod_by

SaxEventsCacheEntry.sendEvents attParms[2]: last_mod_by

SaxEventsCacheEntry.sendEvents attParms[3]: CDATA

SaxEventsCacheEntry.sendEvents attParms[4]: Robert Koberg

SaxEventsCacheEntry.sendEvents attParms[0]:

SaxEventsCacheEntry.sendEvents attParms[1]: modified

SaxEventsCacheEntry.sendEvents attParms[2]: modified

SaxEventsCacheEntry.sendEvents attParms[3]: CDATA

SaxEventsCacheEntry.sendEvents attParms[4]: 2004-08-02T17:00:02

SaxEventsCacheEntry.sendEvents saxEvent: END_ELEMENT

SaxEventsCacheEntry.sendEvents saxEvent: END_PREFIX_MAPPING

SaxEventsCacheEntry.sendEvents saxEvent: END_DOCUMENT


Current Thread
Keywords
xml