Hi Michael,
Many thanks for your quick reply. When executing: XSParticle p = ((XSComplexTypeDefinition)provider.getElementTypeInfo()).getParticle(); // provider is the TypeInfoProvider ... I am in fact retrieving the XSComplexTypeDefinition, analogously to executing getEnclosingCTDefinition(). Indeed, since what I'm working with is the complex type object and not the element object, calling the getEnclosingCTDefinition() method is impossible. My problem is that the XSComplexTypeDefinition, I believed, should have the particle information. This is the case for the other complex elements in my schema, in a higher lever of hierarchy. Do you think this Is this the intended behavior? Forgive me if I repeat myself, but I may not have understood your answer then... Thank you very much for helping me out with this. Nicolas ________________________________ From: Michael Glavassevich [mailto:mrgla...@ca.ibm.com] Sent: Tuesday, March 30, 2010 8:10 PM To: j-users@xerces.apache.org Subject: Re: Retrieving Minimum and Maximum Occurrences Hi Nicolas, Particles are not part of the PSVI in XML Schema 1.0. You would have to walk back up to the complex type definition (see getEnclosingCTDefinition() on XSElementDeclaration) then search for the particle which points to the element declaration within that complex type definition. Note that this doesn't always work (could have multiple particles pointing to the same global element declaration) but is about the best you can do unless you're willing to build a state machine to keep track of where you are in the schema grammar. Thanks. Michael Glavassevich XML Parser Development IBM Toronto Lab E-mail: mrgla...@ca.ibm.com E-mail: mrgla...@apache.org "Zeitlin, Nicolas" <nicolas.zeit...@sabre-holdings.com> wrote on 03/30/2010 05:30:49 PM: > 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