Dear All,
unfortunately I cannot serialize items
using DOM/LS.
I get an NullPointerException because
Node.getParentNode() returns null.
Here's the use-case:
public
class
Test
{
public
static
void
main(String[] args) throws
Exception
{
System.setProperty("org.basex.path",
"D:\\ODX-Development-Neu\\odx-workspace\\.database");
Context context = new
Context();
try
{
//
//
open DB and query an item
//
new
Open("vag").execute(context);
QueryProcessor
queryProcessor = new
QueryProcessor("//BASE-VARIANT[SHORT-NAME='BV_EnginContrModul1UDS']",
context);
Item item
= queryProcessor.iter().next();
//
//
serialize item, proofs that result is here
//
Serializer
serializer = queryProcessor.getSerializer(System.out);
//
can the queryProcessor be closed here?
queryProcessor.close();
serializer.serialize(item);
serializer.close();
//
//
write with DOM fails!!!
//
org.w3c.dom.Node
node = (org.w3c.dom.Node)item.toJava();
DOMImplementationLS
domImplementationLS = (DOMImplementationLS)DOMImplementationRegistry.newInstance().getDOMImplementation("LS");
LSOutput
lsOutput = domImplementationLS.createLSOutput();
lsOutput.setByteStream(System.out);
LSSerializer
lsSerializer = domImplementationLS.createLSSerializer();
lsSerializer.getDomConfig().setParameter("format-pretty-print",
Boolean.TRUE);
lsSerializer.write(node,
lsOutput);
}
finally
{
context.close();
}
}
}
And the exception:
Caused by: java.lang.NullPointerException
at com.sun.org.apache.xml.internal.serialize.DOMSerializerImpl.prepareForSerialization(DOMSerializerImpl.java:1064)
at com.sun.org.apache.xml.internal.serialize.DOMSerializerImpl.write(DOMSerializerImpl.java:747)
... 1 more
I am using the latest snapshot: BaseX76-20130131.202759
Can you help me?
Mit freundlichen Grüßen/Best regards
Dr. Michael Hedenus
Software Developer
Powertrain Engine Systems CSW ETV RGB T2
PIXEL GmbH
Im Gewerbepark C15, 93059 Regensburg, Germany
Telefon/Phone: +49 941 790-6362
Telefax: +49 941 79013-90771
E-Mail: michael.hedenus-ext@continental-corporation.com
www.continental-corporation.com
______________________________________________________________________
Continental Automotive GmbH, Siemensstr. 12, 93055 Regensburg, Germany
Geschäftsführer/Managing Directors: Helmut Matschi, Gérard Cordonnier,
Harald Stuhlmann
Sitz der Gesellschaft/Registered office: Hannover
Registergericht/Commercial registry: Hannover, HRB 59424, USt-Id. Nr. DE814950663
_______________________________________________________________________
Proprietary and confidential. Distribution only by express authority of
Continental AG or its
subsidiaries.