Home | Contact Us | FAQ | Search & Site Map | Link to Us
Sign In | Join | Other 45 Sites in Network
HomeAnnouncementsWhite Papers
Discussion GroupsFirst AidDatabasesJavaBeansGUIJava 3DVirtual MachineCORBASecurityToolsGeneral
Java DirectoryOpen Source ProjectsSample Book ChaptersUser GroupsWeb Resources
Related Topics
Databases.NETMore Topics ...

Java Forum / JavaBeans / September 2004

Tip: Looking for answers? Try searching our database.

Reading XML File which contains two <?xml version...?>

Thread view: 
Progmet - 27 Sep 2004 12:26 GMT
Using javax.xml.parsers and org.xml.sax to read the xml file, but receiving
error "The processing instruction target matching "[xX][mM][lL]" is not
allowed."
The xml looks something like this.
<?xml version="1.0" encoding="UTF-8"?>
<Header>...</Header>
<?xml version="1.0" encoding="UTF-8"?>
<Detail>..</Detail>
I'm receiving the file like this and want to create and xml to response to
this one with same structure, but could not read/print through java the
xml.
Could you give me alternative to do this if possible.
Thanks
Robert Klemme - 27 Sep 2004 15:32 GMT
First of all: This is not beans specific.

> Using javax.xml.parsers and org.xml.sax to read the xml file, but receiving
> error "The processing instruction target matching "[xX][mM][lL]" is not
[quoted text clipped - 9 lines]
> Could you give me alternative to do this if possible.
> Thanks

It looks like as if you were getting two XML documents in one stream.  You
could get away by storing those in two different files and parsing them
separately.  If they are not too big you could keep them in mem in a
ByteArrayInputStream.

FUP set to c.l.j.p

   robert
Progmet - 28 Sep 2004 07:31 GMT
Thanks Robert

Is there a way to store the file seperately without having to split it
manually in java?
Robert Klemme - 28 Sep 2004 08:13 GMT
> Thanks Robert
>
> Is there a way to store the file seperately without having to split it
> manually in java?

AFAIK not.  But it's really not too difficult.

   robert

PS: Why did you post twice?
Progmet - 28 Sep 2004 08:35 GMT
I know but the whole process must be automatically because we receive the
xml file onto a folder on a windows 2000 server where we then have to pick
up the file and send a response back in xml again into another folder on
the server for pickup by them.  The posted xml back is also containing two
xml in one stream.  Do you think I should use a different method to do
this?

PS: I do not know why it posted twice - did not intent to.
Robert Klemme - 28 Sep 2004 09:25 GMT
> I know but the whole process must be automatically because we receive the
> xml file onto a folder on a windows 2000 server where we then have to pick
> up the file and send a response back in xml again into another folder on
> the server for pickup by them.  The posted xml back is also containing two
> xml in one stream.  Do you think I should use a different method to do
> this?

There are 1000 ways to split this up depending on the environment your
application.  But since you seem to use an XML parser in Java I did
suggest to do it in Java.  Heck, this isn't really too difficult, is it?
Where's your creativity?

   robert
Progmet - 28 Sep 2004 13:49 GMT
Sorry but all this is a bit new to me.
So what you said was that to use ByteArrayInputStream to read the file and
then write output to the new file, but what about the values I need from
the original file?
Now you probably think my creativity is gone again?
ilana
Robert Klemme - 29 Sep 2004 13:42 GMT
> Sorry but all this is a bit new to me.
> So what you said was that to use ByteArrayInputStream to read the file and
> then write output to the new file, but what about the values I need from
> the original file?
> Now you probably think my creativity is gone again?
> ilana

read input file and copy the content into a first ByteArrayOutputStream
(BAOS) until you see a second "<? xml...".  When that arrives close the
first BAOS and create a new one.  Now write into this until the end.  Now
you can create a ByteArrayInputStream from the bytes in the first BAOS and
have your XML parser read from that.  Proceed similarly for the second
BOAS.

   robert
Progmet - 28 Sep 2004 07:31 GMT
Thanks Robert

Is there a way to store the file seperately without having to split it
manually in java?


Free Magazines

Get these publications absolutely FREE for up to 12 months. There are no hidden fees and no obligation. Simply choose a title, complete the application form and submit it. Read more ...

Oracle MagazineNetwork ComputingComputer WorldBio-IT WorldeWeekInformation WeekInfosecurity
 
Sign In
Join
My Latest Posts
My Monitored Threads
My Blog
My Photo Gallery
My Profile
My Homepage

Start New Thread
Enable EMail Alerts
Rate this Thread



©2008 Advenet LLC   Privacy Policy - Terms of Use
This website includes both content owned or controlled by Advenet as well as content owned or controlled by third parties.