SPARQL Web Pages (SWP)

A text templating technology for scripting services and user interfaces that interact with RDF data

What is SWP?

SPARQL Web Pages​ (SWP) is a server side scripting technology that can be used to add data services and web pages to TopBraid EDG. Some of the TopBraid EDG’s own web pages are developed in SWP. You can use SWP to modify them and to add your own extensions.

SWP development paradigm is strongly model-driven. Snippets of SWP code are attached directly to class definitions in ontology models. SWP is an HTML templating language similar to Java Server Pages or React’s JSX, but natively optimized for RDF and SPARQL.

TopBraid EDG also offers an alternative approach for server side scripting called Active Data Shapes (ADS). ADS is also model-driven and native RDF yet uses JavaScript instead of HTML as its foundation.

 

How to Use SWP?

SWP scripts can be developed either in TopBraid EDG (File mode) or in TopBraid Composer. When in Composer, you only need to click on the Browser tab to see SWP-based HTML view of the selected resource.

A comprehensive user guide to SWP is available here. It describes all the key elements of the SPARQL Web Pages framework with instructions on:

  • How to structure SWP documents and use SPARQL queries
  • How to connect resources with their SWP views
  • How to define and instantiate customized object types – a key benefit of SWP compared to other template languages
  • How to create multipage SWP applications
  • Object-Oriented model of SWP, its document syntax and functions

SWP can be used to generate more than HTML. It has been used in the following ways:

  • Generation of Markdown and LaTeX documentation
  • Creation of batch files
  • Generation of XML
  • Generation of JSON (using the SWON library)

Different styles of development are supported:

  • For a quick demo, queries can be embedded directly into HTML
  • To create maintainable and scalable systems, SPIN templates encourage query re-use and support the division of labor between HTML designers and the query experts

Most SPARQLMotion modules can be used in SWP scripts. Just like SPARQLMotion, SWP services output RDF, JSON, XML and other formats.

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.

SKOS Concepts Example in HTML

SWP example code for generating HTML list of SKOS concepts from a SPARQL query. Iteration over each result of the query is done with ui:forEach. ?this variable binds to a specific instance of the class (in this case, skos:Concept) associated with the ui:instanceView.
View >>

 

Ready to get started?

Get in touch today to learn how to improve semantic data governance for your enterprise.