diff --git a/org.eclipse.lemminx/src/main/java/org/eclipse/lemminx/extensions/xsd/utils/XSDUtils.java b/org.eclipse.lemminx/src/main/java/org/eclipse/lemminx/extensions/xsd/utils/XSDUtils.java index bcfbe83b5b..a5063b91ef 100644 --- a/org.eclipse.lemminx/src/main/java/org/eclipse/lemminx/extensions/xsd/utils/XSDUtils.java +++ b/org.eclipse.lemminx/src/main/java/org/eclipse/lemminx/extensions/xsd/utils/XSDUtils.java @@ -289,6 +289,9 @@ public static void searchXSOriginAttributes(DOMNode targetNode, BiConsumer getTargetAttrs(DOMNode referencedNode) { List referencedNodes = new ArrayList<>(); + if (referencedNode == null) { + return referencedNodes; + } Document document = referencedNode.getOwnerDocument(); switch (referencedNode.getNodeType()) { case Node.ATTRIBUTE_NODE: @@ -302,6 +305,9 @@ private static List getTargetAttrs(DOMNode referencedNode) { // The referenced node is the DOM document, collect all attributes // xs:complexType/@name, xs:simpleType/@name, xs:element/@name, xs:group/@name // which can be referenced + if (document.getDocumentElement() == null) { + break; + } NodeList nodes = document.getDocumentElement().getChildNodes(); for (int i = 0; i < nodes.getLength(); i++) { Node n = nodes.item(i);