Hi Henry,
First of all, you should not use any Xerces internal classes to query
schema components.
Instead, use the XML Schema API [1] that allows you to access the PSVI
including the XML Schema components, e.g. complex types. The interfaces
defined in the API are isomorphic to the XML Schema components, for example
the XSComplexTypeDefinition corresponds to the complex type definition
schema component [2]. In general, for each property defined for an XML
Schema component there is a corresponding method(s) available, i.e. the
{content type} for complex type definition corresponds to the following
methods:
public short getContentType();
public XSParticle getParticle();
public XSSimpleTypeDefinition getSimpleType()
> How can I get the data types out
> of the declared elements (as shown above) from the object context
> created by XSComplexTypeDecl? what method(s) do I need to connect
> together in order to extract it?
First use getParticle() to retrieve the "all" particle, then iterate the
particles items which are element declarations. From element declaration
you can retrieve type using getTypeDefinition() method.
[1] http://xml.apache.org/xerces2-j/faq-xs.html#faq-3
[2]
http://www.w3.org/TR/2001/REC-xmlschema-1-20010502/#Complex_Type_Definition_details
Thanks,
--
Elena Litani / IBM Toronto
Henry Miller <[EMAIL PROTECTED]> wrote on 03/15/2004 02:53:04 PM:
> Another one from the "yet another newbie question" department...
>
> I'm trying to preparse XML schema files and I've hit a snag that I
> just cannot figure out on my own.
>
> Using Xerces-J, I'm able to get all the information out, except the
> element's data type. In fact, all I can get is the element name and
> nothing else.
>
> Given the following XSD snippet:
>
> <element name="PriceRequest">
> <complexType>
> <all>
> <element name="Symbol" type="string"/>
> <element name="price" type="float"/>
> </all>
> </complexType>
> </element>
>
> I managed to drill down through the Xerces-J methods and end up in
> the XSComplexTypeDecl class when I hit the problem. My code is
> complicated (made worse by my toying with it now), but hopefully the
> question is simple enough to answer: How can I get the data types out
> of the declared elements (as shown above) from the object context
> created by XSComplexTypeDecl? what method(s) do I need to connect
> together in order to extract it? Is there a 'set' list?
>
> I guess that's three questions. I'm so lost... :-)
>
> I'm able to get the element names from a particle list by parsing a
> string that returns all of them using getParticle() in
> XSComplexTypeDecl -- probably not the cleanest, but it works. Why
> doesn't XSComplexTypeDecl provide types here as well? I'm sure
> there's a reason which I don't yet see.
>
> I'm not even sure what is relevant code to clip out for your
viewingpleasure.
>
> Any ideas?
> --
>
>
> --Henry
>
>
> ---------------------------------------------------------------------
> To unsubscribe, e-mail: [EMAIL PROTECTED]
> For additional commands, e-mail: [EMAIL PROTECTED]
>
---------------------------------------------------------------------
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]