You are viewing a plain text version of this content. The canonical link for it is here.
Posted to dev@xalan.apache.org by Erik Dasque <ed...@silverstream.com> on 2000/03/03 20:48:29 UTC
Xerces serializer escape problem
Hi all,
I realize I might just be way over my head with this stuff. Please forgive me, I am a beginner when it comes to this stuff. Plus I am french so you can just blame everything on that :).
I am using Xerces serializer to print out an XML document in the console. While buidling the document in memory at some point I do :
Text myTxtNode = myXMLDocument.createTextNode((String) DOC_VALUES_Data.getProperty("STR_VALUE"));
DOC_VALUE_Elt.appendChild(myTxtNode);
if ((String) DOC_VALUES_Data.getProperty("STR_VALUE")) return null, the serializer bombs out (createTextNode doesn't)
java.lang.NullPointerException
at org.apache.xml.serialize.BaseMarkupSerializer.escape(BaseMarkupSerializer.java:1287)
that's result = new StringBuffer( source.length() );
at org.apache.xml.serialize.BaseMarkupSerializer.characters(BaseMarkupSerializer.java:910)
at org.apache.xml.serialize.BaseMarkupSerializer.serializeNode(BaseMarkupSerializer.java:732)
at org.apache.xml.serialize.XMLSerializer.serializeElement(XMLSerializer.java:464)
at org.apache.xml.serialize.BaseMarkupSerializer.serializeNode(BaseMarkupSerializer.java:754)
at org.apache.xml.serialize.XMLSerializer.serializeElement(XMLSerializer.java:464)
at org.apache.xml.serialize.BaseMarkupSerializer.serializeNode(BaseMarkupSerializer.java:754)
at org.apache.xml.serialize.BaseMarkupSerializer.serializeNode(BaseMarkupSerializer.java:795)
at org.apache.xml.serialize.BaseMarkupSerializer.serialize(BaseMarkupSerializer.java:385)
at com.silverstream.devcenter.drilldown.ServeXML.outputXMLDocumentFromInMemoryTree(ServeXML.java:574)
at com.silverstream.devcenter.drilldown.ServeXML.service(ServeXML.java:144)
at com.sssw.srv.busobj.AgoServletInvoker.serviceRequest(AgoServletInvoker.java:100)
at com.sssw.srv.resources.AgServletResource.service(AgServletResource.java:149)
at com.sssw.srv.resources.AgServletResource.perform(AgServletResource.java:107)
at com.sssw.srv.http.httpd.perform(httpd.java:3692)
at com.sssw.srv.http.Client.processRequest(Client.java:776)
at com.sssw.srv.http.Client.loop(Client.java:1106)
at com.sssw.srv.http.Client.runConnection(Client.java:1307)
at com.sssw.srv.http.Client.run(Client.java:1267)
at java.lang.Thread.run(Thread.java:479)
Should the serializer be careful of this or should the developper make sure the textnode string is not null ? Or should the XERCES DOM implementation should bom out before that when I try to insert it there ? I know that if I take the same document and process it through the Xalan XSLT engine, the text node just return "null". Does Xalan use this serializer ? Should it just insert an empty text node ?
I don't know what the correct behavior would be. It just seems inconsistent the way it is.
BTW I use the following XSLT processor :
org.apache.xalan.xslt.XSLTProcessor processor = new org.apache.xalan.xslt.XSLTEngineImpl(new org.apache.xalan.xpath.xdom.XercesLiaison());
and this code to serialize :
FileOutputStream XMLoutputStream = new FileOutputStream("XMLoutputStream");
XMLSerializer serial = new XMLSerializer(oStream, of);
serial.serialize(XMLdoc);
TIA,
Ed.
Re: Xerces serializer escape problem
Posted by Assaf Arkin <ar...@exoffice.com>.
Erik, I think that Xerces should place an empty string in an empty
TextNode, but at any rate, I'll make sure it doesn't crash and put a new
set of serializers up next week. I want to get some performance
improvements done first.
arkin
> Erik Dasque wrote:
>
> Hi all,
>
> I realize I might just be way over my head with this stuff. Please
> forgive me, I am a beginner when it comes to this stuff. Plus I am
> french so you can just blame everything on that :).
>
> I am using Xerces serializer to print out an XML document in the
> console. While buidling the document in memory at some point I do :
>
> Text myTxtNode = myXMLDocument.createTextNode((String)
> DOC_VALUES_Data.getProperty("STR_VALUE"));
>
> DOC_VALUE_Elt.appendChild(myTxtNode);
>
> if ((String) DOC_VALUES_Data.getProperty("STR_VALUE")) return null,
> the serializer bombs out (createTextNode doesn't)
>
>
> java.lang.NullPointerException
> at
> org.apache.xml.serialize.BaseMarkupSerializer.escape(BaseMarkupSerializer.java:1287)
> that's result = new StringBuffer(
> source.length() );
> at
> org.apache.xml.serialize.BaseMarkupSerializer.characters(BaseMarkupSerializer.java:910)
> at
> org.apache.xml.serialize.BaseMarkupSerializer.serializeNode(BaseMarkupSerializer.java:732)
> at
> org.apache.xml.serialize.XMLSerializer.serializeElement(XMLSerializer.java:464)
> at
> org.apache.xml.serialize.BaseMarkupSerializer.serializeNode(BaseMarkupSerializer.java:754)
> at
> org.apache.xml.serialize.XMLSerializer.serializeElement(XMLSerializer.java:464)
> at
> org.apache.xml.serialize.BaseMarkupSerializer.serializeNode(BaseMarkupSerializer.java:754)
> at
> org.apache.xml.serialize.BaseMarkupSerializer.serializeNode(BaseMarkupSerializer.java:795)
> at
> org.apache.xml.serialize.BaseMarkupSerializer.serialize(BaseMarkupSerializer.java:385)
> at
> com.silverstream.devcenter.drilldown.ServeXML.outputXMLDocumentFromInMemoryTree(ServeXML.java:574)
> at
> com.silverstream.devcenter.drilldown.ServeXML.service(ServeXML.java:144)
> at
> com.sssw.srv.busobj.AgoServletInvoker.serviceRequest(AgoServletInvoker.java:100)
> at
> com.sssw.srv.resources.AgServletResource.service(AgServletResource.java:149)
> at
> com.sssw.srv.resources.AgServletResource.perform(AgServletResource.java:107)
> at com.sssw.srv.http.httpd.perform(httpd.java:3692)
> at com.sssw.srv.http.Client.processRequest(Client.java:776)
> at com.sssw.srv.http.Client.loop(Client.java:1106)
> at com.sssw.srv.http.Client.runConnection(Client.java:1307)
> at com.sssw.srv.http.Client.run(Client.java:1267)
> at java.lang.Thread.run(Thread.java:479)
>
>
>
> Should the serializer be careful of this or should the developper make
> sure the textnode string is not null ? Or should the XERCES DOM
> implementation should bom out before that when I try to insert it
> there ? I know that if I take the same document and process it through
> the Xalan XSLT engine, the text node just return "null". Does Xalan
> use this serializer ? Should it just insert an empty text node ?
>
> I don't know what the correct behavior would be. It just seems
> inconsistent the way it is.
>
> BTW I use the following XSLT processor :
>
> org.apache.xalan.xslt.XSLTProcessor processor = new
> org.apache.xalan.xslt.XSLTEngineImpl(new
> org.apache.xalan.xpath.xdom.XercesLiaison());
>
> and this code to serialize :
>
> FileOutputStream XMLoutputStream = new
> FileOutputStream("XMLoutputStream");
> XMLSerializer serial = new XMLSerializer(oStream, of);
> serial.serialize(XMLdoc);
>
>
> TIA,
>
> Ed.
--
----------------------------------------------------------------------
Assaf Arkin www.exoffice.com
CTO, Exoffice Technologies, Inc. www.exolab.org
Re: Xerces serializer escape problem
Posted by Assaf Arkin <ar...@exoffice.com>.
Erik, I think that Xerces should place an empty string in an empty
TextNode, but at any rate, I'll make sure it doesn't crash and put a new
set of serializers up next week. I want to get some performance
improvements done first.
arkin
> Erik Dasque wrote:
>
> Hi all,
>
> I realize I might just be way over my head with this stuff. Please
> forgive me, I am a beginner when it comes to this stuff. Plus I am
> french so you can just blame everything on that :).
>
> I am using Xerces serializer to print out an XML document in the
> console. While buidling the document in memory at some point I do :
>
> Text myTxtNode = myXMLDocument.createTextNode((String)
> DOC_VALUES_Data.getProperty("STR_VALUE"));
>
> DOC_VALUE_Elt.appendChild(myTxtNode);
>
> if ((String) DOC_VALUES_Data.getProperty("STR_VALUE")) return null,
> the serializer bombs out (createTextNode doesn't)
>
>
> java.lang.NullPointerException
> at
> org.apache.xml.serialize.BaseMarkupSerializer.escape(BaseMarkupSerializer.java:1287)
> that's result = new StringBuffer(
> source.length() );
> at
> org.apache.xml.serialize.BaseMarkupSerializer.characters(BaseMarkupSerializer.java:910)
> at
> org.apache.xml.serialize.BaseMarkupSerializer.serializeNode(BaseMarkupSerializer.java:732)
> at
> org.apache.xml.serialize.XMLSerializer.serializeElement(XMLSerializer.java:464)
> at
> org.apache.xml.serialize.BaseMarkupSerializer.serializeNode(BaseMarkupSerializer.java:754)
> at
> org.apache.xml.serialize.XMLSerializer.serializeElement(XMLSerializer.java:464)
> at
> org.apache.xml.serialize.BaseMarkupSerializer.serializeNode(BaseMarkupSerializer.java:754)
> at
> org.apache.xml.serialize.BaseMarkupSerializer.serializeNode(BaseMarkupSerializer.java:795)
> at
> org.apache.xml.serialize.BaseMarkupSerializer.serialize(BaseMarkupSerializer.java:385)
> at
> com.silverstream.devcenter.drilldown.ServeXML.outputXMLDocumentFromInMemoryTree(ServeXML.java:574)
> at
> com.silverstream.devcenter.drilldown.ServeXML.service(ServeXML.java:144)
> at
> com.sssw.srv.busobj.AgoServletInvoker.serviceRequest(AgoServletInvoker.java:100)
> at
> com.sssw.srv.resources.AgServletResource.service(AgServletResource.java:149)
> at
> com.sssw.srv.resources.AgServletResource.perform(AgServletResource.java:107)
> at com.sssw.srv.http.httpd.perform(httpd.java:3692)
> at com.sssw.srv.http.Client.processRequest(Client.java:776)
> at com.sssw.srv.http.Client.loop(Client.java:1106)
> at com.sssw.srv.http.Client.runConnection(Client.java:1307)
> at com.sssw.srv.http.Client.run(Client.java:1267)
> at java.lang.Thread.run(Thread.java:479)
>
>
>
> Should the serializer be careful of this or should the developper make
> sure the textnode string is not null ? Or should the XERCES DOM
> implementation should bom out before that when I try to insert it
> there ? I know that if I take the same document and process it through
> the Xalan XSLT engine, the text node just return "null". Does Xalan
> use this serializer ? Should it just insert an empty text node ?
>
> I don't know what the correct behavior would be. It just seems
> inconsistent the way it is.
>
> BTW I use the following XSLT processor :
>
> org.apache.xalan.xslt.XSLTProcessor processor = new
> org.apache.xalan.xslt.XSLTEngineImpl(new
> org.apache.xalan.xpath.xdom.XercesLiaison());
>
> and this code to serialize :
>
> FileOutputStream XMLoutputStream = new
> FileOutputStream("XMLoutputStream");
> XMLSerializer serial = new XMLSerializer(oStream, of);
> serial.serialize(XMLdoc);
>
>
> TIA,
>
> Ed.
--
----------------------------------------------------------------------
Assaf Arkin www.exoffice.com
CTO, Exoffice Technologies, Inc. www.exolab.org