xquery version "1.0"; (: XQuery script to format SPARQL Query Results XML Format into xhtml Copyright © 2004, 2005 World Wide Web Consortium, (Massachusetts Institute of Technology, European Research Consortium for Informatics and Mathematics, Keio University). All Rights Reserved. This work is distributed under the W3C® Software License [1] in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. [1] http://www.w3.org/Consortium/Legal/2002/copyright-software-20021231 $Id$ :) declare namespace res="http://www.w3.org/2005/sparql-results#"; declare default element namespace "http://www.w3.org/1999/xhtml"; (: URI of input SPARQL Query Results document :) declare variable $results-doc := doc( "output.srx" ); (: How to set serialization parameters? :) (: doctype-system = "-//W3C//DTD XHTML 1.0 Transitional//EN" :) (: doctype-public = "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd"> :) declare variable $variableNames := for $element in $results-doc/res:sparql/res:head/res:variable return string( $element/@name ) ; declare function local:head($head as node()) {
Link to { string( $link/@href ) }
}Value: { string ($bool) }
Ordered: { string( $vbr/@ordered ) }
Distinct: { string( $vbr/@distinct ) }
{$name} | }
---|
{ if ($item/res:bnode) then (: blank node value :) ( "nodeID ", $item/res:bnode/text() ) else if ($item/res:uri) then (: URI value :) ( "URI ", $item/res:uri/text() ) else if ($item/res:literal/@datatype) then (: datatyped literal value :) fn:concat ( $item/res:literal, " (datatype ", $item/res:literal/@datatype, ")" ) else if ($item/res:literal/@xml:lang) then (: lang-string :) fn:concat ( $item/res:literal, "@", $item/res:literal/@xml:lang ) else if ($item/res:literal/res:unbound) then (: unbound variable - empty cell :) "[unbound]" else if ( exists($item/res:literal/text()) ) then (: present and not empty :) $item/res:literal/text() else if ( exists($item/res:literal) ) then (: present and empty :) "[empty literal]" else (: unbound variable - empty cell :) "[unbound]" } | }