xsl-list
[Top] [All Lists]

RE: using SAX events in URIResolver

2005-01-15 10:07:46
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? 

Saxon 6.5.3 in fact maintains a result tree fragment in the form of a list
of SAX events. See the source code of com.icl.saxon.expr.FragmentValue. In
the end, however, I discovered that the TinyTree is a more efficient
representation of a document (especially, of course, as 2.0 allows full
XPath access into the document). You would be better off building the tree
and caching it in that form, especially as it involves writing less code.

A minor point: if you're transforming the same document multiple times, it's
best not to use xsl:strip-space in the stylesheet.


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

This sort of question really belongs on the saxon-help list, not here. The
relevant line of GeneralOutputter reads:

throw new IllegalArgumentException("Unknown type of Result: " +
result.getClass());

so the NullPointerException occurs during an unsuccessful attempt to report
a fatal error, which looks to me simply like a failure to call setResult()
on the TransformerHandler.

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



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

      at 
com.icl.saxon.output.GeneralOutputter.setOutputDestination(Gen
eralOutputter.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(TransformerHa
ndlerImpl.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(NodeSetExpressio
n.java:39)

      at 
com.icl.saxon.style.XSLGeneralVariable.getSelectValue(XSLGener
alVariable.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(FilterChain
Servlet.java:96)

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

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

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

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

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

      at 
com.caucho.server.http.FilterChainFilter.doFilter(FilterChainF
ilter.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(RunnerReque
st.java:346)

      at 
com.caucho.server.http.RunnerRequest.handleConnection(RunnerRe
quest.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(_dot_)xml(_dot_)sax(_dot_)InputSource(_at_)33b121

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

SaxEventsCacheEntry.startElement localName: md-folder

SaxEventsCacheEntry.startElement qualifiedName: md-folder

SaxEventsCache.getSaxSource entry NEW: 
com(_dot_)livestoryboard(_dot_)SaxEventsCacheEntry(_at_)1aa2c23

SaxEventsCacheEntry.parse source (instanceof SaxEventsInputSource): 
com(_dot_)livestoryboard(_dot_)SaxEventsInputSource(_at_)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


--~------------------------------------------------------------------
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>
--~--




--~------------------------------------------------------------------
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>
--~--