There are methods on XmlSchemaElement that returns the type name (when it's in another schema) or the type (when it's in the same schema). You want getSchemaType().
On Wed, Apr 15, 2009 at 9:23 AM, Patrick Kiernan <[email protected]> wrote: > Ok so I want to parse the notes.xsd file. When I say parse I would like to > extract > the following: > > note > to [string] > from [string] > heading [string] > body [string] > > So I'd like to extract the fact that the elements to, from, heading and body > are of type string. It > may be important to note that I am trying make my parser ask generic as > possible i.e. it will do this > for any schema file. > > The full file is available here: > http://www.redbrick.dcu.ie/~hoss/uploads/note.xsd<http://www.redbrick.dcu.ie/%7Ehoss/uploads/note.xsd> > > So I've the following code: > > try{ > InputStream is = is = new > FileInputStream("C:\\Users\\Patrick\\Documents\\college\\FYP\\xml\\note.xsd"); > > XmlSchemaCollection schemaCol = new XmlSchemaCollection(); > XmlSchema schema = schemaCol.read(new StreamSource(is), > null); > XmlSchemaObjectTable objectTable = schema.getElements(); > > So I have an object called schema. The methods getElements() and getItems() > both return note and not > the elements to, from, heading or body as they are in a sequence in a > complex type. > > You say to ask the elemnt for its type, how do I do this? > > Thanks, > Patrick > > > On Fri, Apr 10, 2009 at 10:38 PM, Benson Margulies > <[email protected]>wrote: > >> You ask the element for its type. You cast the type to >> XmlSchemaComplexType. >> >> You ask it for for the particle. >> >> You cast that to XmlSchemaSequence. >> >> And the elements are in the sequence. >> >
