W3C home > Mailing lists > Public > xmlschema-dev@w3.org > June 2013

Re: xs:include change base type

From: Mukul Gandhi <gandhi.mukul@gmail.com>
Date: Fri, 7 Jun 2013 09:56:23 +0530
Message-ID: <CABuuzNPq26zpa50eO-8vGjQf7JTmKbZ7BqTh5OvCFKdCsqBeYw@mail.gmail.com>
To: Karl Stubsjoen <kstubs@gmail.com>
Cc: xmlschema-dev@w3.org
Hi Karl,
   Your subject line says xs:include, but the use case doesn't mention
xs:include. I'm going by the details within your mail text.

Below is the solution I can propose.

The problem with using an XSD 1.0 style complexType extension and
achieving your requirement is, that "name" attribute would be reported
as duplicate declarations during an extension definition.

Here's an XSD 1.1 solution using an <assert> element,

<xs:schema xmlns:xs="http://www.w3.org/2001/XMLSchema">

     <xs:element name="A" type="myNewComplexType"/>
     <xs:complexType name="myNewComplexType">
              <xs:extension base="myComplexType">
                   <xs:assert test="string-length(@name) eq 5"/>
 <!--<xs:simpleType name="some_simple_type">
	   <xs:restriction base="xs:NCName">
		 <xs:length value="5"/>
      </xs:simpleType> -->
    <xs:complexType name="myComplexType">
	     <xs:element name="x" type="xs:string"/>
         <xs:attribute name="name" type="xs:NCName"/>

The <assert> in this example simulates the commented simpleType shown
in my example.

Here's a valid XML instance document for the above schema:

<A name="x1234">

Here's an invalid XML instance document for the above schema:

<A name="x12345">

There may be other ways of thinking about the solution to this use
case. But this one came to my mind quickly.

On Fri, Jun 7, 2013 at 3:03 AM, Karl Stubsjoen <kstubs@gmail.com> wrote:
> I would like to extend an xs:complexType, and change one of its
> attributes from a type xs:NCName to xs:simpleType, with the same base
> type mind you.  So something like this:
> <xs:complextType name="myComplexType">
>   <xs:sequence>...</xs:sequence>
>   <xs:attribute name="name" type="xs:NCNAME"/>
> </xs:complexType>
> Then...
> <xs:complexType name="myNewComplexType">
> <xs:complexContent>
>   <xs:extension base="myComplextType">
>      <xs:attribute name="name" type="some_simple_type"/>
>   </xs:extension>
> </xs:complexContent>
> </xsl:complexType>
> Is this possible?  I've tried but having no luck.
> --
> Karl Stubsjoen
> MeetScoresOnline.com
> (602) 845-0006

Mukul Gandhi
Received on Friday, 7 June 2013 04:27:11 UTC

This archive was generated by hypermail 2.3.1 : Wednesday, 7 January 2015 14:56:22 UTC