Subject: ResultTreeFragment and XT extension mechanism From: Denys Duchier <Denys.Duchier@xxxxxxxxxxxx> Date: 07 Aug 1999 23:32:56 +0200 |
Hi James, Sorry to bug you again, but I have been trying to figure out how to use the extension mechanism to build a database of result tree fragments (to speed up various transformations). My test example below simply allows to save and retrieve one result tree fragment. >From looking at the code I thought that I needed to invoke an instance method for the `wrapping' process to work (correct me if I am wrong), but that still didn't quite do the trick. With the example below, XT gives me the following output/error: *** PUT *** *** NEW *** *** GET *** <one xmlns:save="http://www.jclark.com/xt/java/Save"> [1] <two>HELLO</two><two xmlns:save="http://www.jclark.com/xt/java/Save">HELLO</two>Exception in thread "main" java.lang.NullPointerException at com.jclark.xsl.sax.XMLOutputHandler.put(Compiled Code) at com.jclark.xsl.sax.XMLOutputHandler.writeRaw(Compiled Code) at com.jclark.xsl.sax.XMLOutputHandler.characters(Compiled Code) at com.jclark.xsl.sax.ResultBase.flush(Compiled Code) at com.jclark.xsl.sax.ResultBase.endElement(Compiled Code) at com.jclark.xsl.tr.LiteralElementAction.invoke(Compiled Code) at com.jclark.xsl.tr.AppendAction.invoke(Compiled Code) at com.jclark.xsl.tr.SheetImpl$ProcessContextImpl.processSafe(Compiled Code) at com.jclark.xsl.tr.SheetImpl.process(Compiled Code) at com.jclark.xsl.sax.XSLProcessorImpl.parse(Compiled Code) at com.jclark.xsl.sax.Driver.transform(Compiled Code) at com.jclark.xsl.sax.Driver.transformFile(Compiled Code) at com.jclark.xsl.sax.Driver.main(Compiled Code) I have tracked the problem down to method endDocument of XMLOutputHandler. It appears to clean things up too early. When I comment out the clean ups as shown below, then my test example works as expected: public void endDocument() throws SAXException { if (bufUsed != 0) flushBuf(); // try { // out.close(); // } // catch (java.io.IOException e) { // throw new SAXException(e); // } // out = null; // buf = null; } Here are the 3 files for my test example: ==== FILE: Save.java import com.jclark.xsl.sax.ResultTreeFragment; public class Save { private static ResultTreeFragment tree; public Save() { System.err.println("*** NEW ***"); } public static boolean put(ResultTreeFragment t) { System.err.println("*** PUT ***"); tree = t; return true; } public ResultTreeFragment get() { System.err.println("*** GET ***"); return tree; } } ==== FILE: save.xsl <xsl:stylesheet xmlns:xsl="http://www.w3.org/XSL/Transform/1.0" xmlns:save="http://www.jclark.com/xt/java/Save" result-ns=""> <xsl:template match="/"> <one> <xsl:variable name="x"> <two>HELLO</two> </xsl:variable> <xsl:if test="save:put($x)"/> <xsl:text> [1] </xsl:text> <xsl:copy-of select="$x"/> <xsl:text> [2] </xsl:text> <xsl:copy-of select="save:get(save:new())"/> <xsl:text> [3] </xsl:text> </one> </xsl:template> </xsl:stylesheet> ==== FILE: save.xml <hello> <world>How are you?</world> </hello> -- Dr. Denys Duchier Denys.Duchier@xxxxxxxxxxxx Forschungsbereich Programmiersysteme (Programming Systems Lab) Universitaet des Saarlandes, Geb. 45 http://www.ps.uni-sb.de/~duchier Postfach 15 11 50 Phone: +49 681 302 5618 66041 Saarbruecken, Germany Fax: +49 681 302 5615 XSL-List info and archive: http://www.mulberrytech.com/xsl/xsl-list
Current Thread |
---|
|
<- Previous | Index | Next -> |
---|---|---|
Re: parameter concatinating, Scott Boag/CAM/Lotus | Thread | More on: ResultTreeFragment and XT , Denys Duchier |
RE: XSL controversy, Sebastian Rahtz | Date | Re: fo:bidi-override - is it necess, Frank Wegmann |
Month |