in xmlschema-core/src/main/java/org/apache/ws/commons/schema/XmlSchema.java [879:929]
private void serializeInternal(Writer out, Map<String, String> options) {
try {
XmlSchemaSerializer xser = new XmlSchemaSerializer();
xser.setExtReg(this.parent.getExtReg());
Document[] serializedSchemas = xser.serializeSchema(this, false);
TransformerFactory trFac = TransformerFactory.newInstance();
trFac.setFeature(XMLConstants.FEATURE_SECURE_PROCESSING, Boolean.TRUE);
try {
trFac.setAttribute("indent-number", "4");
} catch (IllegalArgumentException e) {
// do nothing - we'll just silently let this pass if it
// was not compatible
}
Source source = new DOMSource(serializedSchemas[0]);
Result result = new StreamResult(out);
javax.xml.transform.Transformer tr = trFac.newTransformer();
// use the input encoding if there is one
if (this.inputEncoding != null && !"".equals(this.inputEncoding)) {
tr.setOutputProperty(OutputKeys.ENCODING, this.inputEncoding);
}
// let these be configured from outside if any is present
// Note that one can enforce the encoding by passing the necessary
// property in options
if (options == null) {
options = new HashMap<String, String>();
loadDefaultOptions(options);
}
Iterator<String> keys = options.keySet().iterator();
while (keys.hasNext()) {
Object key = keys.next();
tr.setOutputProperty((String)key, options.get(key));
}
tr.transform(source, result);
out.flush();
} catch (TransformerConfigurationException e) {
throw new XmlSchemaException(e.getMessage());
} catch (TransformerException e) {
throw new XmlSchemaException(e.getMessage());
} catch (XmlSchemaSerializer.XmlSchemaSerializerException e) {
throw new XmlSchemaException(e.getMessage());
} catch (IOException e) {
throw new XmlSchemaException(e.getMessage());
}
}