You are viewing a plain text version of this content. The canonical link for it is here.
Posted to user@xmlbeans.apache.org by Vance Vagell <va...@vancevagell.com> on 2007/04/03 19:45:44 UTC

How can I iterate through children (elements and attributes) of a SchemaType?

Hi folks,

I've been struggling with this issue for the past couple days, and could use any guidance you can provide.  I have a set of schemas that have been compiled (using XmlBeans.compileXsd()) into an array of SchemaTypes.  When I am working with one of those SchemaTypes I need the ability to find out:

1) What valid child elements of this type are (i.e., SchemaTypes representing those children)
2) What valid attributes of this type are  (i.e., SchemaTypes representing those attributes)

For example, I have a reference to a SchemaType that contains the definition of (namespace references removed for simplicity):

...
      <element name="Compliance">
        <complexType>
          <sequence>
            <element minOccurs="0" maxOccurs="1" name="company" type="Company" />
            <element minOccurs="0" maxOccurs="1" name="confidence" type="string" />
          </sequence>
        </complexType>
      </element>
...

I am able to retrieve it's name fine, but I cannot find a way to retrieve the SchemaType objects representing its two children, "Company" and "confidence".  I've tried numerous suggestions I was able to find online, the most promising of which was:

http://www.mail-archive.com/user@xmlbeans.apache.org/msg00244.html

But that approach did not result in an array of two SchemaTypes as expected.  I always reviewed all XmlBeans tutorials, but did not find any examples of this type of deep processing on SchemaType objects.  Additionally, the Javadocs are fairly vague for many SchemaType methods, unfortunately.

In general (not just with this example), given a SchemaType, how can one find all of its children SchemaTypes?

Thanks,
Vance

---------------------------------------------------------------------
To unsubscribe, e-mail: user-unsubscribe@xmlbeans.apache.org
For additional commands, e-mail: user-help@xmlbeans.apache.org


Re: How can I iterate through children (elements and attributes) of a SchemaType?

Posted by Radu Preotiuc-Pietro <ra...@bea.com>.
Hi Vance,

I would be interested in what part of what Lawrence had said in that
post you had trouble with.

I am also afraid that you may be making a slight confusion between
elements and types when you say "i.e. SchemaTypes representing those
children[elements]" Elements and types are distinct entities in
XMLSchema and even though each element has a type, you can have multiple
elements with the same type; therefore, SchemaTypes don't represent
elements.

Radu

On Tue, 2007-04-03 at 10:45 -0700, Vance Vagell wrote:
> Hi folks,
> 
> I've been struggling with this issue for the past couple days, and could use any guidance you can provide.  I have a set of schemas that have been compiled (using XmlBeans.compileXsd()) into an array of SchemaTypes.  When I am working with one of those SchemaTypes I need the ability to find out:
> 
> 1) What valid child elements of this type are (i.e., SchemaTypes representing those children)
> 2) What valid attributes of this type are  (i.e., SchemaTypes representing those attributes)
> 
> For example, I have a reference to a SchemaType that contains the definition of (namespace references removed for simplicity):
> 
> ...
>       <element name="Compliance">
>         <complexType>
>           <sequence>
>             <element minOccurs="0" maxOccurs="1" name="company" type="Company" />
>             <element minOccurs="0" maxOccurs="1" name="confidence" type="string" />
>           </sequence>
>         </complexType>
>       </element>
> ...
> 
> I am able to retrieve it's name fine, but I cannot find a way to retrieve the SchemaType objects representing its two children, "Company" and "confidence".  I've tried numerous suggestions I was able to find online, the most promising of which was:
> 
> http://www.mail-archive.com/user@xmlbeans.apache.org/msg00244.html
> 
> But that approach did not result in an array of two SchemaTypes as expected.  I always reviewed all XmlBeans tutorials, but did not find any examples of this type of deep processing on SchemaType objects.  Additionally, the Javadocs are fairly vague for many SchemaType methods, unfortunately.
> 
> In general (not just with this example), given a SchemaType, how can one find all of its children SchemaTypes?
> 
> Thanks,
> Vance
> 
> ---------------------------------------------------------------------
> To unsubscribe, e-mail: user-unsubscribe@xmlbeans.apache.org
> For additional commands, e-mail: user-help@xmlbeans.apache.org
> 

Notice:  This email message, together with any attachments, may contain information  of  BEA Systems,  Inc.,  its subsidiaries  and  affiliated entities,  that may be confidential,  proprietary,  copyrighted  and/or legally privileged, and is intended solely for the use of the individual or entity named in this message. If you are not the intended recipient, and have received this message in error, please immediately return this by email and then delete it.

---------------------------------------------------------------------
To unsubscribe, e-mail: user-unsubscribe@xmlbeans.apache.org
For additional commands, e-mail: user-help@xmlbeans.apache.org