complexType

The only complex type predefined in XML schema is anyType, the default type for elements, and a super-class of any user-defined type. The nearest analogue is RDF Resource. User defined complex types correspond to OWL classes which may be anonymous, globally qualified by the target namespace, or locally named and defined in a default namespace. For complex types with mixed or simple content, we model these as restrictions on its RDF value.

Global, named complex types are defined in the target namespace. The following schema defines a complex type, <http://example.org/Foo>.

<?xml version="1.0" encoding="UTF-8"?>
<xs:schema xmlns:xs="http://www.w3.org/2001/XMLSchema" targetNamespace="http://example.org/" >
        <xs:complexType name="Foo" />
</xs:schema>
# Base: http://example.org/complexType1.owl
@prefix ns1:     <http://example.org/def/> .
@prefix xs:      <http://www.w3.org/2001/XMLSchema> .
@prefix ns2:     <http://example.org/> .
@prefix rdfs:    <http://www.w3.org/2000/01/rdf-schema#> .
@prefix daml:    <http://www.daml.org/2001/03/daml+oil#> .
@prefix rdf:     <http://www.w3.org/1999/02/22-rdf-syntax-ns#> .
@prefix xs_:     <http://www.w3.org/2001/XMLSchema#> .
@prefix :        <#> .
@prefix owl:     <http://www.w3.org/2002/07/owl#> .

<>    a       owl:Ontology .

ns2:Foo
      a       owl:Class .

If the target namespace ends with an alpha-numeric, a fragment separator '#' is introduced.

For locally defined elements we derive value (OWL allValuesFrom) restrictions from their type. A complex type defines a content model (particle) for element content. For global elements the type is set by the property range. The Russian Doll style of schema mirrors the structure of the XML instance document. Short on references to global definitions, we see attributes & elements defined in-situ (locally), where names are easily recycled. We might foresee a problem with different appearances of an element within the particle having different types. However, the Element Declarations Consistent constraint limits elements within the same particle to be of the same type. This permits us to construct an allValuesFrom restriction based only on the first appearance of an element within a particle.

This example also shows the definition of a property range based on an anonymous complex type. It also shows how simple content is captured in the form of an rdf:value. In this case the element value can appear at most once. If the element is empty the value isn't added.

<?xml version="1.0" encoding="UTF-8"?>
<xs:schema xmlns:xs="http://www.w3.org/2001/XMLSchema" targetNamespace="http://example.org/" >
        <xs:element name="foo">
                <xs:complexType>
                        <xs:simpleContent>
                                <xs:restriction base="xs:string"/>
                        </xs:simpleContent>
                </xs:complexType>
        </xs:element>
</xs:schema>
# Base: http://example.org/complexType2.owl
@prefix ns1:     <http://example.org/def/> .
@prefix xs:      <http://www.w3.org/2001/XMLSchema> .
@prefix ns2:     <http://example.org/> .
@prefix rdfs:    <http://www.w3.org/2000/01/rdf-schema#> .
@prefix daml:    <http://www.daml.org/2001/03/daml+oil#> .
@prefix rdf:     <http://www.w3.org/1999/02/22-rdf-syntax-ns#> .
@prefix xs_:     <http://www.w3.org/2001/XMLSchema#> .
@prefix :        <#> .
@prefix owl:     <http://www.w3.org/2002/07/owl#> .

rdf:value
      a       owl:DatatypeProperty , rdf:Property .

<>    a       owl:Ontology .

ns2:foo
      a       owl:ObjectProperty ;
      rdfs:range
              [ a       owl:Class ;
                rdfs:subClassOf
                        [ a       owl:Restriction ;
                          owl:cardinality "1"^^xs_:int ;
                          owl:onProperty rdf:value
                        ] ;
                rdfs:subClassOf
                        [ a       owl:Restriction ;
                          owl:allValuesFrom xs_:string ;
                          owl:onProperty rdf:value
                        ]
              ] .

Instances of this in both XML and RDF are as follows:

<?xml version="1.0" encoding="UTF-8"?>
<foo xmlns="http://example.org/">foobar</foo>
# Base: http://example.org/complexType2.xml
@prefix ns1:     <http://example.org/def/> .
@prefix xs:      <http://www.w3.org/2001/XMLSchema> .
@prefix ns2:     <http://example.org/> .
@prefix rdf:     <http://www.w3.org/1999/02/22-rdf-syntax-ns#> .
@prefix xs_:     <http://www.w3.org/2001/XMLSchema#> .
@prefix :        <#> .

<>    ns2:foo [ rdf:value "foobar"^^xs_:string
              ] .

We may add attributes to a complex type either directly as in the example below (or as part of an attribute group), or within nested restrictions or extensions.

<?xml version="1.0" encoding="UTF-8"?>
<xs:schema xmlns:xs="http://www.w3.org/2001/XMLSchema" targetNamespace="http://example.org/" >
        <xs:complexType name="Foo">
                <xs:attribute name="bar" type="xs:string" />
        </xs:complexType>
</xs:schema>

The attribute 'bar' is unqualified, so the corresponding property is defined in the default namespace (xmlns=http://example.org/def/).

# Base: http://example.org/complexType3.owl
@prefix ns1:     <http://example.org/def/> .
@prefix xs:      <http://www.w3.org/2001/XMLSchema> .
@prefix ns2:     <http://example.org/> .
@prefix rdfs:    <http://www.w3.org/2000/01/rdf-schema#> .
@prefix daml:    <http://www.daml.org/2001/03/daml+oil#> .
@prefix rdf:     <http://www.w3.org/1999/02/22-rdf-syntax-ns#> .
@prefix xs_:     <http://www.w3.org/2001/XMLSchema#> .
@prefix :        <#> .
@prefix owl:     <http://www.w3.org/2002/07/owl#> .

ns1:bar
      a       owl:DatatypeProperty , rdf:Property .

<>    a       owl:Ontology .

ns2:Foo
      a       owl:Class ;
      rdfs:subClassOf
              [ a       owl:Restriction ;
                owl:maxCardinality "1"^^xs_:int ;
                owl:onProperty ns1:bar
              ] ;
      rdfs:subClassOf
              [ a       owl:Restriction ;
                owl:allValuesFrom xs_:string ;
                owl:onProperty ns1:bar
              ] .

We can add structured content to a complex type, using the compositors, 'all', 'choice', 'sequence', and sometimes 'group'. These don't add any nested structure to the class itself but are used to determine the cardinalities of any added properties.

Child components


Generated on Mon Jun 18 16:02:37 2007 for Gloze by  doxygen 1.5.0