VirtSparqlCxmlPivot CollectionsPivot Collections Contents Part 1: Introduction Introduction Creating Collections Virtuoso Support for Pivot Collections UNKNOWN tag: http://www.w3.org/1999/xhtml:nowikiPivotViewer Combining A Human UI with Machine Readable Data A Viewer for Hypermedia-based Structured Data Configuring Virtuoso's CXML Support Verifying your installation UNKNOWN tag: http://www.w3.org/1999/xhtml:nowikiImageMagick CXML Generation from /sparql Part 2: SparqlCxml UNKNOWN tag: http://www.w3.org/1999/xhtml:nowikiSparqlCxml UNKNOWN tag: http://www.w3.org/1999/xhtml:nowikiPivotViewer & Collection XML - Key Parts UNKNOWN tag: http://www.w3.org/1999/xhtml:nowikiPivotViewer UI Collection XML SPARQL Endpoint CXML Extensions RDF to CXML Mapping - The Basic Approach SELECT DESCRIBE and CONSTRUCT Default Settings Auto-Detection of Facet Type UNKNOWN tag: http://www.w3.org/1999/xhtml:nowikiSparqlCxml Reserved Query Variables Examples Query Variable Order Reserved Query Variables for Geodata Graph virtcxml UNKNOWN tag: http://www.w3.org/1999/xhtml:nowikivirtcxml:FacetType Setting an Item's Image Setting an Item's Name Setting an Item's Description Setting a Facet's Name Setting a Facet's Datatype Setting the Facet Used to Generate a QR code Excluding a Facet from the Filter Panel Using Labels in Place of URIs Exploiting Inferencing Automatic Labels Label Localization Link Typing Link Typing Options Controlling Link Typing through /sparql Query String Parameters Controlling Link Typing through Virtuoso/PL Part 3: SparqlCxml Deep Zoom Collections Part 4: PivotViewer Part 5: Importing CXML Part 6: Facet Pivot Bridge Part 7: DETs : Persisting SPARQL Query Results to DAV Part 8: Frequently Asked Questions (FAQs) Part 9: Glossary Introduction Microsoft's PivotViewer is a Silverlight control which makes it easy to view, sort and filter huge datasets on the web. PivotViewer lets you view thousands of items at once and visualize them in ways that expose relationships, groupings or trends in the data. PivotViewer's powerful sorting and filtering make it simple to drill down into a large dataset to an item of interest with specific features. This functionality makes it a powerful tool in application domains such as business intelligence or deep comparison shopping. Central to PivotViewer is the notion of a Collection. Collections combine large groups of similar items on the internet, allowing the web to be viewed as a web of data rather than a series of isolated pages. Collections are composed of two parts: XML - The items in the collection are described in XML, in a ".cxml" file. Images - The images in the collection are described in Deep Zoom format. Conceptually, a collection is just like any other web content. There?s a set of files on a server, and a local client that knows how to display them. In the current web, the files are traditionally HTML and images. In the collection case, the files are CXML and Deep Zoom-formatted (DZC) images. When the user views the collection from a web browser, a web page hosting the PivotViewer Silverlight Control is used to display the files.
Creating Collections Creating a collection has four distinct steps:Pick your data - First, pick a set of data to turn into a collection. Create XML and images - Describe the data in Collection XML (CXML) and transform the images to the Deep Zoom format. Host the collection - To share your collection with others, host it on a web server. View it - View the collection in a browser by downloading a web page which hosts the PivotViewer Silverlight control. Virtuoso Support for Pivot Collections Virtuoso Universal Application Server is an ideal platform for creating and hosting Pivot collections, combining amongst other things a powerful hybrid RDF/SQL/XML data store and HTTP server, which together support each of the collection creation steps outlined above. Virtuoso provides the ability to generate and view dynamic collections created directly from RDF data, with automatic Deep Zoom image generation, using custom or default images, and the option of including QR codes (matrix bar codes). The source RDF data may be hosted directly in Virtuoso, or extracted from external RDF and non-RDF data sources using the Virtuoso Sponger, or from SQL data using Linked Data Views or SPASQL. Though designed from the outset as a viewer for web data, the reach and utility of PivotViewer are enhanced greatly by driving it using RDF as the "data substrate", the same standards-based data format used by the Data Web and the basis of numerous massive open datasets hosted in the Linked Open Data cloud. To provide this RDF underpinning, the main components of Virtuoso's CXML offering comprise: SparqlCxml - An extension of Virtuoso's standard /sparql endpoint functionality to allow serialization of SPARQL query result sets as CXML PivotViewer - A cross-browser Pivot collection viewer, hosting the Silverlight PivotViewer control, for viewing Virtuoso-hosted or external 3rd party Pivot collections. Facet Pivot Bridge - A bridge to PivotViewer from Virtuoso's Faceted query service for RDF, offering the facility to save Faceted search result sets as Pivot collections. PivotViewer Combining A Human UI with Machine Readable Data Part of what makes PivotViewer compelling as a viewer for the Data Web is its use of images in place of raw URIs. The RDF browsers available to date typically present little more than lists of entity URIs. In contrast, PivotViewer uses an image, rather than an entity URI, as the primary UI representation of the entity, making for a much more intuitive user experience. While the image tiles provide visual cues for human interaction, the underlying machine readable RDF data remains accessible via hyperlinks. To further support this interaction paradigm, Virtuoso's CXML support includes other refinements not evident in typical Pivot collections. These include: the ability to generate collections comprising a mix of several entity types, in contrast to Pivot collections from other sources which support only one entity type the use of icons to supply default images for entities which do not have their own (custom) image an extensible icon ontology to associate different icons with different entity classes The screenshot below shows a Virtuoso generated collection displayed by the Virtuoso PivotViewer, a small VSP-based (Virtuoso Server Pages) application hosting the Silverlight PivotViewer control. The screenshot illustrates the use of a silhouette icon for members of the Frankfurt Semantic Web Meetup group who do not have a foaf:image.
The source data for the above collection was supplied by a SPARQL DESCRIBE query: describe ?s from <http://www.meetup.com/Frankfurt-Semantic-Web-Meetup/members/> where {?s a foaf:Person} limit 2000 submitted to the SPARQL endpoint at http://linkeddata.uriburner.com/sparql via the PivotViewer at http://linkeddata.uriburner.com/PivotViewer/. The full request URI being: http://linkeddata.uriburner.com/PivotViewer/?url=http%3A%2F%2Flinkeddata.uriburner.com%2Fsparql%3Fdefault-graph-uri%3D%26query%3Ddescribe%2520%253Fs%2520from%2520%253Chttp%253A%252F%252Fwww.meetup.com%252FFrankfurt-Semantic-Web-Meetup%252Fmembers%252F%253E%2520where%2520%257B%253Fs%2520a%2520foaf%253APerson%257D%2520limit%25202000%250D%250A%26timeout%3D%26should-sponge%3D%26format%3Dtext%252Fcxml%26CXML_redir_for_subj%3D%26CXML_redir_for_hrefs%3D A Viewer for Hypermedia-based Structured Data While at first glance PivotViewer might be seen as a viewer for RDF data, the utility of PivotViewer and Virtuoso's SparqlCxml subsystem extends beyond RDF. While intended to be a general method of representing information, RDF is nonetheless a form of EAV (Entity-Attribute-Value) model where data is overtly defined and constrained by a conceptual schema that's based on first-order logic. Thus, PivotViewer should be seen in the broader context as a viewer for EAV model data at intranet or interweb scales. The EAV model coupled with the use of dereferenceable identifiers in the entity, attribute or value slots enables the use of hypermedia resources for structured data representation and interchange, more commonly known as Linked Data. It's extremely important to note that Linked Data is not (in any way) inextricably bound to RDF. In this broader (format agnostic) definition of Linked Data, data definition and description is expressed using EAV tuples where each of the following are uniquely discernible: entities (aka subjects) entity attributes (aka subject attributes) and attribute values (aka subject attribute values) Each tuple is a proposition (due to its first-order logic grounding) as well as a database record. Each entity (object) has a dereferenceable ID, a hypermedia link, that resolves to the address of its representation. This representation is negotiable, courtesy of HTTP content-negotiation. It is important to recognize that RDF defines a data model and Subject-Predicate-Object (or Entity-Attribute-Value) 3-tuples (triples) statements (proposition oriented records) that can be expressed in a wide variety of syntaxes that includes: RDF/XML, Turtle, N3, N-Triples, HTML+RDFa etc. At the model level its only tangible distinction from EAV is its overtness with regards to first-order logic foundation. At the data expression level SPO or EAV triples are indistinguishable bar RDF's emphasis on URI/IRI style identifiers in the Subject, Predicate, and Object (optionally) slots. In the context of PivotViewer as a Linked Data explorer, the CXML data format provides a generalized means of describing Linked Data/EAV data for display, while SPARQL provides a query language for specifying the Linked Data to be contained in the dynamic collection being generated. The Linked Data itself can comes from many sources. Virtuoso can ingest data from a plethora of data sources associated with a wide variety of formats that includes RDF, XML (including Web Services), SQL, various binary formats (iCalendar, vCard etc). Pivotviewer, together with SparqlCxml, provides: the ability to interact with Linked Data without the distraction of raw URIs. URIs are normally replaced by or hidden behind (via a link) the label of the entity they identify a powerful tool for drilling down into collections, whether static or dynamically generated from SPARQL queries, and for sharing dynamic collections through query URLs a front-end to utilize Virtuoso's free text search and, through the Pivot Facet Bridge, faceted query capabilities a Linked Data viewer with the focus on 'whole data' representation. Data is displayed at the conceptual level, rather than the logical level as typified by most database exploration tools. Whereas at the logical level, data is often split across tables as an artifact of normalization, the conceptual level provides a 'whole data' view in which the entities and the concepts they represent are no longer fragmented. The concepts remain the focal point of a user's interaction with the data. Configuring Virtuoso's CXML Support Support for CXML is available in the Virtuoso Commercial Edition Release 6.02.3129 or above. It is not included in Virtuoso Open-Source Edition. To enable the CXML functionality, the necessary VADs (Virtuoso Application Distribution) must be installed. These are: sparql_cxml - Supports CXML and Deep Zoom Collection (DZC) generation from a /sparql endpoint PivotViewer - A VSP-based collection viewer for viewing Virtuoso generated and 3rd party collections Requires: c_uri - A URI shortener for creating compressed URIs and optionally: fct_pivot_bridge - An extension to the Facets web service for generating collections from snapshots of faceted query result sets Requires: cartridges - Provides base RDF functionality and the Sponger framework for converting non-RDF data to RDF fct - Virtuoso Facets web service. A general purpose RDF query facility for facet based browsing sparql_cxml, PivotViewer Any VAD listed under 'Requires' must be installed before the VAD under which it appears. In addition, to support Deep Zoom image and QRcode generation, the Virtuoso ImageMagick and QRcode plugins must be installed. A Virtuoso distribution includes both the ImageMagick plugin (im.so or im.dll) and QRcode plugin (qrcode.so or qrcode.dll) as standard. The plugins should be enabled in the Plugins section of your virtuoso.ini file, e.g.: [Plugins] LoadPath=../hosting Load1=Hosting,hosting_perl.so ... Load6=plain, im Load7=plain, qrcode The supporting ImageMagick or QRcode libraries used by these plugins are statically linked, so there is no need to install them separately. Finally, ensure that the DefaultHost parameter under the URIQA section of your virtuoso.ini file is set appropriately for the host. If you anticipate viewing collections served by a host other than the one hosting PivotViewer, cross-domain access must be enabled as detailed in Part 4: PivotViewer, section "Cross-domain Collection Browsing". Verifying your installation ImageMagick To confirm that the ImageMagick plugin is working, execute the following query through Conductor's ISQL interface and check that the return value is 3. select "IM XYtoMorton"(1,1) CXML Generation from /sparql The sparql_cxml VAD creates a small amount of test data for verifying the installation. In Conductor's /sparql interface (e.g. http://localhost:8890/sparql), enter the query below and select 'CXML' from the 'Format Results As' dropdown before running it. prefix ski: <http://www.openlinksw.com/ski_resorts/schema#> prefix camp: <http://www.openlinksw.com/campsites/schema#> describe ?s where {{ ?s a ski:SkiResort . } union { ?s a camp:Campsite . }} Your browser should display the generated CXML file. Copy the URL from your browser's address bar, open a browser window to /PivotViewer (e.g. http://localhost:8890/PivotViewer/) and paste the SPARQL query URL into the 'Pivot collection URL' textbox. After clicking 'Submit', you should see a collection view similar to that below:
Click to enlarge SparqlCxml A Virtuoso /sparql endpoint can render a SPARQL query result in numerous serialization formats, one of which is CXML. The query driving the CXML generation may be a SELECT, DESCRIBE or a CONSTRUCT. The CXML generation process essentially consists of mapping the entities, attributes and values contained in the SPARQL result set to CXML Items, Facets and Facet values. SparqlCxml allows a high degree of control over the SPARQL to CXML mapping through the use of reserved query variables and a configuration graph virtcxml. PivotViewer & Collection XML - Key Parts Before describing the Virtuoso RDF to Pivot interface, it's worthwhile to identify the main components of the PivotViewer UI and Collection XML to establish the terminology for the remainder of the text. PivotViewer UI The main parts of the PivotViewer UI are identified below:
Collection XML The following sample XML specifies a simple collection with only one item. <?xmlversion="1.0"?> <CollectionName="Hello World Collection"SchemaVersion="1.0" xmlns="http://schemas.microsoft.com/collection/metadata/2009" xmlns:p="http://schemas.microsoft.com/livelabs/pivot/collection/2009" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xmlns:xsd="http://www.w3.org/2001/XMLSchema"> <FacetCategories> <FacetCategory Name="Hello World Facet Category One" Type="String"/> </FacetCategories> <Items ImgBase="helloworld.dzc"> <Item Img="#0" Id="0" Href="http://www.getpivot.com"Name="Hello World!"> <Description>This is the only item in the collection.</Description> <Facets> <Facet Name="Hello World Facet Category One"> <String Value="Hello World Facet Value"/> </Facet> </Facets> </Item> </Items> </Collection> Each part of the XML is surfaced in the PivotViewer as depicted below:
SPARQL Endpoint CXML Extensions The Virtuoso SPARQL protocol endpoint /sparql supports a number of extensions to the SPARQL standard specifically for CXML. "text/cxml" and "text/cxml+qrcode" have been added to the list of formats recognized by the query string 'format' parameter. The "text/cxml" output format is available for SELECT, DESCRIBE and CONSTRUCT. "text/cxml+qrcode" is available only for DESCRIBE and CONSTRUCT. e.g. http://uriburner.com/sparql?default-graph-uri=&should-sponge=&query=select+*+WHERE+{%3Fhref+a+foaf%3APerson%3B+foaf%3Aname+%3Fname%3B+foaf%3Adepiction+%3Fimage}+limit+20&format=text%2Fcxml When using the /sparql UI, these format options are activated by selecting either "CXML (Pivot Collection)" or "CXML (Pivot Collection with QRcodes)" from the "Format Results As" dropdown. For DESCRIBE and CONSTRUCT, the "text/cxml+qrcode" output option adds a QRcode adjacent to the custom or default image for each item. For SELECT, the addition or omission of a QRcode alongside the item image is controlled through the ?qrcode reserved query variable. Corresponding pragmas ' define output:format "CXML" ' and ' define output:format "CXML;QRCODE" ' are available for when executing SPARQL queries directly from Virtuoso PL or from a Virtuoso client. e.g. sparql define output:format "CXML" select * WHERE { ?href a foaf:Person; foaf:name ?name; foaf:depiction ?image } limit 20 RDF to CXML Mapping - The Basic Approach The way in which SPARQL result sets are converted to CXML differs for SELECTs and DESCRIBEs or CONSTRUCTs. The broad approach is outlined below to explain the default mapping. Options for tailoring the default mapping are described in subsequent sections. SELECT Each distinct subject URI forms a CXML Item whose Name and Href are the subject URI. Each variable in the query which is not a subject URI becomes a facet named virtcxml:Facetvariable; where the variable name is converted to title case. The variables' values become the values of the corresponding facet. The default type of each facet is CXML String. A query such as: prefix ski: <http://www.openlinksw.com/ski_resorts/schema#> prefix camp: <http://www.openlinksw.com/campsites/schema#> select * where { { ?s a ski:SkiResort . ?s ?p ?o . optional { ?s foaf:depiction ?image } } union { ?s a camp:Campsite . ?s ?p ?o . optional { ?s foaf:depiction ?image } } } creates a collection with facet categories virtcxml:FacetP and virtcxml:FacetO, as shown in the CXML document tree fragment below. ?image is one of several special variables reserved for controlling the RDF to CXML mapping. These reserved variables are not used as facets.
The default facet names generated by a SELECT, in this example virtcxml:FacetP and virtcxml:FacetO, can be changed through graph virtcxml: as described below. DESCRIBE and CONSTRUCT Like SELECT, each distinct subject URI again forms a CXML Item whose Name and Href are the subject URI. Unlike SELECT, no other query variables play a part in determining the facet categories. Instead they are derived directly from the DESCRIBE or CONSTRUCT output, whereby each distinct predicate, i.e. property, becomes a facet category. Each predicate value becomes a facet value. The full set of facet categories is a union of the properties of each entity type in the result set. Again, the default type of each facet is CXML String. The query: describe ?s where {{ ?s a ski:SkiResort } union { ?s a camp:Campsite . }} creates the facet categories shown below. Notice that the reserved variable ?image is not used to identify which entity property will provide the Deep Zoom images. Only SELECTs use reserved variables to tailor the CXML mapping. DESCRIBE and CONSTRUCT instead use entries in graph virtcxml: to both identify which entity properties supply particular CXML names and attributes and, if automatic facet type detection isn't possible, to override the default facet type of CXML String.
Default Settings The default settings for the CXML generation include the following defaults: FacetCategory attributes Name Defaults to a short property name, without a prefix. e.g. Predicate http://www.openlinksw.com/campsites/schema#distance_from_calais_km becomes a FacetCategory with Name="distance_from_calais_km" Type Defaults to CXML type "String" if the RDF data is not typed. If the data is typed, for example through an RDF typed literal, SparqlCxml sets the appropriate CXML facet type automatically. IsFilterVisible, IsMetaDataVisible, IsWordWheelVisible All default to "true" Facet attributes Name As with the FacetCategory Name attribute, defaults to a short property name. Type As with the FacetCategory Type attribute, defaults to "String". Item attributes Name Defaults to the URI of the entity described by the Item element Href Defaults to the URI of the entity described by the Item element Auto-Detection of Facet Type RDF typed literals are automatically mapped to the appropriate CXML type. The xsd:integer, xsd:float, xsd:double and xsd:decimal types are mapped to CXML Number, xsd:datetime is mapped to CXML DateTime and strings longer than 100 characters are mapped to CXML LongString. e.g. :Le_Jard oplcamp:last_updated "2010-12-01T00:00:00Z"^^xsd:dateTime . :La_Plagne oplski:expert_slopes "18"^^xsd:integer . Properties of type CXML Number can be filtered using the PivotViewer "slider filter" (shown below associated with the ski_resort:expert_slopes property/facet) to restrict the displayed items to those within a certain range of the property.
Similarly, PivotViewer enables a date filter for CXML DateTime values.
RDF values which are URIs are handled as a special case. They may be mapped to a CXML Link, String or LongString depending on the SparqlCxml link typing options in force. These are described in section Link Typing SparqlCxml Reserved Query Variables SparqlCxml defines a list of reserved variables for use in SPARQL SELECTs to identify which predicates are to be used to set particular CXML element and attribute values. These reserved variables, or identifiers, are defined in graph virtcxml: which is created when the sparql_cxml VAD is installed. Each identifier is prefixed by virtcxml:Facet. The table below lists the virtcxml:Facetxxx Facet descriptors defined in virtcxml:, the reserved variable used to denote each Facet descriptor in a SELECT and the corresponding CXML element or attribute whose value is set by the reserved variable. <tgroup><thead /><tbody> <row><entry> virtcxml Entity </entry><entry> Reserved SELECT variable </entry><entry> CXML Element/Attribute </entry><entry> Description </entry></row> <row><entry> virtcxml:FacetCopyright </entry><entry> ?copyright </entry><entry> Item/d1p1:Copyright </entry><entry> A facet for a copyright link about the item </entry></row> <row><entry> virtcxml:FacetDescription </entry><entry> ?description </entry><entry> Item/Description </entry><entry> A facet for a text description of an item to be displayed in the info panel </entry></row> <row><entry> virtcxml:FacetHref </entry><entry> ?href </entry><entry> Item/@Href </entry><entry> A facet for an URL associated with an item. Double-clicking the item in the Pivot client will navigate the user to this URL </entry></row> <row><entry> virtcxml:FacetId </entry><entry> ?id </entry><entry> Item/@Id </entry><entry> A facet for an unique id of an item in the item list. If not specified the decimal representation of serial is used </entry></row> <row><entry> virtcxml:FacetImage </entry><entry> ?image </entry><entry> Item/@Img </entry><entry> A facet for an absolute URI of the image that will be added to an automatically created single-use collection </entry></row> <row><entry> virtcxml:FacetImg </entry><entry> ?img </entry><entry> Item/@Img </entry><entry> A facet for a relative image URI (for use with a third party Deep Zoom Collection) </entry></row> <row><entry> virtcxml:FacetItemtype </entry><entry> ?itemtype </entry><entry> - </entry><entry> A facet for an item type that is used, for example, to choose the fallback icon for the item </entry></row> <row><entry> virtcxml:FacetName </entry><entry> ?name </entry><entry> Item/@Name </entry><entry> A facet for a name of the item which will appear at the top of the info panel </entry></row> <row><entry> virtcxml:FacetQrcode </entry><entry> ?qrcode </entry><entry> Item/@Img </entry><entry> A facet for QRcode data that should be placed in the image </entry></row> <row><entry> virtcxml:FacetRelated </entry><entry> ?related </entry><entry> Item/d1p1:Related </entry><entry> A facet for links to web-pages or collections related to the item </entry></row> </tbody></tgroup></table> <para>The reserved variables are only used for a SELECT, not a DESCRIBE or CONSTRUCT. The last two query forms instead use graph virtcxml: to control the CXML mapping. For the moment, we'll confine our attention to SELECTs.</para> <para>The following example, which selects a number of products (or services), illustrates the use of the reserved ?name and ?image variables to identify which predicates, i.e. product attributes, will act as a product's name and image - in this case rdfs:label and foaf:depiction respectively.</para> <programlisting>select distinct * where { ?s a gr:ProductOrServiceModel; foaf:depiction ?image; rdfs:label ?name } limit 500 </programlisting><para> The prefix gr: identifies the GoodRelations namespace, <ulink url="http://purl.org/goodrelations/v1#.">http://purl.org/goodrelations/v1#.</ulink> (An explicit prefix declaration is not needed because this is a well-known namespace predefined in Virtuoso in table DB.DBA.SYS_XML_PERSISTENT_NS_DECL.)</para> <ulink url=""> <para> </para> <bridgehead class="http://www.w3.org/1999/xhtml:h4">Examples</bridgehead> <para>The queries below further illustrate the use of the reserved query variables. All can be executed against <ulink url="http://uriburner.com/sparql.">http://uriburner.com/sparql.</ulink> A snippet of the generated CXML is shown to highlight how an element or attribute is influenced by the variable(s). Refer to the <ulink url="#AncCxmlSurfacing">graphic</ulink> presented earlier for details of how different CXML elements are surfaced in PivotViewer.</para> <para> <emphasis>Example 1:</emphasis> </para> <programlisting>define input:inference "virtrdf-label" prefix geosp: <http://rdf.geospecies.org/ont/geospecies#> select distinct * where { ?s a <http://lod.taxonconcept.org/ontology/txn.owl#GeoSpeciesTaxon> ; foaf:depiction ?image ; virtrdf:label ?name ; geosp:hasCommonName ?cn ; geosp:hasClassName "Insecta" . } limit 2000 </programlisting><para><ulink url="http://uriburner.com/c/DIDNPP">View Pivot collection</ulink></para> <figure><graphic fileref="VirtSparqlCxml/qry_var_eg1.png" /></figure><para> <emphasis>Example 2:</emphasis> </para> <programlisting>define input:inference "virtrdf-label" select * where { ?s a <http://purl.org/ontology/wo/Species> ; <http://purl.org/ontology/wo/order> <http://www.bbc.co.uk/nature/order/Primate#order> ; <http://purl.org/ontology/wo/family> ?family ; <http://purl.org/ontology/wo/livesIn> ?lives_in ; foaf:depiction ?image; virtrdf:label ?name; dcterms:description ?description. ?href foaf:primaryTopic ?s . } limit 2000 </programlisting><para><ulink url="http://uriburner.com/c/DH6J27">View Pivot collection</ulink></para> <figure><graphic fileref="VirtSparqlCxml/qry_var_eg2.png" /></figure> <emphasis>Example 3:</emphasis> <programlisting>define input:inference "virtrdf-label" prefix geosp: <http://rdf.geospecies.org/ont/geospecies#> select distinct * where {?s a <http://lod.taxonconcept.org/ontology/txn.owl#GeoSpeciesTaxon> ; foaf:depiction ?image ; virtrdf:label ?name ; foaf:isPrimaryTopicOf ?href ; rdfs:seeAlso ?related ; geosp:hasCommonName "Tiger" ; geosp:hasClassName ?className . } limit 3000 </programlisting><para><ulink url="http://uriburner.com/c/DIDTV4">View Pivot collection</ulink></para> <figure><graphic fileref="VirtSparqlCxml/qry_var_eg3.png" /></figure> <emphasis>Example 4:</emphasis> <programlisting>prefix mtp: <http://www.openlinksw.com/schemas/meetup/> prefix dc: <http://purl.org/dc/elements/1.1/> select * from <http://www.meetup.com/semweb-25/members/> where { ?href ?p ?o ; foaf:depiction ?image; foaf:name ?name; mtp:id ?id; dc:description ?description .filter (!isBlank(?description)) } limit 200 </programlisting><para><ulink url="http://kingsley.idehen.net/PivotViewer/?url=http%3A%2F%2Fkingsley.idehen.net%2Fc%2FMRLBK%23%2524facet0%2524%3Dvirtcxml%253AFacetP%26%2524view%2524%3D1%26%24tab%24%3D0%26%24zoom%24%3D2">View Pivot collection</ulink></para> <figure><graphic fileref="VirtSparqlCxml/qry_var_eg4.png" /></figure> <emphasis>Example 5:</emphasis> <programlisting>PREFIX wo: <http://purl.org/ontology/wo/> SELECT DISTINCT ?s as ?href ?name ?kname ?image ?hname ?description WHERE {?s wo:kingdom ?kingdom; dcterms:description ?description; rdfs:label ?name; wo:livesIn ?habitat. ?kingdom rdfs:label ?kname. ?habitat rdfs:label ?hname OPTIONAL {?s foaf:depiction ?image.} } limit 2500 </programlisting><para><ulink url="http://uriburner.com/c/DI463N">View Pivot collection</ulink> </para> <emphasis>Example 6:</emphasis> <programlisting># Capture subject URI in QR code # Use foaf:name as anchor text and subject URI as href of main item link in PivotViewer properties panel # Use foaf:depiction image for Tiles (DZI) for DZC SELECT DISTINCT ?href ?image ?href as ?qrcode ?name ?page ?description ?created ?modified ?country ?postcode ?region ?locality ?latitude ?longitude WHERE { ?href a foaf:Person; foaf:depiction ?image; foaf:name ?name; foaf:homepage ?page; dc:description ?description; dcterms:created ?created; dcterms:modified ?modified; vcard:Country ?country; vcard:Pcode ?postcode; vcard:Region ?region; vcard:Locality ?locality; geo:lat ?latitude; geo:long ?longitude. } </programlisting><para> </para> <emphasis>Example 7:</emphasis> <para>The next example shows the use of ?image to identify the custom image to be displayed for an item, and ?qrcode to identify the property (in this case the item URI) to be encoded in the QRcode adjacent to the main image. It also illustrates the use of Virtuoso's federated SPARQL capability (SPARQL-FED) via the service keyword.</para> <programlisting>prefix gr: <http://purl.org/goodrelations/v1#> prefix icecat: <http://linkedopencommerce.com/schemas/icecat/v1/> select distinct ?href ?href as ?qrcode ?name ?description ?manufacturer ?image where { service <http://linkeddata.uriburner.com/sparql> { ?href a gr:ProductOrServiceModel . ?href icecat:hasModelName ?name . ?href icecat:hasLongSummaryDescription ?description . ?href gr:hasManufacturer ?manufacturer . ?href ?p ?o . ?href foaf:depiction ?image . ?o bif:contains '(SONY AND CAMCORDER)' . }} </programlisting><para> The following image slice taken from the resulting PivotViewer display shows product images with their generated QRcodes.</para> <figure><graphic fileref="VirtSparqlCxml/camcorder_qrcode.jpg" /></figure> <emphasis>Example 8:</emphasis><para>If no custom image can be found for an item, an icon is used instead. Here we see the image being provided by the foaf:depiction property which is included in an optional triple pattern so as to include in the collection items without a foaf:depiction. These items are depicted by the default icon, the 'RDF molecule', as shown below.</para> <programlisting>select distinct ?s ?image ?id from <http://www.meetup.com/linkeddata/members/> where { service <http://uriburner.com/sparql> { ?s ?p ?o; foaf:name ?id . optional { ?s foaf:depiction ?image } } } limit 100 </programlisting><figure><graphic fileref="VirtSparqlCxml/select_no_itemtype.jpg" /></figure><para>Rather than use the same icon for all items without an image, it's possible to display a class-specific icon to give an indication of the item's type. The icon to be displayed is selected from a small extensible set provided by the SparqlCxml VAD, based on the item's rdfs:type. (More details of how this is done can be found in <ulink url="VirtSparqlCxmlDzcs">SparqlCxmlDeep Zoom Collections</ulink> in section 'Default Images for Pivot Collections'.)</para> <para>When generating CXML from a DESCRIBE or CONSTRUCT, an item's rdfs:type is readily available and the choice of icon is made automatically. For a SELECT, it's necessary to indicate an item's type through the ?itemtype reserved query variable. When the above query is modified to include ?itemtype, the default icon is replaced by a 'silhouette' which depicts items of type foaf:Person. </para> <programlisting>select distinct ?s ?image ?id ?itemtype from <http://www.meetup.com/linkeddata/members/> where { service <http://uriburner.com/sparql> { ?s ?p ?o; foaf:name ?id ; a ?itemtype . optional { ?s foaf:depiction ?image } } } limit 100 </programlisting><para> <figure><graphic fileref="VirtSparqlCxml/select_with_itemtype.jpg" /></figure> </para> <emphasis>Example 9:</emphasis> <para>Using a fixed image as the item depiction, with the item's URI forming the QRcode </para> <programlisting>prefix rdf: <http://www.w3.org/1999/02/22-rdf-syntax-ns#> prefix rdfs: <http://www.w3.org/2000/01/rdf-schema#> prefix xsd: <http://www.w3.org/2001/XMLSchema#> prefix frbr: <http://purl.org/vocab/frbr/core#> prefix dct: <http://purl.org/dc/terms/> select ?work as ?href ?date ?description ?valid ?subject as ?qrcode ?image ?name (<http://i.telegraph.co.uk/telegraph/multimedia/archive/01590/backbenchers-pa_1590370c.jpg>) as ?image where { service <http://gov.tso.co.uk/legislation/sparql> ( define lang:dialect 65535 ) {{ select * where { ?work a frbr:Work . ?work dct:title ?description . ?work dct:created ?date . ?work dct:subject ?subject . ?work dct:valid ?valid . ?work rdfs:label ?name . optional {?work foaf:depiction ?image} . filter (?date >= "2010-10-15"^^xsd:date) } limit 100 }} } </programlisting><para> or</para> <programlisting>select ?s as ?href, (<http://www.railaroundbirmingham.co.uk/graphics/crests.jpg>) as ?image, ?p, ?o from <http://spending.lichfielddc.gov.uk/data> where {?s ?p ?o} limit 1000 </programlisting><ulink url=""> <para> </para> <bridgehead class="http://www.w3.org/1999/xhtml:h4">Query Variable Order</bridgehead> <para>If a wildcard SELECT list isn't used, the query variables in the SELECT list must include one representing the subject URI. The variable corresponding to the subject URI must also be <emphasis>first</emphasis> in the select list. In the next example, ?href is, as well as setting each Item's Href attribute, also acting as a placeholder for the subject URI (in place of the more usual ?s).</para> <programlisting>PREFIX wo: <http://purl.org/ontology/wo/> SELECT DISTINCT ?href ?name ?kingdom ?image ?habitat ?page ?adaptation ?prog WHERE {?href wo:kingdom ?kingdom; wo:adaptation ?adaptation; wo:livesIn ?habitat; rdfs:label ?name. OPTIONAL {?prog po:subject ?href.} OPTIONAL {?href foaf:depiction ?image.} OPTIONAL {?page foaf:primaryTopic ?href} } limit 500 </programlisting><para>A re-ordered select list of 'SELECT DISTINCT ?name ?href ...' would be rejected by the SPARQL compiler. </para> <ulink url=""> <bridgehead class="http://www.w3.org/1999/xhtml:h4">Reserved Query Variables for Geodata</bridgehead> PivotViewer's "Map" tab displays any geo-data contained in the collection as map markers. Currently PivotViewer looks for two kinds of facet to find geo-location points: <orderedlist spacing="compact"><listitem>A pair of numeric facets named "latitude" and "longitude" (or which have these substrings in the facet name). The facet values are combined to form a geo-marker. </listitem> <listitem>Any facet named "location" (or which contains the substring "location") is used to do geo-location lookups, with some special handing for facet values in the formats below. Any other format is passed to the BingMap GeoLocation API to try to retrieve a co-ordinate pair. <itemizedlist mark="bullet" spacing="compact"><listitem>Twitter coordinates: format - ?t: <double>, <double> </listitem> <listitem>iPhone co-ordinates: format - iPhone: <double>, <double> </listitem> <listitem>Generic co-ordinates: format - <double>, <double> </listitem> <listitem>Generic coordinates: format - <double>?, <double>?</listitem> </itemizedlist></listitem> </orderedlist><para>The searches for "latitude", "longitude" or "location" in a facet name are case-insensitive. PivotViewer uses an internal cache to minimize the number of lookups.</para> <para>Thus ?latitude, ?longitude and ?location can be viewed as special variables specifically for PivotViewer. Conversely, the previously mentioned special variables ?image, ?qrcode etc are only for CXML generation.</para> <para> <ulink url=""> </ulink></para> <bridgehead class="http://www.w3.org/1999/xhtml:h3">Graph virtcxml</bridgehead> <para>Graph <http://www.openlinksw.com/schemas/virtcxml#> can be used to customize the CXML generation for DESCRIBEs and CONSTRUCTs. The graph can also be referred to by its short name virtcxml: which is declared in table DB.DBA.SYS_XML_PERSISTENT_NS_DECL (e.g. select * from virtcxml: where { .... ) The graph is created by the sparql_cxml VAD and populated with some default settings for popular ontologies such as the Dublin Core and FOAF. Add entries to this graph as needed for your own collections.</para> <ulink url=""> <para> </para> <bridgehead class="http://www.w3.org/1999/xhtml:h4">virtcxml:FacetType</bridgehead> <para>Customization of the DESCRIBE output is done primarily by associating a virtcxml:FacetType with an entity property. The entity property to be modified is declared as being an instance of the class virtcxml:FacetCategoryPattern. The property's datatype can then be set by assigning the desired CXML type to the virtcxml:FacetType property. The supported types include the standard CXML datatypes, String, LongString, Number, DateTime and Link; but also some pseudo datatypes for setting certain item attributes from RDF property values. These special datatypes correspond to the <ulink url="#AncReservedQueryVariables">reserved query variables</ulink> presented earlier. They are:</para> <table><title /><tgroup><thead /><tbody> <row><entry> Datatype </entry><entry> Equivalent Reserved SELECT Variable </entry><entry> CXML Element/Attribute </entry></row> <row><entry> Item/d1p1:Copyright </entry><entry> ?copyright </entry><entry> A facet for a copyright link about the item </entry></row> <row><entry> Item/Description</entry><entry> ?description </entry><entry> A facet for a text description of an item to be displayed in the info panel </entry></row> <row><entry> Item/@Href </entry><entry> ?href </entry><entry> A facet for an URL associated with an item. Double-clicking the item in the Pivot client will navigate the user to this URL </entry></row> <row><entry> Item/@Id </entry><entry> ?id </entry><entry> A facet for an unique id of an item in the item list. If not specified the decimal representation of serial is used </entry></row> <row><entry> Item/@virt:Image </entry><entry> ?image </entry><entry> A facet for an absolute URI of the image that will be added to an automatically created single-use collection </entry></row> <row><entry> Item/@Img </entry><entry> ?img </entry><entry> A facet for an relative URI of the image in the collection </entry></row> <row><entry> Item/@virt:Itemtype </entry><entry> ?itemtype </entry><entry> A facet for an item type that is used, for example, to choose the fallback icon for the item </entry></row> <row><entry> Item/@Name </entry><entry> ?name </entry><entry> A facet for a name of the item which will appear at the top of the info panel </entry></row> <row><entry> Item/@virt:QRcode </entry><entry> ?qrcode </entry><entry> A facet for QRcode data that should be placed in the image </entry></row> <row><entry> Item/d1p1:Related </entry><entry> ?related </entry><entry> A facet for links to web-pages or collections related to the item </entry></row> </tbody></tgroup></table> <para>Examples of their use follow.</para> <ulink url=""> <para> </para> <bridgehead class="http://www.w3.org/1999/xhtml:h4">Setting an Item's Image</bridgehead> <para>An item's foaf:depiction property supplies the item's image: </para> <programlisting>foaf:depiction a virtcxml:FacetCategoryPattern ; virtcxml:FacetType "Item/@virt:Image" ; virtcxml:FacetDescription "A facet for absolute URI of depiction of a collection item" . </programlisting><para> As with the other pseudo datatypes, more than one property can be declared as being of type "Item/@virt:Image". This would typically be the case where the collections to be generated include more than one entity type. In which case, there would be one "Item/@virt:Image" declaration for each included type, except where they share the same image property. For any entity type without a "Item/@virt:Image" property, an icon is displayed as a fallback image.</para> <para>Building on the above definition, graph virtcxml supports a virtcxml:aliasOf property as a shorthand notation for declaring properties as having FacetType "Item/@virt:Image". As an illustration of how the graph can be customized by a developer, the SPARUL insert statement below declares mo:image as an alias of foaf:depiction to enable the use of images available through the mo:image property as custom images (aka ABox images) in the DESCRIBE query which follows. The query itself can be executed against endpoint <ulink url="http://lod.openlinksw.com/sparql.">http://lod.openlinksw.com/sparql.</ulink> </para> <programlisting>sparql prefix virtcxml: <http://www.openlinksw.com/schemas/virtcxml#> prefix mo: <http://purl.org/ontology/mo/> prefix foaf: <http://xmlns.com/foaf/0.1/> insert data into virtcxml: { mo:image virtcxml:aliasOf foaf:depiction . }; </programlisting><para>Without this declaration (which is included in the graph virtcxml by default), only icons (aka TBox images) would be displayed by PivotViewer. </para> <programlisting>DESCRIBE ?s FROM <http://www.bbc.co.uk/music/> WHERE { ?s a mo:SoloMusicArtist ; mo:image ?img .} LIMIT 100 </programlisting><para>Note: ?img ensures that each artist has a custom image. It should not be confused with the reserved query variable ?image, used only by SELECTs.</para> <ulink url=""> <para> </para> <bridgehead class="http://www.w3.org/1999/xhtml:h4">Setting an Item's Name</bridgehead> If an item has any of the properties foaf:name, rdfs:label, dc:title or dcterms:title, use it as the item's name: <programlisting>foaf:name a virtcxml:FacetCategoryPattern ; virtcxml:FacetType "Item/@Name" ; virtcxml:FacetDescription "A facet for full name of a person" . ... rdfs:label a virtcxml:FacetCategoryPattern ; virtcxml:FacetType "Item/@Name" ; virtcxml:FacetDescription "Facet to use for name of item" . ... dc:title a virtcxml:FacetCategoryPattern ; virtcxml:FacetType "Item/@Name" ; virtcxml:FacetDescription "Facet to use for name of item" . dcterms:title a virtcxml:FacetCategoryPattern ; virtcxml:FacetType "Item/@Name" ; virtcxml:FacetDescription "Facet to use for name of item" . </programlisting><para> <ulink url=""> </ulink></para> <bridgehead class="http://www.w3.org/1999/xhtml:h4">Setting an Item's Description</bridgehead> <para>For any item with a Dublin Core description property, use this for the CXML Item/Description element. For campsite items, use the camp:description property, and for ski resorts use the ski:description property. Note that the property to use can have any name, it need not be named <emphasis>prefix:</emphasis>description. </para> <programlisting>dc:description a virtcxml:FacetCategoryPattern ; virtcxml:FacetType "Item/Description" ; virtcxml:FacetDescription "Facet to use for item description" . dcterms:description a virtcxml:FacetCategoryPattern ; virtcxml:FacetType "Item/Description" ; virtcxml:FacetDescription "Facet to use for item description" . ... camp:description a virtcxml:FacetCategoryPattern ; virtcxml:FacetType "Item/Description" ; virtcxml:FacetDescription "Facet to use for campsite description" . ... ski:description a virtcxml:FacetCategoryPattern ; virtcxml:FacetType "Item/Description" ; virtcxml:FacetDescription "Facet to use for ski resort description" . </programlisting><para> <ulink url=""> </ulink></para> <bridgehead class="http://www.w3.org/1999/xhtml:h4">Setting a Facet's Name</bridgehead> <para>Use 'Type of Resort' in place of 'camp:resort_type' as the name of the facet: </para> <programlisting>camp:resort_type a virtcxml:FacetCategoryPattern ; virtcxml:FacetName "Type of Resort" ; virtcxml:FacetDescription "Type of resort" . </programlisting><para> The ability to override a facet's name is not limited to DESCRIBEs. The default facet names generated by a SELECT can also be overridden in the same way. For instance, the facet name 'virtcxml:FacetO' created for query variable ?o in a SELECT starting: </para> <programlisting>select ?s ?p ?o where ... </programlisting><para>can be changed to 'Object' with an entry in virtcxml of the form: </para> <programlisting>virtcxml:FacetO a virtcxml:FacetCategoryPattern ; virtcxml:FacetName "Object" ; virtcxml:FacetDescription "Renaming of facet associated with ?o" . </programlisting><para>Likewise for </para> <programlisting>select ?s ?p ?o as ?loc ... </programlisting><programlisting>virtcxml:FacetLoc a virtcxml:FacetCategoryPattern ; virtcxml:FacetName "Location" ; virtcxml:FacetDescription "..." . </programlisting><para> <ulink url=""> </ulink></para> <bridgehead class="http://www.w3.org/1999/xhtml:h4">Setting a Facet's Datatype</bridgehead> <para>Overriding the default CXML String datatype for item properties:</para> <para>The following examples show how to set the facet type using the virtcxml:FacetType property. However this should not be necessary for numeric and datetime values. If the values are RDF typed literals, the facet datatype is set automatically. </para> <programlisting>ski:altitude_m a virtcxml:FacetCategoryPattern ; virtcxml:FacetType "Number" ; virtcxml:FacetDescription "Resort altitude (m)" . ... rdfs:seeAlso a virtcxml:FacetCategoryPattern ; virtcxml:FacetType "Link" ; virtcxml:FacetDescription "Related item" . </programlisting><para> <ulink url=""> </ulink></para> <bridgehead class="http://www.w3.org/1999/xhtml:h4">Setting the Facet Used to Generate a QR code</bridgehead> <para>For SELECTs, reserved query variable ?qrcode identifies the property to use for generating QR codes. However this variable is unavailable for DESCRIBEs and CONSTRUCTs. For the latter, two options exist. Either designate the property to use through an entry in graph virtcxml: or, in the absence of such an entry, use the default behaviour whereby the subject URI is automatically used as the basis for the QR code, assuming QR code generation has been enabled through the /sparql query string setting "format=text/cxml+qrcode", or through the SPASQL pragma 'define output:format "CXML;QRCODE"' as described above in <ulink url="#AncSparqlEndpointCxmlExtensions">SPARQL Endpoint CXML Extensions</ulink>.</para> <para>To specify a QR code source-property in virtcxml:, assign the property a virtcxml:FacetType property of "Item/@virt:QRcode". e.g. </para> <programlisting>gr:hasEAN_UCC-13 a virtcxml:FacetCategoryPattern ; virtcxml:FacetType "Item/@virt:QRcode" ; virtcxml:FacetDescription "Use a product's GoodRelations EAN-UCC-13 code (Universal Product Code) for it's QRcode" . </programlisting><para> In most circumstances it will probably be preferable to QR-encode the item (subject) URI, in which case an entry in virtcxml: is not needed.</para> <ulink url=""> <para> </para> <bridgehead class="http://www.w3.org/1999/xhtml:h4">Excluding a Facet from the Filter Panel</bridgehead> <para>There may be occasion where there is little reason to include a facet in the PivotViewer filter panel, for instance if the facet value is unique for each item and you are unlikely to want to filter on this facet. To exclude a facet from the filter panel, set its virtcxml:PivotIsFilterVisible property to "false" in virtcxml: e.g. </para> <programlisting>foaf:mbox_sha1sum a virtcxml:FacetCategoryPattern ; virtcxml:FacetName "SHA1 of a Personal Mailbox" ; virtcxml:FacetType "String" ; virtcxml:PivotIsFilterVisible "false" . </programlisting><para> <ulink url=""> </ulink></para> <bridgehead class="http://www.w3.org/1999/xhtml:h3">Using Labels in Place of URIs</bridgehead> <para>In the world of RDF, a URI is the primary currency for naming and identifying classes, properties and individuals. In contrast, in PivotViewer items and properties are identified by name, and property values are in the main character strings. The screenshot on the left below shows the visual impact of property values which are resource URIs rather than literals, if <ulink url="PivotViewer">PivotViewer</ulink>'s auto-label feature (see below) is disabled. (This feature cannot be disabled by end-users, but has been in the following example to illustrate its effect). The values for facet virtcxml:FacetHabitat were returned by the query:</para> <programlisting>SELECT DISTINCT ?s as ?href ?kingdom ?image ?habitat WHERE {?s <http://purl.org/ontology/wo/kingdom> ?kingdom; <http://purl.org/ontology/wo/livesIn> ?habitat. OPTIONAL {?s foaf:depiction ?image . } } limit 2500 </programlisting><para> <figure><graphic fileref="VirtSparqlCxml/property_labels1.jpg" /></figure> <figure><graphic fileref="VirtSparqlCxml/property_labels2.jpg" /></figure> The values for property http://purl.org/ontology/wo/livesIn (corresponding to facet virtcxml:FacetHabitat) are individuals identified by URIs, e.g. http://www.bbc.co.uk/nature/habitats/Tropical_and_subtropical_grasslands,_savannas,_and_shrublands#habitat, which while great for machine-readable data does little for end-user readability. From a user's perspective, it's clearly preferable that URIs should be hidden as far as possible.</para> <para>One option would be to display a property's label in place of its URI and keep the property type as CXML String. While for some properties, such as rdfs:seeAlso, it may be desirable to type the property as CXML Link, and use the property label for the anchor text, in most cases using CXML String makes for a better user experience and more searchable collections. The reason being that facets of type CXML Link are not exposed in the Filter panel for filtering, whereas facets of type CXML String are. In order to achieve the desired effect, the query could be recast to retrieve labels attached to properties through the rdfs:label predicate:</para> <programlisting>SELECT DISTINCT ?s as ?href ?name ?kname ?image ?hname WHERE {?s <http://purl.org/ontology/wo/kingdom> ?kingdom; rdfs:label ?name; <http://purl.org/ontology/wo/livesIn> ?habitat. OPTIONAL {?s foaf:depiction ?image.} ?kingdom rdfs:label ?kname. ?habitat rdfs:label ?hname} limit 2500 </programlisting><para><ulink url="http://uriburner.com/c/DIZQEG">View Pivot collection</ulink></para> <para>The screenshot above right shows the effect of ?hname in the PivotViewer Filter panel. (The order of the images is different because PivotViewer orders on virtcxml:FacetHabitat in the first case and virtcxml:FacetHname in the second.) Those below show the impact of ?name on the item name in the Info panel, replacing the aardvark URI by the much more readable 'Aardvark'.</para> <figure><graphic fileref="VirtSparqlCxml/item_name1.jpg" /></figure><figure><graphic fileref="VirtSparqlCxml/item_name2.jpg" /></figure> <ulink url=""> <para> </para> <bridgehead class="http://www.w3.org/1999/xhtml:h4">Exploiting Inferencing</bridgehead> The last example showed rdfs:label being used to supply human-friendly labels for some properties. Inferencing provides a more generic approach to the problem, particularly where a collection may consist of more than one entity type. Virtuoso defines an inference context, virtrdf-label, specifically for inferring property labels. The context, defined in graph virtrdf-label, declares many properties routinely used for labels as being a subproperty of virtrdf:label. e.g. <programlisting>rdfs:label rdfs:subPropertyOf <http://www.openlinksw.com/schemas/virtrdf#label> dcterms:title rdfs:subPropertyOf <http://www.openlinksw.com/schemas/virtrdf#label> ... </programlisting><para>By including the pragma 'define input:inference "virtrdf-label" before the last query above, label inferencing is enabled and any reference to rdfs:label could be replaced by virtrdf:label.</para> <ulink url=""> <para> </para> <bridgehead class="http://www.w3.org/1999/xhtml:h4">Automatic Labels</bridgehead> <para>When handling property values which are URIs, rather than require the query to convert these URIs to labels through the inclusion of additional rdfs:label (or virtrdf:label) patterns, such as "?kingdom rdfs:label ?kname . ?habitat rdfs:label ?hname ." as illustrated above, Virtuoso will attempt to infer such labels automatically. Similarly for property URIs, Virtuoso will attempt to find the property's label and use this for the property (i.e. facet) name rather than use the <ulink url="http://en.wikipedia.org/wiki/CURIE">CURIE</ulink> format of the property URI. For example, "Creator" is used as a property name is place of "dc:creator". When searching for auto-labels, SparqlCxml looks first in graph virtcxml: for facet names set using the virtcxml:FacetName property, before querying the local quad store for labels revealed through the virtrdf-label inference context.</para> <para>The next example shows how the aesthetics of a recipe description can be improved using auto-labels. Starting from the Conductor's /sparql UI and executing the illustrated query</para> <figure><graphic fileref="VirtSparqlCxml/recipe_qry_string_facets.jpg" /></figure><para>generates a query result URI which when passed to PivotViewer results in</para> <figure><graphic fileref="VirtSparqlCxml/recipe_pvt_string_facets.jpg" /></figure><para>Notice that the values for facet dv:ingredient are labels, not URIs. The ingredient URIs have been hidden by the auto-labelling. The full RDF description of the ingredient 'almonds' is given by:</para> <programlisting>SELECT * WHERE { <http://kingsley.idehen.net/about/id/entity/http/www.bbc.co.uk/food/recipes/almondymincepies_14566#hrecipe55g%2F2oz%20ground%20almonds%20> ?p ?o} </programlisting><para>which returns </para> <table><title /><tgroup><thead /><tbody> <row /> <row><entry> http://www.w3.org/1999/02/22-rdf-syntax-ns#type </entry><entry>http://rdf.data-vocabulary.org/Ingredient </entry></row> <row><entry> http://rdf.data-vocabulary.org/name </entry><entry> almonds </entry></row> <row><entry> http://rdf.data-vocabulary.org/amount </entry><entry> 55g/2oz ground almonds </entry></row> </tbody></tgroup></table> <para>and which reveals that the auto-labelling has used property <http://rdf.data-vocabulary.org/name> in place of the ingredient URI. In order for this to happen, the virtrdf-label inference context declares dv:name as an rdfs:subPropertyOf virtrdf:label.</para> <programlisting>SELECT * from <virtrdf-label> WHERE {?s ?p ?o} </programlisting><para>includes in its output </para> <table><title /><tgroup><thead /><tbody> <row /> <row><entry> http://rdf.data-vocabulary.org/name </entry><entry> http://www.w3.org/2000/01/rdf-schema#subPropertyOf </entry><entry> http://www.openlinksw.com/schemas/virtrdf#label </entry></row> </tbody></tgroup></table> <para>Also note that in the above DESCRIBE query, ?image functions as an ordinary variable, not a reserved query variable, as is the case with a SELECT. It is used to ensure each returned recipe has an accompanying image. For this DESCRIBE, in order to specify that the images for the DZC are provided by dv:photo, an appropriate entry was added to graph virtcxml using a simple <ulink url="http://www.w3.org/Submission/SPARQL-Update/">SPARUL</ulink> statement:</para> <programlisting>sparql prefix dv: <http://rdf.data-vocabulary.org/> insert data into virtcxml: { dv:photo a virtcxml:FacetCategoryPattern ; virtcxml:FacetType "Item/@virt:Image" ; virtcxml:FacetDescription "A facet for use as an item image" . } </programlisting><para> <emphasis>Note</emphasis>: Auto-label extraction for URIs will <emphasis>not</emphasis> be performed if a facet is explicitly typed as CXML Link in graph virtcxml. An entry such as </para> <programlisting>prefix dv: <http://rdf.data-vocabulary.org/> . . . dv:ingredient a virtcxml:FacetCategoryPattern ; virtcxml:FacetName "Ingredient" ; virtcxml:FacetType "Link" . </programlisting><para>for facet "Ingredient" will result in the facet values using a URI for both the Link's anchor text and href, instead of an inferred label for the anchor text. Auto-label extraction is only done when <ulink url="#AncFacetTypeAutoDetection">auto-type detection</ulink> takes place.</para> <ulink url=""> <para> </para> <bridgehead class="http://www.w3.org/1999/xhtml:h4">Label Localization</bridgehead> <para>In order to exploit URI to label conversion to maximum effect, it is important that ontologies and instance data use language tags in multi-lingual scenarios to localize property values, as illustrated by this made-up extract </para> <programlisting>:EWD1036 a bibo:Document ; dc:creator "E. W. Dijkstra"@en ; dc:subject "computer science"@en ; dc:subject "informatique"@fr ; dc:title "The Cruelty of Really Teaching Computer Science"@en . </programlisting><para> Graph virtrdf-label declares dc:title rdfs:subPropertyOf virtrdf:label; so that dc:title serves as a potential label. Queries used for CXML generation can then restrict results, and hence labels, to a particular language by specifying the appropriate language tag. e.g. </para> <programlisting>DESCRIBE ?s WHERE { ?s a bibo:Document ; dc:subject "computer science"@en } SELECT * WHERE { ?s dc:subject ?subject ; ... FILTER ( lang(?subject) = "EN" ) } </programlisting><para> At present the onus is on the query writer to use language tags in the base query, but it is anticipated that SparqlCxml will in future perform this kind of filtering automatically through detection of the locale being used by the user agent.</para> <ulink url=""> <para> </para> <bridgehead class="http://www.w3.org/1999/xhtml:h3">Link Typing</bridgehead> <para>The default setting for the auto-label feature is to set the type of the replacement labels to CXML String. However, the property URIs can also be typed as CXML Link, if required, with the auto-label acting as the anchor text and the property URI as the href. In the /sparql UI the dropdowns 'Style for RDF subjects' and 'Style for other links' control the target CXML type used by auto-labelling. The choice of CXML String as the default is because it isn't possible to filter on properties typed as CXML Link; PivotViewer does not display Link properties in the filter panel. Typing a facet like foaf:topicOfInterest as Link would prevent a user from selecting a group of people with the same interest, e.g. http://dbpedia.org/resource/Semantic+Web, via the filter panel.</para> <para>Our recipe example used 'Convert to string facets', as can be seen in the raw CXML for the dv:ingredient facet</para> <programlisting><Collection SchemaVersion="1.0" Name="SPARQL Query Results"> <FacetCategories> <FacetCategory Name="dv:author" Type="String"/> <FacetCategory Name="dv:cookTime" Type="String"/> <FacetCategory Name="dv:ingredient" Type="String"/> <FacetCategory Name="dv:instructions" Type="LongString" d1p1:IsFilterVisible="false"/> <FacetCategory Name="dv:name" Type="String"/> <FacetCategory Name="dv:yield" Type="String"/> <FacetCategory Name="Subject Type" Type="String" d1p1:IsFilterVisible="true" d1p1:IsMetaDataVisible="true" d1p1:IsWordWheelVisible="true"/> </FacetCategories> <Items ImgBase="http://kingsley.idehen.net/DeepZoomCache/cxml35073.dzc"> <Item Id="0" Img="#0" Href="http://kingsley.idehen.net/about/id/entity/http/www.bbc.co.uk/food/recipes/almondymincepies_14566#hrecipe" Name="Almondy mince pies"> <Facets> <Facet Name="dv:author"> <String Value="Silvana Franco"/> </Facet> <Facet Name="dv:cookTime"> <String Value="10 to 30 mins"/> </Facet> <Facet Name="dv:ingredient"> <String Value="cream"/> . . . <String Value="almonds"/> . . . </Facet> </programlisting><para> If 'Style for other links' is set to 'Make plain links', the output for dv:ingredient becomes</para> <programlisting><Collection SchemaVersion="1.0" Name="SPARQL Query Results"> <FacetCategories> . . . <FacetCategory Name="dv:ingredient" Type="Link" d1p1:IsFilterVisible="false"/> . . . </FacetCategories> . . . <Facet Name="dv:ingredient"> <Link Href="http://kingsley.idehen.net/about/id/entity/http/www.bbc.co.uk/food/recipes/almondymincepies_14566#hrecipecream%2C%20custard%2C%20or%20brandy%20butter%2C%20to%20serve" Name="cream"/> . . . <Link Href="http://kingsley.idehen.net/about/id/entity/http/www.bbc.co.uk/food/recipes/almondymincepies_14566#hrecipe55g%2F2oz%20ground%20almonds%20" Name="almonds"/> . . . </Facet> </programlisting><para> Should you want to override the 'Style for ...' dropdown settings and force the type of a suitable property to Link, you can do so by adding an entry for the property in graph virtcxml:, assigning it a virtcxml:FacetType of "Link". The installed virtcxml: does this for rdfs:seeAlso,</para> <programlisting>rdfs:seeAlso a virtcxml:FacetCategoryPattern ; virtcxml:FacetType "Link" ; virtcxml:FacetDescription "Related item" . </programlisting><para> A property with virtcxml:FacetType "Link" will be typed as Link only if all its values are URIs and none are literals. Again, where auto-labels can be found, these provide the anchor text.</para> <ulink url=""> <para> </para> <bridgehead class="http://www.w3.org/1999/xhtml:h4">Link Typing Options</bridgehead> <para>The full set of link-typing options available in the /sparql UI are detailed below. The Facet Pivot Bridge and PivotViewer (via the 'Edit' feature) also expose the same options. Pick one of these options when executing SPARQL from any of these services.</para> <para>'CXML link behavior' Dropdown: </para> <itemizedlist mark="bullet" spacing="compact"><listitem>Sets the CXML type of URIs to String or Link, optionally performing a DESCRIBE on the subject </listitem> <listitem>Permitted Values: <itemizedlist mark="bullet" spacing="compact"><listitem>Local Faceted Navigation Links <itemizedlist mark="bullet" spacing="compact"><listitem>What? <itemizedlist mark="bullet" spacing="compact"><listitem>Generates links that enable faceted navigation/browsing within the local CXML data island hosted by page. If users need to exit the CXML data island they can only do so via the link behind the data item's name at the top of the info panel on the right of the PivotViewer display. </listitem> </itemizedlist></listitem> <listitem>Why? <itemizedlist mark="bullet" spacing="compact"><listitem>Allows a PivotViewer user to search, sort and filter across image tile, bar graph, data grid and map views to find data items of specific interest. </listitem> </itemizedlist></listitem> <listitem>How? <itemizedlist mark="bullet" spacing="compact"><listitem>Instead of using the URI as the facet value with a facet type of CXML Link, this option changes the facet type to CXML String and replaces the facet value with any label associated with the entity identified by the URI. In this context a label is any entity property which is a virtrdf:label, as defined by graph (inference context) virtrdf-label. </listitem> </itemizedlist></listitem> </itemizedlist></listitem> <listitem>External Resource Links <itemizedlist mark="bullet" spacing="compact"><listitem>What? <itemizedlist mark="bullet" spacing="compact"><listitem>Generates links that enable a PivotViewer user to exit the local CXML data island to an external description page for the selected data item reference (URI). </listitem> </itemizedlist></listitem> <listitem>Why? <itemizedlist mark="bullet" spacing="compact"><listitem>Allows a PivotViewer user to search, sort and filter across image tile, bar graph, data grid and map views to find data items of specific interest, and then exit to an external resource via property values. This feature provides an additional exit to the data item name link. </listitem> </itemizedlist></listitem> <listitem>How? <itemizedlist mark="bullet" spacing="compact"><listitem>Uses the unadorned URI directly as the link href, keeping the facet type as CXML Link. </listitem> <listitem>The URI forms the href of the CXML Link, with the anchor text provided by the entity's label. </listitem> </itemizedlist></listitem> </itemizedlist></listitem> <listitem>External Faceted Navigation Links <itemizedlist mark="bullet" spacing="compact"><listitem>What? <itemizedlist mark="bullet" spacing="compact"><listitem>Generates links that enable faceted navigation/browsing via object property values (those that have URI/IRI reference values). </listitem> </itemizedlist></listitem> <listitem>Why? <itemizedlist mark="bullet" spacing="compact"><listitem>Allows a PivotViewer user to search, sort and filter across image tile, bar graph, data grid and map views to find data items of specific interest. Once the data item of interest is located, you also have the option to open up new PivotViewer pages via properties of your current data item of interest. </listitem> </itemizedlist></listitem> <listitem>How? <itemizedlist mark="bullet" spacing="compact"><listitem>Replaces the entity URI by a wrapper URI to perform a SPARQL DESCRIBE of the entity, returning the result as CXML and launching PivotViewer to display it. </listitem> <listitem>The wrapper URI takes the form 'http://<localhost>/PivotViewer?url=http://<localhost>//sparql?query=describe+<URI>&format=text/cxml+qrcode' (the full URL encoding is not shown) </listitem> <listitem>The wrapper URI forms the href of the CXML Link, with the anchor text provided by the entity's label. </listitem> </itemizedlist></listitem> </itemizedlist></listitem> <listitem>External Description Resource (Turtle) <itemizedlist mark="bullet" spacing="compact"><listitem>What? <itemizedlist mark="bullet" spacing="compact"><listitem>Generates links that provide access to data item description resources in Turtle format. </listitem> </itemizedlist></listitem> <listitem>Why? <itemizedlist mark="bullet" spacing="compact"><listitem>Allows a PivotViewer user to search, sort and filter across image tile, bar graph, data grid and map views to find data items of specific interest. Once the data item of interest is located, you can use this link to access a data item description resouce (document) in Turtle format. Of course, you can simply alter the Turtle URL for other data formats supported by Virtuoso. </listitem> </itemizedlist></listitem> <listitem>How? <itemizedlist mark="bullet" spacing="compact"><listitem>Replaces the entity URI by a wrapper URI to perform a SPARQL DESCRIBE of the entity, returning the result as TTL. </listitem> <listitem>The wrapper URI takes the form 'http://<localhost>/sparql?query=describe+<URI>&format=text/rdf+n3' (the full URL encoding is not shown) </listitem> <listitem>The wrapper URI forms the href of the CXML Link, with the anchor text provided by the entity's label. </listitem> </itemizedlist></listitem> </itemizedlist></listitem> <listitem>External Description Resource (CXML) <itemizedlist mark="bullet" spacing="compact"><listitem>What? <itemizedlist mark="bullet" spacing="compact"><listitem>Provides links to access CXML-based resources usable by other PivotViewer instances i.e, Virtuoso or non-Virtuoso hosted. </listitem> </itemizedlist></listitem> <listitem>Why? <itemizedlist mark="bullet" spacing="compact"><listitem>Allows a PivotViewer user to search, sort and filter across image tile, bar graph, data grid and map views to find data items of specific interest. Once the data item of interest is located, you can use this link type to access a CXML resource for use elsewhere. </listitem> </itemizedlist></listitem> <listitem>How? <itemizedlist mark="bullet" spacing="compact"><listitem>Replaces the entity URI by a wrapper URI to perform a SPARQL DESCRIBE of the entity, returning the result as CXML. </listitem> <listitem>The wrapper URI takes the form 'http://<localhost>/sparql?query=describe+<URI>&format=text/cxml+qrcode' (again the full URL encoding is not shown) </listitem> <listitem>The wrapper URI forms the href of the CXML Link, with the anchor text provided by the entity's label.</listitem> </itemizedlist></listitem> </itemizedlist></listitem> </itemizedlist></listitem> </itemizedlist><ulink url=""> <para> </para> <bridgehead class="http://www.w3.org/1999/xhtml:h4">Controlling Link Typing through /sparql Query String Parameters</bridgehead> <para>The link styling options provided by the /sparql UI ultimately reduce to two query string parameters in the SPARQL query URI it builds. Query string parameter CXML_redir_for_hrefs corresponds to the 'CXML link behavior' dropdown. It can take one of the following values: </para> <itemizedlist mark="bullet" spacing="compact"><listitem>null : Sets the "Local Faceted Navigation Links" option </listitem> <listitem>'121' : Sets the "External Resource Links" option </listitem> <listitem>'LOCAL_PIVOT' : Sets the "External Faceted Navigation Links" option </listitem> <listitem>'LOCAL_TTL' : Sets the "External Description Resource (Turtle)" option </listitem> <listitem>'LOCAL_CXML' : Sets the "External Description Resource (CXML)" option</listitem> </itemizedlist><para>Parameter CXML_redir_for_subjs is reserved for future use and should be set to null.</para> <ulink url=""> <para> </para> <bridgehead class="http://www.w3.org/1999/xhtml:h4">Controlling Link Typing through Virtuoso/PL</bridgehead> <para>When executing a SPARQL query directly from Virtuoso/PL, the controls used by the /sparql and /fct UIs for CXML link styling are not available. To specify the required CXML link typing in Virtuoso/PL, set the connection variables SPARQL_CXML_redir_for_subjs and SPARQL_CXML_redir_for_hrefs. In the code extract below: </para> <programlisting> connection_set ('SPARQL_CXML_redir_for_subjs', redir_for_subjs); connection_set ('SPARQL_CXML_redir_for_hrefs', redir_for_hrefs); qry := 'sparql define output:format "CXML;QRCODE" define sql:describe-mode "SPO" describe ?s1 where { . . . } '; sqls := '00000'; exec (qry, sqls, msg, vector(), 1, meta, result); . . . </programlisting><para> variables redir_for_subjs and redir_for_hrefs take the same values as the CXML_redir_for_subjs and CXML_redir_for_hrefs query string parameters. </para> </ulink></ulink></ulink></ulink></ulink></ulink></ulink></ulink></ulink></ulink></ulink></ulink></ulink></ulink></ulink></ulink></ulink></ulink></ulink></ulink></ulink></ulink></ulink></ulink></ulink></ulink></ulink></ulink></ulink></ulink></ulink></ulink></section></docbook>