You are viewing a plain text version of this content. The canonical link for it is here.
Posted to j-dev@xerces.apache.org by bu...@apache.org on 2001/05/11 20:42:20 UTC

[Bug 1726] New - strange processing of the "all"-construct of XML-Schema in Xerces

http://nagoya.apache.org/bugzilla/show_bug.cgi?id=1726

*** shadow/1726	Fri May 11 11:42:20 2001
--- shadow/1726.tmp.27818	Fri May 11 11:42:20 2001
***************
*** 0 ****
--- 1,75 ----
+ +============================================================================+
+ | strange processing of the "all"-construct of XML-Schema in Xerces          |
+ +----------------------------------------------------------------------------+
+ |        Bug #: 1726                        Product: Xerces-J                |
+ |       Status: NEW                         Version: 1.3.1                   |
+ |   Resolution:                            Platform: PC                      |
+ |     Severity: Major                    OS/Version: Windows NT/2K           |
+ |     Priority:                           Component: Schema-Structures       |
+ +----------------------------------------------------------------------------+
+ |  Assigned To: xerces-j-dev@xml.apache.org                                  |
+ |  Reported By: alexander.ruehl@nist.gov                                     |
+ |      CC list: Cc:                                                          |
+ +----------------------------------------------------------------------------+
+ |          URL:                                                              |
+ +============================================================================+
+ |                              DESCRIPTION                                   |
+ Xerces: 1.3.0 and 1.3.1
+ Java: jre 1.1 and jdk 1.3
+ Subject: strange processing of the "all"-construct of XML-Schema in Xerces
+ 
+ The following XML Schema part declares a box element with a,b,c subelements in 
+ arbitrary order:
+ 
+   <element name="box">
+    <complexType>
+     <all>
+      <element name="a" type='string'/>
+      <element name="b" type='string'/>
+      <element name="c" type='string'/>
+     </all>
+    </complexType>
+   </element>
+ 
+ The following XML part which uses the schema contains an error according to it:
+ 
+   <box>
+    <a>1</a>
+    <b>1</b>
+    <c>1</c>
+    <c>1</c>
+   </box>
+ 
+ When this file is checked with the XML parser and activated schema parsing and 
+ error output (taken from SaxCount.java), it outputs:
+ 
+   ...
+   The content of element type "box" must match "((a,b,c)|(a,c,b)|(b,a,c)|(b,c,a)
+ |(c,b,a)|(c,a,b))".
+   ...
+ 
+ So it seems that it translates the "all"-construct into a corresponding DTD 
+ construct which lists all possible combinations.
+ This might be ok for 3 elements, but with just a few more (let's have 
+ additional elements <d>, <e>, <f>, <g>, <h>) it results in:
+ 
+   Exception in thread "main" java.lang.OutOfMemoryError
+         at org.apache.xerces.validators.common.CMStateSet.<init>(Compiled Code)
+         at org.apache.xerces.validators.common.CMNode.lastPos(Compiled Code)
+         at org.apache.xerces.validators.common.DFAContentModel.calcFollowList
+ (Compiled Code)
+         ...
+         at org.apache.xerces.validators.common.DFAContentModel.calcFollowList
+ (Compiled Code)
+         at
+ 	...
+         at
+         at sax.SAXCount.print(SAXCount.java:155)
+         at sax.SAXCount.main(Compiled Code)
+   ...
+ 
+ After a look at the code it seems that the parser produces an awful lot of 
+ nodes (8! = over 40,000 combinations) and thus overflows memory.
+ 
+ How comes that the presence of 8 elments in arbitrary order is not checked by a 
+ simple 8 item array (for example) instead of building thousands of nodes?

---------------------------------------------------------------------
To unsubscribe, e-mail: xerces-j-dev-unsubscribe@xml.apache.org
For additional commands, e-mail: xerces-j-dev-help@xml.apache.org