Hello,

If you're going to set the doctype, you are required to use an interim step before you can get the xml writer. The xml writer does not exist until you call marshalDocument(), you must call setOutput() first.

Something like:

MarshallingContext mc = bfactory.createMarshallingContext();
mc.setOutput(new FileOutputStream("myfile.xml");
IXMLWriter xw = mc.getWriter();
xw.writeDocType( name,sys, pub, subset);
mc.marshalDocument(myObj,"utf-8",null);

Cheers!
C

Expedito Reinaldo da Silva J�nior wrote:

Hi,

I'm very new to Jibx and I'm having a little problem when I try to access the XMLWriter so as I can declare a DTD. My code is below:



1 - IBindingFactory bfact = BindingDirectory.getFactory(rootObject.getClass());
2 - 3 - IMarshallingContext mctx = bfact.createMarshallingContext();
4 - mctx.setIndent(3);
5 -
6 - DTDDefinition dtd = ...; (not null)
7 - mctx.getXmlWriter().writeDocType(dtd.getRootElementName(), dtd.getSystemID(), dtd.getPublicID(),* **null*);
8 - 9 - mctx.marshalDocument(rootObject, "ISO-8859-1",* null*, xmlOut);



P.S.: 'rootObject' is the object i'm trying to write to a XML file.

But, on line 7 i'm getting a NullPointerException cause de XMLWriter is NULL!! Is there something wrong with my code????

Thanks a lot!

Expedito.


-- _________________________________________ < __ __ ____ > < | | \/ ___\ Chris Hill > < | | / /_/ > [EMAIL PROTECTED] > < |____/\___ / http://ubergeek.tv > < /_____/ The Smell of Geek! > <----------------------------------------->



-------------------------------------------------------
This SF.Net email is sponsored by:
Sybase ASE Linux Express Edition - download now for FREE
LinuxWorld Reader's Choice Award Winner for best database on Linux.
http://ads.osdn.com/?ad_idU88&alloc_id065&op=click
_______________________________________________
jibx-users mailing list
[EMAIL PROTECTED]
https://lists.sourceforge.net/lists/listinfo/jibx-users

Reply via email to