Subjects
Home
Xalan extension functions
Fomatting question serializing DOM with pretty print
xalan with pull parser
Cannot find the declaration
Apache Xalan drop support to run on JRE 1 1 x
Why does Doctype change processing of a document
Node set to XML string via Java extensions in Xalan J: possible?
Templates/Transformers + thread safety???
Problem evaluating xpath with muliple prefix with different namespace
remove an arbitrary attribute from xsl output
Xalan3 XSLT 2 0 XPath 2 0 support?
Problem using compiled translets with Xalan !!
Xalan and jstl 1 1 problem with transform tag
NullPointer in DOM2DTM getLocalName
URIResolvers base parameter with xsltc and cascaded imports
Performance problem for Xalan J on intel dual core
Standard libraries in JAXP?
Serializing a DOM tree to XML file, customize entities replacement
Library Conflict Involving BCEL Library
A question on how users are using <xsl:message >
Kevin Cormier as a new Apache Xalan J committer
Struggling to iterate over tokenized string
Xalan count() trouble
Problem with recursive xpath
Error when switching to java 1 5
document( ' ')
Problem with Xalan2 7 0 transformation
cr/lf options
entity encoded XML
can xalan transform 2 xml using one xslt?
Xalan J JIRA defect review Monday October 16, 2006 from 2:00 to 3:30 pm ED
xsl transform with cdata section elements
xslt parameters not expanded
Weird behavior of XPath evaluate()
How to avoid <xsl:message > instruction prints stylesheet file informations ?
Cannot find SimpleTransform subdirectory after installing Xalan J
recover from document not found exceptions
jdk1 5 and Xalan jar differences?
Performance Issue
Error/Bug adding floating point numbers
XPathAPI: eval exp using nodes with default namespace
modifying xalan to output invalid XML
NullPointerException
mege two separate xml nodes into one
Is this a XALAN document identification bug?
is StylesheetRoot really java io Serializable ?
transform() fails for DOMSource but succeeds for StreamSource
Thoughts on Transformer parameter passing
HELP, Xalan and jstl 1 1 problem with transformer
Problem with XPath namespace axis?
string utils:replace deleting search string if replacement string is an HTML
help with enumeration values pls
xalan 2 5 1 vs 2 7 performance question
How to insert/update in XML document
HTML Serialization and Handling of Ampersands in HREF Attributes
XHTML link tag stripping
SystemId Unknown; Line #24; Column #49; java lang NullPointerException
xpath text() help
Apostrophe problem with xalan 2 7 0
How to set variables in XML document?
Links
Home
Oracle database error code ...
 
Search:  
Power your search with and, or, +, -, or "some phrase" operators.
Serialization giving probem with HashMap

Serialization giving probem with HashMap

2003-05-02       - By peter peter
Reply:     1     2  

Hi,   I am creating a new document and could serialize it without fail.  But if
I add the created document to the HashMap. and then get the document from
hashMap and try to serialize, OutputFormat throws NullPointerException, Here's
the exception message--- /*java.lang.NullPointerException
       at org.apache.xml.serialize.OutputFormat.whichMethod(Unknown Source)
       at org.apache.xml.serialize.OutputFormat.<init>(Unknown Source)*/ Here
's the code I am using--->  HashMap documentsMap = new HashMap();
Document doc= new DocumentImpl();
Element root = doc.createElement("person");     // Create Root Element
Element item = doc.createElement("name");       // Create element
item.appendChild( doc.createTextNode("Jeff") );
root.appendChild( item );                       // Attach another Element -  
doc.appendChild( root );                        // Add Root to Document//add to
the HashMap....
documentsMap.put("node1",doc );
 try
 {
  Iterator iterator = documentsMap.entrySet().iterator();
  while (iterator.hasNext() )
  {
     Object key = iterator.next();
     doc= (Document)taxonomyNodesMap.get(key);
     OutputFormat format  = new OutputFormat( doc );   //Serialize DOM
     StringWriter  stringOut = new StringWriter();        //Writer will be a  
     XMLSerializer    serial = new XMLSerializer( stringOut, format );
   serial.asDOMSerializer();                            // As a DOM Serializer
   serial.serialize( doc.getDocumentElement());
  }
 }catch...... Any help will be greatly appreciated.. Regards,Peter



---------------------------------
Do you Yahoo!?
The New Yahoo! Search - Faster. Easier. Bingo.
<DIV>Hi,</DIV>
<DIV>&nbsp;&nbsp; I am creating a new document&nbsp;and could serialize it
without fail.</DIV>
<DIV>&nbsp;</DIV>
<DIV>&nbsp;But&nbsp;if I add the created document&nbsp;to the&nbsp;HashMap.
&nbsp;and then&nbsp;get the document from hashMap and try to serialize,&nbsp
;OutputFormat throws NullPointerException,</DIV>
<DIV>&nbsp;</DIV>
<DIV>Here's the exception message---</DIV>
<DIV>&nbsp;</DIV>
<DIV>/*</DIV>
<DIV>java.lang.NullPointerException<BR>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;
&nbsp; at org.apache.xml.serialize.OutputFormat.whichMethod(Unknown Source)<BR>
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; at org.apache.xml.serialize
.OutputFormat.&lt;init&gt;(Unknown Source)*/</DIV>
<DIV>&nbsp;</DIV>
<DIV>Here's the code I am using---&gt;</DIV>
<DIV>&nbsp;</DIV>
<DIV>&nbsp;HashMap documentsMap = new HashMap();<BR>&nbsp;Document doc= new
DocumentImpl();<BR>&nbsp;Element root = doc.createElement("person");&nbsp;&nbsp
;&nbsp;&nbsp; // Create Root Element<BR>&nbsp;Element item = doc.createElement(
"name");&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; // Create element<BR>&nbsp;item
.appendChild( doc.createTextNode("Jeff") ); <BR>&nbsp;root.appendChild( item );
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; // Attach another Element
-&nbsp;&nbsp; doc.appendChild( root );&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp
;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;
&nbsp;&nbsp;&nbsp; // Add Root to Document</DIV>
<DIV>//add to the HashMap....<BR>documentsMap.put("node1",doc );<BR>&nbsp;&nbsp
;try<BR>&nbsp;&nbsp;{<BR>&nbsp;&nbsp;&nbsp;Iterator iterator = documentsMap
.entrySet().iterator();<BR>&nbsp;&nbsp;&nbsp;while (iterator.hasNext() )<BR>
&nbsp;&nbsp;&nbsp;{<BR>&nbsp;&nbsp; &nbsp;&nbsp;&nbsp;Object key = iterator.next
();<BR>&nbsp;&nbsp;&nbsp;&nbsp; &nbsp;doc= (Document)taxonomyNodesMap.get(key);
<BR>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; OutputFormat format&nbsp; = new OutputFormat(
doc );&nbsp;&nbsp; //Serialize DOM<BR>&nbsp;&nbsp;&nbsp;&nbsp; &nbsp
;StringWriter&nbsp; stringOut = new StringWriter();&nbsp;&nbsp;&nbsp;&nbsp;&nbsp
;&nbsp;&nbsp; //Writer will be a&nbsp;&nbsp; </DIV>
<DIV>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;XMLSerializer&nbsp;&nbsp;&nbsp; serial = new
XMLSerializer( stringOut, format );<BR>&nbsp;&nbsp;&nbsp;&nbsp;serial
.asDOMSerializer();&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;
&nbsp;&nbsp;&nbsp;&nbsp; // As a DOM Serializer<BR>&nbsp;&nbsp;&nbsp;&nbsp
;serial.serialize( doc.getDocumentElement());<BR>&nbsp;&nbsp;&nbsp;}<BR>&nbsp;
&nbsp;}catch......</DIV>
<DIV>&nbsp;</DIV>
<DIV>Any help will be greatly appreciated..</DIV>
<DIV>&nbsp;</DIV>
<DIV>Regards,</DIV>
<DIV>Peter</DIV><BR><BR><p><hr SIZE=1>
Do you Yahoo!?<br>
<a href="http://us.rd.yahoo.com/search/mailsig/*http://search.yahoo.com">The
New Yahoo! Search</a> - Faster. Easier. Bingo.