[oXygen-user] XML Schema question

Timothy Reaves
Tue Jul 10 10:06:50 CDT 2007


     I have an XML Schema I'm trying to lock down (to do more validation
for me).  I have an element with a required attribute that I restrict
as shown below.

<xsd:element name="MyElement1">
  <xsd:complexType>
    <xsd:sequence>
      <xsd:element name="Description" minOccurs="0" type="xsd:string"/>
      <xsd:element maxOccurs="unbounded" ref="MyElement2"/>
      <xsd:element maxOccurs="unbounded" ref="MyElement3"/>
      <xsd:element maxOccurs="unbounded" ref="MyElement4"/>
    </xsd:sequence>
    <xsd:attribute name="scope" use="required">
      <xsd:simpleType>
        <xsd:restriction base="xsd:string">
          <xsd:enumeration value="scope1"/>
          <xsd:enumeration value="scope2"/>
          <xsd:enumeration value="scope3"/>
          <xsd:enumeration value="scope4"/>
        </xsd:restriction>
      </xsd:simpleType>
    </xsd:attribute>
  </xsd:complexType>
</xsd:element>


What I want to do is have MyElement3 only allowable in a MyElement1 where
scope == scope2 (for example).  So have a rule on an element that
restricts what element can contain it based on the attribute value.

     Is this possible?  Any pointer to documentation doing something like
this?  Thanks!




More information about the oXygen-user mailing list