Can you be more explicit ?

I'm not familiar with Java Streams. And the only stream I can create is a
ByteArrayInputStream/ByteArrayOutputStream (all others are created from
another stream). If I do so, I still need to write all the data in the
ByteArrayOutputStream buffer before parsing it...

Maybe if I use another stream type ?

Thank's a lot
Eric.

PS: my code (with streams)

  ByteArrayOutputStream out = new ByteArrayOutputStream();
  org.apache.xml.serialize.OutputFormat outputFormat = new
org.apache.xml.serialize.OutputFormat(document);
  outputFormat.setOmitXMLDeclaration(false);
  outputFormat.setDoctype(null, "/test/territoire_posterscan.dtd");
  outputFormat.setIndenting(true);
  outputFormat.setIndent(1);
  org.apache.xml.serialize.XMLSerializer serializer = new
org.apache.xml.serialize.XMLSerializer(out, outputFormat);
  serializer.serialize(document);

  org.apache.xerces.parsers.DOMParser parser = new
org.apache.xerces.parsers.DOMParser();
  ParserErrorHandler errorHandler = new ParserErrorHandler();
  parser.setErrorHandler(errorHandler);
  parser.setFeature("http://xml.org/sax/features/validation";, true);
  parser.setLocale(new Locale(language, country));
  parser.parse(new org.xml.sax.InputSource(new
ByteArrayInputStream(out.toByteArray()))); // SAXParseException


----- Original Message -----
From: Andy Clark <[EMAIL PROTECTED]>
To: <[EMAIL PROTECTED]>
Sent: Monday, April 10, 2000 11:53 PM
Subject: Re: How to validate an "org.w3c.dom.Document"


> Eric SCHAEFFER wrote:
> > (The way I've found is to serialize the document to a string and to parse
the
> > string, with an ErrorHandler. Not very simple, and a bit stupid ...)
>
> That sounds about right. Except that I would serialize it to a
> stream that is parsed instead of wasting memory by building a
> string. And by doing so you could trap the validation errors
> and associate them to the current node being serialized.
>
> --
> Andy Clark * IBM, JTC - Silicon Valley * [EMAIL PROTECTED]
>

Reply via email to