SWA – SPARQL Web Applications


SPARQL Web Pages (SWP) Application Components are building blocks used to quickly assemble powerful web applications. SWA provides reusable components frequently needed in applications – forms, trees, tables/grids, search and navigation.


Semantic Web and Linked Data technologies make data integration easier. By using unique identifiers for information resources and interlinked ontologies to provide a structure around them, information can be traversed and understood more easily than with heterogeneous formats and data silos. While the data and query layers of RDF have been well-defined and are supported by a wide range of tools, there are few frameworks for building user interfaces to connect the dots. SWA fills this void.


Like SWP, the SWA library is “RDF and SPARQL all the way down”. This makes the framework very self-contained and elegant, and also means that the model of a user interface can be shared and even queried in the same way as the actual data models are.

For example, SWA implements some design patterns that allow users to conveniently declare which properties should go on a form for a class. These declarations are not only executable templates for creating HTML, but also create an RDF model that can be re-purposed for other means. In particular the same layout can be turned into either a read-only form, a search form or an edit form, simply by switching into a different mode.

TopBraid technology enables a new generation of web front ends. These applications have a small, generic core architecture that is ready to work with any type of data, while specific behaviors are brought in from web ontologies.

SWP makes it easy to encapsulate HTML snippets into reusable components. These components can be embedded into other HTML snippets as new XML/HTML tags. Applications are assembled from a growing SWP Application Component Library with pre-built trees, forms, grids components as well as more sophisticated visualizations.

You do not need to develop your whole application with SWP to reuse these components. You can pick your favorite framework such as PHP or any JavaScript framework, for the surrounding page. Simply use the SWP components where they make sense. For example, you may need a SKOS Concept tree to drive the navigation of your application – embed an swa:TreeGadget. Or you may want to expose semantic search over your content – embed an swa:FormSearchGadget. Here is a screenshot of “normal” HTML page that includes SWA gadgets loaded from a TopBraid Live server:

SWA is supported by all TopBraid products. SWA components can be easily customized with CSS stylesheets. Experienced HTML developers can create and publish new components. To view help pages for SWA with embedded working examples, follow these steps:

  1. Download TBC-ME here
  2. Start TBC-ME
  3. Open HELP menu and select SWA Help/Examples

This document has the following sections describing the following key concepts of SWA:

  1. Application Architecture and Layout introduces how SWA applications are constructed from the ground up: a typical solution defines a top-level user-defined SWP element that uses swa:FullScreenBorderLayout to organize the screen into resizable panels. Those panels may be re-loaded by means of the ui:loadable control element, and JavaScript events may trigger reloading. For example, a click on a tree may reload the form. The SWA Gadgets framework makes working with such reloadable windows very easy.
  2. Forms describes how forms can be used and customized for individual ontologies. Forms are collections of swa:Objects elements, arranged in an HTML layout. Forms may be customized in many ways, and new types of widgets can be added.
  3. Grids and Search Results shows how to display tabular data, especially to explore search results. SWA has a built-in mechanism that turns HTML search forms into SPARQL queries, and the results of those queries are then displayed in an interactive grid.
  4. Trees introduces the use of tree structures to navigate through hierarchical data. Finally, there are miscellaneous other SWA elements that are described in Section 6: Other SWA Components.

TBC-ME includes templates for building SWA applications. To use one of the templates right-click on a project you want to place the application in and select from the menu New then SWA Application based on Template. This will create and open a new application with all component assets copied from the selected template. To open your application in a browser use: http://localhost:8083/tbl/swp?_viewClass=”place here URI of the Application class from your new application”&_withImports=true&_base=”place here URI of the graph you want to test your application with”.

While you can begin developing applications by reading through the technical materials listed on this site and consulting the Help facility in TopBraid Composer, for best results we recommend taking TopBraid Platform and Tools training.


Learn how to use SWA Application Template

Your TopBraid system includes SWA Default Application, a template and a good starting point for creating your own SWA applications. Learn more >>

SWA Gadget Reference

SWA defines reusable application components or gadgets.
View the list >>

EPIM ReportingHub

The EPIM Reporting Hub is an SWA application that shows a digest of drilling and production reports from activities on the Norwegian continental shelf.