This HTML5 document contains 34 embedded RDF statements represented using HTML+Microdata notation.

The embedded RDF content will be recognized by any processor of HTML5 Microdata.

PrefixNamespace IRI
dctermshttp://purl.org/dc/terms/
n12http://lod.openlinksw.com/sparql/
atomhttp://atomowl.org/ontologies/atomrdf#
foafhttp://xmlns.com/foaf/0.1/
n9http://vos.openlinksw.com/dataspace/services/wiki/
oplhttp://www.openlinksw.com/schema/attribution#
n2http://vos.openlinksw.com/dataspace/owiki/wiki/VOS/
n17http://vos.openlinksw.com/wiki/main/VOS/VirtSPARQLXSLT/xslt1.
dchttp://purl.org/dc/elements/1.1/
n20http://vos.openlinksw.com/dataspace/dav#
rdfshttp://www.w3.org/2000/01/rdf-schema#
n10http://rdfs.org/sioc/services#
siocthttp://rdfs.org/sioc/types#
n7http://vos.openlinksw.com/dataspace/person/dav#
n22http://vos.openlinksw.com/dataspace/owiki/wiki/VOS/VirtSPARQLXSLT/sioc.
n14http://vos.openlinksw.com/wiki/main/VOS/VirtSPARQLXSLT/xslt2.
n6http://vos.openlinksw.com/dataspace/owiki/wiki/
rdfhttp://www.w3.org/1999/02/22-rdf-syntax-ns#
n15http://vos.openlinksw.com/dataspace/owiki#
xsdhhttp://www.w3.org/2001/XMLSchema#
siochttp://rdfs.org/sioc/ns#
n16http://cname/friends/
n4http://vos.openlinksw.com/dataspace/person/owiki#
Subject Item
n7:this
foaf:made
n2:VirtSPARQLXSLT
Subject Item
n20:this
sioc:creator_of
n2:VirtSPARQLXSLT
Subject Item
n9:item
n10:services_of
n2:VirtSPARQLXSLT
Subject Item
n15:this
sioc:creator_of
n2:VirtSPARQLXSLT
Subject Item
n6:VOS
sioc:container_of
n2:VirtSPARQLXSLT
atom:entry
n2:VirtSPARQLXSLT
atom:contains
n2:VirtSPARQLXSLT
Subject Item
n2:VOSIndex
sioc:links_to
n2:VirtSPARQLXSLT
Subject Item
n2:VirtSPARQLXSLT
rdf:type
sioct:Comment atom:Entry
dcterms:created
2017-06-13T05:49:04.175392
dcterms:modified
2017-06-29T07:40:18.549797
rdfs:label
VirtSPARQLXSLT
foaf:maker
n4:this n7:this
dc:title
VirtSPARQLXSLT
opl:isDescribedUsing
n22:rdf
sioc:has_creator
n15:this n20:this
sioc:attachment
n14:png n17:png
sioc:content
%META:TOPICPARENT{name="VOSIndex"}% ---+ Guide to using SPARQL inside XSLT This guide demonstrates how Virtuoso allows SPARQL queries to be embedded into an XSLT style sheet, and executed against a remote SPARQL endpoint (here, we use the [[http://lod.openlinksw.com/sparql/][LOD Cloud Cache]]) to retrieve data for use in HTML output. ---++Implementation * The key component of this feature is the <code>&lt;xsl:for-each-row&gt;</code> control element. This element has one attribute, named either <code>"sparql"</code> or <code>"sql"</code>; the value of the attribute is an XPath expression that returns the text of the query to executed, e.g., <verbatim> <xsl:for-each-row sparql="string(\044query)"> </verbatim> * The XPath expression can be a plain string constant, but because the query can be quite long, it is usually more convenient to store the text in a variable and refer to that variable. * The SPARQL query may contain parameters (written in the form <code>?:name</code>). A parameter of this sort will get its value from the XSLT variable <code>$name</code>. (If there is any nesting or recursion, the value(s) will come from the innermost variables.) * The query execution in turn creates new XSLT variables that exist inside the body of <code>&lt;xsl:for-each-row&gt;</code>. Each result column of a query becomes one XSLT variable. * The body of <code>&lt;xsl:for-each-row&gt;</code> is instantiated once for each row of the query result set, with new values for the variables in each instantiation. ---++Example 1 Execute from iSQL: <verbatim> SQL> xslt_sheet ('local://friends.xsl', xtree_doc ('<xsl:stylesheet xmlns:xsl = "http://www.w3.org/1999/XSL/Transform" version = "1.0" xmlns:sample="http://xslt/" > <xsl:output method = "html" version="1.0" doctype-public="http://public" doctype-system="http://system" /> <xsl:param name="fname" select="''Kingsley''" /> <xsl:param name="lname" select="''Idehen''" /> <xsl:param name="fullname" select="''Kingsley Idehen''" /> <xsl:variable name = "query"> <![CDATA[ PREFIX foaf: <http://xmlns.com/foaf/0.1/> SELECT DISTINCT ?maxlinkg ?fnick ?ffullname ?ffname ?flname ?fimg WHERE { SERVICE <http://lod.openlinksw.com/sparql/> (DEFINE lang:dialect 65535) { { SELECT DISTINCT ?maxlinkg ?fg ?fnick ?ffullname ?ffname (bif:__max_notnull (?flname1, ?flname2)) AS ?flname ?fimg WHERE { { SELECT (MAX(?linkg)) AS ?maxlinkg ?f WHERE { { SELECT DISTINCT ?k WHERE { GRAPH ?kg { { ?k foaf:firstName ?:fname ; foaf:familyName ?:lname } UNION { ?k foaf:firstName ?:fname ; foaf:family_name ?:lname } UNION { ?k foaf:name ?:fullname } } } } GRAPH ?linkg { ?k foaf:knows ?f } } } GRAPH ?fg { ?f a <http://xmlns.com/foaf/0.1/Person> . OPTIONAL { ?f foaf:firstName ?ffname } OPTIONAL { ?f foaf:nickname ?fnick } OPTIONAL { ?f foaf:name ?ffullname } OPTIONAL { ?f foaf:familyName ?flname1 } OPTIONAL { ?f foaf:family_name ?flname2 } OPTIONAL { ?f foaf:img ?fimg } } FILTER ( bound ( ?ffullname ) || ( bound ( ?ffname ) &amp;&amp; ( bound ( ?flname1 ) || bound ( ?flname2 ) ) ) ) } ORDER BY ?fullname ?ffname } } } ]]></xsl:variable> <xsl:template match = "/"> <html><head>Simple demo for SPARQL inside XSLT</head> <body> <p>Known friends of <xsl:choose> <xsl:when test="\044fullname"><xsl:value-of select="\044fullname" /></xsl:when> <xsl:otherwise><xsl:value-of select="\044fname" />&nbsp;<xsl:value-of select="\044lname" /></xsl:otherwise> </xsl:choose></p> <table> <xsl:for-each-row sparql="string(\044query)"> <tr><td><xsl:if test="\044fimg"><a href="{\044fimg}" ><img src="{\044fimg}" width="64" height="64" /></a></xsl:if></td> <td><a href=".?fname={\044ffname}&lname={\044flname}&fullname={\044ffullname}"> <b><xsl:choose> <xsl:when test="\044ffullname"><xsl:value-of select="\044ffullname" /></xsl:when> <xsl:otherwise><xsl:value-of select="\044ffname" />&nbsp;<xsl:value-of select="\044flname" /></xsl:otherwise> </xsl:choose></b></a><br /> <xsl:if test="\044fnick">Nick: <xsl:value-of select="\044fnick" /><br /></xsl:if> (data from <a href="{\044maxlinkg}" ><xsl:value-of select="\044maxlinkg" /></a> <!-- and <a href="{\044maxfg}" ><xsl:value-of select="\044maxfg" /></a>-->) </td></tr> </xsl:for-each-row> </table> </body> </html> </xsl:template> </xsl:stylesheet>')); DB.DBA.VHOST_DEFINE ( lpath=>'/friends/', ppath => '/!friends/', is_dav => 1, vsp_user => 'dba', opts => vector('noinherit', 1) ); CREATE PROCEDURE WS.WS."/!friends/" ( INOUT path VARCHAR, INOUT params ANY, INOUT lines ANY ) { http_value (xslt ('local://friends.xsl', xtree_doc ('<fake />'), params)); } ; registry_set ('/!friends/', 'no_vsp_recompile') ; </verbatim> 1 Go to [[http://cname/friends/][http://cname/friends/]], where results should look something like this: %BR%%BR%<img src="%ATTACHURLPATH%/xslt1.png" style="wikiautogen"/>%BR%%BR% %BR%%BR%<img src="%ATTACHURLPATH%/xslt2.png" style="wikiautogen"/>%BR%%BR%
sioc:id
c7e78bac175e36d1ca64e3ebdc96131f
sioc:link
n2:VirtSPARQLXSLT
sioc:has_container
n6:VOS
n10:has_services
n9:item
atom:title
VirtSPARQLXSLT
sioc:links_to
n12: n16:
atom:source
n6:VOS
atom:author
n7:this
atom:published
2017-06-13T05:49:04Z
atom:updated
2017-06-29T07:40:18Z
sioc:topic
n6:VOS