Re: redefinition of SimpleType in nested schemas

George Cristian Bina <[email protected]>
Newsgroups gmane.text.xml.schema.devel
Message-ID <[email protected]>
Hi Marie,

Substitution groups have also constraints. The type of the specialized 
subject element needs to be validly derived from the Subject type

http://www.w3.org/TR/xmlschema-1/#e-props-correct
***
4 If there is a {substitution group affiliation}, the {type definition} 
of the element declaration must be validly derived from the {type 
definition} of the {substitution group affiliation}, given the value of 
the {substitution group exclusions} of the {substitution group 
affiliation}, as defined in Type Derivation OK (Complex) (§3.4.6) (if 
the {type definition} is complex) or as defined in Type Derivation OK 
(Simple) (§3.14.6) (if the {type definition} is simple).
***

Assuming a definition for Subject type and element as

     <xs:simpleType name="Subject">
         <xs:restriction base="xs:string">
             <xs:enumeration value="a"/>
             <xs:enumeration value="b"/>
         </xs:restriction>
     </xs:simpleType>

     <xs:element name="Subject" type="Subject"/>

then following to Type Derivation OK (Simple) (§3.14.6)
http://www.w3.org/TR/xmlschema-1/#cos-st-derived-ok

***
Schema Component Constraint: Type Derivation OK (Simple)
For a simple type definition (call it D, for derived) to be validly 
derived from a type definition (call this B, for base) given a subset of 
{extension, restriction, list, union} (of which only restriction is 
actually relevant) one of the following must be true:
1 They are the same type definition.
2 All of the following must be true:
2.1 restriction is not in the subset, or in the {final} of its own {base 
type definition};
2.2 One of the following must be true:
2.2.1 D's ·base type definition· is B.
2.2.2 D's ·base type definition· is not the ·ur-type definition· and is 
validly derived from B given the subset, as defined by this constraint.
2.2.3 D's {variety} is list or union and B is the ·simple ur-type 
definition·.
2.2.4 B's {variety} is union and D is validly derived from a type 
definition in B's {member type definitions} given the subset, as defined 
by this constraint.
***

you can see that a new subject defined as

<xs:element name="NewSubject" substitutionGroup="Subject" 
type="NewSubject"/>

     <xs:simpleType name="NewSubject">
         <xs:union memberTypes="Subject">
             <xs:simpleType>
                 <xs:restriction base="xs:string">
                     <xs:enumeration value="c"/>
                     <xs:enumeration value="d"/>
                 </xs:restriction>
             </xs:simpleType>
         </xs:union>
     </xs:simpleType>

does not work. Only a restriction of the Subject type will work in this 
case.

Best Regards,
George
-- 
George Cristian Bina
<oXygen/> XML Editor, Schema Editor and XSLT Editor/Debugger
http://www.oxygenxml.com

On 9/22/10 3:29 PM, Marie Bilde Rasmussen wrote:
> Hi George,
> You are right. And Thankyou. I just found the same paragraph in the spec
> (grrrr!). I am ow considering a solution with a specialized vocabulary
> in a separate element, placed in substitution group with my <Subject>
> element as it's head. If substitution groups can't be <redefined>d, I'll
> allow these <specialized-subject>-elements in the most general schema -
> these elements probably won't bother my authors as much as if I expanded
> the Simpletype in it's original definition, forcing them to choose from
> a list of alternatives that would be far too long for them.
> Thanks again!
> best regards,
> Marie
> 2010/9/22 George Cristian Bina <[email protected]
> <mailto:[email protected]>>
>
>     Hi Marie,
>
>
>
>      > Danish-English-technical.xsd builds on it's turn upon
>      > Danish-English.xsd, but this time I have chosen to use <xs:redefine>,
>      > because in these special dictionaries, I need to modify the
>     SimpleType
>      > "Subject" by extension.
>     ------------^^^^^^^^^^^^^
>
>     The derivation methods for simple types are restriction, list and
>     union, extension is for complex types. In case of redefinitions of
>     simple types you can use only restriction, see
>     Schema Representation Constraint: Redefinition Constraints and Semantics
>     http://www.w3.org/TR/xmlschema-1/#src-redefine
>     ***
>     5 Within the [children], each <simpleType> must have a <restriction>
>     among its [children] and each <complexType> must have a restriction
>     or extension among its grand-[children] the ·actual value· of whose
>     base [attribute] must be the same as the ·actual value· of its own
>     name attribute plus target namespace;
>     ***
>
>     Best Regards,
>     George
>     --
>     George Cristian Bina
>     <oXygen/> XML Editor, Schema Editor and XSLT Editor/Debugger
>     http://www.oxygenxml.com <http://www.oxygenxml.com/>
>
>
>     On 9/22/10 2:23 PM, Marie Bilde Rasmussen wrote:
>
>         Hello.
>         I have an xml schema, let's call it dictionary.xsd, describing
>         general
>         structures and datatypes used in dictionaries. dictionary.xsd
>         contains a
>         definition of a SimpleType called Subjects. The SimpleType is a
>         restriction of xs:string and it contains a long list of
>         enumerations.
>         Another - more specialized - schema, called Danish-English.xsd
>         is built
>         upon dictionary.xsd. This is done by using <xs:include>.
>         A third - even more specialized - schema, called
>         Danish-English-technical.xsd builds on it's turn upon
>         Danish-English.xsd, but this time I have chosen to use
>         <xs:redefine>,
>         because in these special dictionaries, I need to modify the
>         SimpleType
>         "Subject" by extension.
>         I cannot figure out how to do this. I am not allowed to do so.
>         This has worked for me with only one level of inclusion. Could
>         the fact
>         that I want to redefine a schema on a level that is more than one
>         nesting leve l"away" be the problem?
>         below I have tried to illustrate the nesting and the Type
>         Definitions:
>         Danish-English-technical.xsd (redefines SimpleType "Subjects")
>         ->
>         redefines
>         Danish-English.xsd
>         ->
>         includes
>         dictionary.xsd (declares SimpleType "Subjects" as a restriction of
>         xs:string by enumeration)
>         I would be grateful for any input.
>         Regards,
>         Marie
>
>
lmpx.com only provides a reader for public news (NNTP) servers. It is not affiliated with the servers or forums shown here and is not responsible for the content of articles, which is written by their respective authors.