• 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

schema allowing elements to appear in any order

 
Ranch Hand
Posts: 331
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Im trying to create a schema which allows for elements to appear in any order i.e. ade, eda, dea .. With the following it allows me to do that however I cannot control the # of times the element appears, even with
minOccurs="1" maxOccurs="1"

<?xml version="1.0" encoding="UTF-8"?>
<!--W3C Schema for chartdefs.xml file-->
<xs:schema xmlns:xs="http://www.w3.org/2001/XMLSchema">
<xs:element name="a">
<xs:complexType>
<xs:attribute name="b" use="required">
<xs:simpleType>
<xs:restriction base="xs:string">
<xs:enumeration value="test"/>

</xs:restriction>
</xs:simpleType>
</xs:attribute>
</xs:complexType>
</xs:element>
<xs:element name="c">
<xs:complexType>
<xs:choice maxOccurs="unbounded">

<xs:element ref="a"/>
<xs:element name="d" type="xs:string" minOccurs="1" maxOccurs="1"/>
<xs:element name="e" type="xs:string" minOccurs="0"/>

</xs:choice>
</xs:complexType>
</xs:element>
</xs:schema>

I saw the following on java.sun but I cant seem to get it to work, which should solve the issue

<xsd:schema xmlns:xsd="http://www.w3.org/2001/XMLSchema">

<xsd:element name="root">
<xsd:complexType>
<xsd:sequence>
<xsd:element ref="foobarelements" maxOccurs="unbounded"/>
</xsd:sequence>
</xsd:complexType>
</xsd:element>

<xsd:element name="foo" type="xsd:anyType" substitutionGroup="foobarelements"/>
<xsd:element name="bar" type="xsd:anyType" substitutionGroup="foobarelements"/>
<xsd:element name="foobar" type="xsd:anyType" substitutionGroup="foobarelements"/>
<xsd:element name="foobarelements" type="xsd:anyType"/>

</xsd:schema>
 
john mattucci
Ranch Hand
Posts: 331
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
I figured it out, thought i tried this but guess not


<xs:element name="a">
<xs:complexType>
<xs:all>
<xs:element name="b"/>
<xs:element name="c"/>
<xs:element name="d"/>
</xs:all>
</xs:complexType>
</xs:element>
 
reply
    Bookmark Topic Watch Topic
  • New Topic