Hi,
Can you send me the code that uses the XMLStreamWriter?
I suspect that this problem is caused because writeStartDocument is not
called. Note that you should also call writeEndDocument.
The StAXDocumentSerializer currently requires that writeStartDocument
and writeEndDocument are called to initialize and produce a correct
encoding.
Please CC me on any correspondance as there are some problems
communicating on this email list. Also cam you subscribe to the list,
then we do not have to approve your emails.
Paul.
zell_at_zell.best.vwh.net wrote:
> Hello,
>
> I am attempting to use the November 19th build in order to test integration
> between FI and Apache XMLBeans 2.1.0. The first test I tried was to serialize
> an XMLBeans document through FI which results in a NullPointerException:
>
> java.lang.NullPointerException
> at com.sun.xml.fastinfoset.Encoder.encodeElementQualifiedNameOnThirdBit(Encoder.java:372)
> at com.sun.xml.fastinfoset.stax.StAXDocumentSerializer.encodeTerminationAndCurrentElement(StAXDocumentSerializer.java:592)
> at com.sun.xml.fastinfoset.stax.StAXDocumentSerializer.writeCharacters(StAXDocumentSerializer.java:453)
> at TestFI.write(TestFI.java:128)
> at TestFI.writeAll(TestFI.java:57)
> at TestFI.testFI(TestFI.java:187)
> at TestFI.main(TestFI.java:213)
>
> Code in question looks like the following:
>
> private static void testFI(XMLStreamReader in)
> throws XMLStreamException
> {
> ByteArrayOutputStream bytes = new ByteArrayOutputStream();
> StAXDocumentSerializer sw = new StAXDocumentSerializer();
>
> sw.setOutputStream(bytes);
>
> XMLStreamWriter out = sw;
>
> writeAll(in, out);
> out.close();
>
> System.out.println("FI-serialized size: " + bytes.size());
> }
>
> The XMLStreamReader is created by the XmlObject.newXMLStreamReader() and writeAll
> simply iterates through the different StAX types (START_ELEMENT, etc.). If I change
> from using StAXDocumentSerializer to a more conventional XMLStreamWriter, the code
> works as expected. It is only when I try to serialize with FI that the exception
> occurs.
>
> I can create an archive of the example, if desired.
>
> ---------------------------------------------------------------------
> To unsubscribe, e-mail: dev-unsubscribe_at_fi.dev.java.net
> For additional commands, e-mail: dev-help_at_fi.dev.java.net
>
--
| ? + ? = To question
----------------\
Paul Sandoz
x38109
+33-4-76188109