Reader reader = null;
InputStream stream = null;
try {
// Parse the XSD, measuring the number of bytes as we read ...
Map<?, ?> options = new HashMap<Object, Object>();
XSDParser parser = new XSDParser(options);
AtomicLong contentSize = new AtomicLong();
if (source.getCharacterStream() != null) {
reader = new SizeMeasuringReader(source.getCharacterStream(), contentSize);
source = new InputSource(reader);
} else {
stream = new SizeMeasuringInputStream(source.getByteStream(), contentSize);
source = new InputSource(stream);
}
parser.parse(source);
// Get some metadata about the XSD ...
String encoding = parser.getEncoding();
// Convert the XSD to content ...
XSDSchema schema = parser.getSchema();
process(schema, encoding, contentSize.get(), outputNode);
} finally {
try {
if (reader != null) reader.close();