\hypertarget{elementIdentity}{}\subsection{Example xs:ID, xs:IDREF}\label{elementIdentity}
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 {\tt \href{http://example.org/base}{\tt http://example.org/base}} the RDF mapping below includes a statement with property 'foo' and object {\tt \href{http://example.org/base#foobar}{\tt http://example.org/base\#foobar}}. The 'bar' element is an IDREF, and the object of this statement is the resource identified as 'foobar'.



\begin{DocInclude}\begin{verbatim}<?xml version="1.0" encoding="UTF-8"?>
<identity xmlns="http://example.org/">
        <foo id="foobar" />
        <bar>foobar</bar>
</identity>
\end{verbatim}
\end{DocInclude}


The xml schema for this is as follows:



\begin{DocInclude}\begin{verbatim}<?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>
\end{verbatim}
\end{DocInclude}


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



\begin{DocInclude}\begin{verbatim}# 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
              ] .
\end{verbatim}
\end{DocInclude}
 