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

Re: inheritance problem (newbie)

From: George Cristian Bina <george@sync.ro>
Date: Fri, 17 Sep 2004 14:51:58 +0300
Message-ID: <414ACFDE.8080603@sync.ro>
To: Jan Limpens <jan.limpens@gmail.com>
CC: xmlschema-dev@w3.org

Hi Jan,

 > don't know what to do now. I already stole the idea from
 > http://www.xmlpatterns.com/ExtensibleContentModelMain.shtml, but as it
 > seems this is not working...

That sample seems to be based on an older version of XML Schema, see:

<xsd:schema xmlns:xsd="http://www.w3.org/1999/XMLSchema"

while the current version defines http://www.w3.org/2001/XMLSchema as 
the XML Schema namespace.

You probably want something along the lines:

base.xsd:
=========
<?xml version="1.0"?>
<xs:schema xmlns:xs="http://www.w3.org/2001/XMLSchema" 
targetNamespace="http://limpens.com/blogbase"
     xmlns="http://limpens.com/blogbase" elementFormDefault="qualified">
     <xs:element name="BlogInfo">
         <xs:complexType>
             <xs:sequence>
                 <xs:element name="BlogTitle" type="xs:string"/>
                 <xs:element name="BlogDescription" type="xs:string"/>
                 <xs:element ref="Entry" minOccurs="0" 
maxOccurs="unbounded"/>
             </xs:sequence>
             <xs:attribute name="lang" type="xs:language"/>
         </xs:complexType>
     </xs:element>
     <xs:complexType name="EntryType">
         <xs:sequence>
             <xs:element name="Title"/>
             <xs:element name="Body">
                 <xs:complexType>
                     <xs:sequence>
                         <xs:element name="Para" maxOccurs="unbounded"/>
                     </xs:sequence>
                 </xs:complexType>
             </xs:element>
         </xs:sequence>
         <xs:attribute name="lang" type="xs:language"/>
         <xs:attribute name="pubdate" type="xs:dateTime"/>
     </xs:complexType>
     <xs:element name="Entry" type="EntryType"/>
     <xs:element name="Blog">
         <xs:complexType>
             <xs:sequence>
                 <xs:element ref="BlogInfo"/>
             </xs:sequence>
         </xs:complexType>
     </xs:element>
</xs:schema>

derived.xsd
===========
<?xml version="1.0"?>
<xs:schema xmlns:xs="http://www.w3.org/2001/XMLSchema"
     targetNamespace="http://limpens.com/blog/illustrationblog" 
xmlns="http://limpens.com/blog/illustrationblog"
     elementFormDefault="qualified" xmlns:bb="http://limpens.com/blogbase">

     <xs:import namespace="http://limpens.com/blogbase" 
schemaLocation="base.xsd"/>

     <xs:element name="ImageEntry" type="ImageEntryType"/>

     <xs:complexType name="ImageEntryType">
         <xs:complexContent>
             <xs:extension base="bb:EntryType">
                 <xs:sequence>
                     <xs:element name="SlideShow">
                         <xs:complexType>
                             <xs:sequence>
                                 <xs:element name="Image" 
maxOccurs="unbounded">
                                     <xs:complexType>
                                         <xs:sequence>
                                             <xs:element name="ImageTitle"/>
                                             <xs:element 
name="ImageDescription"/>
                                             <xs:element name="ImageUrl"/>
                                         </xs:sequence>
                                     </xs:complexType>
                                 </xs:element>
                             </xs:sequence>
                         </xs:complexType>
                     </xs:element>
                 </xs:sequence>
             </xs:extension>
         </xs:complexContent>
     </xs:complexType>
</xs:schema>


sample.xml
==========
<?xml version="1.0" encoding="UTF-8"?>
<ImageEntry xmlns="http://limpens.com/blog/illustrationblog"
      xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
      xsi:schemaLocation="http://limpens.com/blog/illustrationblog 
file:/F:/test/derived.xsd">
     <Title xmlns="http://limpens.com/blogbase"></Title>
     <Body xmlns="http://limpens.com/blogbase">
         <Para></Para>
     </Body>
     <SlideShow>
         <Image>
             <ImageTitle></ImageTitle>
             <ImageDescription></ImageDescription>
             <ImageUrl></ImageUrl>
         </Image>
     </SlideShow>
</ImageEntry>

Hope that helps,
George
-----------------------------------------------
George Cristian Bina
<oXygen/> XML Editor & XSLT Editor/Debugger
http://www.oxygenxml.com
Received on Friday, 17 September 2004 11:50:07 UTC

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