\hypertarget{datatypes}{}\subsection{Datatypes}\label{datatypes}
The RDF semantics recommendation identifies a subset of XML schema datatypes that are suitable for use in RDF. The following XML datatypes may be used in RDF typed literals. For example, an xs:string \char`\"{}foobar\char`\"{}, would be represented in RDF (N3) as \char`\"{}foobar\char`\"{}$^\wedge$$^\wedge$$<$\href{http://www.w3.org/2001/XMLSchema#string}{\tt http://www.w3.org/2001/XMLSchema\#string}$>$.

\begin{itemize}
\item xs:string\item xs:boolean\item xs:decimal\item xs:float\item xs:double\item xs:date\-Time\item xs:time\item xs:date\item xs:g\-Year\-Month\item xs:g\-Year\item xs:g\-Month\-Day\item xs:g\-Day\item xs:g\-Month\item xs:hex\-Binary\item xs:base64Binary\item xs:any\-URI\item xs:normalized\-String\item xs:token\item xs:language\item xs:NMTOKEN\item xs:Name\item xs:NCName\item xs:integer\item xs:non\-Positive\-Integer\item xs:negative\-Integer\item xs:long\item xs:int\item xs:short\item xs:byte\item xs:non\-Negative\-Integer\item xs:unsigned\-Long\item xs:unsigned\-Int\item xs:unsigned\-Short\item xs:unsigned\-Byte\item xs:positive\-Integer\end{itemize}


\hyperlink{elementstring}{datatype example}

The exceptions include:\begin{itemize}
\item xs:any\-Simple\-Type\item xs:duration\item xs:ENTITY\item xs:ENTITIES\item xs:ID\item xs:IDREF\item xs:IDREFS\item xs:NMTOKENS\item xs:NOTATION\item xs:QName\end{itemize}


\begin{Desc}
\item[See also:]\href{http://www.w3.org/TR/2004/REC-rdf-mt-20040210/}{\tt http://www.w3.org/TR/2004/REC-rdf-mt-20040210/} \href{http://www.w3.org/TR/xpath-functions/}{\tt http://www.w3.org/TR/xpath-functions/} \href{http://www.w3.org/TR/swbp-xsch-datatypes/}{\tt http://www.w3.org/TR/swbp-xsch-datatypes/}\end{Desc}
The following sections explore work-arounds for all of these datatypes.\hypertarget{datatypes_anySimpleType}{}\subsubsection{The mother of all simple types (xs:any\-Simple\-Type)}\label{datatypes_anySimpleType}
This type is the base of all simple types with an unconstrained lexical space. User defined restrictions of xs:any\-Simple\-Type are not allowed. Indeed, users are generally advised to steer clear of it altogether.

Yet, both elements and attributes may be defined to be of type xs:any\-Simple\-Type (it's also the default type for attributes). Also, any\-Simple\-Type may be used as the base of a simple\-Content extension.

Thinking about an RDF savvy mapping, it occupies a similar place in the pantheon of classes as rdfs:Literal, the superclass of all literals including datatypes. Thus any XML content of type xs:any\-Simple\-Type is mapped to an rdfs:Literal.

\hyperlink{attributeanysimpletype}{any\-Simple\-Type example}

\begin{Desc}
\item[See also:]\href{http://www.w3.org/2001/05/xmlschema-rec-comments#pfiS4SanySimpleType}{\tt http://www.w3.org/2001/05/xmlschema-rec-comments\#pfi\-S4Sany\-Simple\-Type} \href{http://lists.w3.org/Archives/Member/w3c-xml-schema-ig/2002Jan/0065.html}{\tt http://lists.w3.org/Archives/Member/w3c-xml-schema-ig/2002Jan/0065.html}\end{Desc}
\hypertarget{datatypes_duration}{}\subsubsection{Duration (xs:duration)}\label{datatypes_duration}
The problem with xs:duration is that there's no well-defined total ordering over it's value space (durations are partially ordered). The problem stems from there being an indeterminate number of days in a month. The recommended solution used by \hyperlink{classcom_1_1hp_1_1gloze_1_1_gloze}{Gloze} is to distill a single period such as \char`\"{}P7Y2M26DT14H18M10S\char`\"{} (years, months, days, hours, minutes, seconds) into separate xs:year\-Month\-Duration \char`\"{}P7Y2M\char`\"{} (years, months) and xs:day\-Time\-Duration \char`\"{}P26DT14H18M10S\char`\"{} (days, hours, minutes, seconds) datatypes. The reverse process, is equivalent to adding the these values, both of which are subclasses of duration. When adding two durations, each component is added independently, ignoring - in particular - any carry from days to months.

\hyperlink{elementduration}{duration example}\hypertarget{datatypes_entity}{}\subsubsection{Entities (xs:ENTITY)}\label{datatypes_entity}
An XML schema ENTITY allows the substitution of common text values or balanced mark-up defined as XML entities. ENTITY values must match an entity name declared in the DTD of the instance document. The value space of unexpanded entities is scoped to the instance document it appears in. For the XML to RDF mapping, internally defined entities are therefore expanded. As they may include balanced mark-up, an expanded entity can be described as an RDF XMLLiteral. There is currently no reverse mapping due to technical issues in editing document type declarations in level 2 DOM.

\hyperlink{elemententity}{entity example}

\begin{Desc}
\item[See also:]\href{http://jena.sourceforge.net/how-to/typedLiterals.html#xsd}{\tt http://jena.sourceforge.net/how-to/typed\-Literals.html\#xsd}\end{Desc}
\hypertarget{datatypes_xsid}{}\subsubsection{Identity datatypes (xs:ID, xs:IDREF)}\label{datatypes_xsid}
An element is considered to have an ID if it has an attribute of type ID, or if the type of the element itself is an ID.

IDs have no distinguishing features looking at the XML alone, they look like ordinary content. We look to the XML schema which will identify the datatype as xml schema ID. The ID is associated with the enclosing element, and that element can have at most one ID.

XML IDs are defined to have document scope, such that a given ID must be unique within a single document and that each ID reference should have a corresponding ID within the same document. One advantage of the mapping into RDF is that a single RDF model may contain descriptions of multiple documents. We have ensure that we preserve the global uniqueness of identifiers, and do not lose the correlation between IDs and their references when moving to this global context. An identifier of type ID can be transformed into a URI by treating it as a fragment identifier relative to the document base.

For example, a base {\tt \href{http://example.org/base}{\tt http://example.org/base}} an XML ID \char`\"{}foobar\char`\"{} combine to give the URI, {\tt \href{http://example.org/base#foobar}{\tt http://example.org/base\#foobar}} .

Properties of type ID will disappear, as these simply define the URI of the identified resource. A corresponding reference to this resource with an IDREF is similarly expanded into a URI reference.

\hyperlink{elementidentity}{identity example}\hypertarget{datatypes_notation}{}\subsubsection{Notation (xs:NOTATION)}\label{datatypes_notation}
NOTATIONs are restricted to QNames declared in the schema. For the purposes of RDF mapping they are subject to the same rules as QNames. The target namespace and notation name are expanded to give an absolute URI for the notation resource.

\hyperlink{attributenotation}{notation example}\hypertarget{datatypes_qNames}{}\subsubsection{Qualified Names (xs:QName)}\label{datatypes_qNames}
QNames define the space of (optionally) qualified local names. The scope of an XML namespace prefix includes the element it is defined in and its children (subject to shadowing). This lexical scoping doesn't translate directly into RDF where everything has global scope. However, the expanded QName is a URI, so it may be translated into an object reference, though typically we have no knowledge of the type of object referred to. This URI becomes associated with a resource.

For example, given a namespace prefix 'eg' defined as \char`\"{}http://example.org\char`\"{} the QName \char`\"{}eg:foobar\char`\"{} would be expanded to give the URI, {\tt \href{http://example.org#foobar}{\tt http://example.org\#foobar}} .

\hyperlink{elementqname}{QName example}\hypertarget{datatypes_listTypes}{}\subsubsection{List types (xs:IDREFS, xs:ENTITIES, xs:NMTOKENS)}\label{datatypes_listTypes}
Although list types are treated as simple in XML schema, they are not recommended for use in RDF. Instead, we construct an rdf:list of the corresponding non-list type (xs:IDREF, xs:ENTITY, xs:NMTOKEN).

\hyperlink{elementidrefs}{IDREFS example} 