OASIS Mailing List ArchivesView the OASIS mailing list archive below
or browse/search using MarkMail.

 


Help: OASIS Mailing Lists Help | MarkMail Help

 


 

   RE: [xml-dev] (newbie) DTD question

[ Lists Home | Date Index | Thread Index ]


> -----Original Message-----
> From: J. David Eisenberg [mailto:catcode@catcode.com] 
> Sent: Friday, July 12, 2002 12:22 PM
> To: Glen Mazza
> Cc: xml-dev@lists.xml.org
> Subject: Re: [xml-dev] (newbie) DTD question
> You can't redefine an element in a DTD (i.e., make it context 
> dependent). However, it is easily possible in Relax NG:
> 
> <element name="person">
>    <element name="name">
>        <element name="firstname"><text/></element>
>        <element name="lastname"><text/></element>
>    </element>
> </element>
> 
> <element name="pet">
>    <element name="name"><text/></element>
> </element>
> 
> I suspect it's possible with XML Schema as well.

Yup. 

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

 <xs:element name="family">
  <xs:complexType>
   <xs:sequence>
    <xs:element name="person" type="personType" />    
    <xs:element name="pet" type="petType" />         
   </xs:sequence>
  </xs:complexType>
 </xs:element>

 <xs:complexType name="petType">
  <xs:sequence>
   <xs:element name="name" type="xs:string"/>
  </xs:sequence>
 </xs:complexType>

 <xs:complexType name="personType">
  <xs:sequence>
  <xs:element name="name">
   <xs:complexType>
    <xs:sequence>
     <xs:element name="firstname" type="xs:string" />
     <xs:element name="lastname" type="xs:string" />
    </xs:sequence>
   </xs:complexType>
  </xs:element>
  </xs:sequence>
 </xs:complexType>

</xs:schema>


-- 
PITHY WORDS OF WISDOM 
The primary function of the design engineer is to make things difficult
for the fabricator and impossible for the serviceman.

This posting is provided "AS IS" with no warranties, and confers no
rights. 






 

News | XML in Industry | Calendar | XML Registry
Marketplace | Resources | MyXML.org | Sponsors | Privacy Statement

Copyright 2001 XML.org. This site is hosted by OASIS