I am trying to stream out sax events from dom4j (1.6) elements into an
XSL content handler to transform into HTML and I'm getting a null
pointer exception from a saxon (6.5.3) class.  I was wondering if
someone has worked through this before.  Do I need to do something
with namespaces, or is the document not initialized properly?
startDocument is protected, otherwise I'd try calling that first.  Any
help would be appreciated.

java.lang.NullPointerException
        at com.icl.saxon.tinytree.TinyBuilder.startElement(TinyBuilder.java:137)
        at com.icl.saxon.ContentEmitter.startElement(ContentEmitter.java:121)
        at org.dom4j.io.SAXWriter.startElement(SAXWriter.java:810)
        at org.dom4j.io.SAXWriter.writeOpen(SAXWriter.java:233)
…

------------------------------------------------------------------------------------------

Below is the fragment of my code:

 

PrintWriter out = response.getWriter();
StreamResult result = new StreamResult(out);
SAXWriter sax = new SAXWriter();
Source xsltSourceOne = new StreamSource(new File(xslFile));
TransformerHandler tHandler1 = factory.newTransformerHandler(xsltSourceOne);
sax.setContentHandler(tHandler1);
tHandler1.setResult(result);
Element root = DocumentHelper.createElement("Root");
sax.writeOpen(root);     //--- NullPointer thrown here


------------------------------------------------------------------------------------------

Here is the block of code from saxon.
 

    public void startElement (nameCode, Attributes attributes, int[]
namespaces, int namespacesUsed) throws TransformerException
    {
         // System.err.println("TinyBuilder Start element (" + nameCode + ")");
        // Construct element name as a Name object

        TinyDocumentImpl doc = (TinyDocumentImpl)currentDocument;

        // register the namespaces

        int firstNS = (namespacesUsed==0 ? -1 : doc.numberOfNamespaces);
        for (int n=0; n<namespacesUsed; n++) {
            doc.addNamespace(   nodeNr,
                                namespaces[n] );
        }

        namespacesUsed = 0;

        // register the attributes


        int numAtts = attributes.getLength();
        int firstAtt = (numAtts==0 ? -1 : doc.numberOfAttributes);

       doc.addNode(NodeInfo.ELEMENT, currentDepth, firstAtt, firstNS,
nameCode); //--- Line 137 Null Pointer

 

Dave
N¬HS^µéšŠX¬²š'²ŠÞu¼Ž­§%y*Zqä°yêlµ©±f§¶ÚzØ^~*ì¶Ê·«yׯzZ)z¸§²–œxIíz¹èÁú+¶Ž­§%y*Zqä°yêlµ©²m§ÿÚvÊ,vw(›ö?‰

Reply via email to