Re: Restriction error

"C. M. Sperberg-McQueen" <[email protected]> Sun, 31 Mar 2013 17:25:36 -0600
Newsgroups gmane.text.xml.schema.devel
Message-ID <[email protected]>
On Mar 20, 2013, at 8:06 AM, Dave Pawson wrote:

> Note I'm the real newbie here Mike.
>=20
> On 20 March 2013 13:53, Michael Kay <[email protected]> wrote:
>> A complex-type-with-simple-content is generally defined by extension: =
think
>> of it as first defining the simple content of the element, then =
extending it
>> to allow attributes.
>>=20
>> You can define a c-t-with-s-c as a restriction of another =
c-t-with-s-c, but
>> that doesn't seem to be what you are doing here; the suggestion from =
the
>> error message is that dc:SimpleLiteral is a simple type, not a =
c-t-with-s-c.
>>=20
>> Difficult to correct this without knowing what you are trying to =
achieve.
>> Why are you saying xml:lang is prohibited? Does your new type allow =
any
>> attributes, and if so, which? What is the definition of =
dc:SimpleLiteral?
>=20
> I'm trying to understand this schema, then reduce it.
>=20
> Defn:
>=20
> <xs:complexType name=3D"SimpleLiteral" mixed=3D"true">
> 		...
> 	</xs:complexType>
>=20
>=20
>=20
> Is that any help?

Yes, it is.  If I understand correctly, you would like to define
a restricted form of the XML vocabulary defined at=20
http://dublincore.org/schemas/xmls/qdc/2008/02/11/dc.xsd
in which elements are not allowed the use of xml:lang, and
you would like to do so without just copying all the schema
documents and modifying them.

If you have access to an XSD 1.1 processor, your best bet
is probably to use xsd:override to change the declaration of
dc:SimpleLiteral.  Otherwise, you will need to use xsd:redefine.
Both of these constructs are intended (sometimes among
other things) for the use case of local restrictions to a=20
public schema.

Your redefinition of the dc: namespace can look like this:

<xs:schema xmlns:xs=3D"http://www.w3.org/2001/XMLSchema"
  targetNamespace=3D"http://purl.org/dc/elements/1.1/"
  xmlns:dc=3D"http://purl.org/dc/elements/1.1/"
  elementFormDefault=3D"qualified">=20
 =20
  <xs:import namespace=3D"http://www.w3.org/XML/1998/namespace"/>

  <xs:redefine =
schemaLocation=3D"http://dublincore.org/schemas/xmls/qdc/2008/02/11/dc.xsd=
">
    <xs:complexType name=3D"SimpleLiteral">
     =20
      <xs:annotation>
        <xs:documentation xml:lang=3D"en">
          This is a restriction of the default type for all of the DC =
elements.
          It permits text content only with no xml:lang attribute.  =
(That is
          its difference from the standard schema at=20
          http://dublincore.org/schemas/xmls/qdc/2008/02/11/dc.xsd
         =20
          Text is allowed because mixed=3D"true", but sub-elements
          are disallowed because minOccurs=3D"0" and maxOccurs=3D"0"=20
          are on the xs:any tag.
         =20
          This complexType allows for restriction or extension =
permitting
          child elements.
        </xs:documentation>
      </xs:annotation>
     =20
      <xs:complexContent mixed=3D"true">
        <xs:restriction base=3D"dc:SimpleLiteral">
          <xs:sequence/>
          <xs:attribute ref=3D"xml:lang" use=3D"prohibited"/>
        </xs:restriction>
      </xs:complexContent>
    </xs:complexType>
  </xs:redefine>
</xs:schema>

I hope this helps.

Michael Sperberg-McQueen


--=20
****************************************************************
* C. M. Sperberg-McQueen, Black Mesa Technologies LLC
* http://www.blackmesatech.com=20
* http://cmsmcq.com/mib                =20
* http://balisage.net
****************************************************************