XmlOptions xmlOptions = SchemaConversionUtils.createXmlOptions(errors);
SchemaDocument parsed = SchemaDocument.Factory.parse(element, xmlOptions);
if (errors.size() != 0) {
throw new XmlException(errors.toArray().toString());
}
XmlCursor cursor = parsed.newCursor();
try {
cursor.toFirstContentToken();
for (Iterator namespaces = namespaceMap.entrySet().iterator(); namespaces.hasNext();) {
Map.Entry entry = (Map.Entry) namespaces.next();
cursor.insertNamespace((String) entry.getKey(), (String) entry.getValue());