/** <p>Parses the given XML schema. and returns a syntactical
* representation.</p>
* @see #parse(InputSource)
*/
public XsESchema parseSyntax(final InputSource pSource) throws ParserConfigurationException, SAXException, IOException {
XSContext context = getContext();
parser.set(this);
FileOutputStream fos = null;
try {
XsObjectFactory factory = context.getXsObjectFactory();
XsSAXParser xsSAXParser = factory.newXsSAXParser();
context.setCurrentContentHandler(xsSAXParser);
XMLReader xr = factory.newXMLReader(isValidating());
String logDir = System.getProperty("org.apache.ws.jaxme.xs.logDir");
if (logDir != null) {
File tmpFile = File.createTempFile("jaxmexs", ".xsd", new File(logDir));
fos = new FileOutputStream(tmpFile);
LoggingContentHandler lch = new LoggingContentHandler(fos);
lch.setParent(xr);
xr = lch;
String msg = "Read from " + pSource.getPublicId() + ", " + pSource.getSystemId() + " at " + new Date();
lch.comment(msg.toCharArray(), 0, msg.length());
}
xr.setContentHandler(xsSAXParser);
xr.parse(pSource);
if (fos != null) {
fos.close();
fos = null;
}
return (XsESchema) xsSAXParser.getBean();
} finally {
if (fos != null) {
try { fos.close(); } catch (Throwable ignore) {}
}
context.setCurrentContentHandler(null);
parser.set(null);
}
}