Skip to content

Instantly share code, notes, and snippets.

@bpanulla
Created April 14, 2011 18:18
Show Gist options
  • Save bpanulla/920121 to your computer and use it in GitHub Desktop.
Save bpanulla/920121 to your computer and use it in GitHub Desktop.
Taffy Representation class for rendering a Jena model into the various RDF serializations
<cfcomponent extends="taffy.core.baseRepresentation" output="false">
<cfinclude template="/include/CleanHighAscii.cfm">
<!--- Property to receive injected references --->
<cffunction name="init" access="public" returntype="RDFRepresentation">
<cfargument name="rubricUtil" type="org.rubrichub.util.RubricUtil" required="true" />
<cfset variables.rubricUtil = arguments.rubricUtil>
<cfreturn this />
</cffunction>
<!---
HTML5 with RDFa attributes (.html)
http://www.w3.org/TR/rdfa-in-html/#document-conformance
--->
<cffunction
name="getAsHTML"
output="false"
taffy:mime="text/html"
taffy:default="true"
hint="returns model as HTML5+RDFa">
<cfparam name="variables.data" type="any">
<cfreturn variables.rubricUtil.rubricModelToHTML(variables.data) />
</cffunction>
<!---
XHTML with RDFa attributes (.xhtml)
http://www.w3.org/TR/2010/WD-xhtml-rdfa-20100803/#document-conformance
--->
<!---<cffunction
name="getAsXHTML"
output="false"
taffy:mime="application/xhtml+xml"
taffy:default="false"
hint="returns data as RDF/XML">
<cfparam name="variables.data" type="any">
<cfscript>
var local = {};
local.content = variables.data.write(byteStream, "RDF/XML-ABBREV");
</cfscript>
<cfreturn local.content />
</cffunction>--->
<!---
RDF XML Syntax (.rdf)
http://www.w3.org/TR/rdf-syntax-grammar/#section-MIME-Type
--->
<cffunction
name="getAsRDF"
output="false"
taffy:mime="application/rdf+xml"
taffy:default="false"
hint="returns data as RDF/XML">
<cfparam name="variables.data" type="any">
<cfreturn CleanHighAscii(variables.data.dump("RDF/XML-ABBREV")) />
</cffunction>
<!---
RDF Notation3 (N3) Syntax (.n3)
http://www.w3.org/DesignIssues/Notation3
--->
<cffunction
name="getAsN3"
output="false"
taffy:mime="text/n3"
taffy:default="false"
hint="returns data as RDF Notation3 (N3) serialization">
<cfparam name="variables.data" type="any">
<cfreturn variables.data.dump("N3") />
</cffunction>
<!---
RDF N-Triples Syntax (.nt)
http://www.w3.org/TR/rdf-testcases/#ntriples
--->
<cffunction
name="getAsNT"
output="false"
taffy:mime="text/plain"
taffy:default="false"
hint="returns data as RDF N-Triples (NT) serialization">
<cfparam name="variables.data" type="any">
<cfreturn variables.data.dump("N-TRIPLE") />
</cffunction>
<!---
RDF Turtle Syntax (.ttl)
http://en.wikipedia.org/wiki/Turtle_%28syntax%29
--->
<cffunction
name="getAsTTL"
output="false"
taffy:mime="text/turtle"
taffy:default="false"
hint="returns data as RDF Turtle serialization">
<cfparam name="variables.data" type="any">
<cfreturn variables.data.dump("TTL") />
</cffunction>
</cfcomponent>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment