You are viewing a plain text version of this content. The canonical link for it is here.
Posted to j-users@xerces.apache.org by Jean-Guillaume LALANNE <je...@coming.fr> on 2001/03/19 11:11:25 UTC

Re: Inheritence ... No answers ???

Hi,

May anyone give me a trick ???
I haven't got any answers to my question and I am a little bit blocked in my dev...

My question is actually quite simple : 
Can a XML instance document be valid versus not one XML Schema file but ....several ?????

If not, I don't see how it is possible to implement an inheritence mechanism for a XML Instance file.
It is doable to use inheritence between 2 types from different schema files, but after this, in the XML Instance
the inheritence is not seen (transparent).

Have a look:

----------------------------------------------------
schema1.xsd ---> namespace = aaa

element name="vehicle"
has a child element with the type : carType and a 
local name = car
....
type : carType
.....
----------------------------------------------------

schema2.xsd ---> namespace = bbb

import schema1.xsd && import namespace = aaa

...
type : gmcarType extends aaa:carType

element name=gm1  type=gmcarType 
....
---------------------------------------------------


So if  I want to create an XML instance of the element vehicle .....!!!!!

<element 
xmlns="http://www.coming.fr/validation/WHIP-1.0/Schemas/aaa" 
xmlns:xsi="http://www.w3.org/2000/10/XMLSchema-instance" 
xsi:schemaLocation="http://www.coming.fr/validation/WHIP-1.0/Schemas/aaa
schema1.xsd">
....
if I put here <car blablabla .... this is valid !!!
if I put here <bbb:gm1 it is not anymore BECAUSE the schema1 doesn't load the schema2.xsd file that provides the bbb package !!!

What can I do ???
This is the principle of INHERITENCE, isn't it ???

I am forced to use a intermediary schema file that include the schema2 and that works on the same namespace bbb...
Not beautifull and quickly limited solution.

ISN'T IT POSSIBLE TO VALIDATE AGAINST 2 SCHEMA FILES ?????

xsi:schemaLocation="http://www.coming.fr/validation/WHIP-1.0/Schemas/aaa
schema1.xsd"
xsi:schemaLocation="http://www.coming.fr/validation/WHIP-1.0/Schemas/bbb 
schema2.xsd">

Thanks in advance for your answer.
Best Regards
Jean-Guillaume LALANNE
COMING
jglalanne@coming.fr






  ----- Original Message ----- 
  From: Jean-Guillaume LALANNE 
  To: xerces-j-user@xml.apache.org 
  Sent: Friday, March 16, 2001 3:06 PM
  Subject: Fw: Inheritence



  ----- Original Message ----- 
  From: Jean-Guillaume LALANNE 
  To: xmlschema-dev@w3.org 
  Sent: Friday, March 16, 2001 12:44 PM
  Subject: Inheritence


  Dear all..

  excuse me if this message is unappropriate for this list..
  I'm a newbie to the list..

  I have a question..
  I have been trying to use inheritence with my XML schemas but up to now I don't really manage...
  It looks like I have a problem with the namespace declaration in my XML Instance.

  Here is the problem :


  Schema 1: AMContent.xsd

  <?xml version="1.0" encoding="UTF-8"?>
  <xsd:schema 
  targetNamespace="http://www.coming.fr/validation/WHIP-1.0/Schemas/whip-amcontent" 
  xmlns:whip-amcontent="http://www.coming.fr/validation/WHIP-1.0/Schemas/whip-amcontent" 
  xmlns:xsd="http://www.w3.org/2000/10/XMLSchema">
   
   <xsd:element name="site-content">
    <xsd:complexType>
     <xsd:sequence>
      <xsd:element ref="whip-amcontent:module-list"/>
     </xsd:sequence>
    </xsd:complexType>
   </xsd:element> 
   <xsd:element name="module-list">
   
    <xsd:complexType>
     <xsd:sequence>
      <xsd:element ref="whip-amcontent:module" minOccurs="0" maxOccurs="unbounded"/>
     </xsd:sequence>
    </xsd:complexType>
   </xsd:element>
   
   <xsd:element name="module" type="whip-amcontent:moduleType"/>
   
    <xsd:complexType name="moduleType">
    <xsd:sequence>
     <xsd:element ref="whip-amcontent:name"/>
     <xsd:element ref="whip-amcontent:description"/>
     <xsd:element ref="whip-amcontent:details-list"/>
    </xsd:sequence>
   </xsd:complexType>
   
   <xsd:element name="name" type="xsd:string"/>
   
   <xsd:element name="description" type="xsd:string"/>
   
   <xsd:element name="details-list">
    <xsd:complexType>
     <xsd:sequence>
      <xsd:element ref="whip-amcontent:details" minOccurs="0" maxOccurs="unbounded"/>
     </xsd:sequence>
    </xsd:complexType>
   </xsd:element>
   
   <xsd:element name="details" type="whip-amcontent:detailsType"/>
   
   <xsd:complexType name="detailsType"/>
   
  </xsd:schema>


  Schema 2: editorial.xsd

  <?xml version="1.0" encoding="UTF-8"?>
  <xsd:schema targetNamespace="http://www.coming.fr/validation/WHIP-1.0/Schemas/whip-amcontent" xmlns:whip-amcontent="http://www.coming.fr/validation/WHIP-1.0/Schemas/whip-amcontent" xmlns:xsd="http://www.w3.org/2000/10/XMLSchema">
   
   <xsd:include schemaLocation="D:\Users\jgl\WHIP1\src\coming\whip\testing_area\AMContent.xsd"/>

   
   <xsd:element name="editorial">
    <xsd:complexType>
     <xsd:complexContent>
      <xsd:extension base="whip-amcontent:moduleType"/>
     </xsd:complexContent>
    </xsd:complexType>
   </xsd:element>

  </xsd:schema>

  XML Instance : amcontent-test.xml
   
  <?xml version="1.0" encoding="UTF-8"?>
  <site-content 
  xmlns="http://www.coming.fr/validation/WHIP-1.0/Schemas/whip-amcontent" 
  xmlns:xsi="http://www.w3.org/2000/10/XMLSchema-instance" 
  xsi:schemaLocation="http://www.coming.fr/validation/WHIP-1.0/Schemas/whip-amcontent
  D:\Users\jgl\WHIP1\src\coming\whip\testing_area\AMContent.xsd">

   <module-list>
    <editorial xsi:type="whip-amcontent:moduleType">
     <name>aaaaa</name>
     <description>bbbbb</description>
     <details-list/>
    </editorial>
   </module-list>
   
  </site-content>

  Of course, this document is not validated by XMLSpy or xerces1.3.0, because
  the only schema loaded is the schema located at D:\Users\jgl\WHIP1\src\coming\whip\testing_area\AMContent.xsd....
  And in this schema, the element editorial doesn't exist in the namespace "whip-amcontent".
  To validate my XML instance, I will need a way to load also the editorial.xsd schema file to make the parser
  aware in the current working namespace ("whip-amcontent") of the element "editorial" ...!!!!
   
  I have been thinking about pointing the file editorial.xsd from the file AMContent.xsd with the "<xsd:include>" feature. But this is definitively NOT the solution
  because the editorial.xsd already points onto the AMContent.xsd file and it is causing a fatal error in the parsers (infinite loop).

  So my question is how can I tell the parser to also parse my file editorial.xsd to validate my XML file...????

  Maybe I am using inheritence in a wrong way. I really need to use inheritence !!!

  Please if anyone could help me out, or point me to some resources..
  I'd really appreciate it..

  Thank you in advance.
  Jean-Guillaume LALANNE
  jglalanne@coming.fr