Example xs:ID, xs:IDREF

The xs:ID and xs:IDREF types have document scope so are not recommended for use in RDF. Take a fragment of XML with an attribute 'id' of type xs:ID. Instead of adding the 'id' attribute as a property of a resource, we use it to derive the URI of that resource. Given a base http://example.org/base the RDF mapping below includes a statement with property 'foo' and object http://example.org/base#foobar. The 'bar' element is an IDREF, and the object of this statement is the resource identified as 'foobar'.

<?xml version="1.0" encoding="UTF-8"?>
<identity xmlns="http://example.org/">
        <foo id="foobar" />
        <bar>foobar</bar>
</identity>

The xml schema for this is as follows:

<?xml version="1.0" encoding="UTF-8"?>
<xs:schema xmlns:xs="http://www.w3.org/2001/XMLSchema" 
        targetNamespace="http://example.org/" elementFormDefault="qualified">
        
        <xs:element name="identity">
                <xs:complexType>
                        <xs:sequence>
                                <xs:element name="foo">
                                        <xs:complexType>
                                                <xs:simpleContent>
                                                        <xs:extension base="xs:anySimpleType">
                                                                <xs:attribute name="id" type="xs:ID" />
                                                        </xs:extension>
                                                </xs:simpleContent>
                                        </xs:complexType>
                                </xs:element>
                                <xs:element name="bar" type="xs:IDREF" />
                        </xs:sequence>
                </xs:complexType>
        </xs:element>

</xs:schema>

This XML maps to the following RDF. Note how the 'id' attribute has been dropped in the RDF.

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

<>    ns2:identity
              [ ns2:bar :foobar ;
                ns2:foo :foobar
              ] .

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