Schematron Pretty

XML Schema Element and Attribute Validator (Dec99 WD)

     Pattern           

Beta Notes

     Rule   
/*
     Report   
1=1This Schematron schema tests most structural constraints of the December 1999 Working Draft for XML Schema Structures and Datatypes, including the relationships between attribute values and allowed content. The deficiencies are: 1) not fully tested yet, 2) not namespace-aware (you will have to remove xmlns="..." from all schema files, the main and any that are included or imported, otherwise it will not work), 3) only subtyping the builtin types is checked thoroughly. If you use this, please report errors or improvements or more helpful asserts to ricko@gate.sinica.edu.tw.
     Report   
1=1If you are using this over a slow modem connection and the schema user include or import over http, then comment out the reports or asserts which include tests of document() in them.



     Pattern           

Top-Level

     Rule   
/*
     Assert   
/schemaThis may not be an error, but typically the top level element will be 'schema'.



     Pattern           

Elements and Attributes: <schema>

     Rule   
schema
     Assert   
count(*) = count(datatype | type | element | group | notation | attributeGroup | include | import | annotation | unique | key | keyref)A schema element can contain the following elements: first any mix and number of include, import and annotation; then any mix and number of datatype, type, element, group, notation, attributeGroup, unique, key and keyref.
     Assert   
count(@targetNamespace | @version | @xmlns | @extendableDefault | @xml:lang ) = count(attribute::*)The <name path=""/> element can only have the following attributes: targetNamespace, version, xmlns, finalDefault or exactDefault.
     Assert   
not(@extendableDefault) or (@extendableDefault='true') or (@extendableDefault='false')The extendableDefault attribute on a <name path=""/> element can only be 'true' or 'false'. (Hint: check the spelling and case.)



     Pattern           

Elements and Attributes: <annotation>

     Rule   
info | appinfo
     Assert   
parent::annotationAn <name path=""/> element may only appear in an annotation element.
     Assert   
not(attribute::*) or attribute::source or attribute::xml:langAn <name path=""/> element may only have a source attribute.
     Rule   
annotation
     Assert   
parent::minExclusive | parent::maxExclusive | parent::minInclusive | parent::maxInclusive | parent::precision | parent::scale | parent::pattern | parent::enumeration | parent::length | parent::maxLength | parent::minLength | parent::encoding | parent::period | parent::language | parent::schema | parent::datatype | parent::restrictions | parent::element | parent::group | parent::attribute | parent::attributeGroup | parent::typeAn annotation is only expected inside any of the following elements: schema, type, restrictions, element, attribute, group, attributeGroup, datatype or the facets of datatypes: minExclusive or maxExclusive or minInclusive or maxInclusive or precision or scale or pattern or enumeration or length or maxLength or minLength or encoding or period or language



     Pattern           

Elements and Attributes: <any>

     Rule   
any
     Assert   
parent::type | parent::restrictions | parent::group The <name path=""/> element must be a child of type or restrictions or group
     Assert   
not(*)The class element cannot contain subelements.
     Assert   
count( @minOccurs | @maxOccurs | @namespace | @xml:lang ) = count(attribute::*)The <name path=""/> element can only have the following attributes: maxOccurs, minOccurs, namespace.



     Pattern           

Elements and Attributes: <anyAttribute>

     Rule   
anyAttribute
     Assert   
parent::type | parent::restrictions | parent::attributeGroupThe <name path=""/> element must be a child of type or restrictions or attributeGroup.
     Assert   
not(*)The <name path=""/> element cannot contain subelements.
     Assert   
not(attribute::*) or @namespace The <name path=""/> element can have a namespace attribute.



     Pattern           

Elements and Attributes: <attribute>

     Rule   
attribute
     Assert   
parent::attributeGroup | parent::type | parent::restrictionsThe <name path=""/> element must be a child of asttrGroup or type or restrictions.
     Assert   
count(*) = count( annotation | datatype)The <name path=""/> element can contain and optional annotation element followed by an optional datatype element.
     Assert   
count(@name | @type | @minOccurs | @maxOccurs | @default | @fixed | @xml:lang ) = count(attribute::*)The <name path=""/> element can only have the following attributes: name, type minOccurs, maxOccurs, default, fixed.
     Report   
@default and @fixedIn the <name path=""/> element, the attribute default should not be used if the attribute fixed is used.
     Report   
@type='attr' and datatypeIn the <name path=""/> element, the datatype subelement cannot be specified if the value of the attribute type is 'attr'.



     Pattern           

Elements and Attributes: <attributeGroup>

     Rule   
attributeGroup
     Assert   
parent::schema | parent::type | parent::restrictions | parent::attributeGroup The <name path=""/> element must be a child of schema or type or restrictions or attributeGroup.
     Assert   
count(*) = count( annotation | attribute | attributeGroup | anyAttribute)The <name path=""/> element can contain an optional 'annotation' elemment; then 'attribute' or 'attributeGroup' in any mix and number; and then an optional final 'anyAttribute' element.
     Assert   
count(anyAttribute) < 2The <name path=""/> element cannot have more than one subelement anyAttribute.
     Assert   
count(annotation) < 2The <name path=""/> element cannot have more than one subelement annotation.
     Assert   
count(@name | @ref | @xml:lang ) = count(attribute::*)The <name path=""/> element can only have the following attributes: name, ref.
     Report   
@ref and (* | @name) >In the <name path=""/> element, the ref attribute should not be used if the name subelement is used or if the <name path=""/> element has content.



     Pattern           

Elements and Attributes: <datatype> and facets

     Rule   
datatype
     Assert   
count( annotation | minExclusive | maxExclusive | minInclusive | maxInclusive | precision | scale | pattern | enumeration | length | maxLength | minLength | encoding | period | language ) = count (*)A datatype element can only have annotation or facet children.
     Report   
annotation and not(*[position()=1] =annotation)In a <name path=""/> element, an annotation element must come before any facets.
     Assert   
@source and string-length(@source > 0)The <name path=""/> element must have a source attribute.
     Rule   
minExclusive | maxExclusive | minInclusive | maxInclusive | precision | scale | pattern | enumeration | length | maxLength | minLength | encoding | period | language
     Assert   
parent::datatype | parent::restrictionsThe <name path=""/> facet element can only appear in a datatype or restrictions element.
     Assert   
count( annotation ) = count (*)The <name path=""/> element can only contain an annotation element.
     Assert   
@value and string-length(@value > 0)The <name path=""/> element must have a value attribute.
     Assert   
not(@abstract) or (@abstract='true') or (@abstract='false')The abstract attribute on a <name path=""/> element can only be 'true' or 'false'. (Hint: check the spelling and case.)
     Assert   
not(@final) or (@final='restriction') or (@final='extension') or (@final='#all') The final attribute on a <name path=""/> element can only be 'restriction' or 'extension' or '#all'. (Hint: check the spelling and case.)
     Assert   
count(@value | @abstract | @final | @source | @name) = count(attribute::*)The <name path=""/> element can only have the following attributes: abstract, final, name, source and value.
     Assert   
self::enumeration or self::pattern or count( parent::*/*[name()= name()]) = 1The <name path=""/> element cannot be repeated within a single datatype.
     Assert   
@valueThe <name path=""/> element must have a 'value' attribute.
     Assert   
not(@name) or count( datatype[@name = @name ]) = 1In the element <name path=""/>, the name of a datatype must be unique among the datatypes defined in the surrounding schema.
     Assert   
not(@name) or count( datatype[@name = @source]) = 1 In the element <name path=""/>, the name specified must be the name of a datatype in the schema in which the user-generated datatype is defined.



     Pattern           

Elements and Attributes: facets allowed by <datatype source='...' >

     Rule   
datatype[@source='string']
     Assert   
count(*)=count( annotation | minExclusive | maxExclusive | minInclusive | maxInclusive | pattern )A datatype element with a source value of string can only have the following contents: annotation | minExclusive | maxExclusive | minInclusive | maxInclusive | pattern.
     Rule   
datatype[@source='boolean']
     Assert   
count(*)=count( annotation )A datatype element with a source value of boolean can only have the following contents: annotation.
     Rule   
datatype[@source='float']
     Assert   
count(*)=count( annotation | minExclusive | maxExclusive | minInclusive | maxInclusive | enumeration )A datatype element with a source value of float can only have the following contents: annotation | minExclusive | maxExclusive | minInclusive | maxInclusive | enumeration .
     Rule   
datatype[@source='double']
     Assert   
count(*)=count( annotation | minExclusive | maxExclusive | minInclusive | maxInclusive | enumeration )A datatype element with a source value of double can only have the following contents: annotation | minExclusive | maxExclusive | minInclusive | maxInclusive | enumeration .
     Rule   
datatype[@source='decimal']
     Assert   
count(*)= count( annotation | precision | scale | minExclusive | maxExclusive | minInclusive | maxInclusive | enumeration )A datatype element with a source value of decimal can only have the following contents: annotation | precision | scale | minExclusive | maxExclusive | minInclusive | maxInclusive | enumeration .
     Rule   
datatype[@source='timeInstant']
     Assert   
count(*)= count( annotation | pattern | minExclusive | maxExclusive | minInclusive | maxInclusive | enumeration )A datatype element with a source value of timeInstant can only have the following contents: annotation | pattern | minExclusive | maxExclusive | minInclusive | maxInclusive | enumeration .
     Rule   
datatype[@source='timeDuration']
     Assert   
count(*)=count( annotation | minExclusive | maxExclusive | minInclusive | maxInclusive | enumeration )A datatype element with a source value of timeDuration can only have the following contents: annotation | minExclusive | maxExclusive | minInclusive | maxInclusive | enumeration .
     Rule   
datatype[@source='recurringInstant']
     Assert   
count(*)= count( annotation | period | pattern | minExclusive | maxExclusive | minInclusive | maxInclusive | enumeration )A datatype element with a source value of recurringInstant can only have the following contents: annotation |period | pattern | minExclusive | maxExclusive | minInclusive | maxInclusive | enumeration .
     Rule   
datatype[@source='binary']
     Assert   
count(*)= count( annotation | encoding | length | maxLength |minLength )A datatype element with a source value of can only have the following contents: annotation | encoding | length | maxLength |minLength.
     Rule   
datatype[@source='uri']
     Assert   
count(*)=count( annotation | enumeration )A datatype element with a source value of uri can only have the following contents: annotation | enumeration.
     Rule   
datatype[@source='language']
     Assert   
count(*)=count( annotation | minExclusive | maxExclusive | minInclusive | maxInclusive | length | maxLength | minLength | enumeration | pattern | language )A datatype element with a source value of language can only have the following contents: annotation | minExclusive | maxExclusive | minInclusive | maxInclusive | length | maxLength | minLength | enumeration | pattern | language .
     Rule   
datatype[@source='NMTOKEN']
     Assert   
count(*)=count( annotation | minExclusive | maxExclusive | minInclusive | maxInclusive | length | maxLength | minLength | enumeration | pattern | language )A datatype element with a source value of NMTOKEN can only have the following contents: annotation | minExclusive | maxExclusive | minInclusive | maxInclusive | length | maxLength | minLength | enumeration | pattern | language .
     Rule   
datatype[@source='Name']
     Assert   
count(*)=count( annotation | minExclusive | maxExclusive | minInclusive | maxInclusive | length | maxLength | minLength | enumeration | pattern | language )A datatype element with a source value of Name can only have the following contents: annotation | minExclusive | maxExclusive | minInclusive | maxInclusive | length | maxLength | minLength | enumeration | pattern | language .
     Rule   
datatype[@source='NMTOKENS']
     Assert   
count(*)=count( annotation | minExclusive | maxExclusive | minInclusive | maxInclusive | length | maxLength | minLength | enumeration | pattern | language )A datatype element with a source value of NMTOKENS can only have the following contents: annotation | minExclusive | maxExclusive | minInclusive | maxInclusive | length | maxLength | minLength | enumeration | pattern | language .
     Rule   
datatype[@source='QName']
     Assert   
count(*)=count( annotation | minExclusive | maxExclusive | minInclusive | maxInclusive | length | maxLength | minLength | enumeration | pattern | language )A datatype element with a source value of QName can only have the following contents: annotation | minExclusive | maxExclusive | minInclusive | maxInclusive | length | maxLength | minLength | enumeration | pattern | language .
     Rule   
datatype[@source='NCName']
     Assert   
count(*)=count( annotation | minExclusive | maxExclusive | minInclusive | maxInclusive | length | maxLength | minLength | enumeration | pattern | language )A datatype element with a source value of NCName can only have the following contents: annotation | minExclusive | maxExclusive | minInclusive | maxInclusive | length | maxLength | minLength | enumeration | pattern | language .
     Rule   
datatype[@source='ID']
     Assert   
count(*)=count( annotation | minExclusive | maxExclusive | minInclusive | maxInclusive | length | maxLength | minLength | enumeration | pattern | language )A datatype element with a source value of ID can only have the following contents: annotation | minExclusive | maxExclusive | minInclusive | maxInclusive | length | maxLength | minLength | enumeration | pattern | language .
     Rule   
datatype[@source='ENTITY']
     Assert   
count(*)=count( annotation | minExclusive | maxExclusive | minInclusive | maxInclusive | length | maxLength | minLength | enumeration | pattern | language )A datatype element with a source value of ENTITY can only have the following contents: annotation | minExclusive | maxExclusive | minInclusive | maxInclusive | length | maxLength | minLength | enumeration | pattern | language .
     Rule   
datatype[@source='NOTATION']
     Assert   
count(*)=count( annotation | minExclusive | maxExclusive | minInclusive | maxInclusive | length | maxLength | minLength | enumeration | pattern | language )A datatype element with a source value of NOTATION can only have the following contents: annotation | minExclusive | maxExclusive | minInclusive | maxInclusive | length | maxLength | minLength | enumeration | pattern | language .
     Rule   
datatype[@source='IDREF']
     Assert   
count(*)=count( annotation | minExclusive | maxExclusive | minInclusive | maxInclusive | length | maxLength | minLength | enumeration | pattern | language )A datatype element with a source value of IDREF can only have the following contents: annotation | minExclusive | maxExclusive | minInclusive | maxInclusive | length | maxLength | minLength | enumeration | pattern | language .
     Rule   
datatype[@source='IDREFS']
     Assert   
count(*)=count( annotation | minExclusive | maxExclusive | minInclusive | maxInclusive | length | maxLength | minLength | enumeration | pattern | language )A datatype element with a source value of IDREFS can only have the following contents: annotation | minExclusive | maxExclusive | minInclusive | maxInclusive | length | maxLength | minLength | enumeration | pattern | language .
     Rule   
datatype[@source='ENTITIES']
     Assert   
count(*)=count( annotation | minExclusive | maxExclusive | minInclusive | maxInclusive | length | maxLength | minLength | enumeration | pattern | language )A datatype element with a source value of ENTITIES can only have the following contents: annotation | minExclusive | maxExclusive | minInclusive | maxInclusive | length | maxLength | minLength | enumeration | pattern | language .
     Rule   
datatype[@source='integer']
     Assert   
count(*)=count( annotation | minExclusive | maxExclusive | minInclusive | maxInclusive | enumeration )A datatype element with a source value of integer can only have the following contents: annotation | minExclusive | maxExclusive | minInclusive | maxInclusive | enumeration .
     Rule   
datatype[@source='non-negative-integer']
     Assert   
count(*)=count( annotation | minExclusive | maxExclusive | minInclusive | maxInclusive | enumeration )A datatype element with a source value of non-negative-integer can only have the following contents: annotation | minExclusive | maxExclusive | minInclusive | maxInclusive | enumeration .
     Rule   
datatype[@source='non-positive-integer']
     Assert   
count(*)=count( annotation | minExclusive | maxExclusive | minInclusive | maxInclusive | enumeration )A datatype element with a source value of non-positive-integer can only have the following contents: annotation | minExclusive | maxExclusive | minInclusive | maxInclusive | enumeration .
     Rule   
datatype[@source='positive-integer']
     Assert   
count(*)=count( annotation | minExclusive | maxExclusive | minInclusive | maxInclusive | enumeration )A datatype element with a source value of positive-integer can only have the following contents: annotation | minExclusive | maxExclusive | minInclusive | maxInclusive | enumeration .
     Rule   
datatype[@source='negative-integer']
     Assert   
count(*)=count( annotation | minExclusive | maxExclusive | minInclusive | maxInclusive | enumeration )A datatype element with a source value of negative-integer can only have the following contents: annotation | minExclusive | maxExclusive | minInclusive | maxInclusive | enumeration .
     Rule   
datatype[@source='date']
     Assert   
count(*)=count( annotation | minExclusive | maxExclusive | minInclusive | maxInclusive | enumeration )A datatype element with a source value of date can only have the following contents: annotation | minExclusive | maxExclusive | minInclusive | maxInclusive | enumeration .
     Rule   
datatype[@source='time']
     Assert   
count(*)=count( annotation | minExclusive | maxExclusive | minInclusive | maxInclusive | enumeration )A datatype element with a source value of time can only have the following contents: annotation | minExclusive | maxExclusive | minInclusive | maxInclusive | enumeration .



     Pattern           

Elements and Attributes: <element>

     Rule   
element
     Assert   
parent::schema | parent::type | parent::restrictions | parent::group The <name path=""/> element can only be a child of schema or type or restrictions or group.
     Assert   
count(*) = count( type | datatype | annotation | unique | key | keyref)The <name path=""/> element can contain an optional annotation element; then the type and datatype elements, in any mix and number; then the key, unique and keyref elements, in any mix and number.
     Assert   
count(@name | @ref | @type | @nullable | @equivClass | @abstract | @final | @exact | @minOccurs | @maxOccurs | @default | @fixed | @xml:lang ) = count(attribute::*)The <name path=""/> element can only have the following attributes: name, ref, type, minOccurs, maxOccurs, equivClass, default, fixed, abstract, final, nullable, exact.
     Report   
@type and @refThe <name path=""/> element cannot have both the ref attribute and the type attribute specified at the same time.
     Report   
@default and @fixedThe <name path=""/> element cannot have both the default attribute and the fixed attribute specified at the same time.
     Report   
@name and @refThe <name path=""/> element cannot have both the ref attribute and the name attribute specified at the same time.



     Pattern           

Elements and Attributes: <field>

     Rule   
field
     Assert   
parent::unique | parent::key | parent::keyrefThe <name path=""/> element must be a child of unique or key or keyref.
     Assert   
not(*)The <name path=""/> element cannot contain subelements.
     Assert   
string-length(text()) > 0The <name path=""/> element must contain a value.
     Report   
attribute::*The <name path=""/> element cannot have an attribute.



     Pattern           

Elements and Attributes: <group>

     Rule   
group
     Assert   
parent::schema | parent::type | parent::restrictions | parent::groupThe <name path=""/> element can only be a child of schema or type or restrictions or group.
     Assert   
count(*) = count( annotation | element | group | any)The <name path=""/> element can contain an optional 'annotation' element, followed by the 'element', 'group' and 'any' elements, in any mix and number.
     Assert   
count(@name | @ref | @minOccurs | @maxOccurs | @order | @xml:lang ) = count(attribute::*)The <name path=""/> element can only have the following attributes: name, ref, minOccurs, maxOccurs, order.
     Assert   
not(@order) or (@order='choice') or (@order='seq') or (@order='all') The order attribute on a <name path=""/> element can only be 'choice', 'seq', or 'all'. (Hint: check the spelling and case.)
     Report   
group and @order='all'In the <name path=""/> element, if the attribute order has the value all, the group sub-element is not allowed.
     Report   
@order='all' and not(parent::type)In the <name path=""/> element, if the attribute order has the value 'all', then the <name path=""/> element must be at the top level of the content model.



     Pattern           

Elements and Attributes: <import>

     Rule   
import
     Assert   
parent::schemaThe <name path=""/> element must be a child of schema.
     Assert   
(normalize-space(.)='') and (count(*) = 0)The <name path=""/> element cannot contain subelements.
     Assert   
count(attribute::*) = count(@schemaLocation | @namespace ) The <name path=""/> element can only have schemaLocation and namespace attributes.
     Assert   
@namespaceThe <name path=""/> element must have a namespace attribute.
     Assert   
(string-length(@schemaLocation) > 0) and document(@schemaLocation)/schemaOn the element <name path=""/> the schemaLocation attribute should give the URI of an XML schema.



     Pattern           

Elements and Attributes: <include>

     Rule   
include
     Assert   
parent::schemaThe <name path=""/> element must be a child of schema.
     Assert   
(normalize-space(.)='') and (count(*) = 0)The <name path=""/> element cannot contain subelements.
     Assert   
count(attribute::*) = count(@schemaLocation) The <name path=""/> element can only have a schemaLocation attribute.
     Assert   
@schemaLocationThe <name path=""/> element must have a schemaLocation attribute.
     Assert   
(string-length(@schemaLocation) > 0) and document(@schemaLocation)/schemaOn the element <name path=""/> the schemaLocation attribute should give the URI of an XML schema.



     Pattern           

Elements and Attributes: <key> and <unique>

     Rule   
unique | key
     Assert   
parent::schema | parent::elementThe <name path=""/> element must be a child of schema or element.
     Assert   
count(*) = count (selector | field) The <name path=""/> element cannot contain a selector element followed by one or more field elements.
     Assert   
count(selector) = 1The <name path=""/> element must contain one 'selector' element.
     Assert   
field The <name path=""/> element must contain at least one 'field' element.
     Assert   
count(@name | @xml:lang ) = count(attribute::*)The <name path=""/> element can only have the following attribute: name.
     Assert   
not(@name) or ( string-length(@name) > 0)The <name path=""/> element should have a name attribute.



     Pattern           

Elements and Attributes: <keyref>

     Rule   
keyref
     Assert   
parent::schema | parent::elementThe <name path=""/> element must be a child of schema or element.
     Assert   
count(*) = count (selector | field) The <name path=""/> element cannot contain a selector element followed by one or more field elements.
     Assert   
count(selector) = 1The <name path=""/> element must contain one 'selector' element.
     Assert   
field The <name path=""/> element must contain at least one 'field' element.
     Assert   
count(@name | @refer |@xml:lang ) = count(attribute::*)The <name path=""/> element can only have the following attribute: name, refer.
     Assert   
not(@name) or ( string-length(@name) > 0)The <name path=""/> element should have a name attribute.
     Assert   
not(@refer) or ( string-length(@refer) > 0)The <name path=""/> element should have a refer attribute.



     Pattern           

Elements and Attributes: <notation>

     Rule   
notation
     Assert   
parent::schemaThe <name path=""/> element must be a child of schema
     Assert   
not(*)The <name path=""/> element cannot contain subelements.
     Assert   
count(@name | @public | @system | @xml:lang ) = count(attribute::*)The <name path=""/> element can only have the following attributes: name, public, system.
     Assert   
@name and ( string-length(@name) > 0)The <name path=""/> element should have a name attribute.
     Assert   
@public and ( string-length(@public) > 0)The <name path=""/> element should have a public attribute.



     Pattern           

Elements and Attributes: <restrictions>

     Rule   
restrictions
     Assert   
parent::typeThe <name path=""/> element must be a child of type.
     Assert   
count(*) = count(annotation | minExclusive | maxExclusive | minInclusive | maxInclusive | precision | scale | pattern | enumeration | length | maxLength | minLength | encoding | period | language | restrictions | element | group | any | sic | attribute | attributeGroup | anyAttribute)The restrictions element can contain the following elements: ; then any mix of element, group and any (if the content attribute has the value 'mixed' or 'elemOnly'); then any mix of attribute and attributeGroup; and lastly an optional anyAttribute.



     Pattern           

Elements and Attributes: <selector>

     Rule   
selector
     Assert   
parent::unique | parent::key | parent::keyrefThe <name path=""/> element must be a child of unique or key or keyref.
     Assert   
not(*) The <name path=""/> element cannot contain subelements.
     Assert   
string-length(text()) > 0The <name path=""/> element must contain a value.
     Report   
attribute::*The <name path=""/> element cannot have an attribute.



     Pattern           

Elements and Attributes: <sic>

     Rule   
sic
     Assert   
parent::restrictionsThe <name path=""/> element must be a child of restrictions.
     Assert   
count(*) = 0The <name path=""/> element cannot contain subelements.
     Report   
attribute::*The <name path=""/> element should have no attributes.



     Pattern           

Elements and Attributes: <type>

     Rule   
type
     Assert   
parent::schema | parent::element The <name path=""/> element must be a child of schema or element.
     Assert   
count(*) = count(annotation | restrictions | element | group | any |attribute | attributeGroup | anyAttribute)The type element can contain the following elements: an optional annotation element; then either restriction or any mix of element, group and any (if the content attribute has the value 'mixed' or 'elemOnly'); then any mix of attribute and attributeGroup; and lastly an optional anyAttribute.
     Assert   
count(@name | @content | @abstract | @final | @exact | @source | @derivedBy | @xml:lang ) = count(attribute::*)The <name path=""/> element can only have the following attributes: name, content, abstract, final, exact, source, derivedBy.
     Assert   
not(@content) or (@content='textOnly') or (@content='mixed') or (@content='elemOnly') or (@content='empty') >The content attribute on a <name path=""/> element can only be 'textOnly', 'mixed', 'elemOnly' or 'empty'. (Hint: check the spelling and case.)
     Assert   
not(@abstract) or (@abstract='true') or (@abstract='false')The abstract attribute on a <name path=""/> element can only be 'true' or 'false'. (Hint: check the spelling and case.)
     Assert   
not(restrictions) or (restrictions and @derivedBy='restriction')The <name path=""/> element can only have a restrictions subelement if the attribute derivedBy has the value 'restriction'.
     Assert   
not(@name) or (count(//type[@name= current()/@name]) = 1)The same NCName must not appear in two definitions or declarations of the same type.



     Pattern           

Elements and Attributes: contents allowed by <type content='...'>

     Rule   
type[@content='textOnly']
     Report   
element | group | anyIf the attribute content on the <name path=""/> element has the value 'textOnly', the following elements cannot be used: element, group, any.
     Rule   
type[@content='empty']
     Report   
element | group | anyIf the attribute content on the <name path=""/> element has the value 'empty', the following elements cannot be used: element, group, any.



     Pattern           

Constraints on Schema: duplications

     Rule   
attributeGroup/@ref
     Assert   
count(parent::*/attributeGroup[@ref= @ref])=1An attribute group should not be referenced by name more than once per element.
     Assert   
//attributeGroup[@name= @ref]An attribute group reference should refer to an attribute group that has been defined elsewhere in the in schema.
     Assert   
@name=@refAn attribute group should not refer to itself.
     Rule   
attribute/@name
     Assert   
count(parent::*/attribute[@name= current()]/@name) = 1An attribute should not be defined twice.
     Rule   
element/@name
     Assert   
count(//element[@name= @name]) = 1An element cannot be declared more than once.
     Rule   
group[@order='alt']/element/@name
     Assert   
count(parent::*/element[@ref= @name]) = 1A choice group should not have choices between the same element.
     Rule   
group[@order='alt']/element/@ref
     Assert   
count(parent::*/element[@ref= @ref]) = 1A choice group should not have choices between the same element. (If this seems strange in context, please ignore this message: ambiguity is ambiguous in the XML Schema draft.>
     Rule   
length
     Report   
../maxLengthIt is an error for both length and maxLength to be specified for the same datatype.
     Report   
../minLengthIt is an error for both length and minLength to be specified for the same datatype.
     Rule   
minExclusive
     Report   
../minInclusiveIt is an error for both minExclusive and minInclusive to the specified for the same datatype.
     Rule   
maxExclusive
     Report   
../maxInclusiveIt is an error for both minExclusive and maxInclusive to the specified for the same datatype.



     Pattern           

Constraints on Schema: value constraints

     Rule   
*/@maxOccurs/@minOccurs
     Assert   
@minOccurs <= @maxOccursIn the <name path=""/> element, the value of maxOccurs must be greater or equal to the value of minOccurs.
     Rule   
*/@maxOccurs
     Assert   
@maxOccurs > 0In the <name path=""/> element, the value of maxOccurs must be greater or equal to 1 (which is the default value of maxOccurs.)
     Rule   
*/@minOccurs
     Assert   
@minOccurs < 1In the <name path=""/> element, the value of minOccurs must be greater or equal to 1 (which is the default value of maxOccurs.
     Rule   
scale
     Report   
(../precision) and (text() > ../precision/text())It is an error for scale to be greater-than precision.




Schematron Pretty by Rick Jelliffe. The Schematron by Rick Jelliffe, Academia Sinica Computing Centre.