diff --git a/xml/tests/src/com/intellij/codeInsight/daemon/XmlHighlightingTest.java b/xml/tests/src/com/intellij/codeInsight/daemon/XmlHighlightingTest.java
index 6140f8848fec..86e0ff63e1bf 100644
--- a/xml/tests/src/com/intellij/codeInsight/daemon/XmlHighlightingTest.java
+++ b/xml/tests/src/com/intellij/codeInsight/daemon/XmlHighlightingTest.java
@@ -67,6 +67,7 @@ import com.intellij.util.containers.ContainerUtil;
import com.intellij.xml.XmlAttributeDescriptor;
import com.intellij.xml.XmlBundle;
import com.intellij.xml.XmlElementDescriptor;
+import com.intellij.xml.actions.validate.ValidateXmlActionHandler;
import com.intellij.xml.impl.schema.XmlElementDescriptorImpl;
import com.intellij.xml.util.*;
import gnu.trove.THashSet;
@@ -2108,6 +2109,15 @@ public class XmlHighlightingTest extends DaemonAnalyzerTestCase {
doDoTest(true, false);
}
+ public void testMaxOccurLimitValidation() throws Exception {
+ configureByFiles(null, BASE_PATH + "MaxOccurLimit.xml", BASE_PATH + "MaxOccurLimit.xsd");
+ assertTrue(doHighlighting().stream().anyMatch(info -> info.getSeverity() == HighlightSeverity.ERROR));
+
+ configureByFiles(null, BASE_PATH + "MaxOccurLimit.xml", BASE_PATH + "MaxOccurLimit.xsd");
+ System.setProperty(ValidateXmlActionHandler.JDK_XML_MAX_OCCUR_LIMIT, "10000");
+ assertFalse(doHighlighting().stream().anyMatch(info -> info.getSeverity() == HighlightSeverity.ERROR));
+ }
+
public void testTheSameElement() throws Exception {
doTest(
new VirtualFile[] {
diff --git a/xml/tests/testData/xml/MaxOccurLimit.xml b/xml/tests/testData/xml/MaxOccurLimit.xml
new file mode 100644
index 000000000000..75946813de07
--- /dev/null
+++ b/xml/tests/testData/xml/MaxOccurLimit.xml
@@ -0,0 +1,9 @@
+
+
+
+
+ TYPE1
+
+
+
diff --git a/xml/tests/testData/xml/MaxOccurLimit.xsd b/xml/tests/testData/xml/MaxOccurLimit.xsd
new file mode 100644
index 000000000000..efe8d1dccdae
--- /dev/null
+++ b/xml/tests/testData/xml/MaxOccurLimit.xsd
@@ -0,0 +1,37 @@
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
diff --git a/xml/xml-psi-impl/src/com/intellij/xml/actions/validate/ValidateXmlActionHandler.java b/xml/xml-psi-impl/src/com/intellij/xml/actions/validate/ValidateXmlActionHandler.java
index 0e98e6d82663..663d2817b4e4 100644
--- a/xml/xml-psi-impl/src/com/intellij/xml/actions/validate/ValidateXmlActionHandler.java
+++ b/xml/xml-psi-impl/src/com/intellij/xml/actions/validate/ValidateXmlActionHandler.java
@@ -32,11 +32,15 @@ import org.apache.xerces.impl.XMLEntityManager;
import org.apache.xerces.impl.XercesAccessor;
import org.apache.xerces.jaxp.JAXPConstants;
import org.apache.xerces.jaxp.SAXParserFactoryImpl;
+import org.apache.xerces.util.SecurityManager;
import org.apache.xerces.util.XMLGrammarPoolImpl;
import org.apache.xerces.xni.grammars.XMLGrammarPool;
import org.jetbrains.annotations.NonNls;
import org.jetbrains.annotations.Nullable;
-import org.xml.sax.*;
+import org.xml.sax.InputSource;
+import org.xml.sax.SAXException;
+import org.xml.sax.SAXNotRecognizedException;
+import org.xml.sax.SAXParseException;
import org.xml.sax.helpers.DefaultHandler;
import javax.xml.XMLConstants;
@@ -47,6 +51,8 @@ import java.io.StringReader;
import java.util.Arrays;
import java.util.Map;
+import static com.sun.org.apache.xerces.internal.impl.Constants.SECURITY_MANAGER;
+
/**
* @author Mike
*/
@@ -62,6 +68,7 @@ public class ValidateXmlActionHandler {
private static final Key DEPENDENT_FILES_KEY = Key.create("GrammarPoolFilesKey");
private static final Key KNOWN_NAMESPACES_KEY = Key.create("KnownNamespacesKey");
private static final Key