• Post Reply Bookmark Topic Watch Topic
  • New Topic
programming forums Java Mobile Certification Databases Caching Books Engineering Micro Controllers OS Languages Paradigms IDEs Build Tools Frameworks Application Servers Open Source This Site Careers Other Pie Elite all forums
this forum made possible by our volunteer staff, including ...
Marshals:
  • Campbell Ritchie
  • Jeanne Boyarsky
  • Ron McLeod
  • Paul Clapham
  • Liutauras Vilda
Sheriffs:
  • paul wheaton
  • Rob Spoor
  • Devaka Cooray
Saloon Keepers:
  • Stephan van Hulst
  • Tim Holloway
  • Carey Brown
  • Frits Walraven
  • Tim Moores
Bartenders:
  • Mikalai Zaikin

How to: representing a list of objects in XSD??

 
Ranch Hand
Posts: 245
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
In my Java code I have the following datamembers

String text1;
String text2;
...
ArrayList<String> someList;

How do I represent this in XSD? Is it a complex type with only 1 data member? I'm looking through the docs and can't find a match...

is it -

<xs:complexType name="someList" type="java.util.ArrayList">
<xs:element name="info" type="xs:string"/>
</xs:complexType>

or something like <xs:element name="info" type="xs:string" maxoccurs="unbounded"/>



Thanks,

Paul
[ August 04, 2005: Message edited by: Paul Smiley ]
 
Ranch Hand
Posts: 578
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator

Originally posted by Paul Smiley:
In my Java code I have the following datamembers



How do I represent this in XSD? Is it a complex type with only 1 data member? I'm looking through the docs and can't find a match...

is it -

<xs:complexType name="someList" type="java.util.ArrayList">
<xs:element name="info" type="xs:string"/>
</xs:complexType>

or something like <xs:element name="info" type="xs:string" maxoccurs="unbounded"/>


[ August 04, 2005: Message edited by: Paul Smiley ]




Well you cant definetely do it teh first way(as far as I know)..u cant relate a type in Schema to a Java type ..

Teh second way is the definite way to go . See Example below


SCHEMA ..



And Sample XML

 
Paul Smiley
Ranch Hand
Posts: 245
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Thanks for the reply! I'm using XMLBeans and I saw something else on their website:

<xs:simpleType name="intOrString">
<xs:union memberTypes="xs:int xs:string">
</xs:simpleType>

It confused me for a second, but your answer works! Thanks again!


http://xmlbeans.apache.org/docs/2.0.0/guide/conJavaTypesGeneratedFromUserDerived.html
 
Don't get me started about those stupid light bulbs.
reply
    Bookmark Topic Watch Topic
  • New Topic