Subject: RE: [Simple] Question about extending mood in rpids-04

From: [email-masked]
Date: Tue, 9 Nov 2004 09:00:31 +0200

> [email-masked] wrote:
> >  
> >>I'm wondering about the future proofness when using the 
> substitution 
> >>groups. If the recipient is doing document validation, but doesn't 
> >>possess the extension schema, will it be able to validate the 
> >>document.
> > 
> > 
> > As far as I understand, yes it can.
> 
> Can you explain? If I receive a document that has an element I don't 
> understand, how can I tell it is an instance of a particular 
> substitution group if that is what is required for the 
> document to be valid?

Lets take an example. We can have two schema definitions:

1) using substitutiongroups

targetnamespace="car"
xmlns:tns="car"

      <xs:complexType name="car">
        <xs:sequence>
           <xs:element
             ref="tns:carmodel"
             maxOccurs="unbounded"/>
          </xs:element>
         </xs:sequence>
       </xs:complexType>

     <xs:element name="carmodel" abstract="true"/>
     <xs:element name="ferrari" substitutionGroup="tns:carmodel"/>
     <xs:element name="ford" substitutionGroup="tns:carmodel"/>

And if we would define an extension it would look something like

	targetnamespace="ext"
	xmlns:tns="ext"
	xmlns:car="car"

	<xs:element name="newcar" substitutionGroup="car:carmodel"/>

Resulting XML document would be something like:

 	<?xml version="1.0" encoding="UTF-8"?>
 	<car xmlns="car"
      	xmlns:ext="ext">
		<ferrari/>
		<ext:newcar/>
  	</car>

2) using xml ##other extensibility mechanism

      <xs:complexType name="car">
        <xs:sequence>
	     <xs:element name="ferrari"/>
     	     <xs:element name="ford"/>
	     <xs:any namespace="##other"
             processContents="lax" minOccurs="0"
             maxOccurs="unbounded"/>	
        </xs:sequence>
      </xs:complexType>

And if we would define an extension it would look something like

	targetnamespace="ext"
	xmlns:tns="ext"
	xmlns:car="car"

	<xs:element name="newcar"/>

Resulting XML document would be something like:

 	<?xml version="1.0" encoding="UTF-8"?>
 	<car xmlns="car"
      	xmlns:ext="ext">
		<ferrari/>
		<ext:newcar/>
  	</car>

Now what if the receiver of these documents doesn't understand the ext namespace? In both cases it ignores the "ext" namespace and validates rest of it against the "car". I am not sure if there are any cases where validator would need to know that elements from a namespace it doesn't understand belong to a particular substitutionGroup. Can you point out any?
Only case I might come up is:
    
  <xs:complexType name="car">
        <xs:sequence>
           <xs:element
             ref="tns:carmodel"
             maxOccurs="1"
		 minOccurs="1"/>
          </xs:element>
         </xs:sequence>
       </xs:complexType>

and 

 	<?xml version="1.0" encoding="UTF-8"?>
 	<car xmlns="car"
      	xmlns:ext="ext">
		<ext:newcar/>
  	</car>

In this case if I don't understand "ext" I cannot say if <ext:newcar/> really is a member of carmodel substitutionGroup but does it matter? I can still say that there is one element (as required) but I don't understand it.

- Mikko 

> 	Paul

_______________________________________________
Simple mailing list
[email-masked]
https://www1.ietf.org/mailman/listinfo/simple

---

From: Paul Kyzivat <[email-masked]>
Date: Tue, 09 Nov 2004 08:47:12 -0500

Response near the end.

	Paul

[email-masked] wrote:
> Now what if the receiver of these documents doesn't understand
 > the ext namespace? In both cases it ignores the "ext" namespace
 > and validates rest of it against the "car". I am not sure if
 > there are any cases where validator would need to know that
 > elements from a namespace it doesn't understand belong to a
 > particular substitutionGroup. Can you point out any?

I'm not sure the difference matters much, but when the extension is 
introduced via the ##other mechanism, if the application understands 
<car> then it knows that <newcar> satisfies the schema even without 
knowledge of ext. But with the substitution group it has no way to know 
whether the usage of <newcar> satisfies the schema.

	Paul

> In this case if I don't understand "ext" I cannot say if
 > <ext:newcar/> really is a member of carmodel substitutionGroup
 > but does it matter? I can still say that there is one element
 > (as required) but I don't understand it.
> 
> - Mikko 
> 
> 
>>	Paul
>>
>>
> 
>

---

From: Jonathan Rosenberg <[email-masked]>
Date: Wed, 10 Nov 2004 02:10:55 -0500

I had always assumed that if the entity validating the document didn't 
know about the extensions, the validation would proceed as if the 
unknown elements were part of the substitution group. However, I think 
that it is important for us to check this with folks who are more 
familiar with XML...

-Jonathan R.

Paul Kyzivat wrote:

>>> substitution group if that is what is required for the document to be 
>>> valid?
>>
>>
>>

-- 
Jonathan D. Rosenberg, Ph.D.                   600 Lanidex Plaza
Director, Service Provider VoIP Architecture   Parsippany, NJ 07054-2711
Cisco Systems
[email-masked]                              FAX:   (973) 952-5050
http://www.jdrosen.net                         PHONE: (973) 952-5000
http://www.cisco.com

---

From: Paul Kyzivat <[email-masked]>
Date: Wed, 10 Nov 2004 08:29:25 -0500

I am only asking the question as one who has no formal knowledge of xml. 
Whatever is right with xml is fine with me.

	Paul

Jonathan Rosenberg wrote:
>>>> substitution group if that is what is required for the document to 
>>>> be valid?
>>>
>>>
>>>
>>>
>>>              maxOccurs="unbounded"/>           </xs:sequence>
>>>       </xs:complexType>
>>>
>> knowledge of ext. But with the substitution group it has no way to 
>> know whether the usage of <newcar> satisfies the schema.
>>
>>     Paul
>>

---

From: Jari Urpalainen <[email-masked]>
Date: Tue, 16 Nov 2004 15:44:37 +0200

> >>>> substitution group if that is what is required for the document to 

I decided to run some practical tests with xerces schema validator and
it does what common sense says: if you extend abstract element with an
element which does not have a definition within this schema it does not
validate the document. All the examples that i have seen (e.g. xml
schema best practises/schema primer) usually either import or include
the previous schema and define some new elements with substitutionGroup
in this new schema. So some kind of xml Schema versioning is thus needed
if extension is being done with substitutionGroups.

br,
Jari