xsd validation, complexType with large maxOccurs on choice

Mukul Gandhi <[email protected]>
Newsgroups gmane.text.xml.devel
Message-ID <CANGHzgCqbaA5iyM_Gnt+vs+WjUTbxZ-x_z9fX2E7AxbqAcV71w@mail.gmail.com>
Hi all,
   I've tried to do following XML Schema validation, using three different
XML Schema processors.

XML instance document,

<X>
  <a>hello</a>
  <b>world</b>
</X>

XML Schema document,

<?xml version="1.0"?>
<xs:schema xmlns:xs="http://www.w3.org/2001/XMLSchema">

    <xs:element name="X">
       <xs:complexType>
          <xs:choice maxOccurs="50000">
             <xs:element name="a" type="xs:string"/>
             <xs:element name="b" type="xs:string"/>
          </xs:choice>
       </xs:complexType>
    </xs:element>

</xs:schema>

1) XercesJ with default options, reports,

Exception in thread "main" java.lang.OutOfMemoryError: Java heap space

Though XercesJ can avoid this error, by setting a limit via an API, on the
number of complexType content model nodes that are created.

Or if we write, xs:choice maxOccurs="unbounded", XercesJ has no issues.

2) Saxon reports,

Warning on line 5 of test.xsd:
   maxOccurs value of 50000 treated as unbounded

3) .NET XML Schema validator, has no issues with the example posted within
this mail, and works perfectly fine (i.e, xs:choice maxOccurs="50000" is
handled without any issues). That looks great to me.

I wonder, how .NET XML Schema validator is able to handle the example
posted within this mail, that the other two XML Schema processers that I've
mentioned cannot.



-- 
Regards,
Mukul Gandhi
lmpx.com only provides a reader for public news (NNTP) servers. It is not affiliated with the servers or forums shown here and is not responsible for the content of articles, which is written by their respective authors.