I've tried:

XmlSchemaObjectTable objectTable = schema.getElements();

Now I can print the name of the element by doing:
Iterator it = objectTable.getNames();
System.out.println(it.next());

Ok but how do I "obtain" the one element in my schema so that I can call
getSchemaType on
it like you suggest?

On Thu, Apr 16, 2009 at 12:19 PM, Benson Margulies <bimargul...@gmail.com>wrote:

> Same thing I explained before. The top-level collections contain only
> top-level objects. The one element in your schema is sitting in the
> items() collection, or in the elements collection. You obtain it, and
> call getSchemaType on it to work our way down.
>
> The data structures really mirror the XML.
>
>
> On Thu, Apr 16, 2009 at 7:11 AM, Patrick Kiernan <hossb...@gmail.com>
> wrote:
> > I'm not sure how to get the elements into an XmlSchemaElement object.
> > I have the schema in an object called "schema" of type XmlSchema. Looking
> at
> > the API
> > for methods on this and I see getSchemaTypes() which returns an
> > XmlSchemaObjectTable.
> > I've tried doing a getCount() on this but it returns 0 for the file I'm
> > testing.
> >
> > Can you explain further please?
> >
> > On Wed, Apr 15, 2009 at 7:50 PM, Benson Margulies <bimargul...@gmail.com
> >wrote:
> >
> >> 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 <hossb...@gmail.com>
> >> 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 <
> >> bimargul...@gmail.com>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.
> >> >>
> >> >
> >>
> >
>

Reply via email to