anyAttribute

Sometimes it is useful to create a slot that would match a range of attributes. One use of this is to allow predefined xml attributes on an element, such as xml:lang; xml:id; xml:space without having to include the XML schema. XML schema is not savvy to these new features, so they must be explicitly added to the schema.

See also:
http://www.w3.org/XML/1998/namespace
The example below includes two marked-up 'parts'. We use xml:id to add an identifier to 'foo', and xml:lang to define the language in which 'bar' is expressed.

<report xmlns="http://example.org/">
  <part xml:id="foo">foo</part>
  <part xml:lang="en">bar</part>
</report>

The schema for the XML namespace, and hence the xml:id attribute, is not imported, so the interpretation of anyAttribute is non-strict.

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

        <xs:element name="report">
                <xs:complexType>
                        <xs:sequence>
                                <xs:element name="part" maxOccurs="unbounded">
                                        <xs:complexType>
                                                <xs:simpleContent>
                                                        <xs:extension base="xs:string">
                                                        <xs:anyAttribute namespace="http://www.w3.org/XML/1998/namespace" 
                                                         processContents="lax" />                                                               
                                                        </xs:extension>
                                                </xs:simpleContent>
                                        </xs:complexType>
                                </xs:element>
                        </xs:sequence>
                </xs:complexType>
        </xs:element>

</xs:schema>

Note that even without the XML namespace schema to hand, Gloze treats xml:id and xml:lang correctly.

# Base: http://example.org/anyAttribute.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 :        <#> .

:foo  rdf:value "foo"^^xs_:string .

<>    ns2:report
              [ ns2:part :foo ;
                ns2:part
                        [ rdf:value "bar"@en
                        ]
              ] .

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