[XML-DEV Mailing List Archive Home] [By Thread] [By Date] [Recent Entries] [Reply To This Message]

Re: redefine

  • From: Eddie Robertsson <eddie@a...>
  • To: Dan Ferullo <daf176@p...>
  • Date: Wed, 04 Jul 2001 10:46:15 +1000

xsd redefine
Hi Dan,

I'll do my best to answer your questions about redefine and I think the most important thing to remember about redefine is that (as described in the Primer [1]), once a type has been redefined, the redefined type applies to all schema components that make use of the type.

So... (see comments inline)
[1] http://www.w3.org/TR/xmlschema-0/#Redefine

<?xml version="1.0" encoding="UTF-8"?>
<xsd:schema targetNamespace="namespace" xmlns="namespace" xmlns:xsd="http://www.w3.org/2001/XMLSchema" elementFormDefault="qualified">
<xsd:complexType name="top" abstract="true"/>
<xsd:complexType name="middle">
   <xsd:complexContent>
     <xsd:extension base="top"/>
   </xsd:complexContent>
</xsd:complexType>
</xsd:schema>

lower_level.xsd:

<?xml version="1.0" encoding="UTF-8"?>
<xsd:schema targetNamespace="namespace" xmlns="namespace" xmlns:xsd="http://www.w3.org/2001/XMLSchema" elementFormDefault="qualified">
<xsd:redefine schemaLocation="Z:\XML\upper_level.xsd">
  <xsd:complexType name="top">
    <xsd:complexContent>
      <xsd:extension base="top">
        <xsd:sequence>
          <xsd:element name="number" type="xsd:int"/>
        </xsd:sequence>
      </xsd:extension>
    </xsd:complexContent>
  </xsd:complexType>

  <xsd:complexType name="bottom">
    <xsd:complexContent>
      <xsd:extension base="middle"/>
    </xsd:complexContent>
  </xsd:complexType>
</xsd:redefine>
</xsd:schema>

This schema is not valid. Only the type/group that you want to redefine should be within the <xsd:redefine> element. In this case you redefine the top complexType so this is the only complexType that should appear within redefine. So, move the complexType bottom outside the redefine element.
Will an element of type bottom contain an element named number?
Yes
Essentially, since middle extends top in upper_level.xsd, and top is redefined in lower_level.xsd will middle extend from this new redefinition of top, or still extend the older version?
Middle will extend from the redefinition of top
More importantly (for me anyway) if the following two Schemas also exist and are related to the first two:

---------------------------------
other_level.xsd

<?xml version="1.0" encoding="UTF-8"?>
<xsd:schema targetNamespace="namespace" xmlns="namespace" xmlns:xsd="http://www.w3.org/2001/XMLSchema" elementFormDefault="qualified">
  <xsd:include schemaLocation="Z:\XML\upper_level.xsd"/>
  <xsd:complexType name="ceiling">
    <xsd:sequence>
       <xsd:element name="up" type="top"/>
    </xsd:sequence>
  </xsd:complexType>
</xsd:schema>

final_level.xsd

<?xml version="1.0" encoding="UTF-8"?>
<xsd:schema targetNamespace="namespace" xmlns="namespace" xmlns:xsd="http://www.w3.org/2001/XMLSchema" elementFormDefault="qualified">
  <xsd:include schemaLocation="Z:\XML\lower_level.xsd"/>
  <xsd:include schemaLocation="Z:\XML\other_level.xsd"/>
    <xsd:element name="finalElement">
      <xsd:sequence>
        <xsd:element name="above" type="ceiling"/>
        <xsd:element name="floor" type="top"/>
      </xsd:sequence>
    </xsd:element>
</xsd:schema>
---------------------------------

This schema is missing the complexType element in the element declaration of finalElement.
Since upper_level.xsd is included through both other_level.xsd and lower_level.xsd by final_level.xsd will the complexType definition used to define the top complexType (that is the type for the floor element) be the one in upper_level.xsd or the redefined version lower_level.xsd?
The redefined version in lower_level.xsd
 Also, since the above element references the ceiling complexType, which has an element of complexType top will this sub element (up) still be of the complexType top as defined in upper_level.xsd or will it automatically become of the complexType top redefined in lower_level.xsd (even though other_level.xsd makes no reference to lower_level.xsd)?
The redefined complexType in lower_level.xsd
My guess is that anything new that reference top (either an element or an complexType that uses extension) will use the most *redefined*version.
Yes
However, the up element will still be of complexType top as defined in upper_level.xsd.
No, this will also use the redefined type.

This means that a valid instance for your final_level schema would be:

<finalElement xmlns="namespace" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:schemaLocation="namespace final_level.xsd">
  <above>
    <up>
      <number>1</number>
    </up>
  </above>
  <floor>
    <number>2</number>
  </floor>
</finalElement>
 

Cheers,
/Eddie


  • References:
    • redefine
      • From: Dan Ferullo <daf176@p...>

PURCHASE STYLUS STUDIO ONLINE TODAY!

Purchasing Stylus Studio from our online shop is Easy, Secure and Value Priced!

Buy Stylus Studio Now

Download The World's Best XML IDE!

Accelerate XML development with our award-winning XML IDE - Download a free trial today!

Don't miss another message! Subscribe to this list today.
Email
First Name
Last Name
Company
Subscribe in XML format
RSS 2.0
Atom 0.3
 

Stylus Studio has published XML-DEV in RSS and ATOM formats, enabling users to easily subcribe to the list from their preferred news reader application.


Stylus Studio Sponsored Links are added links designed to provide related and additional information to the visitors of this website. they were not included by the author in the initial post. To view the content without the Sponsor Links please click here.

Site Map | Privacy Policy | Terms of Use | Trademarks
Free Stylus Studio XML Training:
W3C Member
Stylus Studio® and DataDirect XQuery ™are products from DataDirect Technologies, is a registered trademark of Progress Software Corporation, in the U.S. and other countries. © 2004-2013 All Rights Reserved.