Chad la Joie <[EMAIL PROTECTED]> wrote on 09/07/2006 07:11:26 AM:
> Thank you Michael, by using the LSOutput with my FileWriter I was able
> to get this to work. For those who may have also encountered this
> problem, the actual code is below.
You may find this doesn't work if you try running your app on another
platform. I still recommend feeding the serializer an OutputStream ( i.e.
serializerOut.setByteStream(new FileOutputStream(outputFile)); ). There
are good reasons for using a Writer but it's often the wrong choice.
> Looking at this further, how would the use of an LSParser w/ LSInputs
> compare to using the DocumentBuilder JAXP interface?
See DocumentBuilder.parse(InputSource). An LSInput contains all of the
fields of an InputSource and has a few more of its own.
> Is the LSParser
> just DOM 3's answer to the lack of a parser interface in the DOM 1 & 2
> standards
Yes.
> , or is it something more?
Well... It also has capabilities which a DocumentBuilder doesn't have such
as filtering and asynchronous parsing.
> Again, thanks for the help.
>
> ---------------------
> public void writeXML(Element element, File outputFile) throws Exception{
> DOMImplementation domImpl =
> element.getOwnerDocument().getImplementation();
>
> DOMImplementationLS domImplLS = (DOMImplementationLS)
> domImpl.getFeature("LS", "3.0");
>
> LSSerializer serializer = domImplLS.createLSSerializer();
>
> LSOutput serializerOut = domImplLS.createLSOutput();
> serializerOut.setCharacterStream(new FileWriter(outputFile));
>
> serializer.write(element, serializerOut);
> }
>
> --
> Chad La Joie 2052-C Harris Bldg
> OIS-Middleware 202.687.0124
>
> ---------------------------------------------------------------------
> To unsubscribe, e-mail: [EMAIL PROTECTED]
> For additional commands, e-mail: [EMAIL PROTECTED]
Michael Glavassevich
XML Parser Development
IBM Toronto Lab
E-mail: [EMAIL PROTECTED]
E-mail: [EMAIL PROTECTED]
---------------------------------------------------------------------
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]