XMLSchema workaround not supporting maxOccurs greater than 5000

My problem is parsing an XSD schema that has elements with maxOccurs greater than 5000 (but not unbounded ).

This is really a problem with the information in Xerces (which I use, version 2.9.1) or JAXP, as described here: http://bugs.sun.com/view_bug.do;jsessionid=85335466c2c1fc52f0245d20b2e?bug_id=4990915

I already know that if I changed the maxOccurs numbers in my XSD from numbers greater than 5000 to unbounded , everything would work fine. Unfortunately, this is not an option in my case (I cannot interfere with the XSD file).

My question is:

  • Does anyone know of a different way to work around the solution in Xerces for this problem? Or
  • Can someone recommend another XML parser that does not have this limitation?

Thanks!

+4
source share
3 answers

I found a solution that does not require a parser change.

There is a FEATURE_SECURE_PROCESSING function that sets a limit of 5000 on maxOccurs (along with several others). A.

And here is a document describing the limitations: http://docs.oracle.com/javase/7/docs/technotes/guides/xml/jaxp/JAXP-Compatibility_160.html#JAXP_security

+6
source

I had the same problem. I used this:

 System.setProperty("jdk.xml.maxOccurLimit", "XXXXX"); 
+7
source

I came across this question when looking for solutions to this problem when using the xjc in the console.

For those using the xjc command to parse xsd, this works for me:

 $ xjc -nv foo.xsd 

Remember:

By default, the XJC binding compiler performs a rigorous check on the source schema before processing it. Use this option to disable strict schema validation. This does not mean that the binding compiler will not perform any validation, but does mean that it will perform a less stringent validation.

So, if you think your xsd has a good source, using a less stringent check should not be a problem.

+1
source

Source: https://habr.com/ru/post/1481763/


All Articles