Re: [Servingxml-help] Content is notallowed in prolog?
Brought to you by:
danielaparker
From: Daniel P. <dan...@sy...> - 2006-02-21 06:46:50
|
Akhil, In version 0.4.0c, I've added a helper class = com.servingxml.io.helpers.StreamSourceHelper which has the static method "fromJaxpSource", for creating the most = efficient StreamSource from a JAXP source. It checks whether the source = is a javax.transform.stream.StreamSource, whether it has an InputStream = or a Reader, and if not, if it has a resolvable systemId. If all else = fails, it creates a default Source adaptor that will transform the = source into a byte array, and use that to create a ByteArrayInputStream. There are some test cases in = framework/src/test/java/com/servingxml/io/StreamSourceHelperTest.java. Also, the source and sink classes have been moved (since 0.4.0) to the = com.servingxml.io package, and the class = com.servingxml.io.streamsink.StringStreamSink has been added, which = basically wraps your code. =20 You might also want to pass an optional third argument to the = constructor of FlowImpl, import com.servingxml.io.saxsource.SaxSource; import com.servingxml.io.helpers.SaxSourceHelper; SaxSource saxSource =3D SaxSourceHelper.fromJaxpSource(source); Flow flow =3D new FlowImpl(streamSource, streamSink, saxSource); This is not required, but if the JAXP source happens to wrap a DOM or an = XMLReader, it will be more efficient. =20 Regards, Daniel ----- Original Message -----=20 From: Akhil S. Srinivasan=20 To: Akhil S. Srinivasan=20 Cc: ser...@li...=20 Sent: Saturday, February 04, 2006 2:50 AM Subject: RE: [Servingxml-help] Content is notallowed in prolog? These lines seemed to be the problem StreamSource defaultStreamSource =3D new = StringStreamSource(source.toString()); =20 The fix I have used is=20 InputStream siss =3D = ((javax.xml.transform.stream.StreamSource)source).getInputStream(); StreamSource defaultStreamSource = =3D new InputStreamSourceAdaptor(siss); =20 I guess haste makes for a lot of waste =20 Thanks and really sorry for this stupid problem. =20 Akhil Srinivasan =20 PS: servingXML is a pretty cool piece of software and usefull too J -------------------------------------------------------------------------= ----- |