Home. 
.

transparent

transparent

transparent

Altova Mailing List Archives


RE: [xml-dev] extend two elements?

From: "Paul Spencer" <xml-dev-list@--------.--.-->
To: "Amy Wong" <amy_wanes@-----.--->,<xml-dev@-----.---.--->
Date: 11/1/2006 11:06:00 AM
Amy,
 
You do 
not give the definition of your "student" type.
 
Let me 
make a few assumptions:
 
1. 
Your "student" type is sufficiently complex that it is worth doing this as an 
extension, rather than just a separate definition (the easy 
way).
 
2. 
Your "student" already contains an address, and you want to replace this with 
the "grad_address".
 
You 
already have a reply from Jack Lindsey making different 
assumptions.
 
If my 
assumptions are correct, you have a slight problem as an extension cannot 
replace the "address" type with the "grad_address" type. I would create a 
new type and derive both "student" and "grad_student" from this. Let's call the 
abstract type "student_base", with a definition that is the same as student but 
without the address. Then "student" extends this by adding the "address" and 
"grad_student" extends it by adding the "grad_address" and the appropriate 
attributes.
 
Note 
that you can make it impossible to create an element based on the "student_base" 
type directly if you like, but this is not strictly 
necessary.
 
Regards
 
Paul 
Spencer
 
 

  -----Original Message-----
From: Amy Wong 
  [mailto:amy_wanes@y...]
Sent: 31 October 2006 
  19:59
To: xml-dev@l...
Subject: [xml-dev] extend 
  two elements? 

Hi, 

I have an element called 
  "grad_student" which extends "student". Now I want to extend "grad_address" 
  element too since "grad_student" element needs address related info. 
  Unfortunately I cannot merge address info from "grad_address" element into 
  "grad_student" element. I am wondering how I can
extend another element 
  when this element already extends a base element?

regards,

    <xsd:complexType name="grad_student">
          <xsd:complexContent>
             <xsd:extension base="student">
                <xsd:attribute name="name" type="xsd:string" use="required"/>
                <xsd:attribute name="grade" type="xsd:string" use="required"/>
             </xsd:extension>
         
 </xsd:complexContent>
       </xsd:complexType>
       <xsd:element name="grad_student" type="xyz:grad_student"/>
       
          <xsd:complexType name="grad_address">
             <xsd:complexContent>
                <xsd:extension base="address"> 
                   <xsd:attribute name="state" type="xsd:string" use="required"/>
                   <xsd:attribute name="zip_code" type="xsd:string" use="required"/>
                </xsd:extension>
             </xsd:complexContent>
          </xsd:complexType>
       <xsd:element name="grad_address" type="xyz:grad_address"/>

  
  
  Low, Low, Low Rates! Check out Yahoo! Messenger's cheap PC-to-Phone 
  call rates.


transparent
Print
Mail
Like It
Disclaimer
.

These Archives are provided for informational purposes only and have been generated directly from the Altova mailing list archive system and are comprised of the lists set forth on www.altova.com/list/index.html. Therefore, Altova does not warrant or guarantee the accuracy, reliability, completeness, usefulness, non-infringement of intellectual property rights, or quality of any content on the Altova Mailing List Archive(s), regardless of who originates that content. You expressly understand and agree that you bear all risks associated with using or relying on that content. Altova will not be liable or responsible in any way for any content posted including, but not limited to, any errors or omissions in content, or for any losses or damage of any kind incurred as a result of the use of or reliance on any content. This disclaimer and limitation on liability is in addition to the disclaimers and limitations contained in the Website Terms of Use and elsewhere on the site.

.
.

transparent

transparent