You are viewing a plain text version of this content. The canonical link for it is here.
Posted to user@xmlbeans.apache.org by Miroslav Genov <mg...@gmail.com> on 2007/01/10 14:27:33 UTC

Parsing from input stream

Hi everyone
I have problem with parsing from memory input stream. This is my code:
File f = new File("c:\\msg.xml");
byte b[] = new byte[(int) (f.length() + 1)];
FileInputStream fin = new FileInputStream(f);
fin.read(b,0,b.length);
ByteArrayInputStream sid = new ByteArrayInputStream(b);

When i invoke Factory.Parse(sid)  is thrown exception. This is stack trace:
org.apache.xmlbeans.XmlException: error: Illegal XML character: 0x0
org.apache.xmlbeans.impl.piccolo.io.IllegalCharException: Illegal XML
character: 0x0
    at org.apache.xmlbeans.impl.piccolo.xml.UTF8XMLDecoder.decode(
UTF8XMLDecoder.java:196)
    at
org.apache.xmlbeans.impl.piccolo.xml.XMLStreamReader$FastStreamDecoder.read(
XMLStreamReader.java:762)
    at org.apache.xmlbeans.impl.piccolo.xml.XMLStreamReader.read(
XMLStreamReader.java:162)
    at org.apache.xmlbeans.impl.piccolo.xml.PiccoloLexer.yy_refill(
PiccoloLexer.java:3474)
    at org.apache.xmlbeans.impl.piccolo.xml.PiccoloLexer.yynextChar(
PiccoloLexer.java:3721)
    at org.apache.xmlbeans.impl.piccolo.xml.PiccoloLexer.parseElementNameNS(
PiccoloLexer.java:2351)
    at org.apache.xmlbeans.impl.piccolo.xml.PiccoloLexer.parseCloseTagNS(
PiccoloLexer.java:2157)
    at org.apache.xmlbeans.impl.piccolo.xml.PiccoloLexer.parseTagNS(
PiccoloLexer.java:1359)
    at org.apache.xmlbeans.impl.piccolo.xml.PiccoloLexer.parseXMLNS(
PiccoloLexer.java:1293)
    at org.apache.xmlbeans.impl.piccolo.xml.PiccoloLexer.parseXML(
PiccoloLexer.java:1261)
    at org.apache.xmlbeans.impl.piccolo.xml.PiccoloLexer.yylex(
PiccoloLexer.java:4808)
    at org.apache.xmlbeans.impl.piccolo.xml.Piccolo.yylex(Piccolo.java:1290)
    at org.apache.xmlbeans.impl.piccolo.xml.Piccolo.yyparse(Piccolo.java
:1400)
    at org.apache.xmlbeans.impl.piccolo.xml.Piccolo.parse(Piccolo.java:714)
    at org.apache.xmlbeans.impl.store.Locale$SaxLoader.load(Locale.java
:3435)
    at org.apache.xmlbeans.impl.store.Locale.parseToXmlObject(Locale.java
:1270)
    at org.apache.xmlbeans.impl.store.Locale.parseToXmlObject(Locale.java
:1257)
    at org.apache.xmlbeans.impl.schema.SchemaTypeLoaderBase.parse(
SchemaTypeLoaderBase.java:345)
    at
ec.dgtaxud.seed.message.export.v1.RetrieveOrExtractEconomicOperatorResponseMessageDocument$Factory.parse(Unknown
Source)
    at
com.itt.ems.seed.messages.util.converters.TestDDSConvertAction.testDDSConverter
(TestDDSConvertAction.java:42)
    at com.itt.ems.seed.messages.util.converters.TestDDSConvertAction.main(
TestDDSConvertAction.java:25)

    at org.apache.xmlbeans.impl.store.Locale$SaxLoader.load(Locale.java
:3467)
    at org.apache.xmlbeans.impl.store.Locale.parseToXmlObject(Locale.java
:1270)
    at org.apache.xmlbeans.impl.store.Locale.parseToXmlObject(Locale.java
:1257)
    at org.apache.xmlbeans.impl.schema.SchemaTypeLoaderBase.parse(
SchemaTypeLoaderBase.java:345)
    at
ec.dgtaxud.seed.message.export.v1.RetrieveOrExtractEconomicOperatorResponseMessageDocument$Factory.parse(Unknown
Source)
    at
com.itt.ems.seed.messages.util.converters.TestDDSConvertAction.testDDSConverter
(TestDDSConvertAction.java:42)
    at com.itt.ems.seed.messages.util.converters.TestDDSConvertAction.main(
TestDDSConvertAction.java:25)
Caused by: org.apache.xmlbeans.impl.piccolo.io.IllegalCharException: Illegal
XML character: 0x0
    at org.apache.xmlbeans.impl.piccolo.xml.Piccolo.reportFatalError(
Piccolo.java:1038)
    at org.apache.xmlbeans.impl.piccolo.xml.Piccolo.parse(Piccolo.java:717)
    at org.apache.xmlbeans.impl.store.Locale$SaxLoader.load(Locale.java
:3435)
    ... 6 more


When i try to read from file directly it works.

Any ideas ?
-- 
The human knowledge belongs to the world.

Re: Parsing from input stream

Posted by Balakumar Narayanasamy <ba...@gmail.com>.
Hi Jacob,
Actually the problem is on back end which is has send the junk characters.
So it is not a java or xml problem.

Thanks,
Balakumar, N

Jacob Danner-2 wrote:
> 
> Is there additional content at the start of the file?
> can you check the start of the contents of the stream too? i.e, I
> think there may be some additional bytes being added that are causing
> this. Do you get this problem when you are not using a byte stream?
> -jacobd
> 
> On 11/11/07, Balakumar Narayanasamy <ba...@gmail.com> wrote:
>>
>> Hi,
>> Did you got any solution to this problem. I am also facing the similar
>> problem while parsing an xml request.
>> Thanks in advance...
>>
>>
>> mgenov wrote:
>> >
>> > Hi everyone
>> > I have problem with parsing from memory input stream. This is my code:
>> > File f = new File("c:\\msg.xml");
>> > byte b[] = new byte[(int) (f.length() + 1)];
>> > FileInputStream fin = new FileInputStream(f);
>> > fin.read(b,0,b.length);
>> > ByteArrayInputStream sid = new ByteArrayInputStream(b);
>> >
>> > When i invoke Factory.Parse(sid)  is thrown exception. This is stack
>> > trace:
>> > org.apache.xmlbeans.XmlException: error: Illegal XML character: 0x0
>> > org.apache.xmlbeans.impl.piccolo.io.IllegalCharException: Illegal XML
>> > character: 0x0
>> >     at org.apache.xmlbeans.impl.piccolo.xml.UTF8XMLDecoder.decode(
>> > UTF8XMLDecoder.java:196)
>> >     at
>> >
>> org.apache.xmlbeans.impl.piccolo.xml.XMLStreamReader$FastStreamDecoder.read(
>> > XMLStreamReader.java:762)
>> >     at org.apache.xmlbeans.impl.piccolo.xml.XMLStreamReader.read(
>> > XMLStreamReader.java:162)
>> >     at org.apache.xmlbeans.impl.piccolo.xml.PiccoloLexer.yy_refill(
>> > PiccoloLexer.java:3474)
>> >     at org.apache.xmlbeans.impl.piccolo.xml.PiccoloLexer.yynextChar(
>> > PiccoloLexer.java:3721)
>> >     at
>> > org.apache.xmlbeans.impl.piccolo.xml.PiccoloLexer.parseElementNameNS(
>> > PiccoloLexer.java:2351)
>> >     at
>> org.apache.xmlbeans.impl.piccolo.xml.PiccoloLexer.parseCloseTagNS(
>> > PiccoloLexer.java:2157)
>> >     at org.apache.xmlbeans.impl.piccolo.xml.PiccoloLexer.parseTagNS(
>> > PiccoloLexer.java:1359)
>> >     at org.apache.xmlbeans.impl.piccolo.xml.PiccoloLexer.parseXMLNS(
>> > PiccoloLexer.java:1293)
>> >     at org.apache.xmlbeans.impl.piccolo.xml.PiccoloLexer.parseXML(
>> > PiccoloLexer.java:1261)
>> >     at org.apache.xmlbeans.impl.piccolo.xml.PiccoloLexer.yylex(
>> > PiccoloLexer.java:4808)
>> >     at
>> > org.apache.xmlbeans.impl.piccolo.xml.Piccolo.yylex(Piccolo.java:1290)
>> >     at
>> org.apache.xmlbeans.impl.piccolo.xml.Piccolo.yyparse(Piccolo.java
>> > :1400)
>> >     at
>> > org.apache.xmlbeans.impl.piccolo.xml.Piccolo.parse(Piccolo.java:714)
>> >     at org.apache.xmlbeans.impl.store.Locale$SaxLoader.load(Locale.java
>> > :3435)
>> >     at
>> org.apache.xmlbeans.impl.store.Locale.parseToXmlObject(Locale.java
>> > :1270)
>> >     at
>> org.apache.xmlbeans.impl.store.Locale.parseToXmlObject(Locale.java
>> > :1257)
>> >     at org.apache.xmlbeans.impl.schema.SchemaTypeLoaderBase.parse(
>> > SchemaTypeLoaderBase.java:345)
>> >     at
>> >
>> ec.dgtaxud.seed.message.export.v1.RetrieveOrExtractEconomicOperatorResponseMessageDocument$Factory.parse(Unknown
>> > Source)
>> >     at
>> >
>> com.itt.ems.seed.messages.util.converters.TestDDSConvertAction.testDDSConverter
>> > (TestDDSConvertAction.java:42)
>> >     at
>> > com.itt.ems.seed.messages.util.converters.TestDDSConvertAction.main(
>> > TestDDSConvertAction.java:25)
>> >
>> >     at org.apache.xmlbeans.impl.store.Locale$SaxLoader.load(Locale.java
>> > :3467)
>> >     at
>> org.apache.xmlbeans.impl.store.Locale.parseToXmlObject(Locale.java
>> > :1270)
>> >     at
>> org.apache.xmlbeans.impl.store.Locale.parseToXmlObject(Locale.java
>> > :1257)
>> >     at org.apache.xmlbeans.impl.schema.SchemaTypeLoaderBase.parse(
>> > SchemaTypeLoaderBase.java:345)
>> >     at
>> >
>> ec.dgtaxud.seed.message.export.v1.RetrieveOrExtractEconomicOperatorResponseMessageDocument$Factory.parse(Unknown
>> > Source)
>> >     at
>> >
>> com.itt.ems.seed.messages.util.converters.TestDDSConvertAction.testDDSConverter
>> > (TestDDSConvertAction.java:42)
>> >     at
>> > com.itt.ems.seed.messages.util.converters.TestDDSConvertAction.main(
>> > TestDDSConvertAction.java:25)
>> > Caused by: org.apache.xmlbeans.impl.piccolo.io.IllegalCharException:
>> > Illegal
>> > XML character: 0x0
>> >     at org.apache.xmlbeans.impl.piccolo.xml.Piccolo.reportFatalError(
>> > Piccolo.java:1038)
>> >     at
>> > org.apache.xmlbeans.impl.piccolo.xml.Piccolo.parse(Piccolo.java:717)
>> >     at org.apache.xmlbeans.impl.store.Locale$SaxLoader.load(Locale.java
>> > :3435)
>> >     ... 6 more
>> >
>> >
>> > When i try to read from file directly it works.
>> >
>> > Any ideas ?
>> > --
>> > The human knowledge belongs to the world.
>> >
>> >
>>
>> --
>> View this message in context:
>> http://www.nabble.com/Parsing-from-input-stream-tf2952430.html#a13701164
>> Sent from the Xml Beans - User mailing list archive at Nabble.com.
>>
> 
> ---------------------------------------------------------------------
> To unsubscribe, e-mail: user-unsubscribe@xmlbeans.apache.org
> For additional commands, e-mail: user-help@xmlbeans.apache.org
> 
> 
> 

-- 
View this message in context: http://www.nabble.com/Parsing-from-input-stream-tf2952430.html#a13726096
Sent from the Xml Beans - User mailing list archive at Nabble.com.


---------------------------------------------------------------------
To unsubscribe, e-mail: user-unsubscribe@xmlbeans.apache.org
For additional commands, e-mail: user-help@xmlbeans.apache.org


Re: Parsing from input stream

Posted by Jacob Danner <ja...@gmail.com>.
Is there additional content at the start of the file?
can you check the start of the contents of the stream too? i.e, I
think there may be some additional bytes being added that are causing
this. Do you get this problem when you are not using a byte stream?
-jacobd

On 11/11/07, Balakumar Narayanasamy <ba...@gmail.com> wrote:
>
> Hi,
> Did you got any solution to this problem. I am also facing the similar
> problem while parsing an xml request.
> Thanks in advance...
>
>
> mgenov wrote:
> >
> > Hi everyone
> > I have problem with parsing from memory input stream. This is my code:
> > File f = new File("c:\\msg.xml");
> > byte b[] = new byte[(int) (f.length() + 1)];
> > FileInputStream fin = new FileInputStream(f);
> > fin.read(b,0,b.length);
> > ByteArrayInputStream sid = new ByteArrayInputStream(b);
> >
> > When i invoke Factory.Parse(sid)  is thrown exception. This is stack
> > trace:
> > org.apache.xmlbeans.XmlException: error: Illegal XML character: 0x0
> > org.apache.xmlbeans.impl.piccolo.io.IllegalCharException: Illegal XML
> > character: 0x0
> >     at org.apache.xmlbeans.impl.piccolo.xml.UTF8XMLDecoder.decode(
> > UTF8XMLDecoder.java:196)
> >     at
> >
> org.apache.xmlbeans.impl.piccolo.xml.XMLStreamReader$FastStreamDecoder.read(
> > XMLStreamReader.java:762)
> >     at org.apache.xmlbeans.impl.piccolo.xml.XMLStreamReader.read(
> > XMLStreamReader.java:162)
> >     at org.apache.xmlbeans.impl.piccolo.xml.PiccoloLexer.yy_refill(
> > PiccoloLexer.java:3474)
> >     at org.apache.xmlbeans.impl.piccolo.xml.PiccoloLexer.yynextChar(
> > PiccoloLexer.java:3721)
> >     at
> > org.apache.xmlbeans.impl.piccolo.xml.PiccoloLexer.parseElementNameNS(
> > PiccoloLexer.java:2351)
> >     at org.apache.xmlbeans.impl.piccolo.xml.PiccoloLexer.parseCloseTagNS(
> > PiccoloLexer.java:2157)
> >     at org.apache.xmlbeans.impl.piccolo.xml.PiccoloLexer.parseTagNS(
> > PiccoloLexer.java:1359)
> >     at org.apache.xmlbeans.impl.piccolo.xml.PiccoloLexer.parseXMLNS(
> > PiccoloLexer.java:1293)
> >     at org.apache.xmlbeans.impl.piccolo.xml.PiccoloLexer.parseXML(
> > PiccoloLexer.java:1261)
> >     at org.apache.xmlbeans.impl.piccolo.xml.PiccoloLexer.yylex(
> > PiccoloLexer.java:4808)
> >     at
> > org.apache.xmlbeans.impl.piccolo.xml.Piccolo.yylex(Piccolo.java:1290)
> >     at org.apache.xmlbeans.impl.piccolo.xml.Piccolo.yyparse(Piccolo.java
> > :1400)
> >     at
> > org.apache.xmlbeans.impl.piccolo.xml.Piccolo.parse(Piccolo.java:714)
> >     at org.apache.xmlbeans.impl.store.Locale$SaxLoader.load(Locale.java
> > :3435)
> >     at org.apache.xmlbeans.impl.store.Locale.parseToXmlObject(Locale.java
> > :1270)
> >     at org.apache.xmlbeans.impl.store.Locale.parseToXmlObject(Locale.java
> > :1257)
> >     at org.apache.xmlbeans.impl.schema.SchemaTypeLoaderBase.parse(
> > SchemaTypeLoaderBase.java:345)
> >     at
> >
> ec.dgtaxud.seed.message.export.v1.RetrieveOrExtractEconomicOperatorResponseMessageDocument$Factory.parse(Unknown
> > Source)
> >     at
> >
> com.itt.ems.seed.messages.util.converters.TestDDSConvertAction.testDDSConverter
> > (TestDDSConvertAction.java:42)
> >     at
> > com.itt.ems.seed.messages.util.converters.TestDDSConvertAction.main(
> > TestDDSConvertAction.java:25)
> >
> >     at org.apache.xmlbeans.impl.store.Locale$SaxLoader.load(Locale.java
> > :3467)
> >     at org.apache.xmlbeans.impl.store.Locale.parseToXmlObject(Locale.java
> > :1270)
> >     at org.apache.xmlbeans.impl.store.Locale.parseToXmlObject(Locale.java
> > :1257)
> >     at org.apache.xmlbeans.impl.schema.SchemaTypeLoaderBase.parse(
> > SchemaTypeLoaderBase.java:345)
> >     at
> >
> ec.dgtaxud.seed.message.export.v1.RetrieveOrExtractEconomicOperatorResponseMessageDocument$Factory.parse(Unknown
> > Source)
> >     at
> >
> com.itt.ems.seed.messages.util.converters.TestDDSConvertAction.testDDSConverter
> > (TestDDSConvertAction.java:42)
> >     at
> > com.itt.ems.seed.messages.util.converters.TestDDSConvertAction.main(
> > TestDDSConvertAction.java:25)
> > Caused by: org.apache.xmlbeans.impl.piccolo.io.IllegalCharException:
> > Illegal
> > XML character: 0x0
> >     at org.apache.xmlbeans.impl.piccolo.xml.Piccolo.reportFatalError(
> > Piccolo.java:1038)
> >     at
> > org.apache.xmlbeans.impl.piccolo.xml.Piccolo.parse(Piccolo.java:717)
> >     at org.apache.xmlbeans.impl.store.Locale$SaxLoader.load(Locale.java
> > :3435)
> >     ... 6 more
> >
> >
> > When i try to read from file directly it works.
> >
> > Any ideas ?
> > --
> > The human knowledge belongs to the world.
> >
> >
>
> --
> View this message in context:
> http://www.nabble.com/Parsing-from-input-stream-tf2952430.html#a13701164
> Sent from the Xml Beans - User mailing list archive at Nabble.com.
>

---------------------------------------------------------------------
To unsubscribe, e-mail: user-unsubscribe@xmlbeans.apache.org
For additional commands, e-mail: user-help@xmlbeans.apache.org


Re: Parsing from input stream

Posted by Balakumar Narayanasamy <ba...@gmail.com>.
Hi,
Did you got any solution to this problem. I am also facing the similar
problem while parsing an xml request.
Thanks in advance...


mgenov wrote:
> 
> Hi everyone
> I have problem with parsing from memory input stream. This is my code:
> File f = new File("c:\\msg.xml");
> byte b[] = new byte[(int) (f.length() + 1)];
> FileInputStream fin = new FileInputStream(f);
> fin.read(b,0,b.length);
> ByteArrayInputStream sid = new ByteArrayInputStream(b);
> 
> When i invoke Factory.Parse(sid)  is thrown exception. This is stack
> trace:
> org.apache.xmlbeans.XmlException: error: Illegal XML character: 0x0
> org.apache.xmlbeans.impl.piccolo.io.IllegalCharException: Illegal XML
> character: 0x0
>     at org.apache.xmlbeans.impl.piccolo.xml.UTF8XMLDecoder.decode(
> UTF8XMLDecoder.java:196)
>     at
> org.apache.xmlbeans.impl.piccolo.xml.XMLStreamReader$FastStreamDecoder.read(
> XMLStreamReader.java:762)
>     at org.apache.xmlbeans.impl.piccolo.xml.XMLStreamReader.read(
> XMLStreamReader.java:162)
>     at org.apache.xmlbeans.impl.piccolo.xml.PiccoloLexer.yy_refill(
> PiccoloLexer.java:3474)
>     at org.apache.xmlbeans.impl.piccolo.xml.PiccoloLexer.yynextChar(
> PiccoloLexer.java:3721)
>     at
> org.apache.xmlbeans.impl.piccolo.xml.PiccoloLexer.parseElementNameNS(
> PiccoloLexer.java:2351)
>     at org.apache.xmlbeans.impl.piccolo.xml.PiccoloLexer.parseCloseTagNS(
> PiccoloLexer.java:2157)
>     at org.apache.xmlbeans.impl.piccolo.xml.PiccoloLexer.parseTagNS(
> PiccoloLexer.java:1359)
>     at org.apache.xmlbeans.impl.piccolo.xml.PiccoloLexer.parseXMLNS(
> PiccoloLexer.java:1293)
>     at org.apache.xmlbeans.impl.piccolo.xml.PiccoloLexer.parseXML(
> PiccoloLexer.java:1261)
>     at org.apache.xmlbeans.impl.piccolo.xml.PiccoloLexer.yylex(
> PiccoloLexer.java:4808)
>     at
> org.apache.xmlbeans.impl.piccolo.xml.Piccolo.yylex(Piccolo.java:1290)
>     at org.apache.xmlbeans.impl.piccolo.xml.Piccolo.yyparse(Piccolo.java
> :1400)
>     at
> org.apache.xmlbeans.impl.piccolo.xml.Piccolo.parse(Piccolo.java:714)
>     at org.apache.xmlbeans.impl.store.Locale$SaxLoader.load(Locale.java
> :3435)
>     at org.apache.xmlbeans.impl.store.Locale.parseToXmlObject(Locale.java
> :1270)
>     at org.apache.xmlbeans.impl.store.Locale.parseToXmlObject(Locale.java
> :1257)
>     at org.apache.xmlbeans.impl.schema.SchemaTypeLoaderBase.parse(
> SchemaTypeLoaderBase.java:345)
>     at
> ec.dgtaxud.seed.message.export.v1.RetrieveOrExtractEconomicOperatorResponseMessageDocument$Factory.parse(Unknown
> Source)
>     at
> com.itt.ems.seed.messages.util.converters.TestDDSConvertAction.testDDSConverter
> (TestDDSConvertAction.java:42)
>     at
> com.itt.ems.seed.messages.util.converters.TestDDSConvertAction.main(
> TestDDSConvertAction.java:25)
> 
>     at org.apache.xmlbeans.impl.store.Locale$SaxLoader.load(Locale.java
> :3467)
>     at org.apache.xmlbeans.impl.store.Locale.parseToXmlObject(Locale.java
> :1270)
>     at org.apache.xmlbeans.impl.store.Locale.parseToXmlObject(Locale.java
> :1257)
>     at org.apache.xmlbeans.impl.schema.SchemaTypeLoaderBase.parse(
> SchemaTypeLoaderBase.java:345)
>     at
> ec.dgtaxud.seed.message.export.v1.RetrieveOrExtractEconomicOperatorResponseMessageDocument$Factory.parse(Unknown
> Source)
>     at
> com.itt.ems.seed.messages.util.converters.TestDDSConvertAction.testDDSConverter
> (TestDDSConvertAction.java:42)
>     at
> com.itt.ems.seed.messages.util.converters.TestDDSConvertAction.main(
> TestDDSConvertAction.java:25)
> Caused by: org.apache.xmlbeans.impl.piccolo.io.IllegalCharException:
> Illegal
> XML character: 0x0
>     at org.apache.xmlbeans.impl.piccolo.xml.Piccolo.reportFatalError(
> Piccolo.java:1038)
>     at
> org.apache.xmlbeans.impl.piccolo.xml.Piccolo.parse(Piccolo.java:717)
>     at org.apache.xmlbeans.impl.store.Locale$SaxLoader.load(Locale.java
> :3435)
>     ... 6 more
> 
> 
> When i try to read from file directly it works.
> 
> Any ideas ?
> -- 
> The human knowledge belongs to the world.
> 
> 

-- 
View this message in context: http://www.nabble.com/Parsing-from-input-stream-tf2952430.html#a13701164
Sent from the Xml Beans - User mailing list archive at Nabble.com.