Hi once you have accessed the elements underlying type with
> elem.getType(); simply cast it to ComplexType (or whatever is needed), and use it. Cheers Werner [email protected] wrote: > Hi , > > My code : > Vector elementsV = new Vector(); > for (Enumeration e = schema.getElementDecls(); e.hasMoreElements();) { > elementsV.add(e.nextElement()); > System.out.println("Size :" + elementsV.size()); > > ElementDecl elem = (ElementDecl) elementsV.lastElement(); > System.out.println( "Element: " + elem.getName() ); // this is giving > "profile" > > XMLType type = elem.getType(); > if (type != null) { > if (type.isSimpleType()) { > > }else if (type.isComplexType()) { > ComplexType ct = schema.getComplexType(elem.getName()); > System.out.println("Count -->"+ct.getParticleCount()); > } > } > } > > getComplexType() is the wrong way I am trying to access , right ?? > What would be the the correct way to access the complexType defination. > > Regards > Anupam Das > > -----Original Message----- > From: Werner Guttmann [mailto:[email protected]] > Sent: Friday, November 27, 2009 3:29 AM > To: [email protected] > Subject: Re: [castor-user] After generating Schema ..... > > Hi, > > [email protected] wrote: >> Hi All, >> >> I am new to Castor ........ >> >> I am able to create schema with >> Schema schema = xi2s.createSchema(inputSource); and after writing it >> in a file it gives me : >> <?xml version="1.0" encoding="UTF-8"?> <schema >> xmlns="http://www.w3.org/2001/XMLSchema >> <http://www.w3.org/2001/XMLSchema> " >> xmlns:xsd="http://www.w3.org/2001/XMLSchema >> <http://www.w3.org/2001/XMLSchema> "> >> <element name="profile"> >> <complexType> >> <sequence> >> <element name="name" type="string"/> >> <element name="lastname" type="string"/> >> <element name="leavetype" type="string"/> >> <element name="leavesavail" type="integer"/> >> <element name="totalleaves" type="integer"/> >> </sequence> >> </complexType> >> </element> >> </schema> >> >> I want to get the list of elements under <profile> tag , that is name >> , lastname , leavetype...... >> I tried with : >> for (Enumeration e = schema.getElementDecls(); e.hasMoreElements();) >> {} > Well, Schema.getElementDecls() returns the top level element(s) of your > XML schema, in your case <profile> only. You will have to access the > underlying complex type definition and its sub-elements. >> but only able to access the top element ... >> >> HOW can i traverse through all the elements ? >> >> Thanks in advance . >> >> Regards >> Anupam Das > Cheers > Werner >> >> >> >> Please do not print this email unless it is absolutely necessary. >> >> The information contained in this electronic message and any > attachments to this message are intended for the exclusive use of the > addressee(s) and may contain proprietary, confidential or privileged > information. If you are not the intended recipient, you should not > disseminate, distribute or copy this e-mail. Please notify the sender > immediately and destroy all copies of this message and any attachments. >> WARNING: Computer viruses can be transmitted via email. The recipient > should check this email and any attachments for the presence of viruses. > The company accepts no liability for any damage caused by any virus > transmitted by this email. >> www.wipro.com >> > > --------------------------------------------------------------------- > To unsubscribe from this list, please visit: > > http://xircles.codehaus.org/manage_email > > > > Please do not print this email unless it is absolutely necessary. > > The information contained in this electronic message and any attachments to > this message are intended for the exclusive use of the addressee(s) and may > contain proprietary, confidential or privileged information. If you are not > the intended recipient, you should not disseminate, distribute or copy this > e-mail. Please notify the sender immediately and destroy all copies of this > message and any attachments. > > WARNING: Computer viruses can be transmitted via email. The recipient should > check this email and any attachments for the presence of viruses. The company > accepts no liability for any damage caused by any virus transmitted by this > email. > > www.wipro.com > > --------------------------------------------------------------------- > To unsubscribe from this list, please visit: > > http://xircles.codehaus.org/manage_email > > --------------------------------------------------------------------- To unsubscribe from this list, please visit: http://xircles.codehaus.org/manage_email

