<?xml version="1.0" encoding="utf-8"?>
<?xml-stylesheet type="text/xsl" href="xmlspec.xsl"?>
<!DOCTYPE spec PUBLIC "-//W3C//DTD Specification V2.1//EN"
     "http://www.w3.org/XML/1998/06/xmlspec-v21.dtd" [
    <!ENTITY note.name "RDF/A Containers">
    <!ENTITY version "0.1">
    <!ENTITY prev-dd "27">
    <!ENTITY prev-mm "10">
    <!ENTITY prev-year "2005">
    <!ENTITY dd "13">
    <!ENTITY MM "February">
    <!ENTITY mm "02">
    <!ENTITY year "2006">
    <!ENTITY iso.doc.date "&year;&MMDD;">
    <!ENTITY MMDD "&mm;&dd;">
    <!ENTITY ne "≠">
    <!ENTITY ouml "ö">
    <!ENTITY times "×">
    <!ENTITY order "£">
    <!ENTITY le "≤">
    <!ENTITY cellback "#d0d9fa">
    <!ENTITY eacute "é">
    <!ENTITY copy "©">
    <!ENTITY sect "§">
    <!ENTITY mdash "&#8212;">
]>
<!-- "http://www.w3.org/XML/1998/06/xmlspec-v21.dtd" -->
<spec w3c-doctype="draft">
    <header>
        <title>&note.name;</title>
        <subtitle>Using XHTML constructs as RDF Containers.</subtitle>
        <version>&version;</version>
        <w3c-designation>Internal Working Draft</w3c-designation>
        <w3c-doctype>draft</w3c-doctype>
        <pubdate>
            <day>&dd;</day>
            <month>&MM;</month>
            <year>&year;</year>
        </pubdate>
        <!-- notice>Notice this!!</notice -->
        <publoc>
            <loc href="2006-rdfa-containers">&note.name; $Id: 2006-rdfa-containers.xml,v 1.2 2006/02/24 23:25:42 adida Exp $</loc>
        </publoc>
        <prevlocs>
        </prevlocs>
        <latestloc>
        </latestloc>
        <authlist>
            <author>
                <name>Ben Adida</name>
                <affiliation>Creative Commons</affiliation>
                <email href="mailto:ben@creativecommons.org">ben@creativecommons.org</email>
            </author>
        </authlist>
        <abstract>
            <p>
                This document describes the use of certain XHTML elements to define
                RDF containers, such as <el>rdf:Bag</el> or <el>rdf:Seq</el>.
            </p>
        </abstract>
        <status>
          <p>This is an internal draft produced by the RDF-in-HTML
            task force <bibref ref="RDFHTML" />, a joint task force of
            the Semantic Web Best Practices and Deployment Working
            Group <bibref ref="SWBPD-WG" /> and HTML Working Group
            <bibref ref="HTML-WG" />.</p>
      <p>
        This document is for internal review only and is subject
        to change without notice. This document has <em>no formal
        standing within the W3C</em>. Even more important, <em>if approved by the TF, this document is almost certain to be integrated into the RDF/A syntax and primer</em>. In other words, pointing to this document is for TF and WG internal discussions only.
      </p>
            <p>
<!--                <emph>Last Modified: &year;-&mm;-&dd;</emph>-->
            </p>
        </status>
        <languages>
            <language>en</language>
        </languages>
        <revisiondesc>
            <p>
                <emph>Last Modified: $Id: 2006-rdfa-containers.xml,v 1.2 2006/02/24 23:25:42 adida Exp $</emph>
            </p>
        </revisiondesc>
    </header>
    <body>
      <div1>
        <head>Motivation</head>
        <p>
            RDF/A <bibref ref="RDFA-PRIMER" /> defines the embedding of RDF statements in XHTML. As such, 
            it is possible to define RDF containers, such as <el>rdf:Bag</el>, in RDF/A, using explicit 
            <el>rdf:type</el> declarations and <el>rdf:_1</el>, <el>rdf:_2</el>, etc... Two factors motivate the introduction
            of syntactic sugar for RDF containers in RDF/A:
        </p>
            <ol>
                <li> the explicit use of such RDF properties is inconvenient for human authors, and</li>
                <li> XHTML already offers elements that naturally exhibit RDF container semantics.</li>
            </ol>
      </div1>
    <div1>
        <head>The Syntax</head>
        <p>
            We define the syntax we <em>wish</em> to have for expressing RDF Containers.
        </p>
        <div2>
            <head>XHTML Constructs</head>
            <p>
                XHTML2 defines a number of list constructs <bibref ref="XHTML-LISTS" />:
            </p>
            <ul>
                <li> <el>dl</el> - Definitions Lists: lists of terms with definitions.</li>
                <li> <el>ul</el> - Unordered Lists: lists with unordered items.</li>
                <li> <el>ol</el> - Ordered Lists: lists with ordered items.</li>
                <li> <el>nl</el> - Navigation Lists: lists with navigation items.</li>
            </ul>
            <p>
                These elements clearly have semantic value regarding the information they contain.
            </p>
        </div2>
        <div2>
            <head>RDF Containers</head>
            <p>
                RDF defines the type <el>rdf:Container</el>. A container is a single RDF node, 
                linked to any number of other RDF nodes using the <el>rdf:_1</el>, <el>rdf:_2</el>, <el>rdf:_3</el>
                ... properties. <el>rdf:Container</el> has 3 subtypes:
                <ul>
                    <li><el>rdf:Bag</el>: the members of this container are unordered</li>
                    <li><el>rdf:Seq</el>: the members of this container are ordered</li>
                    <li><el>rdf:Alt</el>: the members of this container are options out of a set of alternatives</li>
                </ul>
            </p>
            
            <p>
                RDF also defines <em>Collections</em>, which provide null-terminated linked-lists of elements.
            </p>
        </div2>
        <div2>
            <head>XHTML Constructs as RDF Containers</head>
            
            <p>
                It does not appear that RDF Collections &mdash; null-terminated linked-lists &mdash; are the right 
                semantic construct for XHTML. Thus, we make no attempt to provide syntactic sugar for RDF Collections.
                Instead, we focus on the RDF Containers: <el>rdf:Bag</el> and friends.
            </p>
            
            <p>
                It is fairly clear that there is a semantic "match made in heaven" between the following:
                <ul>
                    <li><el>rdf:Bag</el> corresponds to <el>ul</el></li>
                    <li><el>rdf:Seq</el> corresponds to <el>ol</el></li>
                    <li><el>rdf:Alt</el> corresponds to <el>nl</el></li>
                </ul>
            </p>
            
            <p>
                <el>dl</el> is less clear, though it also appears to be an unordered set of elements.
			</p>
			
			<p>
                <em>IMPORTANT</em>: for now, we do not address <el>dl</el>, as the semantics are more complicated and we want to get <el>ul</el>,<el>ol</el>, and <el>nl</el> right first.
            </p>
        </div2>
        <div2>
            <head>The Syntax</head>
            <p>
                Thus, we want the following XHTML2 syntax:
            </p>
            <eg><![CDATA[<ul id="mylist">
    <li href="#foo">Foo Item</li>
    <li href="#bar">Bar Item</li>
    <li href="#baz">Baz Item</li>
</ul>]]></eg>
            
			<p>
				to result, via RDF/A, in the following triples:
			</p>
			<eg><![CDATA[
<#mylist> rdf:type rdf:Bag .
<#mylist> rdf:_1 <#foo> .
<#mylist> rdf:_2 <#bar> .
<#mylist> rdf:_3 <#baz> .
]]></eg>	

		<p>
			Similarly, the use of <el>ol</el> would have generated the same RDF triples, with the exception 
			of the <el>rdf:type</el> property set to <el>rdf:Seq</el>. The use of <el>nl</el> would have generated an
			<el>rdf:type</el> of <el>rdf:Alt</el>.
		</p>
		
		<p>
			If the list element in XHTML is not given an <att>id</att>, then it is, of course, a bnode. The following XHTML:
		</p>

            <eg><![CDATA[<ol>
    <li href="#foo">Foo Item</li>
    <li href="#bar">Bar Item</li>
    <li href="#baz">Baz Item</li>
</ol>]]></eg>
            
			<p>
				results in:
			</p>
			<eg><![CDATA[_:ol_0 rdf:type rdf:Seq .
_:ol_0 rdf:_1 <#foo> .
_:ol_0 rdf:_2 <#bar> .
_:ol_0 rdf:_3 <#baz> .
]]></eg>	
		
        </div2>
    </div1>
    <div1>
        <head>Implementation Details</head>
		<p>
			Here we define the implementation details required to build an RDF/A Parser correctly. We note that
			any additions here do NOT interfere with previous triple resolutions under typical RDF/A rules. In other words,
			this document only specifies the generation of new triples. Any triples generated according to prior RDF/A specification
			are <em>still</em> generated. This document defines <em>new</em> triples generated in addition.
		</p>
		<div2>
			<head><el>ul</el>, <el>ol</el>, <el>nl</el></head>
			<p>
				An XHTML2 element that defines a list, <el>ul</el>, <el>ol</el>, or <el>nl</el>,
				automatically generates an RDF triple that defines the type of that node. The normal RDF/A
				rules of naming/bnode apply: if the element has <att>id</att>, then the <el>rdf:type</el> property is
				applied to the node identified as such. Otherwise, a bnode is generated to correspond to that XHTML element,
				and the <el>rdf:type</el> property is applied to this bnode. Note that the absence or presence of an <att>about</att>
				attribute on this list element does not affect this automatically generated triple: the subject of
				this automatic triple is still the list element.
			</p>
			
		</div2>
		<div2>
			<head><el>li</el></head>
			<p>
				An XHTML2 element that defines a list item, <el>li</el>, automatically indicates an implied RDF
				property. The processing rules are as follows, in the explicit order given:
				
				<ol>
					<li> The subject of this automatic assertion triggered by the <el>li</el> is the element's corresponding
					list node. Note that this is the case <em>even</em> if the list element has an <att>about</att> attribute.</li>
					
					<li> If <el>li</el> has an <att>href</att> attribute, then a triple is generated with 
					the corresponding list node as subject, the appropriate membership property (see below),
					and the <att>href</att> value as object. This may be in addition to another triple generated by
					an explicit <att>rel</att> attribute (which may resolve to a different subject).</li>
					
					<li> If <el>li</el> has no <att>href</att> attribute, then a triple is generated with the corresponding
					list node as subject, the appropriate membership property (see below), and the <el>li</el> element content as
					a literal object. This may be in addition to the triple generated by an explicit
					<att>property</att> attribute (which may resolve to a different subject).
					</li>
				</ol>
				
			</p>

			<p>
				The appropriate membership property &mdash; <el>rdf:_1</el>, <el>rdf:_2</el>, ... &mdash; are exactly
				those for resolving <el>rdf:li</el> in RDF/XML: find the previous member in the collection as defined by the XML DOM,
				determine its membership property, and use the next one for the current <el>li</el>. If there is no previous member,
				use <el>rdf:_1</el>.				
			</p>
		</div2>
		
		<div2>
			<head>Advanced Examples</head>
			<p>Beyond the above simple examples, the following examples show how to resolve more confusing setups.</p>
			<div3>
				<head>No <att>href</att></head>
            	<eg><![CDATA[My Grocery List:
<ol>
    <li>Bacon</li>
    <li>Lettuce</li>
    <li>Tomato</li>
</ol>]]></eg>
            
				<p>
					results in:
				</p>
				<eg><![CDATA[_:ol_0 rdf:type rdf:Seq .
_:ol_0 rdf:_1 "Bacon" .
_:ol_0 rdf:_2 "Lettuce" .
_:ol_0 rdf:_3 "Tomato" .
]]></eg>	
			</div3>
			
			<div3>
				<head>Explicit <att>about</att> in the list element</head>
            	<eg><![CDATA[This document is licensed under the following multiple licenses:
<ul about="">
    <li rel="cc:license" href="http://creativecommons.org/licenses/by-nc/2.5/">
       Attribution Non-Commercial.
    </li>
    <li rel="cc:license" href="http://creativecommons.org/licenses/by-sa/2.5/">
        Attribution Share-Alike.
    </li>
</ul>]]></eg>
            
				<p>
					results in:
				</p>
				<eg><![CDATA[<> cc:license <http://creativecommons.org/licenses/by-nc/2.5/> .
<> cc:license <http://creativecommons.org/licenses/by-sa/2.5/> .

_:ul_0 rdf:type rdf:Bag .
_:ul_0 rdf:_1 <http://creativecommons.org/licenses/by-nc/2.5/> .
_:ul_0 rdf:_2 <http://creativecommons.org/licenses/by-sa/2.5/> .
]]></eg>	
				
				<p>
					<em>NOTE</em>: the <att>about=""</att> attribute in the example above is there for clarity only. If the enclosing HTML does not specify an alternate <att>about</att>, it could easily be taken out and the same triples would be generated. This is consistent with current RDF/A rules and has nothing to do with these additional container rules.
				</p>
			</div3>
		</div2>
    </div1>
      <div1>
        <head>Bibliography</head>
        <blist>
          <bibl id="RDFA-PRIMER" href="http://w3.org/2001/sw/BestPractices/HTML/2006-01-24-rdfa-primer">RDF/A Primer</bibl>
          <bibl id="RDFHTML" href="http://w3.org/2001/sw/BestPractices/HTML/">RDF-in-HTML Task Force</bibl>
          <bibl id="SWBPD-WG" href="http://w3.org/2001/sw/BestPractices/">Semantic Web Best Practices and Deployment Working Group</bibl>
          <bibl id="HTML-WG" href="http://w3.org/MarkUp/Group/">HTML Working Group</bibl>
          <bibl id="XHTML-LISTS" href="http://www.w3.org/TR/xhtml2/mod-list.html#s_listmodule">XHTML2 Lists</bibl>
        </blist>
      </div1>
    </body>
</spec>
