Displaying Turtle and more XHTML
authorGavin Carothers <gavin@carothers.name>
Fri, 23 Sep 2011 13:53:04 -0700
changeset 153 e8e55b809b94
parent 152 412015e1cc6f
child 154 164a635f064e
Displaying Turtle and more XHTML
rdf-turtle/index.html
--- a/rdf-turtle/index.html	Fri Sep 23 13:27:25 2011 -0700
+++ b/rdf-turtle/index.html	Fri Sep 23 13:53:04 2011 -0700
@@ -859,7 +859,7 @@
       <section id="in-html">
         <h2>Turtle in HTML</h2>
         <p>HTML ([[!HTML5]]) <code>script</code> <a href="http://dev.w3.org/html5/spec/Overview.html#scripting-1">tags</a> 
-        can be used to embed data blocks in pages. Turtle can be easily embedded in HTML this way.</p>
+        can be used to embed data blocks in documents. Turtle can be easily embedded in HTML this way.</p>
         <pre class="example">
 &lt;script type="text/turtle">
 @prefix dc: &lt;http://purl.org/dc/terms/> .
@@ -878,16 +878,43 @@
      dc:type &lt;http://books.example.com/product-types/EBOOK> .
 &lt;/script>
         </pre>
-        <p>Turtle content should be placed in <code>script</code> with the 
+        <p>Turtle content should be placed in a <code>script</code> tag with the 
         <code>type</code> attribute set to <code>text/turtle</code>. <code>&lt;</code> and <code>&gt;</code> symbols
         do not need to be escaped inside of script tags. The character encoding of the embedded Turtle
         MUST match the HTML documents encoding.</p>
         <section>
           <h3>XHTML</h3>
-          <p>There are some special steps that need to be taken when publishing Turtle in XHTML rather then HTML (text/html)
+          <p>
+          Like JavaScript Turtle authored for HTML (<code>text/html</code>) can break when used in an XHTML 
+          (<code>application/xhtml+xml</code>). The solution is the same one used for JavaScript.
           </p>
-          <p class="issue">
-          Still needs CDATA and commenting for XHTML explained. Polyglut issues.
+        <pre class="example">
+&lt;script type="text/turtle">
+<strong># &lt;![CDATA[</strong>
+@prefix frbr: &lt;http://purl.org/vocab/frbr/core#> .
+
+&lt;http://books.example.com/works/45U8QJGZSQKDH8N> a frbr:Work .
+<strong># ]]></strong>
+&lt;/script>
+        </pre>
+          <p>When embedded in XHTML Turtle data blocks MUST be enclosed in CDATA sections. Those CDATA markers MUST be 
+          in Turtle comments. This will also make Turtle safe in polyglut documents served as both <code>text/html</code>
+          and <code>application/xhtml+xml</code>.</p>
+        </section>
+        <section>
+          <h3>Displaying Examples</h3>
+          <p>
+          It is possible to display the contents of script tags containing Turtle for use in examples or other guides
+          using Cascading Style Sheets Selectors Level 3 ([[SELECT]]).
+<pre class="example">
+script[type='text/turtle'] {
+  display:block;
+  white-space: pre;
+  font-family: monospace;
+}
+</pre>
+          However, this creates issues with polyglut documents. If you wish to display Turtle from script tags you 
+          SHOULD only use <code>text/html</code>.
           </p>
         </section>
         <section id="in-html-parsing">