Added tdef/tref integrity checks with a couple of fixes.
--- a/microdata-rdf/index.html Tue Oct 18 18:43:55 2011 -0700
+++ b/microdata-rdf/index.html Wed Oct 26 12:37:16 2011 -0700
@@ -47,6 +47,7 @@
}
// now do terms
refs = document.querySelectorAll('tdef') ;
+ var tdefs = [];
for (var i = 0; i < refs.length; i++) {
var item = refs[i];
if (!item) continue ;
@@ -57,10 +58,15 @@
ref = item.textContent ;
}
if (ref) {
- ref = ref.replace(/\n/g, '_') ;
- ref = ref.replace(/\s+/g, '_') ;
+ ref = ref.replace(/\s+/g, '_').toLowerCase() ;
}
+
+ if ( tdefs[ref]) {
+ throw "Duplicate definition of term '" + ref + "'" ;
+ }
+
var sp = document.createElement( 'dfn' ) ;
+ tdefs[ref] = sp ;
sp.title = ref ;
sp.innerHTML = con ;
p.replaceChild(sp, item) ;
@@ -77,10 +83,12 @@
ref = item.textContent ;
}
if (ref) {
- ref = ref.replace(/\n/g, '_') ;
- ref = ref.replace(/\s+/g, '_') ;
+ ref = ref.replace(/\s+/g, '_').toLowerCase() ;
}
+ if ( !tdefs[ref]) {
+ throw "Reference to undefined term '" + ref + "'" ;
+ }
var sp = document.createElement( 'a' ) ;
var id = item.textContent ;
sp.className = 'tref' ;
@@ -369,7 +377,7 @@
to ensure that values returned are consisted with this spec.
</div>
<dl>
- <dt>If the element also has an <tref>itemscope</tref> attribute</dt>
+ <dt>If the element also has an <aref>itemscope</aref> attribute</dt>
<dd>
The value is the <tref>item</tref> created by the element as a <tref>URI reference</tref> or
<tref>blank node</tref>
@@ -572,7 +580,7 @@
following the last SOLIDUS U+002F ("/") or NUMBER SIGN U+0023 ("#") in <em>type</em> and append
the fragment escaped value of <em>name</em>. If <em>type</em> contains no
SOLIDUS U+002F ("/") or NUMBER SIGN U+0023 ("#") it may not be used for generating a predicate
- URI; skip this property and any associated <tref>property value</tref>s
+ URI; skip this property and any associated <tref>property value</tref>s.
</li>
<li>
Let <em>value</em> be the <tref>property value</tref> of <em>element</em>.