diff --git a/org.eclipse.lemminx/src/main/java/org/eclipse/lemminx/extensions/contentmodel/uriresolver/LSPXMLCatalogResolver.java b/org.eclipse.lemminx/src/main/java/org/eclipse/lemminx/extensions/contentmodel/uriresolver/LSPXMLCatalogResolver.java
new file mode 100644
index 0000000000..e771893dbd
--- /dev/null
+++ b/org.eclipse.lemminx/src/main/java/org/eclipse/lemminx/extensions/contentmodel/uriresolver/LSPXMLCatalogResolver.java
@@ -0,0 +1,33 @@
+package org.eclipse.lemminx.extensions.contentmodel.uriresolver;
+
+import java.io.IOException;
+
+import org.apache.xerces.impl.xs.XSDDescription;
+import org.apache.xerces.util.XMLCatalogResolver;
+import org.apache.xerces.xni.XMLResourceIdentifier;
+import org.apache.xerces.xni.XNIException;
+
+class LSPXMLCatalogResolver extends XMLCatalogResolver {
+
+ public LSPXMLCatalogResolver(String[] catalogs) {
+ super(catalogs);
+ }
+
+ @Override
+ public String resolveIdentifier(XMLResourceIdentifier resourceIdentifier) throws IOException, XNIException {
+ if (isXSDInclude(resourceIdentifier)) {
+ return resourceIdentifier.getExpandedSystemId();
+ }
+ return super.resolveIdentifier(resourceIdentifier);
+ }
+
+ private boolean isXSDInclude(XMLResourceIdentifier resourceIdentifier) {
+ if (resourceIdentifier != null && resourceIdentifier instanceof XSDDescription
+ && resourceIdentifier.getNamespace() != null) {
+ XSDDescription description = (XSDDescription) resourceIdentifier;
+ int contextType = description.getContextType();
+ return contextType == XSDDescription.CONTEXT_INCLUDE || contextType == XSDDescription.CONTEXT_IMPORT;
+ }
+ return false;
+ }
+}
diff --git a/org.eclipse.lemminx/src/main/java/org/eclipse/lemminx/extensions/contentmodel/uriresolver/XMLCatalogResolverExtension.java b/org.eclipse.lemminx/src/main/java/org/eclipse/lemminx/extensions/contentmodel/uriresolver/XMLCatalogResolverExtension.java
index d684c65c3f..f0aeed0d04 100644
--- a/org.eclipse.lemminx/src/main/java/org/eclipse/lemminx/extensions/contentmodel/uriresolver/XMLCatalogResolverExtension.java
+++ b/org.eclipse.lemminx/src/main/java/org/eclipse/lemminx/extensions/contentmodel/uriresolver/XMLCatalogResolverExtension.java
@@ -120,7 +120,7 @@ public boolean setCatalogs(String[] catalogs) {
}
}
if (xmlCatalogFiles.size() > 0) {
- XMLCatalogResolver catalogResolver = new XMLCatalogResolver(xmlCatalogFiles.toArray(new String[0]));
+ XMLCatalogResolver catalogResolver = new LSPXMLCatalogResolver(xmlCatalogFiles.toArray(new String[0]));
setCatalogResolver(catalogResolver);
} else {
setCatalogResolver(null);
diff --git a/org.eclipse.lemminx/src/test/java/org/eclipse/lemminx/extensions/contentmodel/XMLSchemaDiagnosticsTest.java b/org.eclipse.lemminx/src/test/java/org/eclipse/lemminx/extensions/contentmodel/XMLSchemaDiagnosticsTest.java
index 384492b1ac..788e5d9a30 100644
--- a/org.eclipse.lemminx/src/test/java/org/eclipse/lemminx/extensions/contentmodel/XMLSchemaDiagnosticsTest.java
+++ b/org.eclipse.lemminx/src/test/java/org/eclipse/lemminx/extensions/contentmodel/XMLSchemaDiagnosticsTest.java
@@ -1006,6 +1006,15 @@ public void diagnosticRelatedInformationWithSchemaLocationSyntaxProblem() throws
diagnostic);
}
+ @Test
+ public void testWithCatalogAndXSDInclude() throws BadLocationException {
+ String xml = "\r\n" + //
+ " \r\n" + //
+ "";
+ Diagnostic diagnostic = d(1, 2, 1, 6, XMLSchemaErrorCode.cvc_complex_type_2_4_b);
+ XMLAssert.testDiagnosticsFor(xml, "src/test/resources/catalogs/include/catalog-include.xml", diagnostic);
+ }
+
private static void testDiagnosticsFor(String xml, Diagnostic... expected) {
XMLAssert.testDiagnosticsFor(xml, "src/test/resources/catalogs/catalog.xml", expected);
}
diff --git a/org.eclipse.lemminx/src/test/resources/catalogs/include/catalog-include.xml b/org.eclipse.lemminx/src/test/resources/catalogs/include/catalog-include.xml
new file mode 100644
index 0000000000..8a1f1c4b22
--- /dev/null
+++ b/org.eclipse.lemminx/src/test/resources/catalogs/include/catalog-include.xml
@@ -0,0 +1,5 @@
+
+
+
\ No newline at end of file
diff --git a/org.eclipse.lemminx/src/test/resources/catalogs/include/test-include.xsd b/org.eclipse.lemminx/src/test/resources/catalogs/include/test-include.xsd
new file mode 100644
index 0000000000..3350c15828
--- /dev/null
+++ b/org.eclipse.lemminx/src/test/resources/catalogs/include/test-include.xsd
@@ -0,0 +1,19 @@
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
\ No newline at end of file
diff --git a/org.eclipse.lemminx/src/test/resources/catalogs/include/test.xml b/org.eclipse.lemminx/src/test/resources/catalogs/include/test.xml
new file mode 100644
index 0000000000..139d9df704
--- /dev/null
+++ b/org.eclipse.lemminx/src/test/resources/catalogs/include/test.xml
@@ -0,0 +1,13 @@
+
+
+
+
+
+ Page 1
+ Content for page 1
+
+
+ Page 2
+ Content for page 2
+
+
\ No newline at end of file
diff --git a/org.eclipse.lemminx/src/test/resources/catalogs/include/test.xsd b/org.eclipse.lemminx/src/test/resources/catalogs/include/test.xsd
new file mode 100644
index 0000000000..1f688d704b
--- /dev/null
+++ b/org.eclipse.lemminx/src/test/resources/catalogs/include/test.xsd
@@ -0,0 +1,4 @@
+
+
+
+
\ No newline at end of file