Home. 
.

transparent

transparent

transparent

Altova Mailing List Archives


Re: Diamond problem using extensions and substitution groups

From: Eric Sirois <easirois@------.--->
To: "Antoli, Leo" <Leo.Antoli@-----.--->
Date: 8/17/2006 10:56:00 PM
There is a way you can mimic substitutionGroups without the having to 
deal with its inheritance restrictions. I use this mechanism in the DITA 
schemas to include element domains in the base schemas because of we 
can't fully make use of  WXSs inheritance model. Things are a bit more 
modularized  in that architecture, but this should give you the gist of 
it.   The structures defined Example 1 will make MyVehicule valid where 
ever Vehicle is valid.   

The trick mimic substitutionGroups without the dependency on the 
inheritance model is to to create a named group for each element, add 
each element to the group and any addtional elements you want to 
substitute for it.  Instead of referencing each element in the content 
models you reference the named group.

However, I'm not sure if you from based on your diagram and your problem 
statement  whether or not MyCar should be a substitutionGroup for Car 
and MyVehicle  or only that you only want to extend their content model?

If it MyCar is going to be a substitutionGroup for Car and MyVehicle, 
Example 2,  you are going to run into some issues if you make MyCar a 
subtitution for Car and MyVehicle. You will a "Unique Particle 
Attribution" error from Xerces and MSXML 4.0 (even if a I put 
maxOccurs="unbounded" <root>'s particle).  XSV and MSXML .NET accept it 
as valid.  I don't have SaxonSA installed. I can't say whether or not it 
would be valid the schema.

Hope this helps,

Eric


Example 1:

<xs:element name="Vehicle"  type="vehicle.class"/>
<xs:element name="Car" type="car.class"/>
 <xs:element name="MyCar" type="mycar.class"/>
 <xs:element name="MyVehicle" type="myvehicle.class"/>

<xs:element name="root">
        <xs:complexType>
            <xs:sequence>
                <xs:group ref="Vehicle" />
            </xs:sequence>
        </xs:complexType>
    </xs:element>
   
   
    <xs:group name="Vehicle">
        <xs:choice>
            <xs:element ref="Vehicle" />
            <xs:group ref="MyVehicle" />
        </xs:choice>
    </xs:group>
   
    <xs:group name="MyVehicle">
        <xs:choice>
            <xs:element ref="MyVehicle"/>
        </xs:choice>
    </xs:group>

Example 2: This will cause a "Unique Particle Attribution" error with 
Xerces and MSXML 4.0

<xs:group name="Vehicle">
        <xs:choice>
            <xs:element ref="Vehicle" />
            <xs:group ref="MyVehicle" />
             <xs:group ref="Car" />
        </xs:choice>
    </xs:group>


<xs:group name="Car">
        <xs:choice>
            <xs:element ref="Car"/>
            <xs:groupref="MyCar"/>
        </xs:choice>
    </xs:group>

<xs:group name="MyVehicle">
        <xs:choice>
            <xs:element ref="MyVehicle"/>
            <xs:group ref="MyCar"/>
        </xs:choice>
    </xs:group>




Antoli, Leo wrote:
> Dear all,
>
> I have the following schema element types:
>
>
> Vehicle  <---   MyVehicle
>
>      ^               ^  
>      |               |
>
>     Car    <-- 	 MyCar
>
>
> Vehicle is the base element type. Car extends from Vehicle.
>
> I want to add new elements to Vehicle, so I've created MyVehicle.
> Now I want to extend Car with MyCar, but I want MyCar also to have MyVehicle
> new child elements.
>
>
> Any idea about how to get this? I don't want to change or redefine Vehicle
> or Car as they are official elements, but I want to be able to extend them
> to add new child elements.
>
> The problem in Java or other languages is only solved for operations (using
> interfaces) but not for properties.
>
> I was thinking in using element groups instead of inheritance but then I
> can't use substitution groups. I want to use them so I could be able to use
> MyVehicle in all places in a XML document where Vehicle is allowed. 
>
> Thank you very much.
>
> Kind Regards,
> Leo Antoli
>
>
>
>
>


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