Re: Restricting text in mixed content element

Hi Richard,

> I have a mixed-content element. I would like to restrict the text in
> the element. Specifically, I would like to exclude the square
> brackets.

I think that you're out of luck. XML Schema doesn't allow you to
control the type of the text that you have in mixed content. You'll
need to use a schema adjunct, for example Schematron, to test this
kind of condition.

> I tried defining a datatype that restricts xs:string, then extending
> that to the element in question. That seems to work except when an
> occurrence of the element contains not only text, but also some of
> the other elements that are permitted.

Yes. You should get an error in your schema if you try to derive a
complex type with complex content by extension from a complex type
with simple content or from a simple type. This falls under the
"Schema Component Constraint: Derivation Valid (Extension)" rule set
which says:

  If the {derivation method} is extension, the appropriate case among
  the following must be true:

  1 If the {base type definition} is a complex type definition, then
    all of the following must be true:
  ...
  1.4 One of the following must be true:
  1.4.1 The {content type} of the {base type definition} and the
        {content type} of the complex type definition itself must be
        the same simple type definition.
  1.4.2 All of the following must be true:
  1.4.2.1 The {content type} of the complex type definition
          itself must specify a particle.
  1.4.2.2 One of the following must be true:
  1.4.2.2.1 The {content type} of the {base type definition}
            must be empty.
  1.4.2.2.2 All of the following must be true:
  1.4.2.2.2.1 Both {content type}s must be mixed or both
              must be element-only.
  1.4.2.2.2.2 The particle of the complex type definition
              must be a ·valid extension· of the {base type
              definition}'s particle, as defined in Particle Valid
              (Extension) (§3.9.6).

If you derive a mixed complex type (with some elements in the content)
by extension from a complex type with simple content, then 1.4.1
applies, and the content type of the base type (which is a simple type
definition) must be the same as the content type of the derived type
(i.e. the same simple type definintion). That isn't the case.

Basically, you can only derive by extension from a simple type or a
complex type with simple content to add attributes to the base type.
              
Cheers,

Jeni

---
Jeni Tennison
http://www.jenitennison.com/

Received on Monday, 10 December 2001 06:40:17 UTC