Skip to content

Commit

Permalink
fix: XML schema enforcer fails with empty namespace
Browse files Browse the repository at this point in the history
Fixes: #2190
Fixes: #2189
  • Loading branch information
igarashitm committed Jun 16, 2020
1 parent 356907e commit 7e4ee66
Showing 1 changed file with 10 additions and 1 deletion.
Expand Up @@ -360,7 +360,16 @@ private Document enforceSchema(Document doc) {
if (namespaceUri == null) {
namespaceUri = XMLConstants.NULL_NS_URI;
}
XSElementDecl rootDecl = schemaSet.getElementDecl(namespaceUri, sourceRoot.getLocalName());
String localName = sourceRoot.getLocalName();
if (XMLConstants.NULL_NS_URI.equals(namespaceUri)) {
localName = sourceRoot.getTagName();
}
XSElementDecl rootDecl = schemaSet.getElementDecl(namespaceUri, localName);
if (rootDecl == null) {
LOG.warn("Declaration of the root element '{}' was not found in the schema",
namespaceUri != null ? namespaceUri + ":" + localName : localName);
return doc;
}
DocumentBuilderFactory dbf = DocumentBuilderFactory.newInstance();
dbf.setNamespaceAware(true);
Document targetDoc = dbf.newDocumentBuilder().newDocument();
Expand Down

0 comments on commit 7e4ee66

Please sign in to comment.