Hi David, Sorry, I should have been clearer. You need to get the enclosing complex type definition. When you're processing the *parent* element you would retrieve its type definition from the ElementPSVI and then use it to find the XSParticles for its children.
Thanks. Michael Glavassevich XML Parser Development IBM Toronto Lab E-mail: mrgla...@ca.ibm.com E-mail: mrgla...@apache.org govelogo <govel...@gmail.com> wrote on 06/29/2009 01:00:35 AM: > Hi Michael, > > If I understand you correctly, I have done this, > > XSElementDeclaration xsElemDel = elemPSVI.getElementDeclaration ();. > XSTypeDefinition xsTypeDef = xsElemDel.getTypeDefinition(); > XSComplexTypeDefinition xsComplexTypeDef; > if (xsElemDel.getTypeDefinition().getTypeCategory() == > XSTypeDefinition.COMPLEX_TYPE) { > typeString = "Complex"; > xsComplexTypeDef = (XSComplexTypeDefinition)xsElemDel. > getTypeDefinition(); > } > > but xsComplexTypeDef is shown "cannot be resolved". So, I guess how > to get hold of a XSComplexTypeDefinition is the problem. Is there > other way to do so? > > thanks a lot, > David > > On Sun, Jun 28, 2009 at 11:46 PM, Michael Glavassevich <mrgla...@ca.ibm.com > > wrote: > getEnclosingCTDefinition() is only going to work for local element > declarations. A faster route than starting from the XSModel (which > you can only retrieve from the validation root anyway) would be to > get the type definition [1] from the ElementPSVI and walk to the > XSParticle from there. Note that when there are multiple XSParticles > whose term is the same element declaration determining which > XSParticle matched requires that you also look at the preceding > elements in the instance document. In general you also need to pay > attention to wildcard particles (XSParticle.getTerm() -> XSWildcard). > > Thanks. > > [1] http://xerces.apache.org/xerces2- > j/javadocs/xs/org/apache/xerces/xs/ItemPSVI.html#getTypeDefinition() > > Michael Glavassevich > XML Parser Development > IBM Toronto Lab > E-mail: mrgla...@ca.ibm.com > E-mail: mrgla...@apache.org > > jeff.gr...@gmail.com wrote on 06/28/2009 09:39:07 PM: > > > > Sorry to reply to my own post, but I forgot to mention that from the > > XSElementDeclaration you can get its enclosing complex type definition > > (using getEnclosingCTDefinition()) and from there work back to the > > particle for the element declaration. > > > > Jeff > > > > On Sun, Jun 28, 2009 at 6:36 PM, Jeff Greif<jgr...@alumni.princeton. > > edu> wrote: > > > From the ElementPSVI on the root of the document, you can get the > > > XSModel using getSchemaInformation. From there you can work your way > > > through the complex type definition to the XSParticle whose term is > > > the XSElementDeclaration in question, and get access to the > > > max/minOccurs info. > > > > > > Jeff > > > > > > On Sun, Jun 28, 2009 at 1:00 PM, govelogo<govel...@gmail.com> wrote: > > >> Hi Mukul, > > >> I think you are right. I could not find a way to get > > >> a XSComplexTypeDefinition from an ElementPSV. > > >> I am building parser between XML and MS Excel for some business > > analysts. To > > >> be able to present an sequence type inside the Excel template as > > required, I > > >> need to know which elements are of sequence type. Is > an XSParticle the only > > >> way to tell whether a element is a sequence or not? > > >> Thanks a lot, > > >> David > > >> On Sat, Jun 27, 2009 at 2:59 AM, Mukul Gandhi <gandhi.mu...@gmail.com> > > >> wrote: > > >>> > > >>> Hi David, > > >>> Using the public APIs provided in, XSElementDeclaration it seems > > >>> you cannot retrieve occurrence indicator values (maxOccurs and > > >>> minOccurs) of an element declaration. > > >>> Perhaps somebody can correct me.. > > >>> > > >>> Just curious, why do you need to retrieve this information using an > > >>> API, as an end user facility? > > >>> > > >>> On Fri, Jun 26, 2009 at 10:59 PM, govelogo<govel...@gmail.com> wrote: > > >>> > Hi there, > > >>> > I am trying to identify a complex type defined in a similar manner as > > >>> > the > > >>> > following sketch of schema. I was hoping to be able to get the > > >>> > information > > >>> > from a XSElementDeclaration class retrieved from an ElementPSVI class. > > >>> > However, it seems I have not found the right method to do it. > > >>> > <xs:complexType name="ArrayOfParameterType"> > > >>> > <xs:sequence> > > >>> > <xs:element name="item" type="ParameterType" nillable="true" > > >>> > minOccurs="0" > > >>> > maxOccurs="unbounded" /> > > >>> > </xs:sequence> > > >>> > </xs:complexType> > > >>> > Is there a way I can tell the minOccurs and maxOccurs of the > sequence of > > >>> > an > > >>> > element in using JAXP ? > > >>> > thanks, > > >>> > David > > >>> > > >>> > > >>> -- > > >>> Regards, > > >>> Mukul Gandhi > > >>> > > >>> --------------------------------------------------------------------- > > >>> To unsubscribe, e-mail: j-users-unsubscr...@xerces.apache.org > > >>> For additional commands, e-mail: j-users-h...@xerces.apache.org > > >>> > > >> > > >> > > > > > > > --------------------------------------------------------------------- > > To unsubscribe, e-mail: j-users-unsubscr...@xerces.apache.org > > For additional commands, e-mail: j-users-h...@xerces.apache.org