You are viewing a plain text version of this content. The canonical link for it is here.
Posted to j-dev@xerces.apache.org by Shanthi Nellaiappan <ns...@cisco.com> on 2000/10/17 18:38:56 UTC

Multiple xml documents in a file

Hi,
   How to parse multiple xml documents stored in one file or from a
stream...
  If it has to be read one xml from stream and sent to the parser.. is
it like this??

<Pre>
    String line;
    StringBuffer parserStr;
    BufferedReader inputstr = new ()....

   while (!(line.equals("</xml_doc_end_tag>"))) {
        line=inputStr.readLine();
        parseStr.append(line);
   }
   parseStr.append(line);
   parserInput = new InputSource(new StringReader(parseStr.toString()));

.....

SAXParser p;
p.parse(parserInput);


.</Pre>

If so, at the end of the doc, it gives the foll error,
Line 1
uri null
message: not well formatted...



Re: Multiple xml documents in a file

Posted by Jeff Lansing <je...@polexis.com>.
Hi,
How does your input stream reader know that "</xml_doc_end_tag>" will be on
a line by itself?
Jeff

Shanthi Nellaiappan wrote:

> Hi,
>    How to parse multiple xml documents stored in one file or from a
> stream...
>   If it has to be read one xml from stream and sent to the parser.. is
> it like this??
>
> <Pre>
>     String line;
>     StringBuffer parserStr;
>     BufferedReader inputstr = new ()....
>
>    while (!(line.equals("</xml_doc_end_tag>"))) {
>         line=inputStr.readLine();
>         parseStr.append(line);
>    }
>    parseStr.append(line);
>    parserInput = new InputSource(new StringReader(parseStr.toString()));
>
> .....
>
> SAXParser p;
> p.parse(parserInput);
>
> .</Pre>
>
> If so, at the end of the doc, it gives the foll error,
> Line 1
> uri null
> message: not well formatted...
>
> ---------------------------------------------------------------------
> To unsubscribe, e-mail: xerces-j-dev-unsubscribe@xml.apache.org
> For additional commands, e-mail: xerces-j-dev-help@xml.apache.org


Re: Multiple xml documents in a file

Posted by Andy Clark <an...@apache.org>.
Shanthi Nellaiappan wrote:
>    How to parse multiple xml documents stored in one file or 
> from a stream...

The XML specification doesn't allow for multiple XML documents
to appear in the same file or stream. You would have to provide 
some kind of wrapper around the XML documents in the stream. 
Because of the different character encodings that documents 
can use, this can be complicated. 

You'll have to devise some kind of solution that works for your 
application because the parser cannot handle this directly.

-- 
Andy Clark * IBM, JTC - Silicon Valley * andyc@apache.org