Attribute Identity

The following example demonstrates the use of xs:ID, xs:IDREF, and xs:IDREFS. The element 'foobar' includes an 'id' attribute that identifies it. The bar element references it via its 'href' or 'hrefs' attributes, of type xs:IDREF or xs:IDREFS, respectively.

<?xml version="1.0" encoding="UTF-8"?>
<identity xmlns="http://example.org/" >
        <foobar id="foobar"/>
        <bar idref="foobar"/>
        <bar idrefs="foobar foobar" />
</identity>
<?xml version="1.0" encoding="UTF-8"?>
<xs:schema xmlns:xs="http://www.w3.org/2001/XMLSchema" 
        targetNamespace="http://example.org/" xmlns="http://example.org/"
        elementFormDefault="qualified">
        
        <xs:element name="identity">
                <xs:complexType>
                        <xs:sequence>
                                <xs:element name="foobar">
                                        <xs:complexType>
                                                <xs:attribute name="id" type="xs:ID"/>
                                        </xs:complexType>
                                </xs:element>
                                <xs:element name="bar" maxOccurs="unbounded">
                                        <xs:complexType>
                                                <xs:attribute name="idref" type="xs:IDREF"/>
                                        <xs:attribute name="idrefs" type="xs:IDREFS"/>
                                        </xs:complexType>
                                </xs:element>
                        </xs:sequence>
                </xs:complexType>
        </xs:element>

</xs:schema>

Observe that no resources of types xs:ID, xs:IDREF, or xs:IDREFS appear in the mapped RDF. These are all translated into resource URIs, and in the case of xs:IDREFS to an RDF:List of URIs.

# Base: http://example.org/attributeID.xml
@prefix ns1:     <http://example.org/> .
@prefix xs:      <http://www.w3.org/2001/XMLSchema> .
@prefix ns2:     <http://example.org/def/> .
@prefix xs_:     <http://www.w3.org/2001/XMLSchema#> .
@prefix rdf:     <http://www.w3.org/1999/02/22-rdf-syntax-ns#> .
@prefix :        <#> .

<>    ns1:identity
              [ ns1:bar [ ns2:idref :foobar
                        ] ;
                ns1:bar [ ns2:idrefs (:foobar :foobar)
                        ] ;
                ns1:foobar :foobar
              ] .

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