xml-xalan-j-users mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From peter peter <marseboy2...@yahoo.com>
Subject Serialization giving probem with HashMap
Date Fri, 02 May 2003 22:35:15 GMT
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.
Mime
View raw message