Given a wsdl uri, the schemas must be found at the xpath
/wsdl:definitions/wsdl:types/xsd:schema
(you'd have to use the appropriate namespace prefixes for the document, or
supply a prefix resolver to your xpath engine).
Given an import in a wsdl, the spectrum is a little wider and you might just
look for nodes
//xsd:schema.
The reason is that a wsdl may import a schema directly, or may import part
of its wsdl contents, (e.g. its <types>).
In principle, you should not have to worry about imports or includes within
a schema file, since the parser will deal with them appropriately anyway.

First, initialize a Xerces DomParser, using the various settings for the
PSVI DOM (see the Xerces schema and grammar FAQs), and configuring it to use
a grammar pool.  So, using xpath, or just DOM traversal, you find various
<xsd:schema> nodes.  Now you convert them to strings using Xerces
XmlSerializer.  Then you use the Xerces SchemaLoader to read the serialized
schemas and preparse them into the grammar pool.  As long as you use this
parser object, any reference in any instance document to the namespaces of
the parsed schemas will result in lookup of the appropriate grammar from the
grammar pool.

You can also use these grammars for you own purposes.  From the parser, you
access the grammar pool, and retrieve the grammar for a given namespace.
grammar.toXSModel() produces an XSModel object from the grammar, which you
can traverse to examine the various types, elements, etc.

Jeff

----- Original Message -----
From: "Xserty" <[EMAIL PROTECTED]>
To: <[EMAIL PROTECTED]>
Sent: Friday, February 28, 2003 2:34 AM
Subject: Re: WSIF, WSDL and Complex Types!


> plz see inline...
>
> At 08:51 AM 2/26/03 -0800, you wrote:
> >Another possibility is to take that <xsd:schema> node you've found, and
use
> >the Xerces PSVI DOM and Grammar interfaces (see the FAQ about using
grammars
> >in the Xerces distribution).  Essentially, you can serialize the schema
node
> >to a string, use the grammar preparser to build a SchemaGrammar from it,
> >convert it to an XSModel, and then rummage around in that, finding the
> >various element, type and attribute definitions, with all their various
> >properties and facets -- the whole structure of the schema as expressed
in
> >the PSVI (post-schema-validation-infoset).
> >
> >I'm doing this in a project I'm working on, and it works nicely.
> >
> >Jeff
>
> This seems a bit tricky, but should do the job.
> I've tried to search for some examples, but dosen't seem to be any around.
> Even the Xerces docs aren't usefull. :(
> Do you know any references, examples or HowTo's to start from?
>
> Thank you very much,
> Xserty
>
> >----- Original Message -----
> >From: "Owen D Burroughs" <[EMAIL PROTECTED]>
> >To: <[EMAIL PROTECTED]>
> >Sent: Wednesday, February 26, 2003 7:34 AM
> >Subject: Re: WSIF, WSDL and Complex Types!
> >
> >
> > > Xserty,
> > >
> > > The Parser class in WSIF might help but it depends on what you want to
> > > achieve. If you want to be able to find any of the elements/attributes
in
> > > the schema, the Parser code will not do this. It does not provide full
> > > schema parsing functionality and there is no intention for it to do
so.
> > > What it can do, is find you all of the names of the global elements in
the
> > > schema and tell you if they are complexTypes, simpleTypes or Elements
and
> > > whether or not they represent Arrays. To establish any greater detail
> >about
> > > the types in the schema you would need to use a full schema parsing
API
> > > such as the one recently contributed to Axis or the one in eclipse.
> > >
> > > Owen
>
>

Reply via email to