In using Xerces2-J 2.9.0 to parse and query XML Schema components in memory (ref: <http://xerces.apache.org/xerces2-j/faq-xs.html#faq-9> http://xerces.apache.org/xerces2-j/faq-xs.html#faq-9), I have noticed what seems to be a bug when parsing the attached schema, test.xsl. The instance of org.apache.xerces.impl.xs.XSModelGroupImpl created for the fragment: <xs:sequence> <xs:element ref="a"/> <xs:element ref="b" minOccurs="0" maxOccurs="1"/> <xs:element ref="c" minOccurs="1" maxOccurs="unbounded"/> </xs:sequence>
...of test.xsl contains a ternary array XSParticleDecl[] fParticles containing instances for each of the three xs:element declarations in the sequence, however the corresponding fParticleCount attribute (recording the number of particles in fParticles) seems to have not been set, defaulting to 0. I discovered the problem via a call to getParticles() on org.apache.xerces.impl.xs.XSModelGroupImpl, which builds a new XSObjectListImpl via constructor XSObjectListImpl(XSObject[] array, int length), where array is set to fParticles and length to fParticleCount. Using fParticles.length for the latter (in this case) solves the problem. Attached is a test file to reproduce this behaviour. If someone can confirm this as a bug, I'll submit it... thanks! David
test.xsd
Description: XML document
Test.java
Description: Binary data
smime.p7s
Description: S/MIME cryptographic signature