Here is how the connector JSON elements should be applied to the Atom Syndication Format document.
The "type" element being set to "feed" tells the Jangle core that it should serialize the response into an Atom Syndication Format document.
See an example feed for a point of reference.
- feed/title
- This is not strictly defined, but preferred practice would be to set it from the service_name/entity or in the case of a single resource service_name/entity/entity_title: openbiblio/resources, openbiblio/actors/Kucinich, Dennis
- feed/updated
- The "time" element or "Last-Modified" HTTP header from the connector.
- id
- The request URI of the feed. This can come from the "request" element.
- feed/link/@self
- This, like the <id> element, is the request URI. This element should include a jangle:format element on feeds with homogeneous record formats. The value of this attribute should be the only item in the "formats" element.
- feed/link/@next
- Drawn from the paging model. If the ["totalResults"] is a greater number than the sum of the ["offset"] element and the number of objects in the ["data"] array, this needs to have a value.
- feed/link/@previous
- Needs to be set if ["offset"] is anything but 0.
- feed/link/@last
- The feed of the last page of resources, if paging is needed.
- feed/entry/id
- The resource URI, taken from ["data"][i]["id"]
- feed/entry/link (no "rel" attribute or rel="self")
- The href attribute should be populated with the ["data"][i]["id"] element. Each entry must have link element that contains a jangle:format attribute that explicitly defines the record type contained in the content element. This attribute's value can be derived from ["data"][i]["format"].
- feed/entry/title
- Taken from ["data"][i]["title"]
- feed/entry/updated
- Supplied by ["data"][i]["updated"]
- feed/entry/created
- From ["data"][i]["created"]
- feed/entry/author/name
- If ["data"][i]["author"] exists, use that, otherwise, set to "n/a"
- feed/entry/content
- The data contained in ["data"][i]["content"]
- feed/entry/content/@type
- The value of ["data"][i]["content_type"]
- feed/entry/summary
- If it exists, use ["data"][i]["description"]
- feed/entry/category/@term
- Provided by ["data"][i]["categories"]
To build the <link> elements, it is probably easiest to look at this from the opposite direction.
The link elements would be built from the "alternate_formats", ["data"][i]["alternate_formats"], ["data"][i]["relationships"], "links", ["data"][i]["links"] elements.
From the "alternate_formats" and ["data"][i]["alternate_formats"] elements, the <link> element's attributes would come from:
- rel
- This is special Jangle URI. The value is the key of the "alternate_formats" hash.
- href
- The value is the value of the "alternate_formats" hash.
- type
- This should always be application/atom+xml
The ["data"][i]["relationships"] are used the following way:
- rel
- This uses the standard rel="related" relationship.
- href
- The value is the value of the "relationships" hash.
- type
- This should always be application/atom+xml.
- jangle:relationship
- The value is set from the key of the "relationship" hash. This is an extension to Atom.
The <link> tags created from the "link" elements is pretty straightforward. The "rel" attribute value is set from the hash key ("alternate", "relation", etc.). The remaining object properties should be set as the element attributes ("href", "type", "title", etc.).