Processing Linked Web Data with XSLT

Processing Linked Web Data with XSLT

he Semantic Web is a grand vision for increasing the power of the web through better expression and management of context. Semantic Web developers are building a framework to open up and connect organized information, which takes advantage of many popular developments on the web, such as the success of Wikipedia, Creative Commons-licensed publishing on sites like Flickr, and various blogs. A portion of this framework is the Linking Open Data (LOD) community initiative (seeded by the W3C Semantic Web Education and Outreach group). A goal of LOD is to weave together separate collections of open data using deep linking and RDF (Resource Description Framework) representations.

The hallmark of LOD is to make it easy for web developers to create and process compatible data. Utilizing LOD calls for a broad war chest of tools and techniques that cover the diverse expertise of Web developers. One popular tool for processing data on the web is XSLT (Extensible Stylesheet Language Transformations), building on the growth of XML as a data format on the web. XSLT is not a general-purpose programming language—so it is limited in its uses—including LOD processing. However, XSLT is very useful to handle auxiliary roles in such processing that involves transforming XML. This article explores specialized areas for the use of XSLT 1.0 in LOD processing. The focus is on XSLT 1.0 (XSLT 2.0 does offer more for LOD processing, but it is far more complex and much less used by the community). XSLT 1.0 has more processors than 2.0 and the EXSLT set of community extensions, which has strong support in Firefox 3.0, provides facilities that bring it close to the power of XSLT 2.0.

XSLT in the Browser
Mainstream web browsers, such as Internet Explorer and Firefox, are the most obvious places for deploying LOD processing using XSLT. However, due to security reasons, using LOD processing increases your limitations, which are already hampered by using XSLT. Listing 1 is an example of XSLT that tries to process a page from DBPedia, which is an LOD wrapper for Wikipedia and other data sources.Save this code as documenttest.xslt and try loading it into a browser; you will see a security error. For example, using the FireFox 3.0 beta the result is a blank page. And if you check the Error Console (in the Tools menu) you will see an error such as:

Security Error: Content at file:///temp/lod-xslt/documenttest.xslt may not load data from http://dbpedia.org/page/XSL_Transformations.

This error occurs because you cannot use the document() function to access a resource at a different URI scheme or host from the base URI of the XSLT. This same restriction applies to xsl:import and xsl:include, and you cannot get around it using ordinary Javascript. To get the full power of XSLT in Firefox—and in any browser that takes security seriously enough—you need to deploy the XSLT through an extension (this article does not focus on this deployment issue). Luckily there are a couple of handy add-ons you can use to run XSLT with many fewer restrictions.

For the purpose of this article, the author worked with the XSLT engine in Firefox 3.0, which is an excellent place for tools to process LOD because Firefox is known for power and conformance. It is also a pervasive toolkit and you can expect anything developed for Firefox to be ready for a wide variety of users. Firefox 3.0 is still in beta, and should be complete by late 2008. It offers many important improvements for XSLT processing, among other things.

Mining What’s Described
One key LOD practice is to offer multiple representations for a resource and use content negotiation to determine which representation to send upon request. This involves using HTTP headers to tell the server what representations the client prefers. You might, for example, send HTML or XHTML to a plain browser and RDF to a more specialized tool. It is very handy to provide links between these representations so that if content negotiation does not do the trick the users have a way of finding the exact representation they prefer.

If you send (X)HTML, the conventional way of linking to the RDF representation is through a link in the document header. Once again, DBPedia is used for an example, which has the following convention:

  • The abstract resource is at http://dbpedia.org/resource/{id} — the server uses content negotiation to determine what representation to send back
  • The abstract resource is at http://dbpedia.org/page/{id} — the server always sends back XHTML
  • The abstract resource is at http://dbpedia.org/data/{id} — the server always sends back RDF/XML

Listing 2 shows the XHTML head element from http://dbpedia.org/page/XSL_Transformations.The first link connects this representation to the alternative RDF representation. The author developed a bit of XSLT to take advantage of this convention. The code does the following:

  1. Processes an XHTML file
  2. Retrieves any RDF alternative representation
  3. Summarizes the resources described there
  4. Generates XBEL (XML Bookmark Exchange Language), a simple format for lists of links

Because the RDF is technically another representation of the abstract resource, this XSLT is essentially a tool to summarize what resources are described in an XHTML page (see Listing 3).

There are two technical points to examine in Listing 3, which are marked with comments (comment A and comment B). The following describe the two comments:

A. In general, it is recommended to use the push style of XSLT rather than the pull style, especially if you are not dealing with a very rigid document structure. This terminology means that you should use xsl:apply-templates and modes in many cases where you might be tempted to use xsl:for-each.

B. The code to generate a title from an RDF description does illustrate a significant limitation of XSLT for such work. XSLT is not really RDF-aware and works only at the syntax layer. Look for both rdfs:label and dc:title for wider coverage, even though this is redundant because the latter is defined as a subproperty of the former. Sometimes a vocabulary defines other such subproperties, which would not be picked up in Listing 3. This is not a major problem for this use case since the title is only grabbed as a convenience to the user. Notice how the XSLT lang() function is used to grab only English labels (DBPedia includes labels in many languages).

Listing 4 shows the output from running Listing 3 against http://dbpedia.org/page/XSL_Transformations.

You can see that the script found several described resources, most of which are synonyms for “XSL_Tansformations” pulled in from Wikipedia. Only one title was discovered, because of the problems previously mentioned for interpreting RDF semantics.

Choosing XSLT
As for any web development, use whatever tools you prefer for Linking Open Data (LOD), but there are a few things that make XSLT attractive. For one, XSLT processing is much faster than Javascript/DOM in almost all browsers. Also, some web developers prefer to learn XSLT rather than other more general programming languages. By using Semantic Web technologies now, you strengthen your position as a web developer for the future. Ideally, you should feel empowered to use a combination of languages for processing, and to target each language to its greatest strength.

devx-admin

devx-admin

Share the Post:
Poland Energy Future

Westinghouse Builds Polish Power Plant

Westinghouse Electric Company and Bechtel have come together to establish a formal partnership in order to design and construct Poland’s inaugural nuclear power plant at

EV Labor Market

EV Industry Hurting For Skilled Labor

The United Auto Workers strike has highlighted the anticipated change towards a future dominated by electric vehicles (EVs), a shift which numerous people think will

Soaring EV Quotas

Soaring EV Quotas Spark Battle Against Time

Automakers are still expected to meet stringent electric vehicle (EV) sales quotas, despite the delayed ban on new petrol and diesel cars. Starting January 2023,

Affordable Electric Revolution

Tesla Rivals Make Bold Moves

Tesla, a name synonymous with EVs, has consistently been at the forefront of the automotive industry’s electric revolution. The products that Elon Musk has developed

Poland Energy Future

Westinghouse Builds Polish Power Plant

Westinghouse Electric Company and Bechtel have come together to establish a formal partnership in order to design and construct Poland’s inaugural nuclear power plant at the Lubiatowo-Kopalino site in Pomerania.

EV Labor Market

EV Industry Hurting For Skilled Labor

The United Auto Workers strike has highlighted the anticipated change towards a future dominated by electric vehicles (EVs), a shift which numerous people think will result in job losses. However,

Soaring EV Quotas

Soaring EV Quotas Spark Battle Against Time

Automakers are still expected to meet stringent electric vehicle (EV) sales quotas, despite the delayed ban on new petrol and diesel cars. Starting January 2023, more than one-fifth of automobiles

Affordable Electric Revolution

Tesla Rivals Make Bold Moves

Tesla, a name synonymous with EVs, has consistently been at the forefront of the automotive industry’s electric revolution. The products that Elon Musk has developed are at the forefront because

Sunsets' Technique

Inside the Climate Battle: Make Sunsets’ Technique

On February 12, 2023, Luke Iseman and Andrew Song from the solar geoengineering firm Make Sunsets showcased their technique for injecting sulfur dioxide (SO₂) into the stratosphere as a means

AI Adherence Prediction

AI Algorithm Predicts Treatment Adherence

Swoop, a prominent consumer health data company, has unveiled a cutting-edge algorithm capable of predicting adherence to treatment in people with Multiple Sclerosis (MS) and other health conditions. Utilizing artificial

Personalized UX

Here’s Why You Need to Use JavaScript and Cookies

In today’s increasingly digital world, websites often rely on JavaScript and cookies to provide users with a more seamless and personalized browsing experience. These key components allow websites to display

Geoengineering Methods

Scientists Dimming the Sun: It’s a Good Thing

Scientists at the University of Bern have been exploring geoengineering methods that could potentially slow down the melting of the West Antarctic ice sheet by reducing sunlight exposure. Among these

why startups succeed

The Top Reasons Why Startups Succeed

Everyone hears the stories. Apple was started in a garage. Musk slept in a rented office space while he was creating PayPal with his brother. Facebook was coded by a

Bold Evolution

Intel’s Bold Comeback

Intel, a leading figure in the semiconductor industry, has underperformed in the stock market over the past five years, with shares dropping by 4% as opposed to the 176% return

Semiconductor market

Semiconductor Slump: Rebound on the Horizon

In recent years, the semiconductor sector has faced a slump due to decreasing PC and smartphone sales, especially in 2022 and 2023. Nonetheless, as 2024 approaches, the industry seems to

Elevated Content Deals

Elevate Your Content Creation with Amazing Deals

The latest Tech Deals cater to creators of different levels and budgets, featuring a variety of computer accessories and tools designed specifically for content creation. Enhance your technological setup with

Learn Web Security

An Easy Way to Learn Web Security

The Web Security Academy has recently introduced new educational courses designed to offer a comprehensible and straightforward journey through the intricate realm of web security. These carefully designed learning courses

Military Drones Revolution

Military Drones: New Mobile Command Centers

The Air Force Special Operations Command (AFSOC) is currently working on a pioneering project that aims to transform MQ-9 Reaper drones into mobile command centers to better manage smaller unmanned

Tech Partnership

US and Vietnam: The Next Tech Leaders?

The US and Vietnam have entered into a series of multi-billion-dollar business deals, marking a significant leap forward in their cooperation in vital sectors like artificial intelligence (AI), semiconductors, and

Huge Savings

Score Massive Savings on Portable Gaming

This week in tech bargains, a well-known firm has considerably reduced the price of its portable gaming device, cutting costs by as much as 20 percent, which matches the lowest

Cloudfare Protection

Unbreakable: Cloudflare One Data Protection Suite

Recently, Cloudflare introduced its One Data Protection Suite, an extensive collection of sophisticated security tools designed to protect data in various environments, including web, private, and SaaS applications. The suite

Drone Revolution

Cool Drone Tech Unveiled at London Event

At the DSEI defense event in London, Israeli defense firms exhibited cutting-edge drone technology featuring vertical-takeoff-and-landing (VTOL) abilities while launching two innovative systems that have already been acquired by clients.

2D Semiconductor Revolution

Disrupting Electronics with 2D Semiconductors

The rapid development in electronic devices has created an increasing demand for advanced semiconductors. While silicon has traditionally been the go-to material for such applications, it suffers from certain limitations.

Cisco Growth

Cisco Cuts Jobs To Optimize Growth

Tech giant Cisco Systems Inc. recently unveiled plans to reduce its workforce in two Californian cities, with the goal of optimizing the company’s cost structure. The company has decided to

FAA Authorization

FAA Approves Drone Deliveries

In a significant development for the US drone industry, drone delivery company Zipline has gained Federal Aviation Administration (FAA) authorization, permitting them to operate drones beyond the visual line of

Mortgage Rate Challenges

Prop-Tech Firms Face Mortgage Rate Challenges

The surge in mortgage rates and a subsequent decrease in home buying have presented challenges for prop-tech firms like Divvy Homes, a rent-to-own start-up company. With a previous valuation of

Lighthouse Updates

Microsoft 365 Lighthouse: Powerful Updates

Microsoft has introduced a new update to Microsoft 365 Lighthouse, which includes support for alerts and notifications. This update is designed to give Managed Service Providers (MSPs) increased control and

Website Lock

Mysterious Website Blockage Sparks Concern

Recently, visitors of a well-known resource website encountered a message blocking their access, resulting in disappointment and frustration among its users. While the reason for this limitation remains uncertain, specialists