RE: Changing "substitutionGroup" to "choice" and maintaining the validation equality of the schema

Hi,

the trick is ok if only one namespace is involved.
It gets more complex if you have a schema hierarchie:

Schema 1: targetNamespace: ns1
 element A (abstract=true)
 element B (substitutionGroup="ns1:A")
 element C (substitutionGroup="ns1:A")
 element D () - sequence - element (ref="ns1:A")

Schema 2: targetNamespace: ns2
 element E (substitutionGroup="ns1:A")
 element F () - sequence - element (ref="ns1:A")

D translates into:
 element D () - sequence - element - ref="ns1:B"
                                   - ref="ns1:C"
F translates into:
 element F () - sequence - element - ref="ns1:B"
                                   - ref="ns1:C"
                                   - ref="ns2:E"

so far so good, but imagine the following instance:
<ns1:root><ns1:D><ns2:F>... [ns2 is located by xsi:schemaLocation]

Now you have to add an any to your choice:
D translates into:
 element D () - sequence - element - ref="ns1:B"
                                   - ref="ns1:C"
                                   - any: ##other lax
But what to do with F? You have to relax it and remove the explicit
references to B and C:
 element F () - sequence - element - ref="ns2:E"
                                   - any: ##other lax

But what if the reference to "ns1:A" is used from below a choice. If you
insert an any here you have to care for the unambiguity constraint and that
is very tricky.

If you have to support substitutionGroups completely, fully for every
possible XML Schema, better implement it than implement the workaround.

The transformation from substitution group to choice is already implemented
in the latest version of the "Tamino Schema Editor"
(http://www.softwareag.com/Tamino).

Kind regards,
Harald


-----Original Message-----
From: Marko Smiljanic [mailto:m.smiljanic@utwente.nl]
Sent: Mittwoch, 15. Oktober 2003 19:07
To: xmlschema-dev@w3.org
Subject: Changing "substitutionGroup" to "choice" and maintaining the
validation equality of the schema



Hi,

This is a question concerned with the property of "validation equality"
between the schemas using "substitutionGroup"s and schemas using a
"choice" compositor as a replacement for a substitutionGroup.

The term "validation equality" between different schemas means that the
sets of XML documents that can be validated by those different schemas
are equal.

Now, a short intro and then a question.

*** The Short Intro (written in XSD-like language)...

Lets have Schema 1 defined as:

 element A (abstract=true)
 element B (substitutionGroup="A")
 element C (substitutionGroup="A")
 element D () - sequence - element (ref="A")

Now I convert Schema 1 to a "validation equal" Schema 2, presented
below:

 element B ()
 element C ()
 element D () - sequence - choice -- element (ref="B")
                                  \_ element (ref="C")

What I did is, replaced a reference to an abstract element "A" with a
choice compositor, and then nest all the possible substitutions for "A"
within this choice. I also removed element A as it is defined as
abstract, otherwise, I would add it under the choice too.

*** The question

Do you think/know that it is possible to transform every XML schema
having substitutionGroups using the "choice" trick above, and get the
"validation equal" schema?

Thanks,
Marko Smiljanic

ps. FYI I'm defining a graph-like model for XML schema needed in my
research. The trick above would be a nice workaround to represent
substitution groups in the model using "choice" that is already
supported by the model.
 

*************************
Research assistant, Database Technology
Department of Computer Science, University of Twente 
P.O. Box 217, 7500 AE Enschede, The Netherlands
Phone +31 (053) 489 4520, Fax ~ 2927
E-mail: m.smiljanic@utwente.nl
WWW: www.cs.utwente.nl/~markosm

Received on Thursday, 16 October 2003 10:14:23 UTC