How to parse multiple xml documents from single buffer

10-11  Source: Network gathering  Views:2 

Advertisement
Hello,
I am trying to use jaxb 2.0 to parse a buffer which contains multiple xml documents. However, it seems that it is meant to only parse a single document at a time and throws an exception when it gets to the 2nd document.
Is there a way I can tell jaxb to only parse the first complete document and not fetch the next one out of the buffer? Or what is the most efficient way to separate the buffer into two documents without parsing it manually. If I have to search the buffer for the next document root and then split the buffer, it seems like that defeats the purpose of using jaxb as the parser.
I am using the Unmarshaller.unmarshall method and the exception I am getting is:
org.xml.sax.SAXParseException: Illegal character at end of document, <.]
     at javax.xml.bind.helpers.AbstractUnmarshallerImpl.createUnmarshalException(AbstractUnmarshallerImpl.java:315)
     at com.sun.xml.bind.v2.runtime.unmarshaller.UnmarshallerImpl.createUnmarshalException(UnmarshallerImpl.java:476)
     at com.sun.xml.bind.v2.runtime.unmarshaller.UnmarshallerImpl.unmarshal0(UnmarshallerImpl.java:198)
     at com.sun.xml.bind.v2.runtime.unmarshaller.UnmarshallerImpl.unmarshal(UnmarshallerImpl.java:167)
     at javax.xml.bind.helpers.AbstractUnmarshallerImpl.unmarshal(AbstractUnmarshallerImpl.java:137)
     at javax.xml.bind.helpers.AbstractUnmarshallerImpl.unmarshal(AbstractUnmarshallerImpl.java:184)
Thank you for your help
It's just like any other XML parser, it's only designed to parse one XML document. If you have something that concatenates two XML documents together (that's what your "buffer" sounds like), then stop doing that.
Related articles
  • How to parse multiple xml documents from single buffer 10-11

    Hello, I am trying to use jaxb 2.0 to parse a buffer which contains multiple xml documents. However, it seems that it is meant to only parse a single document at a time and throws an exception when it gets to the 2nd document. Is there a way I can te

  • How to create an XML document from a String. 10-11

    Can anyone help,      In the Microsoft XML Document DOM there is a load function load(string) which will create an XML document, but now we are switching to Java and I do not know how to create and XML document from a string, this string �xml documen

  • How can I access xml document from javascript whithin a JSP page 10-11

    how can I access xml document from javascript whithin a JSP page? I have a JSP that receives an XML document from a JavaBean, so I can access it within the entire JSP, but I need to access it from the javascript inside the JSP... and I have no idea h

  • How to Create an XML document from XSQL servlet which follows a particular DTD struct 11-30

    how to Create an XML document from XSQL servlet which follows a particular DTD structure.Could anyone send me a sample code for this.You'll need to associate an XSLT transformation with your XSQL page that transforms the canonical result into your DT

  • How to call multiple strus actions froma single jsp 11-30

    how to call multiple strus actions froma single jsp, and that actions should be automatically called pls help me Thanks in advancehow to call multiple strus actions froma single jsp, and that actions should be automatically called pls help me Thanks

  • How to generate multiple idoc's from single appl document 10-11

    All, Iam looking for a way to generate multiple idoc's from single appl document (sales order). Based on the plant details on line items in the sales order i have to generate multiple idocs, i.e., send one idoc to each plant entered in sales order li

  • Parsing an xml data from a buffer 10-11

    I have an XML file loaded into a string buffer in java. I would like to know if I can parser XMl data from that buffer using the SAX parser. I do not want to load the xml using the parser, I would like to load the buffer instead. Thanks in advance, S

  • How to generate an XML Document from XQuery 10-11

    The following query returns me the required XML output. However, I need to generate an XML Document out of it. How do I go about generating an XML Doc?. SELECT XMLQuery('<Data> {for $tert in ora:view("DATA"),            $tert_audit in ora:

  • How to parse an XML document with oracle8i 10-11

    Has anyone a good link or an example how to decode and store an XML document into an oracle8i database. I' ve found only good things for oracle9i. Thank you RogerHere is an example of parsing xml taken fro Oracle8i 8.1.7 xdk. This one uses external O

  • [Solved] How to create multiple target nodes from single input node (XSL) 10-11

    Hello all, I have identified what I think is a bug in the visual XSLT mapper (JDev 10.1.3.3). Here is the simplified scenario: I have a source XML file that contains a bill-to address and a ship-to address, something like this: <header> <bill-to-

  • How can I change a document from booklet to single pages 10-11

    How can I change a document from booklet to single pages?Very cumbersome. How many pages? Make a copy first. In Acrobat use the Crop tool to crop half the width. (Pages > Crop Pages.) For 11x17 to 8.5 x11  crop all even pages 8.5 left, all odd pages

  • How to use java to create an XML document from an SQL database? 10-11

    Hi, I'm a complete novice at XML and have only recently started programming in Java. I'm currently trying to develop a package in Java 1.1.8 which requires a set of very specifically formatted XML documents. These documents would need to be updated r

  • Can we create multiple billing document from delivery with single line item 10-11

    can we create multiple billing document from delivery with single line itemHi Please check the link [can v create multiple billing document from delivery with single line item] and as Lakshmi said, check the forum before posting an issue. Regards AAR

  • Can v create multiple billing document from delivery with single line item 10-11

    can v create multiple billing document from delivery with single line itemDear Sandesh Go to VOV7, select your item category.  In this maintain K  for Billing Relevance Now go to VF01, give the delivery number and do not press Enter.  Instead click o

  • How to extract the actual XML document from soap message? 10-11

    My problem is " how to extract the actual XML document from soap message? " i just want to extract the attachment i.e. (pure XML document without any soap header or envolope). i could be ver thank full if u could solve my problem. [email protect

  • How to delete multiple data domains with single step ? 10-11

    how to delete multiple data domains with single step ?You can go to your Endeca-Server domain home e.g.($WEBLOGIC-HOME$/user_projects/domains/endeca_server_domain/EndecaServer/bin) run [HOST]$ ./endeca-cmd.sh list-dd default is enabled. GettingStarte

  • Parseing an XML Document as a String 10-11

    Hi all, i am trying to parse an XML document to a parser. I get the file as a request parameter, which is filled in to at String variable. But for some reason i get an SAXException, does anyone se the problem? Thank you for your help... Below is the

  • Unable to find XML document from class path resource 10-11

    Hi, I am trying to learn spring and wrote my first class today. I added all the jar files to the lib folder and created all the classes. When I try to run the client program I get [INFO] XmlBeanDefinitionReader - Loading XML bean definitions from cla

  • How to insert multiple records in a single query 10-11

    Dear all, Can you please tell how to insert multiple records in a single query ??INSERT INTO table_name (column_1, column_2) VALUES ('value_A', 'value_B')OR INSERT INTO table_name (column_1, column_2) SELECT 'value_A', 'value_B' FROM DUAL UNION ALL S

  • How to write an xml Document to a flat file using JAVA.... 10-11

    Can any one help me out..... How to write a XML Document to the current filesystem using JAVA.... without using com.sun.xml.tree.*.... Document xmlDoc;      Node rows = (Node) xmlDoc.createElement("ROWS"); xmlDoc.appendChild(rows); and i have to