Hi guys,

 

I have read the past threads regarding minimum and maximum occurrences'
attributes, but I think I've stumbled with a new troublesome scenario.

 

I'm working with a schema that allows multiple instances
(maxOccurs="unbounded") of different elements. The following snippet
should be enough to illustrate:

 

        <xs:element name="bag" maxOccurs="unbounded">

          <xs:complexType>

            <xs:sequence>

              <xs:element name="pocket" maxOccurs="unbounded">

                <xs:complexType>

                    <xs:sequence>

                      <xs:element name="item" maxOccurs="unbounded">

                        <xs:complexType>

                          <xs:attribute name="name" type="xs:string"/>

                        </xs:complexType>

                      </xs:element>

                    </xs:sequence>

                  <xs:attribute name="name" type="xs:string"/>

                </xs:complexType>

              </xs:element>

            </xs:sequence>

            <xs:attribute name="name" type="xs:string"/>

          </xs:complexType>

        </xs:element>

 

 

As you can see from the code above, all three elements, the bag, the
pocket, and the item are allowed to repeat themselves indefinitely.
However, when retrieving the Element Type Information from within the
xerces code, I am not being able to retrieve the item particle
information. Indeed, if I rewrite the pocket so that it has no embedded
sub-element, then it is the pocket element the one with no particle. For
all I can tell from the tests I have done, the last element in the
hierarchy (i.e. the element with no further nested sub-elements) has no
particles, and therefore no available maxOccurs/minOccurs information.

 

I'm retrieving the occurrence information form within my own content
handler, from where I have overridden the startElement() and included
the following snippet:

 

XSParticle p =
((XSComplexTypeDefinition)provider.getElementTypeInfo()).getParticle();

int maxOccurs = ((XSParticleDecl)p).maxEffectiveTotalRange();

 

As I was saying earlier, the particle itself is not available in the
last element of the hierarchy, so the maxOccurs is unavailable. Has
anyone stumbled with this before? Is there another way to retrieve the
attribute, whether it's through the particle or not? 

Thanks in advance,

Nicolas Zeitlin

Reply via email to