Using same InputSource twice cause IOException

Crash

New Member
I have an \[code\]xml\[/code\] source of \[code\]org.xml.sax.InputSource\[/code\] type. I used it twice, once for validation and once for parsing. It resulted in IOException when used the second time.This code to perform validation against an xsd\[code\]SchemaFactory factory = SchemaFactory.newInstance(W3C_XML_SCHEMA_NS_URI);Schema schema = null;try { schema = factory.newSchema(new StreamSource(xsd));} catch (SAXException e2) {}if (schema != null) { Validator validator = schema.newValidator(); MyErrorHandler errorHandler = new MyErrorHandler(); validator.setErrorHandler(errorHandler); try { validator.validate(new SAXSource(xml)); // will be using back the same xml source object } catch (SAXException e) { } catch (IOException e) { }}\[/code\]After validation (ignore if it is valid or invalid for now, assuming XML is well-form and I want to continue parsing it..), I continue with XML parsing with the same \[code\]xml\[/code\] source object. (currently I ).\[code\]DocumentBuilderFactory factory = DocumentBuilderFactory.newInstance();DocumentBuilder builder = null;try { builder = factory.newDocumentBuilder();} catch (ParserConfigurationException e) { }Document document = null;try {document = builder.parse(xml); // using back same xml object here again.. causes IOE!} catch (SAXException e) {} catch (IOException e) { // caught IOException here.. why? }\[/code\]it ended up with an IOException. Anyone know why?
 
Back
Top