W3C home > Mailing lists > Public > xmlschema-dev@w3.org > September 2004

Re: Extending abstract elements with a choice

From: George Cristian Bina <george@sync.ro>
Date: Sat, 4 Sep 2004 08:38:37 +0300
Message-ID: <001901c49241$71610610$30a14d52@notebook>
To: "Shane Lauf" <srl01@uow.edu.au>, <xmlschema-dev@w3.org>

Hi Shane,

I guess you can have something like:

test.xsd
--------

<?xml version="1.0"?>
<xsd:schema xmlns:xsd="http://www.w3.org/2001/XMLSchema">
  <xsd:element name="test">
    <xsd:complexType>
      <xsd:sequence>
        <xsd:element ref="myAbstractElement"/>
      </xsd:sequence>
    </xsd:complexType>
  </xsd:element>
  <xsd:element name="myAbstractElement" type="myAbstractElementType"
abstract="true"/>
  <xsd:element name="myConcreteElement" type="myConcreteElementType"
substitutionGroup="myAbstractElement"/>
  <xsd:complexType name="myAbstractElementType">
    <xsd:sequence>
      <xsd:element ref="Object1" minOccurs="0"/>
      <xsd:element ref="Object2" minOccurs="0"/>
    </xsd:sequence>
  </xsd:complexType>
  <xsd:element name="Object1"/>
  <xsd:element name="Object2"/>
  <xsd:complexType name="myConcreteElementType">
    <xsd:complexContent>
      <xsd:restriction base="myAbstractElementType"/>
    </xsd:complexContent>
  </xsd:complexType>
</xsd:schema>

redefined.xsd
-------------
<?xml version="1.0" encoding="UTF-8"?>
<xsd:schema xmlns:xsd="http://www.w3.org/2001/XMLSchema">
  <xsd:redefine schemaLocation="test.xsd">
    <xsd:complexType name="myConcreteElementType">
      <xsd:complexContent>
        <xsd:extension base="myConcreteElementType">
          <xsd:choice>
            <xsd:element ref="SpecialObject1"/>
            <xsd:sequence>
              <xsd:element ref="Object1" minOccurs="1"/>
              <xsd:element ref="Object2" minOccurs="1"/>
            </xsd:sequence>
          </xsd:choice>
        </xsd:extension>
      </xsd:complexContent>
    </xsd:complexType>
  </xsd:redefine>
  <xsd:element name="SpecialObject1"/>
</xsd:schema>

test.xml
-------
<?xml version="1.0" encoding="UTF-8"?>
<test xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xsi:noNamespaceSchemaLocation="redefined.xsd">
  <myConcreteElement>
    <SpecialObject1></SpecialObject1>
  </myConcreteElement>
</test>

Best Regards,
George
-------------------------------------------------------
George Cristian Bina mailto:george@oxygenxml.com
<oXygen/> XML Editor and XSLT Editor/Debugger
http://www.oxygenxml.com/


----- Original Message -----
From: "Shane Lauf" <srl01@uow.edu.au>
To: <xmlschema-dev@w3.org>
Cc: "'George Cristian Bina'" <george@sync.ro>
Sent: Saturday, September 04, 2004 2:05 AM
Subject: RE: Extending abstract elements with a choice


> Thanks George, oYxgen has made all those errors clear now. Would what I am
> trying to achieve be possible with <redefine>, do you think?
>
> Shane
Received on Saturday, 4 September 2004 05:41:31 UTC

This archive was generated by hypermail 2.3.1 : Wednesday, 7 January 2015 14:56:06 UTC