\hypertarget{attributeID}{}\subsection{Attribute Identity}\label{attributeID}
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.



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

\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/" 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>
\end{verbatim}
\end{DocInclude}


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.



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