And aside from RDF and RDFS, there are further standards such as OWL: a complex but decidable ontology language representable in RDF based primarily on Description Logics, and RIF: a format for representing and …
Abstract: Given that semantic Web realization is based on the critical mass of metadata accessibility and the representation of data with formal knowledge, it needs to generate metadata that is specific, easy to understand and …
The short article “Analyzing RDF Data: A Realm of Possibilities” by Alexandra Roatis has been accepted for publication in ERCIM News 96 (Special Theme: Linked Open Data). Joint work with Dario Colazzo, François …
Today’s business journalists report that many kinds of businesses in many different fields and industries are choosing to use a procedural element called Information Technology Infrastructure Library (ITIL) to change the ways that they do business. ITIL can help business leaders to reorder information technology practices in order to streamline business processes or improve overall operations. There are many different ways to implement ITIL in a business or company. Here are some of the best tips and recommendations on how to implement ITIL.
Assess the business processes that can benefit from implementing ITIL.
Experts point out a range of different business processes to which business owners or leaders can apply ITIL. These include problem management or change management as well as incident handling and some other types of business issues like capacity, financial accounting and supply chains.
Get staffers involved in identifying applicable business processes. Some experts recommend using “process workshops” and other inclusive strategies to get more feedback on what can be improved with ITIL. This kind of collective brainstorming can help a business get better data for the following tasks.
Use benchmarks to evaluate existing processes.
Often, it’s important to start at the beginning and document how existing processes work in order to build an environment for implementing ITIL and improving certain aspects of the business.
Make goals.
In order to implement ITIL effectively, you’ll want to have goals and objectives on hand in order to craft strategies that will work.
Use people-centered tactics to assess business processes, set goals and achieve them by implementing ITIL. Those who are experienced in business communications know that it’s important to reach out to individuals to get them engaged and active in promoting this sort of business strategy. This may require some creativity from a management perspective, but according to many of those who have used ideas like ITIL to streamline business operations, getting more hands on deck is critical.
Narrow down the options for improving processes.
Some businesses may need to cull their original list and further identify viable improvements as needed. Identify gaps between your goals and your existing processes.
Defining the problem or the gap helps business leadership to craft the right kinds of responses and strategies. Get access to a project management methodology.
Some business consultants recommend specific methods for implementing ITIL. In other situations, it might be as simple as creating relevant PowerPoint applications with conventional project management charts, including timelines and other resources as necessary. Measure improvements.
When ITIL has been implemented, it’s a good idea to keep looking at current operations to observe whether or not these strategies are paying off as they should.
Whether you’re a webmaster or a web designer, there’s a question you’ve most likely either asked or answered many times over the years. That question is, “How many<h1> tags can I use per page, and how exactly should I implement them?”
There are generally two reasons this question is asked. The first and most common is for SEO purposes; ensuring content is formatted in the best way possible to aid search engine indexing. The second is technical correctness; ensuring that markup is written in accordance with the appropriate W3C spec.
With the advent of HTML5 the answer to this question has significantly changed in both SEO and technical regards. It’s now not only possible to have multiple <h1> level headings per webpage that will make sense to search engines, but in most cases it’s actually the recommended course.
However, because the HTML5 spec is not all that widely understood yet, there is still a lot of advice floating around, some even written very recently, based on the rules of pre-HTML5 web design.
In this tutorial we’re going to clear up some misconceptions. We’ll take an in-depth look at what HTML5 means for <h1> tag usage, as well as how you can take advantage of the enhancements now available to create web pages that are more semantically rich and well-structured than ever before.
The Pre HTML5 “Single <h1> Tag” Rule
For a long time it was considered one of the cardinal rules of HTML and SEO that each individual page of a site should have one <h1> level heading, and one only. Additionally, the rule prescribed that this singular <h1> heading should denote the primary subject matter of the page.
This rule was generally followed with the goal of helping search engines better understand the primary subject matter of each page, so they could determine their relevance to various search phrases, improve search engine accuracy and hence improve rankings for well-crafted sites.
Let’s consider an example pre-HTML5 business website. In this example site the business name is displayed in the header section on all pages, the homepage features a description of the business, and in another area of the site expert articles are published.
In following the “Single <h1> Tag” rule, the homepage of this website has <h1> tags applied to the name of the business in the header section, indicating the business itself is the primary subject matter of that page.
However, in an article published elsewhere on that same website, <h1> tags are removed from the business name in the header and instead applied to the article’s title. This is done because the article title provides a more representative label for the primary subject matter of the page, which is now the article’s content as opposed to the description of the business that was on the homepage.
A pre-HTML5 version of this website would therefore be marked up something like this:
Why Headings Matter: Document Outlines
Despite the long-time heavy focus on <h1> tags, they were never an element that operated in isolation, independent of the rest of the document. There is a reason behind the importance of careful heading tag placement in both the HTML5 and pre-HTML5 eras, and that is the generation of document outlines.
Document outlines are something akin to a table of contents for a website. They are automatically generated from the markup on any given webpage.
Prior to HTML5, document outlines were generated from your use of heading tags<h1> through to <h6>. Every use of a heading would imply the beginning of a new section of content.
Take for example the following html, noting the placement of <h1>, <h2> and <h3>tags, which will determine the document’s outline:
<p>Peanuts are infinitely better when combined with chocolate.</p>
<p>We recommend this approach for best results</p>
<h2>Incorrect application of peanuts</h2>
<p>Peanuts should not be used to fill parking meters.</p>
<p>They will not be effective in this capacity.</p>
</body>
</html>
Pre-HTML5, the markup above would generate a document outline as follows:
1. (document) The proper use of peanuts
1. (h2) How to eat peanuts
1. (h3) Superior peanut eating methods
2. (h2) Incorrect application of peanuts
The first <h1> element is considered the label for the entire document. The subsequent headings are considered the labels for sections of content within that document, forming a tree beneath it.
The above example is simple enough, but in the wild webpages are rarely this simple. When we need more complex content presentation we run into the big problem with pre-HTML5 markup, and the reason it was previously necessary to use only one <h1>level heading per page.
In the example above we have a single topic being discussed: “The proper use of peanuts”. But what if this topic is being discussed on a page with multiple articles of equal importance, as you might see on a blog for example?
Take this html with a second article displayed, (each article is wrapped in <div> tags):
<p>Peanuts are infinitely better when combined with chocolate.</p>
<p>We recommend this approach for best results</p>
<h2>Incorrect application of peanuts</h2>
<p>Peanuts should not be used to fill parking meters.</p>
<p>They will not be effective in this capacity.</p>
</div>
<div>
<h1>Boiling beans</h1>
<h2>Is boiling beans really worth it?</h2>
<p>Let's be honest, it takes ages.</p>
<p>We advise just buying canned beans instead.</p>
</div>
</body>
</html>
Pre-HTML5, this markup would have generated the following document outline:
1. (document) The proper use of peanuts
1. (h2) How to eat peanuts
1. (h3) Superior peanut eating methods
2. (h2) Incorrect application of peanuts
2. (h1) Boiling beans
1. (h2) Is boiling beans really worth it?
Now, even though there are two articles of equal importance on the page, the first article’s heading “The proper use of peanuts” is still interpreted as the label representing the entire document simply because it is the first one encountered. This would thus indicate that the entire subject matter of the page is “The proper use of peanuts” even though the second article is about a totally different topic.
The typical way to combat this was to create a catch-all heading with <h1> tags wherever multiple sections of content of equal importance were displayed, in an attempt to represent them all to the greatest extent possible. For example:
<p>Peanuts are infinitely better when combined with chocolate.</p>
<p>We recommend this approach for best results</p>
<h3>Incorrect application of peanuts</h3>
<p>Peanuts should not be used to fill parking meters.</p>
<p>They will not be effective in this capacity.</p>
</div>
<div>
<h2>Boiling beans</h2>
<h3>Is boiling beans really worth it?</h3>
<p>Let's be honest, it takes ages.</p>
<p>We advise just buying canned beans instead.</p>
</div>
</body>
</html>
Note the addition of the generalized <h1> tagged heading, and the demotion of each subsequent heading down one level.
The following document outline would now be generated:
1. (document) Legume Literature Blog
1. (h2) The proper use of peanuts
1. (h3) How to eat peanuts
1. (h4) Superior peanut eating methods
2. (h3) Incorrect application of peanuts
2. (h2) Boiling beans
1. (h3) Is boiling beans really worth it?
Problems Caused by Pre-HTML5 Document Outlines
This document outline, though it’s the best that could be done pre-HTML5, presents some significant problems:
The generalized label for the whole page dilutes relevance.
We have the <h1> tagged “Legume Literature Blog” title acting as the label for the whole page, and yet the text of this heading gives only a generalized representation of the content. This dilutes the ability of search engines to interpret the actual subject matter on the page and in turn its relevance to search phrases.
Separate articles are seen as subsections of a single piece of content.
There is no way to distinguish the two articles on the same page as equally important and self-contained entities. They are both seen as a part of a single overall piece of content, even though they are not.
Different markup is required in different site areas.
Should a visitor view one of the articles by itself, as can be done on a typical blog, the markup would have to be reworked so the <h1> tags are applied to the article title instead of the site title, as I demonstrated with my example business website in the previous section.
There are restrictions on the nature of the document label/site title.
In many cases a site title, (which tends to play the role of document label even in HTML5), may not relate to a page’s content in any meaningful way. For example, I might run a blog with the site title “Kezz Says” and it might display one article on HTML coding and another on cute puppies. In this case it would not make sense for the site title to be interpreted as representing either of these articles, so I would have to change the name of my blog. This can be a problem, particularly if a site wishes to brand itself with a name that may be memorable, but not necessarily meaningful.
This is where HTML5 comes along to save the day and solve each of these problems.
The HTML5 Document Outline Algorithm
If you consider each of the problems just described above, they all have a common and somewhat simple root: The assumption that each web page is a singular document with a singular topic requiring only a singular label.
The equally simple solution to these problems would come from the ability to indicate if a webpage had discrete sections, potentially with multiple topics each with their own meaningful label.
If it were possible to specify that each article on a page was separate, this would make it possible to label them with meaningful headings that accurately represented their contents, and give each one the same weight of importance.
If it were possible to make it clear when a site title was not representative of the page’s content, the problem of diluting relevance would be solved.
With a clear indication in place of the difference between the site title, articles and article titles, it would no longer be necessary to change markup from one area to another. A <h1> tagged site title could keep its <h1> tags throughout the site.
And because it would be made clear if the site title didn’t represent the article content on the page, it would be possible to set it to anything at all, no matter how abstract.
HTML5 makes all these things possible through the introduction of its semantic elements and the HTML5 document outline algorithm.
Key Aspects of the HTML5 Document Outlining Algorithm
While the pre-HTML5 document outline was drawn purely from heading tags alone, the HTML5 document outline algorithm utilizes the following key aspects:
Sectioning root: A sectioning root is a container that provides a scope for the discrete content sections that will be defined within it. Each sectioning root gets its own individual outline.The top level sectioning root of any page is formed by its<body> tags, so there is always an outline generated for any webpage, starting from the <body> tags and working through the sections it is broken into.
Sectioning content: Each sectioning root is broken into a series of content sections. These sections are created by placing sectioning content element tags around discrete pieces of content. Sectioning content elements are nestable and semantic. The type that should be used depends on the nature of the content it will contain. (We’ll discuss how to use each sectioning content element further on.)
Heading content: Text-only labels for sections of content. In the absence of sectioning content tags, the presence of a heading tag will still be interpreted as the beginning of a new content section..
Heading tags: <h1>, <h2>, <h3>, <h4>, <h5>, <h6>
Understanding how these aspects of HTML5 are used is relatively straightforward, and the process typically goes much like this:
The sectioning root of the document is formed by its <body> tags.
Within that sectioning root, the document is broken into sectioning content, e.g. by wrapping articles with the <article> tags.
Heading tags are placed into the content sections as required, with the first heading tag in any section acting as the label for that section.
There are many other aspects to the HTML5 document outline algorithm. Extensive information on these is available on W3C.
However, with just the aspects listed above, we are able to solve all the problems described in the previous section of this tutorial.
Solving the Old Document Outline Problems
Let’s take another look at our “Legume Literature Blog”, as it could be marked up using HTML5. The following simple modifications have been made:
<!DOCTYPE html> added to invoke HTML5
<article> tags have been added wrapping each article, replacing the generic<div> tags
Article headings have been changed from <h2> up to <h1> tags
The other heading tags in each article have been adjusted up one level in kind
A branded/non-meaningful site title is used
01
02
03
04
05
06
07
08
09
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
<!DOCTYPEhtml>
<html>
<head>
<title>HTML5 markup example</title>
</head>
<body>
<div>
<h1>Whackamoon Legumes!</h1>
</div>
<article>
<h1>The proper use of peanuts</h1>
<h2>How to eat peanuts</h2>
<p>Peanuts can be eaten with salt.</p>
<p>This is an acceptable use of peanuts.</p>
<h3>Superior peanut eating methods</h3>
<p>Peanuts are infinitely better when combined with chocolate.</p>
<p>We recommend this approach for best results</p>
<h2>Incorrect application of peanuts</h2>
<p>Peanuts should not be used to fill parking meters.</p>
<p>They will not be effective in this capacity.</p>
</article>
<article>
<h1>Boiling beans</h1>
<h2>Is boiling beans really worth it?</h2>
<p>Let's be honest, it takes ages.</p>
<p>We advise just buying canned beans instead.</p>
</article>
</body>
</html>
Now the HTML5 document outline algorithm would give us the following:
1. (document) Whackamoon Legumes!
1. (article) The proper use of peanuts
1. (h2) How to eat peanuts
1. (h3) Superior peanut eating methods
2. (h2) Incorrect application of peanuts
2. (article) Boiling beans
1. (h2) Is boiling beans really worth it?
The first thing you may notice is the appearance of the (article) element in the outline, and next to those the headings for each of our articles.
Note that in HTML5, <article> tags are specifically used to indicate “a complete, or self-contained, composition in a document, page, application, or site and that is, in principle, independently distributable or reusable, e.g. in syndication. This could be a forum post, a magazine or newspaper article, a blog entry, a user-submitted comment, an interactive widget or gadget, or any other independent item of content.” (source:W3C)
The appearance of the (article) element next to our article headings, rather than the heading tags as we saw before, tells us these things are now occurring in the outline:
Each article has been recognized as a self-contained piece of content with equal weight of importance to one another.
The article headlines are now being correctly matched to the articles as meaningful labels that represent their subject matter.
Because the articles are correctly labeled with their own headings, the site title is no longer being interpreted as representative of the content in those articles.
This means that all the problems we outlined earlier in this tutorial have immediately been solved:
Solved: The generalized label for the whole page dilutes relevance.
We no longer have any dilution of relevance from generalized labels, as the label of each article is clearly associated with it.
Solved: Separate articles are seen as subsections of a single piece of content.
The page is no longer seen as one singular piece of content, because the presence of the article tags indicates where the page is broken into independent sections.
Solved: Different markup is required in different site areas.
Because all the <h1> tags used in the markup are now correctly interpreted, and we no longer have to worry about labels diluting relevance, we no longer need to apply different tags to the site title—it can remain tagged at <h1> level throughout.
Solved: There are restrictions on the nature of the document label/site title.
Because the site title is no longer interpreted as a label for the article content we’re free to set it to anything we like. It no longer has to act as a “catch-all” representative for all the content on the page, so it can be an abstract or branded title that doesn’t relate to the article content at all.
Why Multiple <h1> Tags Are Correct
You can also now see from the HTML5 document outline generated by our markup that it is perfectly fine to use as many <h1> tags as your document calls for; that is one per sectioning root or content section.
You can also see from this example how it would be less correct to use only one set of<h1> tags in this example, and that multiple sets of <h1> tags more accurately represent the content.
If you still had <h1> tags applied only to the site title, and <h2> tags applied to your article titles, the outline of your articles would be thrown out.
This is because by marking up your article headlines with <h2> tags you are effectively saying they are level two headings, even though they are actually level one headings within the scope of the <article> section.
In turn, the second level subheadings of your articles would necessarily be marked up with <h3> tags incorrectly setting them to level three, your third level headings marked up with <h4> tags and so on.
It is permissible by the HTML5 spec to use lower level headings than <h1> to label a section, and sometimes you may want to for presentation reasons, such as displaying a smaller sized heading in a sidebar blogroll section. However, I would recommend doing this only in the case of minor, non-article/content sections of your site where it’s not a priority for heading levels to produce a document outline that effectively forms a table of contents.
The best thing to do in all cases is carefully consider the content at hand, and determine the best way to section and label it based on what you now know about the HTML5 document outlining algorithm.
HTML5’s New <h1> Usage Rules
Yes, it’s true. You can now use as many sets of <h1> tags as are required, via HTML5. But that doesn’t mean they should be freely added in arbitrary locations.
Just as there were rules of <h1> tag usage that came from old document outlines, so too are there now new rules based on the HTML5 document outlining algorithm.
Here they are at a glance:
Use one set of <h1> tags per sectioning root or content section.
There should always be a <h1> level heading between the opening <body> tag and the first content section, to label the overall document.
When a <h1> level heading is to be used to label a content section, it should be the first heading that appears in the section, because the first heading is always interpreted as the section’s label.
If a <h1> level heading is used to label a content section, any other headings used in that section should be H2 or lower in order to create an accurate document outline.
As I mentioned above, section labels don’t absolutely have to be <h1> tags. The HTML5 spec permits any heading tag to act as the label for a section, from <h1>through to <h6>. Again however, I always recommend using <h1> level tags to markup article content.
But if you do decide to use a tag other than <h1> for a section label, just ensure you follow the same rules as listed above, replacing <h1> in each rule with your chosen tag.
About Sectioning Content Element Tags
There are only four sets of element tags you can use to denote content sections within your webpage, but they can be a little tricky to wrap your mind around at first.
They are:
<article>
<section>
<nav>
<aside>
The two you are likely to use the most are <article> and <section> tags. They are similar to one another, but with an important distinction.
<article> tags should be used where a piece of content could be taken out of a page completely and still make sense by itself with no surrounding content.
<section> tags, on the other hand, should be used for content that is grouped together according to a theme, but makes sense only in the context of the content surrounding it.
For detailed examples on how to use each of these tags, take a moment to check out these W3C pages:
The Article Element
The Section Element
<nav> tags are designed to indicate major navigation blocks on a webpage, such as a menu bar or pagination. They shouldn’t be applied to regular links, only to significant sections that are wholly dedicated to navigation.
<aside> tags could effectively be described as the “everything else” element for content that is neither article, section nor navigation. W3C prescribes this tag for use when something is tangentially related to the content around it, but is separate from the main content of the page, such as sidebars, blogrolls and so on.
For more information on <nav> and <aside> tags visit:
We now know that in HTML5 we can happily use <h1> tags on our site titles in every area of our sites. However, despite it being a common practice, technically speaking<h2> tags shouldn’t be used for standalone subheadings or taglines.
W3C has this to say:
h1–h6 elements must not be used to markup subheadings, subtitles, alternative titles and taglines unless intended to be the heading for a new section or subsection.
The reason for this is that the HTML5 document outline always interprets a heading tag as beginning a new section of content, whether sectioning content tags are wrapped around them or not.
For a while there was a work-around to this whereby <h2> tags could be used for a tagline if they were grouped with the main heading inside a set of <hgroup> tags. However, the <hgroup> is being removed from the HTML5 spec and its use will cause code to fail validation checks.
So now the best way to handle taglines is just to use <div> or <p> tags and apply CSS to make them look like taglines, achieving your presentation goal without negatively affecting your document outline.
Further HTML5 Elements to Employ
In this tutorial we’ve been focusing on <h1> tags in HTML5 and how the new document outlining algorithm works. For that reason I haven’t touched on any HTML5 elements that are not assessed by the document outlining algorithm.
However, I would be remiss if I did not point you in the right direction on a few of the most valuable HTML5 tags you can employ in your markup to make it even more semantically rich.
The <main> Element
The <main> element should be used once per page to indicate the main content area of that page.
If you are displaying a group of articles, it would wrap around all those articles. For example:
01
02
03
04
05
06
07
08
09
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
<!DOCTYPEhtml>
<html>
<head>
<title>HTML5 markup example</title>
</head>
<body>
<h1>Whackamoon Legumes!</h1>
<main>
<article>
<h1>The proper use of peanuts</h1>
<h2>How to eat peanuts</h2>
<p>Peanuts can be eaten with salt.</p>
<p>This is an acceptable use of peanuts.</p>
<h3>Superior peanut eating methods</h3>
<p>Peanuts are infinitely better when combined with chocolate.</p>
<p>We recommend this approach for best results</p>
<h2>Incorrect application of peanuts</h2>
<p>Peanuts should not be used to fill parking meters.</p>
<p>They will not be effective in this capacity.</p>
</article>
<article>
<h1>Boiling beans</h1>
<h2>Is boiling beans really worth it?</h2>
<p>Let's be honest, it takes ages.</p>
<p>We advise just buying canned beans instead.</p>
The <header> element can be used at the beginning of any sectioning root, or content section, to group introductory content for that section.
You could use it to wrap your site title and tagline, or an article title and blog category. For example:
01
02
03
04
05
06
07
08
09
10
11
12
13
14
15
16
17
18
19
20
21
22
23
<!DOCTYPEhtml>
<html>
<head>
<title>HTML5 markup example</title>
</head>
<body>
<header>
<h1>Whackamoon Legumes!</h1>
<p>We've been luvin beans</p>
</header>
<main>
<article>
<header>
<h1>Boiling beans</h1>
<p>Category: Mean Beans</p>
</header>
<h2>Is boiling beans really worth it?</h2>
<p>Let's be honest, it takes ages.</p>
<p>We advise just buying canned beans instead.</p>
</article>
</main>
</body>
</html>
The <footer> Element
The <footer> element is basically the inverse of the <header> element, in that it can be used at the end of any sectioning root, or content section, to group supplementary content for that section.
W3C recommends its use for items such as author information, links, copyright messages and so on. For example:
01
02
03
04
05
06
07
08
09
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
<!DOCTYPEhtml>
<html>
<head>
<title>HTML5 markup example</title>
</head>
<body>
<header>
<h1>Whackamoon Legumes!</h1>
<p>We've been luvin beans</p>
</header>
<main>
<article>
<header>
<h1>Boiling beans</h1>
<p>Category: Mean Beans</p>
</header>
<h2>Is boiling beans really worth it?</h2>
<p>Let's be honest, it takes ages.</p>
<p>We advise just buying canned beans instead.</p>
<footer>
<ahref="../">Back home...</a>
</footer>
</article>
</main>
<footer>
<p>Copyright Whackamoon Legumes 2013</p>
</footer>
</body>
</html>
Wrapping Up
In conclusion, let’s take a look at our original business website example and see how it could now be marked up using what we have learned:
This simple example shows just how easy it is to use an understanding of the HTML5 document algorithm to solve the old problems surrounding use of <h1> tags, and to ensure the content of your webpages is more accurately communicated than ever before.
Can I use SPARQL to search for substring matches within literal values?
SPARQL provides the function, regex(), which can be used to test whether a literal value contains a certain substring:
SELECT ?title
WHERE {
_:book :title ?title .
FILTER (regex(?title, “SPARQL”)) .
}
Why don’t I get any matches when I use regex() to match typed literals or plain literals with language tags?
The regex() function expects its first argument to be either a plain literal without a language tag or else a typed literal with a datatype of xsd:string. Plain literals witha language tag or typed literals of other datatypes will evaluate to a type error which causes the filter to fail. If you wish regex() to match solely based upon a literal’s lexical value, use the str() function, which converts typed and plain literals to simple literals—i.e., plain literals without a language tag:
SELECT ?title
WHERE {
_:book :title ?title .
FILTER (regex(str(?title), “SPARQL”)) .
} How can I query transitive closures / trees / hierarchies / RDF lists in SPARQL?
There is no built-in support within SPARQL to query hierarchical structures of an unknown depth (e.g. trees or lists), to query transitive relations, or to query via XPath like paths. The Data Access Working Group postponed this issue in early 2005.
There are several workarounds to perform these queries using SPARQL:
Repeated queries. A repeating structure can be queried via a series of queries. If the structure’s internal nodes have URIs (or if the SPARQL endpoint supports blank node identifiers which are stable across queries (“told bnodes”), then the same query can be issued repeatedly to explore the structure. Alternatively, an ever-growing query can be created which repeatedly queries the structure from its root to an increasing, fixed depth (until a desired value is found or the end of the structure is reached).
Inference. In an environment which supports querying over an inferred graph, inference rules can be used to specify transitive closures or hierarchy membership relations that can then be queried with SPARQL. Jos De Roo has sketched examples of such SPARQL queries using cwm and Euler and a suitable set of N3 rules.
Implementation-specific approaches. Several SPARQL implementations provide ways to address this question. In ARQ, for example, there are two approaches:
A filter function named <java:com.hp.hpl.jena.query.function.library.listMember> which takes an RDF list node and a resource as parameters and returns true if the resource is a member of the list.
A special predicate named <http://www.jena.hpl.hp.com/ARQ/list#member> can be used inside the SPARQL query pattern (the WHERE clause) to associate an RDF list head with all the list members.
Can I include subqueries in a SPARQL query?
While SPARQL does support nested graph patterns, it does not directly support subqueries (for example, the FROM clause of a SPARQL query cannot itself contain aCONSTRUCT query which generates the dataset to be queried against). The Data Access Working Group postponed this issue in early 2005. A very limited form of subqueries can be accomplished with SPARQL engines that will perform HTTP GETs upon graphs named in FROM or FROM NAMED clauses by creating a URL consisting of an embedded SPARQL CONSTRUCT query submitted to a SPARQL endpoint and supplying this URL as part of the RDF dataset being queried. In practice, this technique is often inefficient and is subject to possible URL-maximum-length restrictions of the involved software.
Can I bind a variable to a specific value (e.g., the result of a function call)?
SPARQL does not support setting variable bindings except via graph pattern matching or via the GRAPH ?g construct. Expressions are not allowed in the SELECT list of a SPARQL query.
How can I use SPARQL to query maximum/minimum values or other universally quantified criteria?
A combination of the SPARQL OPTIONAL keyword and the bound(…) filter function can be used to mimic some universally quantified queries. As an example, consider this query which finds the minimum price of every book in the underlying default graph:
PREFIX ex: <http://example.org/>
SELECT ?book ?minprice
WHERE {
?book a ex:book ; ex:price ?minprice .
OPTIONAL {
?book ex:price ?otherprice .
FILTER( ?otherprice < ?minprice ) .
} .
FILTER ( !bound(?otherprice) ) .
} Can I use SPARQL to select a single value based on an ordered list of predicates which might appear in the data?
When writing SPARQL queries against heterogeneous data sources, one often wants to select a value for a certain purpose without knowing which one of several predicates might be used in the data. The SPARQL OPTIONAL keyword can be used to accomplish this. Suppose we are selecting a human-readable label for a Web page, and we want to use the value of the Dublin Core title predicate (dc:title) if it exists, and otherwise use the value of the rdfs:label predicate. This can be accomplished with SPARQL idiom:
PREFIX rdfs: <http://www.w3.org/2000/01/rdf-schema#>
PREFIX dc: <http://purl.org/dc/elements/1.1/>
SELECT ?text
WHERE {
OPTIONAL { <http://example.org/myWebPage> dc:title ?text . }
OPTIONAL { <http://example.org/myWebPage> rdfs:label ?text . }
} Can I use SPARQL to query RDFS entailments?
It is sometimes desirable to use SPARQL to query triples entailed from subclass, subproperty, range, domain, and other relations which can be represented using RDF Schema.
The SPARQL specification defines the results of queries based on RDF simple entailment. However, the specification does present a general, parametrized definition of graph pattern matching that can be expanded to other entailments beyond RDF simple entailment.
As an alternative, the SPARQL specification acknowledges that queries are often performed against a virtual graph which may not be fully materialized. Because RDFS entailment rules will always lead to a unique, deductive closure of a base graph, a query engine can treat the RDFS deductive closure of a base graph as the virtual graph against which (simple-entailment based) SPARQL queries are executed.
Whether or not a particular query endpoint supports RDFS entailment is implementation defined. Such a property might be advertised as part of the endpoint’sfunctional description.
For more information, see information on SPARQL extensions for other entailment regimes.
Can I use SPARQL to query OWL entailments?
For the most part, the answer to this question is the same as the above answer regarding RDFS entailment. However, OWL-DL axioms do not always result in a uniquedeductive closure, and as such querying OWL-DL entailments requires instantiating the parametrized SPARQL basic graph pattern definition with values appropriate for OWL-DL entailment. The open-source OWL-DL reasoner, Pellet, will answer SPARQL queries while considering OWL-DL entailments.
For more information, see information on SPARQL extensions for other entailment regimes.
What do blank nodes mean in a SPARQL query?
For the most part, blank nodes in SPARQL queries function exactly as variables which cannot be returned to the user/client. So, the following two queries behave identically:
SELECT ?title WHERE { _:book :hasTitle ?title }
SELECT ?title WHERE { ?book :hasTitle ?title }
However, a SPARQL query may not reuse the same blank node label twice in different basic graph patterns. That is, the following is not a legal SPARQL query:
SELECT ?title WHERE {
_:book rdfs:seeAlso ?g .
GRAPH ?g { _:book dc:title ?title }
}
In most cases, it is best practice to use the [] and [ :prop :obj ] syntaxes for blank nodes and to only use explicit blank node labels for constructs that cannot be expresed otherwise.
Did you know that the SPARQL WHERE keyword is optional?
Well, it is!
Why don’t I get any matches when I search for numbers?
Numbers in RDF data can be represented as plain literals or as typed literals (using XML Schema datatypes such as xsd:int). Numbers written in a SPARQL query withsurrounding quotation marks (e.g., “4”) will only match plain literals in the dataset. Numbers written without quotation marks (e.g. 4) will only match typed literals. Be sure to use the appropriate form for the data you are querying.
If your data contains numbers as plain literals, then they will be compared as strings not numbers, and you may have to cast them to typed literals to get the desired results. For example, to check if a number expressed as a plain literal is less than 100, you’d say:
…
FILTER (xsd:int(?number) < 100)
…
Many thanks to Richard Cyganiak for contributing this question and answer.
Can I use SPARQL to insert, update, or delete RDF data?
The current, standardized version of SPARQL deals only with retrieving selected data from RDF graphs. There is no equivalent of the SQL INSERT, UPDATE, or DELETEstatements. Most RDF-based applications handle new, changing, and stale data directly via the APIs provided by specific RDF storage systems. Alternatively, RDF data can exist virtually (i.e. created on-demand in response to a SPARQL query). Also, there are systems which create RDF data from other forms of markup, such as Wiki markup or the Atom Syndication Format.
However, there is significant active work going on to extend SPARQL to support update operations. See the SPARQL extension wiki page dealing with update for more details.
SPARQL is a recursive acronym standing for SPARQL Protocol and RDF Query Language. As the name implies, SPARQL is a general term for both a protocol and a query language.
Most uses of the SPARQL acronym refer to the RDF query language. In this usage, SPARQL is a syntactically-SQL-like language for querying RDF graphs via pattern matching. The language’s features include basic conjunctive patterns, value filters, optional patterns, and pattern disjunction.
The SPARQL protocol is a method for remote invocation of SPARQL queries. It specifies a simple interface that can be supported via HTTP or SOAP that a client can use to issue SPARQL queries against some endpoint.
Both the SPARQL query language and the SPARQL protocol are products of the W3C’s RDF Data Access Working Group. The latest released versions of the Working Group’s specifications (excluding intermediate working drafts) can be found here:
SPARQL Query Language
SPARQL Protocol
SPARQL Query Results XML Format
1.2. How can I learn SPARQL?
There are a variety of SPARQL tutorials and introductions scattered around the Web. Some notable ones include:
Jena/ARQ SPARQL tutorial
Leigh Dodds’ “Introducing SPARQL” article
Philip McCarthy’s “Search RDF data with SPARQL” article
SPARQL By Example
1.3. What are the benefits/drawbacks of SPARQL vis a vis SQL and XQuery?
The jury is still out on best practices surrounding using SPARQL compared to other query languages. Some benefits of SPARQL include:
Queries RDF data. If your data is in RDF, then SPARQL can query it natively.
Implicit join syntax. SPARQL queries RDF graphs, which consist of various triples expressing binary relations between resources, by specifying a subgraph with certain resources replaced by variables. Because all relationships are of a fixed size and data lives in a single graph, SPARQL does not require explicit joins that specify the relationship between differently structured data. That is, SPARQL is a query language for pattern matching against RDF graphs, and the queies themselves look and act like RDF. This is one main point made by Oracle’s Jim Melton in his analysis of SPARQL vis a vis SQL and XQuery: SQL, XQuery, and SPARQL: What’s Wrong With This Picture?.
SPARQL has strong support for querying semistructured and ragged data—i.e., data with an unpredictable and unreliable structure. Variables may occur in the predicate position to query unknown relationships, and the OPTIONAL keyword provides support for querying relationships that may or may not occur in the data (a la SQL left joins).
SPARQL is often an appropriate query language for querying disparate data sources (not sharing a single native representation) in a single query. Because RDF represents all data as a collection of simple binary relations, most data can be easily mapped to RDF and then queried and joined using SPARQL. Often, these mappings can be performed on the fly, meaning that SPARQL can be used to join heterogeneous data at a higher level than that of the native structure of the data.
SPARQL is built to support queries in a networked, web environment. SPARQL introduces the notion of an RDF dataset, which is the pairing of a default graph and zero or more named graphs. As both the default graph and the named graphs are identified by URIs, it is common for SPARQL implementations to retrieve a graph by performing an HTTP GET on the graph’s URI. This allows a single query to join information from multiple data sources accessible across different Web sites.
Similarly, the SPARQL GRAPH keyword allows data to be queried along with its provenance information. GRAPH can be used to discover the URI of the graph that contains the data that matches the query.
Some drawbacks are:
Lack of wide deployment. SPARQL is relatively young, and as such there are not many data stores which can be directly queried with SPARQL (as compared with SQL or XPath).
Immaturity. As a young query language, SPARQL lacks the explicit processing model of XQuery or the decades of SQL-optimization research. As with the above point, this is likely to improve as current and new research and implementations contribute to a body of knowledge surrounding SPARQL.
Lack of support for transitive/hierarchical queries. While SPARQL is designed to query RDF graphs, SPARQL has no facilities for easily querying transitive relations or hierarchical structures within a graph. There are some workarounds for this, but SPARQL does not approach the power of, for instance, XQuery’s axes.
1.4. What SPARQL implementations are available?
The community maintains a list of SPARQL implementations at the W3C ESW Wiki.
1.5. Can I use SPARQL to query data that’s not stored in RDF?
Several software packages exist which allow SPARQL queries to generate answers from data sources other than RDF, such as relational databases, LDAP servers, or XML data. The community maintains a list of these tools at the W3C ESW Wiki.
The W3C recently completed an incubator group examining the state of the art in accessing relational databases via SPARQL. As a result of this incubator group, a new Working Group may be established to produce specifications in this area.
1.6. How can I tell what dataset, functions, or extensions a SPARQL endpoint supports?
There is currently no established, interoperable method for representing or accessing functional descriptions of SPARQL endpoints. (This is not to be confused with the WSDL which describes the SPARQL Protocol itself.)
The Data Access Working Group postponed this topic in 2005, leaving behind a draft “of historical interest only.” In the meantime, implementations have devised their own vocabularies and techniques for specifying and advertising the services and datasets supported by a SPARQL endpoint. For example, HP Labs’ Joseki allows service descriptions to be specified with an RDF configuration vocabulary. See the SPARQL service description wiki page for more information.
1.7. Do SPARQL queries perform well against small datasets? Large datasets?
The performance of a SPARQL query against any particular dataset depends not only upon the size of the dataset but also on the nature of the dataset’s storage (a relational store, a native triple store, LDAP, etc.), the complexity of the query itself, optimizations in use by the SPARQL engine, the distribution of the data, and other environmental factors. To date, little work has been done in analyzing SPARQL query performance in particular, and the field of SPARQL query optimization is relatively inchoate.
Some analysis has been done on the topic of RDF stores which can handle large datasets. (A large dataset in this context is usually considered one on the order of tens or hundreds of millions of triples). The W3C ESW wiki contains information on a variety of RDF stores which can scale to large numbers of triples, but does not speak specifically to the performance of SPARQL queries against these stores.
1.8. Is there anywhere on the Web where I can try out SPARQL queries?
The creators of several SPARQL implementations provide online services where SPARQL queries can be input and executed against either canned datasets or arbitrary datasets (identified by URLs). The community maintains a list of SPARQL endpoints on the W3C ESW Wiki.
The objective of this document is to provide a template for developing process implementation plans that will be usable across a wide range of diverse organisations. The guidelines within this document are designed for use as a general roadmap or plan, for any major process development or re-engineering project.
We Are About To Enter A New War Over ‘Semantic’ Search — A War Google … Business Insider Google Now predicts what you want, such as warning you of Calendar appointments even if you have forgotten to ask it to.
As the performance of semantic reasoners change significantly with respect to all included characteristics, and therefore requires assessment and evaluation before selecting an appropriate reasoner for a given application. There are number of inference engines like Pellet, FaCT++, Hermit, RacerPro, KaON2, F-OWL and BaseVISor. Some of them are reviewed and tested for few prebuilt ontologies. This paper proposes performance evaluation and comparison of semantic reasoner for the ontologies of Health and Anatomy domain. Reasoners are characterized based on reasoning method, reasoning algorithm, computational complexity, classification, scalability, query and rule support.