. . . . . . . . . . . . . . . . . . . "2017-06-13T05:42:29Z" . "%VOSWARNING%\n\n\n%META:TOPICPARENT{name=\"VirtuosoWhitePapers\"}%\n---+ Deploying Linked Data\n\nv1.2 (Virtuoso 5.0) April 2008\n\nThis document describes the process of deploying Linked Data into the existing Web. It discusses some of the difficulties \nfaced in exposing RDF data and in bridging the \"Semantic Data-Web\" and the traditional \"Document Web\". Two generic \napproaches to resolving these deployment challenges are described, content negotiation and URL rewriting, before looking \nat OpenLink Virtuoso, both from the standpoint of how it implements these solutions and how Linked Data is deployed. \n\nA companion document, [[RDFViewOverviewDoc][Virtuoso Linked Data Views Getting Started Guide]], focuses on Virtuoso Linked Data Views, a facility for exposing relational data as RDF. In addition, it provides useful background information for readers \nunfamiliar with RDF and outlines some of the key technologies of the Semantic Web.\n\n%TOC%\n\n---++ Introduction\n\nThe ubiquitous \"Web,\" born as the \"World Wide Web,\" is primarily experienced today as a \"Web of Documents,\" where \ndocuments (or Web pages) are connected by simple hypertext links. When you click on a hypertext link within one document, \nthe result is simply that the browser loads (or downloads) the linked document. This widely understood and accepted pattern \nof interaction with the Web is made possible by two things — the Uniform Resource Identifier, or URI, \nand the Hypertext Transfer Protocol, or HTTP.\n\n(Uniform Resource Identifier? URI? Don't we mean URL, or Uniform Resource Locator? Yes and no. A Uniform Resource Locator (URL) is a particular \nkind of Uniform Resource Identifier; a Uniform Resource Name, or URN, is another. As may be obvious from these names, \na URL specifies the location of a resource -- like, \"the piece of paper centered on the blotter on your desk,\" or \"the third book from \nthe left on the top shelf of the bookcase in the entryway.\" A URN specifies the name of a resource -- like \"your resume,\" or \"the\nlocal Chicago telephone directory.\" Both of these are URIs -- as both can be used to identify the resource in question, at a given \nmoment in time. The piece of paper centered on the blotter on your desk, and where the book is shelved, may change -- and though \nthe URL is the same as what once referred to your resume, the URN is now different, as it is now \"the menu for the pizza place \ndown the street,\" or \"the Tom Robbins novel, Still Life With Woodpecker.\" On the Web, URLs can only lead to HTTP-transmissible \ndocuments, so the paper on which your resume is printed cannot actually have a URL -- but the word processing document which was \nprinted on that paper can have a URL. In this example, both the word processing document and the printout are associated with \nthe URN, \"your resume,\" and each is a different representation thereof -- one which is only easily consumable by humans, \nand one which is easily consumable by humans or machines. URNs are typically less transient, as \"your resume\" will always mean the same \ndocument, but that document's content will change over time -- so increasingly common practice is to have URNs that incorporate \nsome sense of time into the name, often leading to two \"special\" URNs which are tied to the \"first\" and the \"latest\" version of the \ndocument. The \"first\" always leads to the same content -- but the \"latest\" is obviously likely to change over time.)\n \nThe popularity of the current \"Document Web\" sometimes obscures the fact that from the onset, Tim Berners-Lee envisaged \na broader and deeper Web of Linked Data, where URIs weren't simply URLs and therefor limited to association with\nHTTP-transmissible documents, and where links between resources were not limited to simple hypertext. URNs make it\npossible to have \"hyperdata\" links — explicit connections between Named Entities or Data Objects, \nrather than vague connections between document locations. Hyperdata links include descriptions of the kind of link exposed \n— such as \"the PDF representation of your resume,\" \"the Microsoft Word representation of your resume,\" \"the website \nof the company at which you worked in 1998 which was named Widgets, Inc.\" There is no natural requirement that URNs\nbe based on HTTP, but as we discuss below this is necessary to enabling the Web of Linked Data.\n\nThis document describes one way to start sprinkling Linked Data into the existing Document Web, gradually bringing the \nWeb closer to Tim Berners-Lee's vision, without breaking its current functionality.\n\n---+++ What is Linked Data?\n\n\"Linked Data\" is the title of a Web Design Issues Note by Berners-Lee that issues a best practice recipe for injecting data \ninto the Web as part of a broader effort to evolve the current Web of interlinked documents to a Web of interlinked data \nknown as the \"Semantic Data-Web\" (Data-Web). The principles he outlined are paraphrased as:\n\n * Identify things (real or abstract) in your universe-of-discourse (or \"data space\") using URIs (whether URNs or URLs \n— each has its place)\n * Make each URI (URN, URL, or otherwise) acessible via HTTP, so that people can discover and explore your data \nspaces via the Web\n * Use URIs to expose the context of your data (i.e., describe and provide other information about your data, using URIs)\n * Enhance your URIs by adding links to other URIs, enabling discovery of other things on the Web\n\n---+++ Deployment Challenges\n\nThe Data-Web and the Document Web are two dimensions of the same Web separated by a common element: the URI. On the \nDocument Web, URIs always point to physical resources, while in the Data-Web they point to physical things that are \nassociated with physical and/or abstract things. Of course, this unveils a number of deployment challenges.\n\n---+++ Data Object Names\n\nIn the current Document Web, resource URIs do not separate identity from representation. The Document Web \nassumes that a resource URI points to the location of a physical Web information resource. The HTTP payload that conveys \nthe \"GET\" request for a resource also includes a mechanism for defining representation. Thus, the URI \n[[http://demo.openlinksw.com/Northwind/Customer/ALFKI][http://demo.openlinksw.com/Northwind/Customer/ALFKI]] \npoints to the (X)HTML document representation of the physical resource ALFKI located in the directory /Northwind/Customer/ \non host machine demo.openlinksw.com that accepts HTTP requests at the default port 80.\n\nThe Data-web on the other hand, seeks to use the URI scheme in a manner that separates identity from representation. A URI may \nsimply identify a physical or abstract entity, aka a \"data object\", and so serve as a unique data object name or ID. Accessing, \nor de-referencing, the data object returns a representation of the object, not the object itself. (For instance, the object in \nquestion may be Paris!)\n\n---++++ Unambiguous Reference vs Ambiguous Access\n\nWhen we refer to, or identify, a data object through a data object name, that reference should be unambiguous. However, when we \naccess (or de-reference) a data object, access is inherently ambiguous. Accessing an abstract data object relies on materialization \nof a description of the entity in a form compatible with the transmission medium. As the object may have many possible descriptions \n(facets), the act of accessing it is ambiguous.\n\n---++++URIs As Unique Data Object Names\n\nThus, unlike in the Document Web, in the Semantic Web the same URI \n[[http://demo.openlinksw.com/Northwind/Customer/ALFKI][http://demo.openlinksw.com/Northwind/Customer/ALFKI]] \ncannot serve as both the identity and representation of the Customer ALFKI. The Linked Data provider needs to adhere to \na URI based naming convention in order to avoid data access ambiguity. For example, the URI \n[[http://demo.openlinksw.com/Northwind/Customer/ALFKI#this][http://demo.openlinksw.com/Northwind/Customer/ALFKI#this]], \ncould always to taken to imply the ID of the Customer data object referred to as ?ALFKI?. The URI with the #this suffix is a so-called \nhash URI, which is a convention adopted by some practitioners.\n\n---+++Difficulties with Hash URIs As Data Object Names\n\nIn the prior section, we established the need for disambiguating references and accesses to resources via the Data-Web, and \nhighlighted the hash URI scheme as one scheme some practitioners have adopted when using URIs as unique data object \nnames. However from the perspective of the Data-Web Server (the piece responsible for understanding Reference), the URIs \n[[http://demo.openlinksw.com/Northwind/Customer/ALFKI][http://demo.openlinksw.com/Northwind/Customer/ALFKI]] and \n[[http://demo.openlinksw.com/Northwind/Customer/ALFKI#this][http://demo.openlinksw.com/Northwind/Customer/ALFKI#this]] \nare identical, and thereby inherently ambiguous, because nothing following the fragment identifier, \"#\", ever leaves \nthe Web Client, due to the fact that the Web Client expects to process \"#this\" locally, post resource retrieval. \nAs a result, the Data-Web Server has to figure out how to dereference the Information Resource URI\n[[http://demo.openlinksw.com/Northwind/Customer/ALFKI][http://demo.openlinksw.com/Northwind/Customer/ALFKI]] \nand the Identity URI\n[[http://demo.openlinksw.com/Northwind/Customer/ALFKI#this][http://demo.openlinksw.com/Northwind/Customer/ALFKI#this]] \nfrom the HTTP GET request payload that will only predictably contain the URI\n[[http://demo.openlinksw.com/Northwind/Customer/ALFKI][http://demo.openlinksw.com/Northwind/Customer/ALFKI]]. (Even if \na Web client knowingly tacks the data following the \"#\" to the HTTP GET request it has no control over proxies along the way that \nmay strip out \"#this\".) Likewise, referencing an entity via its identity URI (the act of dereferencing) is only achieved via \ninteraction with an associated Web information resource that \"DESCRIBE\" the entities in question. In reality, this associative \nprocess is inherently ambiguous and unavoidable.\n\nIt is also important to note that descriptive Web information resources can take the form of bona fide parameterized URLs of the kind \ncommonly associated with RESTful Web Services.\n\n---+++ Resolution of the Deployment Challenge\n\nTo unobtrusively evolve the dominant Document Web usage pattern to a Data-Web usage pattern, the challenges of Data Access and Data \nReference need to be resolved using the existing Web infrastructure. The best means of resolution is content negotiation as it \nprovides the foundation for an unobtrusive mechanism known as URL rewriting.\n\n---+++ Content Negotiation\n\nContent negotiation is a mechanism defined in the HTTP specification that makes it possible to serve different representations of \n#BodyNote1\na document (or any resource) at the same ([[#FootNote1][Note 1]]) URL, so that software agents can choose which representation best fits their capabilities. \nThe originally conceived need for this mechanism stemmed from mobile phone browsers, which were better suited to smaller page sizes, \nwithout many graphics and other niceties of the fully featured Web, often satisfied by a WAP representation. In the world of RDF, \na user interacting through a traditional Web browser may want a resource represented in HTML or XHTML, whereas a Semantic Web \napplication would prefer an RDF/XML representation due to its Structured Data orientation.\n\nA browser or any other HTTP based web application indicates it resource representation preferences by packaging these preferences \nvia the \"Accept:\" headers of each HTTP request. For example, a browser could send this HTTP request to indicate that it wants an \nHTML or XHTML version of [[http://www.openlinksw.com/whitepapers/data_management][http://www.openlinksw.com/whitepapers/data_management]] in English or French:\n\n\nGET /whitepapers/data_management HTTP/1.1 \nHost: www.openlinksw.com \nAccept: text/html, application/xhtml+xml \nAccept-Language: en, fr \n\n\nHere, the HTTP Accept header sent by the browser indicates the MIME types it wants (text/html or application/xhtml+xml). An RDF \nbrowser, in contrast, might stipulate a MIME type of application/rdf+xml or application/rdf+n3 to receive a rendering in RDF/XML \nor N3 respectively. \n\nRather than returning the content in the required format directly, servers often implement content negotiation by redirecting to \na URL where the appropriate representation is found. For example, a server might respond with:\n\n\nHTTP/1.1 302 Found \nLocation: http://www.openlinksw.com/whitepapers/data_management.en.html\n\n\nThe redirect is indicated by the HTTP status code 302 (Found). The client would then send another HTTP request to the new URL. \nHTTP defines a number of 3xx status codes all of which indicate the client is being redirected. Instead of 302, servers can \nalso use 303 (See Other) to indicate the response to the request can be found at another location (as expressed via the \n\"Location:\" response header).\n\n---++++ HttpRange - 14 Recommendations\n\nThe problem of URI/resource-type interpretation was originally addressed by the W3C Technical Architecture Group (TAG) around \n2005 and was known as the \"HttpRange-14\" issue. After a good deal of deliberation, the TAG proposed the guidelines below on the \ninformation that can be inferred from the HTTP protocol response codes when dereferencing a URI:\n\n|*HTTP Response Code*|*Material Returned*|*Inference*|\n|200 %BR%(success)|A Resource Representation and its Location|A Web information resource has been located in the desired Representation.|\n|303 %BR%(see other)|A Resource Location|A redirection to the Location of an associated Web information resource in a desired Representation.|\n|4XX or 5XX %BR% (error)|Nothing|No Web information resource or Resource Location is discernible from the Resource and Representation combination used in the message.|\n\n---++++ Solving Linked Data Challenges using Content Negotiation\n\nReturning to our earlier example URIs \n([[http://demo.openlinksw.com/Northwind/Customer/ALFKI][http://demo.openlinksw.com/Northwind/Customer/ALFKI]] and \n[[http://demo.openlinksw.com/Northwind/Customer/ALFKI#this][http://demo.openlinksw.com/Northwind/Customer/ALFKI#this]]) \nwe can construct a decision table that demonstrates how a deployer of Linked Data would leverage content negotiation en route to \nalleviating the previously outlined Data Access and Data Reference challenges.\n\n|*URI*|*URI Type*|*Requested Representation (X)HTML*|*Requested Representation RDF*|\n|[[http://demo.openlinksw.com/Northwind/Customer/ALFKI][http://demo.openlinksw.com/Northwind/Customer/ALFKI]] | Slash based | 406 (Not available or applicable) or 303 (Redirect to an associated resource in requested representation format, e.g., [[http://demo.openlinksw.com/][http://demo.openlinksw.com/]])| 303 (Redirect to URL of information resource that DESCRIBEs the entity [[http://demo.openlinksw.com/][http://demo.openlinksw.com/]] in the Data space [[http://demo.openlinksw.com/][http://demo.openlinksw.com/]]) |\n|[[http://demo.openlinksw.com/Northwind/Customer/ALFKI#this][http://demo.openlinksw.com/Northwind/Customer/ALFKI#this]] | Hash based | 200 OK (Since fragment ID component of the URI doesn't affect the URL for the information resource | 200 OK (Return an information resource that DESCRIBEs the entity [[http://demo.openlinksw.com/][http://demo.openlinksw.com/]] |\n\n---+++ URL Rewriting\n\nURL rewriting is the act of modifying a source URL prior to the final processing of that URL by a Web Server.\n\nThe ability to rewrite URLs may be desirable for many reasons that include:\n\n * Changing Web information resource URLs on the a Web Server without breaking existing bookmarks held in \nUser Agents (e.g., Web browsers)\n\n * URL compaction where shorter URLs may be constructed on a conditional basis for specific User Agents \n(e.g., Email clients)\n\n * Construction of search engine friendly URLs that enable richer indexing since most search engines cannot \nprocess parameterized URLs effectively.\n\n---++++ Using URL Rewriting to Solve Linked Data Deployment Challenges\n\nIn the previous section we demonstrated how content negotiation and HTTP response messages could be used to \naddress the data access issues arising from the use of URIs associated with resource identity and representation.\n\nWe determined earlier that URI naming schemes don't resolve the challenges associated with referencing data. \nTo reiterate, this is demonstrated by the fact that the URIs \n[[http://demo.openlinksw.com/Northwind/Customer/ALFKI][http://demo.openlinksw.com/Northwind/Customer/ALFKI]] and \n[[http://demo.openlinksw.com/Northwind/Customer/ALFKI#this][http://demo.openlinksw.com/Northwind/Customer/ALFKI#this]] \nboth appear as [[http://demo.openlinksw.com/Northwind/Customer/ALFKI][http://demo.openlinksw.com/Northwind/Customer/ALFKI]] \nto the Web Server, since data following the fragment identifier \"#\" never makes it that far.\n\nThe only way to address data referencing is by pre-processing source URIs (e.g., via regular expression or \nsprintf substitutions) as part of a URL rewriting processing pipeline. The pipeline process has to take the \nform of a set of rules that cater for elements such as HTTP Accept headers, HTTP response code, HTTP response \nheaders, and rule processing order.\n\nAn example of such a pipeline for the hash URI scheme is depicted in the table below:\n\n|*URI Source (Regular Expression Pattern)*|*HTTP Accept Headers (Regular Expression)*|*HTTP Response Code*|*HTTP Response Headers*|*Rule Processing Order*|\n|/Northwind/Customer/([^#]*)|None (meaning default)|200 or 303 responses depending on the user agent default or server side quality of service rules via Transparent Content Negotiation.|None|Normal (order irrelevant)|\n|/Northwind/Customer/([^#]*)|(text/rdf.n3) / (application/rdf.xml) | 200 OK and return the information resource that DESCRIBEs the entity identified by the hash URI in the requested representation. | None | Normal (order irrelevant) |\n|/Northwind/Customer/([^#]*)| (text/html) / (application/xhtml.xml) | 200 OK and return an information resource in requested representation. | None | Normal (order irrelevant) |\n\nA similar pipeline for the slash URI scheme would be:\n\n|*URI Source (Regular Expression Pattern)*|*HTTP Accept Headers (Regular Expression)*|*HTTP Response Code*|*HTTP Response Headers*|*Rule Processing Order*|\n|/Northwind/Customer/([^#]*)|None (meaning default)|200 or 303 responses depending on the user agent default or server side quality of service rules via Transparent Content Negotiation.| None | Normal (order irrelevant) |\n|/Northwind/Customer/([^#]*)|(text/rdf.n3) / (application/rdf.xml)| 303 Redirect to an associated URL of an information resource that DESCRIBEs the entity identified by the URI | None|Normal (order irrelevant)|\n|/Northwind/Customer/([^#]*)|(text/html) / (application/xhtml.xml)|406 (Not Acceptable) or 303 Redirect to location of resource in requested representation|Vary: negotiate, accept Alternates: {\"ALFKI\" 0.9 {type application/rdf+xml}}|Last (must be last in processing chain)|\n\nThe source URI patterns refer to virtual or physical directories at [[http://demo.openlinksw.com/][http://demo.openlinksw.com/]]. Rules can be \nplaced at the head or tail of the pipeline, or applied in the order they are declared, by specifying a Rule \nProcessing Order of First, Last, or Normal, respectively. The decision as to which representation to return \nfor URI [[http://demo.openlinksw.com/Northwind/Customer/ALFKI][http://demo.openlinksw.com/Northwind/Customer/ALFKI]] is based on the MIME\ntype(s) specified in any Accept header accompanying the request.\n\nIn the case of the last rule, the Alternates response header applies only to response code 406. 406 would be \nreturned if there were no (X)HTML representation available for the requested resource. In the example shown, \nan alternative representation is available in RDF/XML.\n\nWhen applied to matching HTTP requests, the last two rules might generate responses similar to those below:\n\n\n\n$ curl -I -H \"Accept: application/rdf+xml\" http://demo.openlinksw.com/Northwind/Customer/ALFKI\n\nHTTP/1.1 303 See Other\nServer: Virtuoso/05.00.3016 (Solaris) x86_64-sun-solaris2.10-64 PHP5\nConnection: close\nContent-Type: text/html; charset=ISO-8859-1\nDate: Mon, 16 Jul 2007 22:40:03 GMT\nAccept-Ranges: bytes\nLocation: /sparql?query=CONSTRUCT+{+%3Chttp%3A//demo.openlinksw.com/Northwind/Custom\ner/ALFKI%23this%3E+%3Fp+%3Fo+}+FROM+%3Chttp%3A//demo.openlinksw.com/Northwind%3E+WHE\nRE+{+%3Chttp%3A//demo.openlinksw.com/Northwind/Customer/ALFKI%23this%3E+%3Fp+%3Fo+}&\nformat=application/rdf%2Bxml\nContent-Length: 0 \n\n\nIn the cURL exchange depicted above, the target Virtuoso server redirects to a SPARQL endpoint that retrieves \nan RDF/XML representation of the requested entity.\n\n\n$ curl -I -H \"Accept: text/html\" http://demo.openlinksw.com/Northwind/Customer/ALFKI\n\nHTTP/1.1 406 Not Acceptable\nServer: Virtuoso/05.00.3016 (Solaris) x86_64-sun-solaris2.10-64 PHP5\nConnection: close\nContent-Type: text/html; charset=ISO-8859-1\nDate: Mon, 16 Jul 2007 22:40:23 GMT\nAccept-Ranges: bytes\nVary: negotiate,accept\nAlternates: {\"ALFKI\" 0.9 {type application/rdf+xml}}\nContent-Length: 0 \n\n\nIn this second cURL exchange, the target Virtuoso server indicates that there is no resource to deliver in the \nrequested representation. It provides hints in the form of an alternate resource representation and URI that \nmay be appropriate, i.e., an RDF/XML representation of the requested entity.\n\n---++ Deploying Linked Data using Virtuoso\n\nThe preceding sections described a generic approach to deploying linked data into the existing Web. We now turn \nour attention to Virtuoso, to describe its solution for linked data deployment.\n\nIn fact, Virtuoso's solution is to implement the generic approach outlined in the prior sections, using the twin \npillars of Content Negotiation and URL rewriting.\n\n---+++ The Virtuoso Rules-Based URL Rewriter\n\nVirtuoso provides a URL rewriter that can be enabled for URLs matching specified patterns. Coupled with \ncustomizable HTTP response headers and response codes, Data-Web server administrators can configure highly \nflexible rules for driving content negotiation and URL rewriting. The key elements of the URL rewriter are:\n\n * Rewriting rule\n * Each rule describes how to parse a single source URL, and how to compose the URL of the page ultimately \nreturned in the \"Location:\" response headers\n * Every rewriting rule is uniquely identified internally (using IRIs).\n * Two types of rule are supported, based on the syntax used to describe the source URL pattern matching: \nsprintf-based and regex-based.\n * Rewrite rules list\n * A named ordered list of rewrite rules or rule lists where rules of the list are processed from top to \nbottom or in line with processing pipeline precedence instructions\n * Configuration API\n * The rewriter configuration API defines functions for creating, dropping, and enumerating rules and \nrule lists.\n * Virtual hosts and virtual paths\n * URL rewriting is enabled by associating a rewrite rules list with a virtual directory\n\nEach of these elements is described in more detail below, although complete descriptions of the features or \nfunctions in question are not given. The intention here is to provide an overview of Virtuoso's URL rewriting \ncapabilities and their application to deploying linked data. Please refer to the Virtuoso Reference \nDocumentation for full details.\n\n---+++ Conductor UI for the URL Rewriter\n\nVirtuoso is a full-blown HTTP server in its own right. The HTTP server functionality co-exists with the \nproduct core (i.e., DBMS Engine, Web Services Platform, WebDAV filesystem, and other components of the \nUniversal Server). As a result, it has the ability to multi-home Web domains within a single instance \nacross a variety of domain name and port combinations. In addition, it also enables the creation of \nmultiple virtual directories per domain.\n\nIn addition to the basic functionality describe above, Virtuoso facilitates the association of URL Rewriting \nrules with the virtual directories associated with a hosted Web domain. \n\nIn all cases, Virtuoso enables you to configure virtual domains, virtual directories and URL rewrite rules \nfor one or more virtual directories, via the (X)HTML-based Conductor Admin User Interface or a collection \nof Virtuoso Stored Procedure Language (PL)-based APIs.\n\n---+++ Virtual Domains (Hosts) & Directories\n\nA Virtuoso virtual directory maps a logical path to a physical directory that is file system or WebDAV based. \nThis mechanism allows physical locations to be hidden or simply reorganized. Virtual directory definitions \nare held in the system table DB.DBA.HTTP_PATH. Virtual directories can be administered in \nthree basic ways:\n\n * Using the Visual Administration Interface via a Web browser;\n * Using the functions vhost_define() and vhost_remove(); and\n * Using SQL statements to directly update the HTTP_PATH system table.\n\n---+++ \"Nice\" URLs vs. \"Long\" URLs\n\nAlthough we are approaching the URL Rewriter from the perspective of deploying linked data, the Rewriter was \ndeveloped with additional objectives in mind. These in turn have influenced the naming of some of the formal \nargument names in the Configuration API function prototypes. In the following sections, long URLs are those \ncontaining a query string with named parameters; nice (aka. source) URLs have data encoded in some other \nformat. The primary goal of the Rewriter is to accept a nice URL from an application and convert this into \na long URL, which then identifies the page that should actually be retrieved.\n\n---+++ Rule Processing Mechanics\n\nWhen an HTTP request is accepted by the Virtuoso HTTP server, the received nice URL is passed to an internal \npath translation function. This function takes the nice URL and, if the current virtual directory has a \nurl_rewrite option set to an existing ruleset name, tries to match the corresponding rulesets and rules; \nthat is, it performs a recursive traversal of any rule-list associated with it. For every rule in the rule-list, \nthe same logic is applied (only the logic for regex-based rules is described; that for sprintf-based rules is \nvery similar):\n\n * The input for the rule is the resource URL as received from the HTTP header, i.e., the portion of the URL \nfrom the first solidus ('/') after the host:port fields to the end of the URL.\n * The input is normalized.\n * The input is matched against the rule's regex. If the match fails, the rule is not applied and the next \nrule is tried. If the match succeeds, the result is a vector of values.\n * If the URL contains a query string, the names and values of the parameters are decoded by \nsplit_and_decode().\n * The names and values of any parameters in the request body are also decoded.\n * The destination URL is composed:\n * The value of each parameter in the destination URL is taken from (in order of priority):\n * the value of a parameter in the match result;\n * the value of a named parameter in the query string of the input nice URL;\n * if the original request was submitted by the POST method, the value of a named parameter in the body of \nthe POST request; or\n * if a parameter value cannot be derived from one of these sources, the rule is not applied and the next \nrule is tried.\n\nNote: \n\nThe path translation function described above is internal to the Web server, so its signature is not appropriate \nfor Virtuoso/PL calls and thus is not published. Virtuoso/PL developers can harness the same functionality using \nthe DB.DBA.URLREWRITE_APPLY API call.\n\n---+++ Enabling URL Rewriting via the Virtuoso Conductor UI\n\nThe steps for configuring URL Rewrite rules via the Virtuoso Conductor are as follows:\n\n 1. Assuming you are using the local demonstration database, load [[http://localhost:8890/conductor][http://localhost:8890/conductor]] into your \nbrowser, and then proceed through the Conductor as follows:\n 1. Click the \"WebDAV & HTTP\", and \"HTTP Hosts & Directories\" tabs\n 1. Pick the domain that contains the virtual directories to which the rules are to be applied (in this case \nthe default was taken)\n 1. Click on the \"URL-rewrite\" link to create, delete, or edit a rule as shown below:\n 1. Create a Rule for HTML Representation Requests (via SPARQL SELECT Query)\n 1. Create a Rule for RDF Representation Requests (via SPARQL CONSTRUCT Query)\n 1. Then save and exit the Conductor, and test your rules with curl or any other User Agent.\n%BR%%BR%%BR%%BR%\n\n---+++ Enabling URL Rewriting via Virtuoso PL\n\nThe vhost_define() API is used to define virtual hosts and virtual paths hosted by the Virtuoso \nHTTP server. URL rewriting is enabled through this function's opts parameter. opts is of type ANY, e.g., a vector \nof field-value pairs. Numerous fields are recognized for controlling different options. The field value \nurl_rewrite controls URL rewriting. The corresponding field value is the IRI of a rule list \nto apply.\n\n---++++ Configuration API\n\nVirtuoso includes the following functions for managing URL rewriting rules and rule lists. The names are self-explanatory.\n\n * DB.DBA.URLREWRITE_DROP_RULE — Deletes a rewriting rule\n * DB.DBA.URLREWRITE_CREATE_SPRINTF_RULE — Creates a rewriting rule which uses sprintf-based pattern matching\n * DB.DBA.URLREWRITE_CREATE_REGEX_RULE — Creates a rewriting rule which uses regular expression (regex) based pattern matching\n * DB.DBA.URLREWRITE_DROP_RULELIST — Deletes a rewriting rule list\n * DB.DBA.URLREWRITE_CREATE_RULELIST — Creates a rewriting rule list\n * DB.DBA.URLREWRITE_ENUMERATE_RULES — Lists all the rules whose IRI match the specified 'SQL like' pattern\n * DB.DBA.URLREWRITE_ENUMERATE_RULELISTS — Lists all the rule lists whose IRIs match the specified 'SQL like' pattern\n\n---++++ Creating Rewriting Rules\n\nRewriting rules take two forms: sprintf-based or regex-based. When used for nice URL to long URL conversion, the \nonly difference between them is the syntax of format strings. The reverse long to nice conversion works only for \nsprintf-based rules, whereas regex-based rules are unidirectional. \n\nFor the purposes of describing how to make dereferenceable URIs for linked data, we will stick with the nice to \nlong conversion using regex-based rules.\n\nRegex rules are created using the URLREWRITE_CREATE_REGEX_RULE() function.\n\n---+++++ Function Prototype:\n\n\nURLREWRITE_CREATE_REGEX_RULE (\nrule_iri,\nallow_update,\nnice_match,\nnice_params,\nnice_min_params,\ntarget_compose,\ntarget_params,\ntarget_expn := null,\naccept_pattern := null,\ndo_not_continue := 0,\nhttp_redirect_code := null\n);\n\n\n---+++++ Parameters:\n\n * rule_iri: VARCHAR. The rule's name / identifier\n * allow_update: INTEGER. Indicates whether the rule can be updated. Non-zero indicates yes; \n0 indicates no. The update is subject to the following rules:\n * If the given rule_iri is already in use as a rule list identifier, an error is signaled.\n * If the given rule_iri is already in use as a rule identifier and allow_update \nfor the existing rule is 0, an error is signaled.\n * If the given rule_iri is already in use as a rule identifier and allow_update \nfor the existing rule is non-zero, the existing rule is updated.\n * nice_match: VARCHAR. A regex match expression to parse the URL into a vector of occurrences.\n * nice_params: ANY. A vector of the names of the parsed parameters. The length of the vector should \nbe equal to the number of '(...)' specifiers in the format string.\n * nice_min_params: INTEGER. Used to specify the minimum number of sprintf format patterns to be matched in order to trigger the given rule. It \nonly affects sprintf rules and has no effect for regex rules.\n * target_compose: VARCHAR. A regex compose expression for the URL of the destination page.\n * target_params: ANY. A vector of names of parameters that should be passed to the compose expression (target_compose) as $1, $2 and so on.\n * target_expn: VARCHAR. Optional SQL text that should be executed instead of a regex compose call.\n * accept_pattern: VARCHAR. A regex expression to match the HTTP Accept header\n * do_not_continue: INTEGER. If the given rule satisfies the match conditions, 1 signifies do not try the next rule from same rule list, and \n0 signifies try the next rule.\n * http_redirect_code: INTEGER. NULL or the integer values 301, 302, 303, or 406, are currently allowed. If a 3xx redirect code is given, an HTTP \nredirect response will be sent back to client. If NULL is specified, the server will process the redirect internally.\n\n---+++ Example - URL Rewriting For the Northwind Linked Data View\n\nIn our Linked Data Views of SQL white paper we covered the process of declaring Linked Data Views of SQL data via the Virtuoso \nMeta-schema Language. When producing the Linked Data Views we used the Virtuoso \"Demo\" database, which is very similar \nto the \"Northwind\" database that comes as an installation bundle with Microsoft ACCESS and SQL Server.\n\nThe Northwind schema is comprised of commonly understood SQL Tables including Customers, Orders, Employees, \nProducts, Product Categories, Shippers, Countries, Provinces, etc.\n\nAn Linked Data View of SQL data is an RDF Named Graph (RDF data set) comprised of RDF Linked Data (triples) stored in \na Virtuoso Quad Store (the native RDF Data Management realm of Virtuoso).\n\nIn the example that follows, we are going interact with Linked Data deployed into the Data-Web from a live instance \nof Virtuoso, which uses the URL Rewrite rules from the prior section.\n\nThe components used in the example are as follows:\n\n 1. Virtuoso SPARQL Endpoint: [[http://demo.openlinksw.com/sparql][http://demo.openlinksw.com/sparql]]\n 1. Named RDF Graph: [[http://demo.openlinksw.com/Northwind][http://demo.openlinksw.com/Northwind]]\n 1. Entity ID - [[http://demo.openlinksw.com/Northwind/Customer/ALFKI#this][http://demo.openlinksw.com/Northwind/Customer/ALFKI#this]]\n 1. Information Resource: [[http://demo.openlinksw.com/Northwind/Customer/ALFKI][http://demo.openlinksw.com/Northwind/Customer/ALFKI]]\n 1. Interactive SPARQL Query Builder (iSPARQL) - [[http://demo.openlinksw.com/DAV/JS/isparql/index.html][http://demo.openlinksw.com/DAV/JS/isparql/index.html]]\n\n---++++ Interacting with Linked Data via RDF Browser\n\nSteps:\n\n 1. Start the browser - [[http://demo.openlinksw.com/DAV/JS/rdfbrowser/index.html][http://demo.openlinksw.com/DAV/JS/rdfbrowser/index.html]]\n 1. Enter the Information Resource URI, \n[[http://demo.openlinksw.com/Northwind/Customer/ALFKI][http://demo.openlinksw.com/Northwind/Customer/ALFKI]], \ninto the input field labeled \"URI\"\n%BR%%BR%%BR%%BR%\n 1. Click on the \"Query\" button or simply hit \"Enter\" after typing (or pasting in) the Information Resource URI\n 1. For the purpose of this exercise, view the data returned via the \"Navigator\" Viewer\n%BR%%BR%%BR%%BR%\n 1. Click on the \"Raw Triples\" viewer tab and observe the exposure of the Entity \n[[http://demo.openlinksw.com/Northwind/Customer/ALFKI#this][http://demo.openlinksw.com/Northwind/Customer/ALFKI#this]] \nvia the Triple based (Subject, Predicate, Object) records in the results table.\n%BR%%BR%%BR%%BR%\n\n---++++ Interacting with Linked Data via iSPARQL\n\nWe can interact with the same Information Resource and associated RDF using the iSPARQL Query tool as follows:\n\n 1. Start the Query Builder by entering the following into your browser: \n[[http://demo.openlinksw.com/isparql][http://demo.openlinksw.com/isparql]] \nYou will be presented with a default Query By Example (QBE) canvas that includes a default Graph Pattern and \na default URI. Change the URI to: \n[[http://demo.openlinksw.com/Northwind/Customer/ALFKI][http://demo.openlinksw.com/Northwind/Customer/ALFKI]] \n(Information Resource as a Data Resource in the context of RDF)\n%BR%%BR%%BR%%BR%\n 1. Then execute the default query (which simply gets a list of concepts), by clicking on the \">\" button. \nNote: There is a single record in the result table. It indicates that there is a single concept, Organization, \nas defined by the FOAF schema.\n%BR%%BR%%BR%%BR%\n 1. Click on the foaf:Organization record, and you will be presented with a Data Web-optimized hyperlink that \npresents you with three options: Dereference, Explore, and (X)HTML Page Open.\n%BR%%BR%%BR%%BR%\n 1. Click Explore (since you are interested in \"instance data\" for the foaf:Organization concept, as opposed \nto the schema definitions of said concept). You will be presented with \n[[http://demo.openlinksw.com/Northwind/Customer/ALFKI#this][http://demo.openlinksw.com/Northwind/Customer/ALFKI#this]] \nwhich is an RDF Entity ID of a foaf:Organization instance.\n%BR%%BR%%BR%%BR%\n 1. Click on the \n[[http://demo.openlinksw.com/Northwind/Customer/ALFKI][http://demo.openlinksw.com/Northwind/Customer/ALFKI]] \nrecord, and you will once again be presented with the enhanced hyperlink and its options. This time, click \nDereference, since you are interested in the description of the entity \n[[http://demo.openlinksw.com/Northwind/Customer/ALFKI][http://demo.openlinksw.com/Northwind/Customer/ALFKI]], \nas opposed to all the records in the RDF database that are related to it.\n%BR%%BR%%BR%%BR%\n%BR%%BR%%BR%%BR%\n\n\n---++++ Interacting with Linked Data via a standard Document Web Browser\n\nIn the prior sections, we used the OpenLink RDF Browser and iSPARQL Query-By-Example tools to interact with \nRDF Entities via associated Information Resources. Each of these tools includes a Resource Save feature that \nenables you to save an RDF Browser session or an iSPARQL Query for future reuse. In either scenario the \nend-product is a Dynamic Linked Data Page — a Web Information Resource (document) that includes links to RDF \nbased Linked Data.\n\n---+++++ Saved Browser Session\n\nSteps:\n\n 1. From your RDF Browser session, go to the Session >> Save menu item.\n%BR%%BR%%BR%%BR%\n 1. Select a directory location (note: this is a WebDAV location in the Virtuoso Server) and then enter \na file name, e.g., ALFKI_Linked_Datay. The saved file will automatically be assigned the \nextension .wqx.\n%BR%%BR%%BR%%BR%\n 1. Open a standard browser instance on your internet device (desktop, notebook, phone, etc.), and enter \nthe URL for the location into which you just saved your browser session, e.g., \n[[http://demo.openlinksw.com/DAV/home/demo/Public/Queries/SQLRDFIntegraton/][http://demo.openlinksw.com/DAV/home/demo/Public/Queries/SQLRDFIntegraton/]] \n(based on our example).\n%BR%%BR%%BR%%BR%\n 1. Click on the file ALFKI_Linked_Data.wqx, which will then reveal a browser session-oriented \nLinked Data page.\n%BR%%BR%%BR%%BR%\n%BR%%BR%%BR%%BR%\n\n---+++++ Saved iSPARQL Query\n\nSteps:\n\n 1. From your iSPARQL Session, pick the File >> Save (if first time) or File >> Save As (for saving to different name)\n%BR%%BR%%BR%%BR%\n 1. Type in a name for your saved query, e.g., ALFKI_Linked_Data. Note that you have a number of file \ntype options. For this exercise, we are going to choose the .isparql type, since we are attempting to create a Dynamic \nLinked Data page.\n%BR%%BR%%BR%%BR%\n 1. Open a standard browser instance on your internet device (desktop, notebook, phone, etc.), and enter the URL for \nthe location into which you save your browser session, e.g., \n[[http://demo.openlinksw.com/DAV/home/demo/Public/Queries/SQLRDFIntegraton/][http://demo.openlinksw.com/DAV/home/demo/Public/Queries/SQLRDFIntegraton/]] \n(based on our example).\n%BR%%BR%%BR%%BR%\n 1. Click on the file ALFKI_Linked_Data.isparql, and then interact with the Linked Data page.\n%BR%%BR%%BR%%BR%\n\n---++++ Northwind URL Rewriting Verification Using curl\n\nAs illustrated earlier, the curl utility provides a useful tool for verifying HTTP server responses and rewriting rules. \nThe curl exchanges below show the URL rewriting rules defined for the Northwind Linked Data View being applied.\n\n---+++++Example 1\n\n\n$ curl -I -H \"Accept: text/html\" http://demo.openlinksw.com/Northwind/Customer/ALFKI \n\nHTTP/1.1 303 See Other \nServer: Virtuoso/05.00.3016 (Solaris) x86_64-sun-solaris2.10-64 PHP5 \nConnection: close \nContent-Type: text/html; charset=ISO-8859-1\nDate: Tue, 14 Aug 2007 13:30:02 GMT \nAccept-Ranges: bytes \nLocation: /isparql/execute.html?query=SELECT%20%3Fp%20%3Fo%20FROM%20%3Chttp%3A//dem\no.openlinksw.com/Northwind%3E%20WHERE%20{%20%3Chttp%3A//demo.openlinksw.com/Northwin\nd/Customer/ALFKI%23this%3E%20%3Fp%20%3Fo%20}&endpoint=/sparql\nContent-Length: 0 \n\n\n---+++++Example 2\n\n\n$ curl -I -H \"Accept: application/rdf+xml\" http://demo.openlinksw.com/Northwind/Cust\nomer/ALFKI\n\nHTTP/1.1 303 See Other\nServer: Virtuoso/05.00.3016 (Solaris) x86_64-sun-solaris2.10-64 PHP5 \nConnection: close\nContent-Type: text/html; charset=ISO-8859-1\nDate: Tue, 14 Aug 2007 13:30:22 GMT\nAccept-Ranges: bytes \nLocation: /sparql?query=CONSTRUCT+{+%3Chttp%3A//demo.openlinksw.com/Northwind/Custom\ner/ALFKI%23this%3E+%3Fp+%3Fo+}+FROM+%3Chttp%3A//demo.openlinksw.com/Northwind%3E+WHE\nRE+{+%3Chttp%3A//demo.openlinksw.com/Northwind/Customer/ALFKI%23this%3E+%3Fp+%3Fo+}&\nformat=application/rdf%2Bxml\nContent-Length: 0 \n\n\n---+++++Example 3\n\n\n$ curl -I -H \"Accept: text/html\" http://demo.openlinksw.com/Northwind/Customer/ALFKI\n#this \n\nHTTP/1.1 404 Not Found \nServer: Virtuoso/05.00.3016 (Solaris) x86_64-sun-solaris2.10-64 PHP5 \nConnection: Keep-Alive\nContent-Type: text/html; charset=ISO-8859-1 \nDate: Tue, 14 Aug 2007 13:31:01 GMT \nAccept-Ranges: bytes \nContent-Length: 0 \n\n\nThe output above shows how RDF entities from the Data-Web, in this case customer ALFKI, are exposed in the Document Web. \nThe power of SPARQL coupled with URL rewriting enables us to produce results in line with the desired representation. \nA SPARQL SELECT or CONSTRUCT query is used depending on whether the requested representation is text/html or \napplication/rdf+xml, respectively.\n\nThe 404 response in Example 3 indicates that no HTML representation is available for entity ALFKI#this. In most cases, \na URI of this form (containing a '#' fragment identifier) will not reach the server. This example supposes that it does, \ni.e., the RDF client and network routing allows the suffixed request. The presence of the #this suffix implicitly states \n#BodyNote2\nthat this is a request for a data resource in the Data-Web realm, not a document resource from the Document Web. [[#FootNote2][Note 2]]\n\nRather than return 404, we could instead choose to construct our rewriting rules to perform a 303 redirect, so that the \nresponse for ALFKI#this in Example 3 becomes the same as that for ALFKI in Example 1.\n\n---+++ Transparent Content Negotiation\n\nSo as not to overload our preceding description of Linked Data deployment with excessive detail, the description of content \nnegotiation presented thus far was kept deliberately brief. This section discusses content negotiation in more detail.\n\n---++++ HTTP/1.1 Content Negotiation\n\nRecall that a resource (conceptual entity) identified by a URI may be associated with more than one representation (e.g., \nmultiple languages, data formats, sizes, resolutions). If multiple representations are available, the resource is referred \nto as negotiable and each of its representations is termed a variant. For instance, a Web document resource, named 'ALFKI' \nmay have three variants: alfki.xml, alfki.html, and alfki.txt, all representing the same data. Content negotiation provides \na mechanism for selecting the best variant.\n\nAs outlined in the earlier brief discussion of content negotiation, when a user agent requests a resource, it can include \nwith the request Accept headers (Accept, Accept-Language, Accept-Charset, Accept-Encoding, etc.) which express the user \npreferences and user agent capabilities. The server then chooses and returns the best variant based on the Accept headers. \nBecause the selection of the best resource representation is made by the server, this scheme is classed as server-driven \nnegotiation.\n\n---++++ Transparent Content Negotiation\n\nAn alternative content negotiation mechanism is Transparent Content Negotiation (TCN), a protocol defined by RFC2295. TCN \noffers a number of benefits over standard HTTP/1.1 negotiation, for suitably enabled user agents.\n\nRFC2295 introduces a number of new HTTP headers including the Negotiate request header, and the TCN and Alternates response \nheaders. (Krishnamurthy et al note that although the HTTP/1.1 specification reserved the Alternates header for use in agent-\ndriven negotiation, it was not fully specified. Consequently under a pure HTTP/1.1 implementation as defined by RFC2616, \nserver-driven content negotiation is the only option. RFC2295 addresses this issue.)\n\n---+++++ Deficiencies of HTTP/1.1 Server-Driven Negotiation\n\nWeaknesses of server-driven negotiation highlighted by RFCs 2295 and 2616 include:\n\n * Inefficiency — Sending details of a user agent's capabilities and preferences with every request is very inefficient, \nnot least because very few Web resources have multiple variants, and expensive in terms of the number of Accept headers \nrequired to fully describe all but the most simple browser's capabilities.\n * Server doesn't always know 'best' — Having the server decide on the 'best' variant may not always result in the most \nsuitable resource representation being returned to the client. The user agent might often be better placed to decide what \nis best for its needs.\n\n---+++++ Variant Selection By User Agent\n\nRather than rely on server-driven negotiation and variant selection by the server, a user agent can take full control over \ndeciding the best variant by explicitly requesting transparent content negotiation through the Negotiate request header. \nThe negotiation is 'transparent' because it makes all the variants on the server visible to the agent.\n\nUnder this scheme, the server sends the user agent a list, represented in an Alternates header, containing the available \nvariants and their properties. The user agent can then choose the best variant itself. Consequently, the agent no longer \nneeds to send large Accept headers describing in detail its capabilities and preferences. (However, unless caching is used, \nuser-agent driven negotiation does suffer from the disadvantage of needing a second request to obtain the best representation. \nBy sending its best guess as the first response, server driven negotiation avoids this second request if the initial best \nguess is acceptable.)\n\n---+++++ Variant Selection By Server\n\nAs well as variant selection by the user agent, TCN allows the server to choose on behalf of the user agent if the user agent \nexplicitly allows it through the Negotiate request header. This option allows the user agent to send smaller Accept headers \ncontaining enough information to allow the server to choose the best variant and return it directly. The server's choice is \ncontrolled by a 'remote variant selection algorithm' as defined in RFC2296.\n\n---+++++ Variant Selection By End-User\n\nA further option is to allow the end-user to select a variant, in case the choice made by negotiation process is not optimal. \nFor instance, the user agent could display an HTML-based 'pick list' of variants constructed from the variant list returned \nby the server. Alternatively the server could generate this pick list itself and include it in the response to a user agent's \nrequest for a variant list. (Virtuoso currently responds this way.)\n\n---+++ Transparent Content Negotiation in Virtuoso HTTP Server\n\nThe following section describes the Virtuoso HTTP server's TCN implementation which is based on RFC2295, but without \"Feature\"\nnegotiation. OpenLink's RDF rich clients, iSparql and the OpenLink RDF Browser, both support TCN. User agents which do not \nsupport transparent content negotiation continue to be handled using HTTP/1.1 style content negotiation (whereby server-side \nselection is the only option - the server selects the best variant and returns a list of variants in an Alternates response \nheader).\n\n---++++ Describing Resource Variants\n\nIn order to negotiate a resource, the server needs to be given information about each of the variants. Variant descriptions \nare held in SQL table HTTP_VARIANT_MAP. The descriptions themselves can be created, updated or deleted using \nVirtuoso/PL or through the Conductor UI.\n\n---+++++ HTTP_VARIANT_MAP Table Definition\n\nThe table definition is as follows:\n\n\ncreate table DB.DBA.HTTP_VARIANT_MAP (\n VM_ID integer identity, -- unique ID \n VM_RULELIST varchar, -- HTTP rule list name \n VM_URI varchar, -- name of requested resource e.g. 'page' \n VM_VARIANT_URI varchar, -- name of variant e.g. 'page.xml', 'page.de.html' etc. \n VM_QS float, -- Source quality, a number in the range 0.001-1.000, with 3 digit precision \n VM_TYPE varchar, -- Content type of the variant e.g. text/xml \n VM_LANG varchar, -- Content language e.g. 'en', 'de' etc. \n VM_ENC varchar, -- Content encoding e.g. 'utf-8', 'ISO-8892' etc. \n VM_DESCRIPTION long varchar, -- a human readable description about the variant e.g. 'Profile in RDF format' \n VM_ALGO int default 0, -- reserved for future use \n primary key (VM_RULELIST, VM_URI, VM_VARIANT_URI)\n ) \ncreate unique index HTTP_VARIANT_MAP_ID on DB.DBA.HTTP_VARIANT_MAP (VM_ID)\n\n\n\n---+++++ Configuration using Virtuoso/PL\n\nTwo functions are provided for adding or updating, or removing variant descriptions using Virtuoso/PL:\n\n---++++++ Adding or Updating a Resource Variant:\n\n\nDB.DBA.HTTP_VARIANT_ADD ( \n in rulelist_uri varchar, -- HTTP rule list name \n in uri varchar, -- Requested resource name e.g. 'page' \n in variant_uri varchar, -- Variant name e.g. 'page.xml', 'page.de.html' etc. \n in mime varchar, -- Content type of the variant e.g. text/xml \n in qs float := 1.0, -- Source quality, a floating point number with 3 digit precision in 0.001-1.000 range \n in description varchar := null, -- a human readable description of the variant e.g. 'Profile in RDF format' \n in lang varchar := null, -- Content language e.g. 'en', 'bg'. 'de' etc. \n in enc varchar := null -- Content encoding e.g. 'utf-8', 'ISO-8892' etc. \n)\n\n\n---++++++Removing a Resource Variant\n\n\nDB.DBA.HTTP_VARIANT_REMOVE ( \n in rulelist_uri varchar, -- HTTP rule list name \n in uri varchar, -- Name of requested resource e.g. 'page' \n in variant_uri varchar := '%' -- Variant name filter \n)\n\n\n---+++++ Configuration using Conductor UI\n\nThe Conductor 'Content negotiation' panel for describing resource variants and configuring content negotiation is \ndepicted below. It can be reached by selecting the 'HTTP Hosts & Directories' tab under the 'WebDAV & HTTP' menu \nitem, then selecting the 'URL rewrite' option for a logical path listed amongst those for the relevant HTTP host, \ne.g., '{Default Web Site}'.\n\nThe screen snapshot shows the variant descriptions created by issuing the HTTP_VARIANT_ADD and \nVHOST_DEFINE Virtuoso/PL calls detailed in the examples at the end of this section. Obviously \nthese definitions could instead have been created entirely 'from scratch' through the Conductor UI.\n\nThe input fields reflect the supported 'dimensions' of negotiation which include content type, language and encoding. \nQuality values corresponding to the options for 'Source Quality' are as follows:\n\n|*Source Quality*|*Quality Value*|\n|perfect representation|1.000|\n|threshold of noticeable loss of quality|0.900|\n|noticeable, but acceptable quality reduction|0.800|\n|barely acceptable quality|0.500|\n|severely degraded quality|0.300|\n|completely degraded quality|0.000|\n\n---++++ Variant Selection Algorithm\n\nWhen a user agent instructs the server to select the best variant, Virtuoso does so using the selection algorithm \nbelow:\n\nIf a virtual directory has URL rewriting enabled (has the 'url_rewrite' option set), the web server:\n\n * Looks in DB.DBA.HTTP_VARIANT_MAP for a VM_RULELIST matching the one specified \nin the 'url_rewrite' option\n\n * If present, it loops over all variants for which VM_URI is equal to the resource requested\n\n * For every variant it calculates the source quality based on the value of VM_QS and the source \nquality given by the user agent\n\n * If the best variant is found, it adds TCN HTTP headers to the response and passes the \nVM_VARIANT_URI to the URL rewriter\n\n * If the user agent has asked for a variant list, it composes such a list and returns an 'Alternates' HTTP header \nwith response code 300\n\n * If no URL rewriter rules exist for the target URL, the web server returns the content of the dereferenced \nVM_VARIANT_URI.\n\nThe server may return the best-choice resource representation or a list of available resource variants. When a user \nagent requests transparent negotiation, the web server returns the TCN header \"choice\". When a user agent asks for \na variant list, the server returns the TCN header \"list\".\n\n---++++ Examples\n\nIn this example we assume the following files have been uploaded to the Virtuoso WebDAV server, with each containing \nthe same information but in different formats:\n\n * /DAV/TCN/page.xml - a XML variant\n * /DAV/TCN/page.html - a HTML variant\n * /DAV/TCN/page.txt - a text variant\n\nWe add TCN rules and define a virtual directory:\n\n\nDB.DBA.HTTP_VARIANT_ADD ('http_rule_list_1', 'page', 'page.html', 'text/html', \n0.900000, 'HTML variant'); DB.DBA.HTTP_VARIANT_ADD ('http_rule_list_1', 'page', \n'page.txt', 'text/plain', 0.500000, 'Text document'); DB.DBA.HTTP_VARIANT_ADD \n('http_rule_list_1', 'page', 'page.xml', 'text/xml', 1.000000, 'XML variant'); \nDB.DBA.VHOST_DEFINE (lpath=>'/DAV/TCN/', ppath=>'/DAV/TCN/', is_dav=>1, \nvsp_user=>'dba', opts=>vector ('url_rewrite', 'http_rule_list_1'));\n\n\nHaving done this we can now test the setup with a suitable HTTP client, in this case the curl command line utility. In \nthe following examples, the curl client supplies Negotiate request headers containing content negotiation directives \nwhich include:\n\n * \"trans\" — The user agent supports transparent content negotiation for the current request.\n * \"vlist\" — The user agent requests that any transparently negotiated response for the current request includes an \nAlternates header with the variant list bound to the negotiable resource. Implies \"trans\".\n * \"*\" — The user agent allows servers and proxies to run any remote variant selection algorithm.\n\nThe server returns a TCN response header signaling that the resource is transparently negotiated and either a choice \nor a list response as appropriate.\n\nIn the first curl exchange, the user agent indicates to the server that, of the formats it recognizes, HTML is preferred \nand it instructs the server to perform transparent content negotiation. In the response, the Vary header field expresses \nthe parameters the server used to select a representation, i.e., only the Negotiate and Accept header fields are considered.\n\n\n$ curl -i -H \"Accept: text/xml;q=0.3,text/html;q=1.0,text/plain;q=0.5,*/*;q=0.3\" -H \n\"Negotiate: *\" http://localhost:8890/DAV/TCN/page \n\nHTTP/1.1 200 OK \nServer: Virtuoso/05.00.3021 (Linux) i686-pc-linux-gnu VDB \nConnection: Keep-Alive \nDate: Wed, 31 Oct 2007 15:43:18 GMT \nAccept-Ranges: bytes \nTCN: choice \nVary: negotiate,accept \nContent-Location: page.html \nContent-Type: text/html \nETag: \"14056a25c066a6e0a6e65889754a0602\" \nContent-Length: 49\n\n some html \n\n\n\nNext, the source quality values are adjusted so that the user agent indicates that XML is its preferred format.\n\n\n$ curl -i -H \"Accept: text/xml,text/html;q=0.7,text/plain;q=0.5,*/*;q=0.3\" -H \"Negot\niate: *\" http://localhost:8890/DAV/TCN/page \n\nHTTP/1.1 200 OK \nServer: Virtuoso/05.00.3021 (Linux) i686-pc-linux-gnu VDB \nConnection: Keep-Alive \nDate: Wed, 31 Oct 2007 15:44:07 GMT \nAccept-Ranges: bytes \nTCN: choice \nVary: negotiate,accept \nContent-Location: page.xml \nContent-Type: text/xml \nETag: \"8b09f4b8e358fcb7fd1f0f8fa918973a\" \nContent-Length: 39\n\n some xml\n\n\n\nIn the final example, the user agent wants to decide itself which is the most suitable representation, so it asks \nfor a list of variants. The server provides the list, in the form of an Alternates response header, and, in addition, \nsends an HTML representation of the list so that the end user can decide on the preferred variant himself if the user \nagent is unable to.\n\n\n$ curl -i -H \"Accept: text/xml,text/html;q=0.7,text/plain;q=0.5,*/*;q=0.3\" -H \"Negot\niate: vlist\" http://localhost:8890/DAV/TCN/page \n\nHTTP/1.1 300 Multiple Choices \nServer: Virtuoso/05.00.3021 (Linux) i686-pc-linux-gnu VDB \nConnection: close \nContent-Type: text/html; charset=ISO-8859-1 \nDate: Wed, 31 Oct 2007 15:44:35 GMT \nAccept-Ranges: bytes \nTCN: list \nVary: negotiate,accept \nAlternates: {\"page.html\" 0.900000 {type text/html}}, {\"page.txt\" 0.500000 {type text\n/plain}}, {\"page.xml\" 1.000000 {type text/xml}} \nContent-Length: 368\n\n\n\n\n300 Multiple Choices\n\n\n

Multiple Choices

\nAvailable variants: \n\n\n\n
\n\n---+++ Glossary\n\n * class: A concept in a domain of interest. A class describes the common attributes and behaviors shared \nby entities belonging to the same group by virtue of their common characteristics.\n * content negotiation: A mechanism defined in HTTP which supports serving different representations of a \nURL-addressable resource. An HTTP client can indicate which representation formats it understands and prefers.\n * cURL: A command line tool for transferring files to or from a URL. It writes to standard output by default \nand provides a good tool for simulating a web browser's interaction with an HTTP server. \n * data resource: same as data source\n * data source: A source of data (e.g., a place that provides access to property values associated with one \nor more Entities).\n * data space: A moniker for Web-accessible atomic containers that manage and expose data, information, \nservices, processes, and knowledge. Data Spaces are fundamentally problem-domain-specific database applications \nwith the benefit of being data model and query language agnostic.\n * dereferencing: The act of accessing and retrieving data, in desired representation, from a location \nidentified by URL.\n * document resource: A Web information resource in a specific representation that is identifiable and \naccessible via a URL. Documents are the dominant information resource form on the Document Web (i.e., the \ncurrent Web).\n * Document Web: Web of Linked Documents.\n * entity: Something, real or conceptual, which exists apart from other things.\n * entity ID: A unique identifier for an entity, uniquely identifying and distinguishing a particular entity \ninstance from other similar entities (typically of the same type or class).\n * entity set: A collection of entities all belonging to the same class.\n * HTTP: Hypertext Transport Protocol.\n * HTTP header: A text record exchanged between an HTTP client and server, which forms part of an HTTP request \nor HTTP response message. A request consists of a method (or verb), headers, and an optional message body. The \nrequest header fields allow the client to send additional information about the request and the client itself. \nA response consists of a status line, headers, and an optional message body. A response header typically contains \ninformation about the data being returned and about the server itself.\n * Hypertext Transport Protocol): A communication protocol for information transfer on the World Wide Web.\n * information resource: An encapsulation of data and representation that forms the basic payload unit (packet) \non the Web Information Bus.\n * IRI (Internationalized Resource Identifier): An internationalized version of a Uniform Resource Identifier \n(URI). While URIs are limited to a subset of the ASCII character set, IRIs may contain any Unicode character.\n * Linked Data: Information resource(s) encapsulating Structured Data expressed in RDF.\n * non-information resource: Any resource that is not an information resource (i.e., not Web transportable in \nbasic form). Structured data resource (see below) is a more accurate and preferable term.\n * Semantic Data-Web: Web of Linked Data.\n * structured data: Data organized into semantic chunks or entities, with similar entities grouped together in \nrelations or classes, and presented in a patterned manner.\n * structured data resource: A Web accessible container of structured data representing physical and abstract \nentities.\n * structured data source: A repository of structured data.\n * URI (Uniform Resource Identifier ): An Internet naming syntax which identifies a resource. The resource may \nbe abstract and consequently not dereferenceable.\n * URL (Uniform Resource Locator): An Internet naming syntax, which specifies both the identity and location of \na physical, dereferenceable Web information resource. Although URLs and URIs share the same syntax, a URI specifies \nonly the identity of a resource.\n * Web information resource: An entity of interest, which both exists in some form and is accessible on the \nWorld Wide Web.\n\n\n---++ Notes\n\n#FootNote1\n 1. Reiterating our earlier point, the URL identifies the resource, not its representations. [[#BodyNote1][return]]\n#FootNote2\n 2. Some Semantic Web (SemWeb) practitioners have argued in favor of using the URI format to \ndistinguish between requests for document resources (also sometimes termed as information resources) belonging \nto the Document Web, and Data Sources, i.e., physical or abstract RDF entities (also sometimes referred to as \nnon-information resources) belonging to the Data Web. (The terms information resource and non-information resource \nare disliked by many and have generated a good deal of debate.) With this so-called 'hash vs. slash' URI convention, \nthe presence of a fragment identifier (a hash URI, using the \"#\") is taken to mean that a data source (entity) is \nbeing referenced; the absence of a fragment identifier (a slash URI, not using the \"#\") implies a document resource \nis being referenced. [[#BodyNote2][return]]\n\n---++ Bibliography\n\n * OpenLink Software: Virtuoso Linked Data Views - Getting Started Guide\n * T. Berners-Lee: Linked Data\n * C. Bizer et al.: How to Publish Linked Data on the Web\n * L. Sauermann et al.: Cool URIs for the Semantic Web\n * P. Hayes: In Defence of Ambiguity\n * R. Cyganiak: Debugging Semantic Web Sites With cURL\n * W3C: Dereferencing HTTP URIs\n * W3C: What do HTTP URIs Identify?\n * W3C: What URIs Identify\n * W3C: [httpRange-14] Resolved\n * W3C: Best Practice Recipes for Publishing RDF Vocabularies\n * Wikipedia: Using HTTP URIs to identify abstract resources\n * B. Krishnamurthy et al.: Key Differences between HTTP/1.0 and HTTP/1.1\n * R. Fielding et al.: RFC2616 - HyperText Transfer Protocol - HTTP/1.1\n * K. Holtman & A. Mutz: RFC2295 - Transparent Content Negotiation in HTTP\n\n---++ See Also \n\n * [[VirtEvaluatorGuideLinkedDataDeployment][Evaluator Guide for Linked Data Deployment]]\n * [[VirtLinkedDataDeploymentTutorialDOAP][Linked Data Deployment DOAP Tutorial]]\n\n---++ Change History\n\n1.0 Initial draft (K. Idehen / C. Blakeley, 14 Aug 2007)\n\n1.1 Additions covering transparent content negotiation (C. Blakeley, 07 Nov 2007)\n\n1.2 ???\n\n1.3 Edit and polish (T. Thibodeau, K. Idehen, etc., Nov 2008)" . . . . "2017-06-13T05:42:29Z" . . . . . . . . . "VirtLinkedDataDeployment" . . . . . "VirtLinkedDataDeployment" . . . . . . . . . . . "ae25dd376c28fa087f7feadcf6b24694" . . . . . . . "VirtLinkedDataDeployment" . . . "2017-06-13T05:42:29.985629"^^ . . . "2017-06-13T05:42:29.985629"^^ . . . . . .