Sign in or register
for additional privileges

Scalar 1 User’s Guide

You appear to be using an older verion of Internet Explorer. For the best experience please upgrade your IE version or switch to a another web browser.

RDF Syntax

All API results are returned in RDF, serialized as either RDF-XML or RDF-JSON. The serialization can be managed by the ?format=[xml|json] GET variable (xml is the default). RDF can be intimidating when first encountered. However, it can be summed up by stating that it is content presented in a flatted or non-hierarchical way. For example, each Scalar node — page, media, annotation, etc. — is a node in the RDF output. Additionally, each relationship is also a node, linking two other nodes together. The relationship nodes are at the same hierarchical level as the content nodes, thus presenting RDF’s flattened hierarchy.

Content Nodes

As a practical example, consider the home page of this User's Guide represented in RDF-XML:

In the above example, you can see that a piece of Scalar content is broken into two RDF nodes: first, the content wrapper, and then its version. In this case, the version number 23 of the piece of content is output.

Relationship Nodes

Now consider a second piece of content with the URL, http://scalar.usc.edu/works/guide/getting-started. To create a relationship between the two pieces of content, a third node can be provided in RDF (using the ?rec=1 GET variable):


In this relationship node, a body is described as the home page (/index), and the target as the getting started page (/getting-started). This node is describing a relationship where “getting started” is index 1 of the home page. Put another way, the home page is a path containing other pages where “getting started” is the first page in the path. All RDF follows these three node types: content, version, and relationship nodes. 

RDF-JSON

RDF-XML can be difficult to traverse, therefore the Scalar API also offers the same data in the RDF-JSON format. For example, here is the same content described above in JSON format (using the ?format=json GET variable):


In RDF-JSON, data is provided as an object. The only difference between an RDF-JSON object and a typical JSON object is that rather than index numbers to denote each node as in JSON (e.g., 0, 1, 2, …), in RDF-JSON the URL of each node acts as its key (e.g., http://scalar.usc.edu/works/guide/index.23).

Comment on this page
 

Discussion of "RDF Syntax"

Add your voice to this discussion.

Checking your signed in status ...

Previous page on path Working with the API, page 2 of 6 Next page on path