You are viewing a plain text version of this content. The canonical link for it is here.
Posted to java-user@axis.apache.org by st...@pacbell.net on 2002/11/11 22:04:28 UTC
Restricting "anyType"
Hi-
I'm new to AXIS and XML Schema. I've looked through the axis-user list
archives but if the answer's there, I haven't been able to find it or
figure it out. I'd greatly appreciate any tips on how I might go about
solving the following problem.
Let's say I have several Java classes: Library.class, Books.class, and
Movies.class.
Library has three variables:
String name;
Vector books; // a vector of Book objects
Vector movies; // a vector of Movie objects
//BTW: I see from the list's messages that an array would be a better
choice than a vector, so I may change this later. But for now, please
bear with me.
If I use Java2WSDL on the Library class, it will give me something like
this:
<schema targetNamespace="http://mynamespace"
xmlns="http://www.w3.org/2001/XMLSchema">
<import namespace="http://schemas.xmlsoap.org/soap/encoding/"/>
<complexType name="library">
<sequence>
<element name="name" type="xsd:string"/>
<element name="books" type="apachesoap:Vector"/>
<element name="movies" type="apachesoap:Vector"/>
</sequence>
</complexType>
<element name="ourlibrary" type="impl:library"/>
</schema>
<schema targetNamespace="http://xml.apache.org/xml-soap"
xmlns="http://www.w3.org/2001/XMLSchema">
<import namespace="http://schemas.xmlsoap.org/soap/encoding/"/>
<complexType name="Vector">
<sequence>
<element maxOccurs="unbounded" minOccurs="0" name="item"
type="xsd:anyType"/>
</sequence>
</complexType>
</schema>
I could then create two complexTypes "book" and "movie" to represent the
data in those classes.
I'd like to restrict the Vector complexType to hold either impl:books
(for use only in the "books" element) or impl:movies (for use only in
the "movies" element), not "xsd:anyType." The problem is, I'm not clear
on how this can be done.
Thank you.