You are here

README.txt in Views Datasource 7

Same filename and directory in other branches
  1. 5 README.txt
  2. 6 README.txt
INTRODUCTION
------------

Views Datasource is a set of plugins for Views for rendering node content in a
set of shareable, reusable data formats based on XML, JSON, and XHTML. These
formats allow content in a Drupal site to be easily used as data sources for
Semantic Web clients and web mash-ups. Views Datasource plugins output content
from node lists created in Drupal Views as:

 * XML data documents using schemas like OPML and Atom;
 * RDF/XML data documents using vocabularies like FOAF, SIOC and DOAP;
 * JSON data documents in plain JSON or in a format like MIT Simile/Exhibit;
 * XHTML data documents using microformat like hCard and hCalendar

The project consists of 4 Views style plugins:

 * views_xml - Output as raw XML, OPML, and Atom;
 * views_json - Output as simple JSON, Simile/Exhibit JSON and JqGrid;
 * views_rdf - Output as FOAF, SIOC and DOAP;
 * views_xhtml - Output as hCard and hCalendar.

In Drupal 7.x, to use these plugins you should:

1. Enable the module containing the format you want to render your views as.

2. In the Views UI set the view style (in Format section) to one of:
   * JSON data document (render as Simple JSON or Simile/Exhibit JSON)
   * XML data document (render as raw XML, OPML, or Atom)
   * RDF data document (render as a FOAF or SIOC or DOAP RDF/XML document)
   * XHTML data document (render as hCard or hCalendar XHTML)

3. In the view format settings choose the options or vocabulary for your format
   (like raw or the OPML or Atom vocabulary for XML rendering.)

4. Add the fields to your view that contain the information you want to be
   pulled into the format renderer. All formats will output the fields
   recognized as belonging to that format, and certain formats like Atom and
   SIOC require certain fields to be present (see below.)
   The SIOC format requires the fields: node id, type, title, body, posted date

5. That's it! The rendered view will be visible in the preview and at your
   view's page displaypath. When you create a page display for your view with a
   unique URL, no Drupal markup is emitted from this page, just the data for
   the particular content type with the proper Content-Type HTTP header (like
   text/xml or application/rdf+xml.)

A JSON data document will render the nodes generated by a view as a
serialization of an array of Javascript objects with each object's properties
corresponding to a view field. Simple JSON is just plain-vanilla JSON
serialization usable in most apps while Simile/Exhibit JSON is the serialization
format used by the Exhibit web app - http://simile.mit.edu/exhibit/

An XML data document with render the nodes generated by a view as XML. The raw
XML format creates a root element called 'nodes' and then a 'node' child element
for each node in the view, with each node's child elements corresponding to a
view field. OPML is a very simple XML schema useful for generating simple lists
(like lists of tracks in an music playlist.) Atom is a syndication schema with
similar intents as RSS. The following fields will bviews_rdf will render
the nodes generated by a view as an RDF/XML FOAF document with each
<foaf:Person> element corresponding to a node in the view. To use just have
fields in the view named as their equivalent FOAF properties - for example to
have a <foaf:name> or <foaf:nick> element, have a field named 'name' and 'nick'
in your view. Similarly views_xhtml provides the hCard plugin which will render
each node in the XHTML hCard format - just have fields corresponding to hCard
properties defined in the view. For example to create an <email> element inside
the <div class="hcard"> root element, just have one or more fields in the view
containing the text 'email'.

The FOAF and hCard renderers are most useful with view based on user profiles
where you can create profile fields corresponding to properties defined in the
FOAF (http://xmlns.com/foaf/spec/) or hCard
(http://microformats.org/wiki/hcard-cheatsheet) spec. However any node type
(like those created with nodeprofile or Bio or Advanced Profile or Content
Profile) can be used in the view. It doesn't matter what data table the view
is based on, only what fields are present in the view.


CONFIGURATION
-------------

CORS headers can be added using the CORS module:
https://www.drupal.org/project/cors

Each style has a range of options you can use to customize the output.

The following options are common to all plugins:

 * Field output: Normal or Raw
   This determines if each object in the view is displayed as normally
   rendered by Drupal, or as the raw result object. Raw is useful if
   you don't want any Drupal formatting applied to the view result, for
   example, if you have a field with a date and you just want the timestamp
   value from the database. Note that both a field's label and content are
   rendered as raw so XML element or attribute labels will have the internal
   field name - for example instead of 'Body' a raw field will have the
   label 'node_revisions_body'.

 * Plaintext output
   Selecting this means that all HTML markup will be stripped from the
   view result. This is useful, for example, if you are generating an
   XML document from nodes and you just want the plain text content
   of a node without markup tags mixing with the other XML elements.
   (Note that you can also escape XML content using CDATA sections,
   see below.)

 * Content-Type
   This determine the Content-Type header sent in a page display of
   a view. This header is necessary for most clients consuming data
   from the view. You can use the default Content-Type for the
   particular plugin or choose from alternate types.

 * Use Views API mode
   By default the plugins stop Drupal from doing any additional processing
   when a view is rendered, allowing the content to be output without any
   additional Drupal markup. However, if you are calling a view
   programatically then this will hlar your code prematurely. The solution
   is to use the Use Views API mode option if you are going to call
   the view from code. This option causes the plugin to not terminate
   Drupal execution.

The following options are common to the views_xml, and views_xhtml plugins:

 * Escape row content as CDATA
   This option escapes all content from the result row using the ![CDATA[
   XML directive. This is useful if you want all content markup preserved,
   but kept separate from the other XML tags in the document. You will
   have to instruct your client that the data you are processing is
   in CDATA blocks, and different XML processors may handle these blocks
   differently.

 * XML document header
   This option lets you specify the XML document header which precedes the
   root XML element. If you specify a header here it will override any
   header generated automatically by the plugin.

The views_json plugin has the following options:

 * Root object name
   This specifies the name of the top-level object in the JSON object. The
   default is the name of the view base table (nodes, users, etc.)

 * JSON data format
   This specifies the format of the JSON output - either simple,
   single simple object with key value properties, plain-
   vanilla JSON, or the JSON format compatible with the Simile/Exhibit
   application.

 * "Single Simple Object with key value properties" JSON data format
	It is useful when you want to return a single object just for one row,
	{ title: "Example", status: "published" } instead of {[ ... ]}.

	This format available when you set "Items per page" views pager setting,
	that available on all pager formats except "Display all items".
	Also if you try to return more results than one, it will return only first row.

	This format ignores such options as: "Root object name" & "Top-level child object".

The views_xml plugin has the following options:

 * XML schema:
   This specifies the XML schema the view will render.
   Raw simply renders each view field using the field name as
   a element/attribute label and the field content as the element/attribute
   value.

   OPML renders each field as an attribute-value pair in an <outline>
   element. The OPML schema requires at least one field labelled 'text' - or
   if this is not found it falls back to 'body' or 'node_revisions_body'.
   The following fields are recommended (fallback in brackets):
   type (node_type), created(published, node_created, Post date).

   Atom renderes a view using the Atom syndication schema. You can use this
   format to create an Atom syndication of the content in your view. Atom
   requires the following fields to be present (fields in bracket indicate
   what the plugin will fall back to if it can find the explicitly named
   Atom field):
   id (nid), title(node_title) updated(last_updated, Updated date, changed,
   Last updated/commented, Last comment time)
   The following fields are recommended: content(Body, node_body,
   node_revisions_body), link (nid {a link will be constructed from the
   Drupal path and the nid), summary author(uid).

 * Root element name:
   Only applies to the Raw XML schema. This specifies the root XML element
   in the document. All other elements will be children of this element.
   The default is the name of the view base table.

 * Element output:
   Only applies to the Raw XML schema. This specifies whether the view
   fields will be output as nested child elements or attributes. For example
   if Element output is set to Nested then a field labelled 'title' with
   content 'foo' will be output as <title>foo</title> If Element output
   is set to Attributes then this field will be output as title = "foo"
   for each row element. Note that the plugin automatically strips invalid
   XML element and attribute label characters (like spaces), so a field like
   'Post date' will become 'postdate'.

 * View author:
   This is used by the Atom and OPML plugins to provide the author
   of the Atom or OPML document. It can be a valid Drupal user name,
   a Drupal user uid, or any name otherwise.

The views_rdf plugin has the following options:

 * RDF vocabulary:
   This indicates what RDF vocabulary to use in the document: either
   FOAF or SIOC or DOAP . FOAF (Friend of a Friend) is useful for sharing a
   list of  users or people, while SIOC
   (Semantically-Interlinked Online Communities Project) is most useful for
   describing a set of pages, stories, blogs,
   or forum posts with comments from different people. SIOC itself uses
   FOAF to describe the posts and comments from different people. DOAP
   (Description of a Project) is useful for - as the name suggests - projects.
   See these links for more info:
    http://www.foaf-project.org/
    http://sioc-project.org/
    http://trac.usefulinc.com/doap

   The following fields are recognized when using the FOAF vocabulary
   (fallbacks in brackets):
   name, firstname, surname, title, nick, mbox (mail, email), mbox_sha1sum,
   openid, workplacehomepage, homepage, weblog, img, depiction, member,
   phone, jabberID, msnChatID, aimChatID, yahooChatID.

   The following fields are required when using the SIOC vocabulary:
   id (nid), created(node_created, Post date, title, type (node_type),
   changed (node_changed, updated/commented date) last_updated(updated date),
   body(node_body, node_revisions_body), uid (users_uid).

   The following fields are recognized when using the DOAP vocabulary:
   (optional fields in square brackets)
   nid, name, homepage, [license], [shortdesc], [language], [repositories],
   [developers]

The views_xhtml plugin has the following options:

 * Microformat
   This specifies the microformat to be rendered: hCard is most useful for a
   list of users or people. hCalendar can be used to describe a list of
   events.
   The following fields are recognized by hCard:
   Address Type, Post office box, Street Address, Extended Address, region,
   Locality. Postal Code, Country name, agent, bday, class, category, email,
   honorific prefix, Given name, Additional name, Family name, Honoric suffix,
   Nickname, Organization name, Organization unit, photo, tel.

   The following fields are recognized by hCalendar:
   class, category, description, summary, dtstart(Event start, event_start)
   dtend(Event end, event_end).


TODO
----
 Proper date handling for each format
 Check for separator in profile fields
 Properly handle grouped multiple values in views_xhtml et. al
 Strict conformance with Atom spec
 Recognize when field rewriting rules are used
 Represent multiple-valued fields using nested child elements

File

README.txt
View source
  1. INTRODUCTION
  2. ------------
  3. Views Datasource is a set of plugins for Views for rendering node content in a
  4. set of shareable, reusable data formats based on XML, JSON, and XHTML. These
  5. formats allow content in a Drupal site to be easily used as data sources for
  6. Semantic Web clients and web mash-ups. Views Datasource plugins output content
  7. from node lists created in Drupal Views as:
  8. * XML data documents using schemas like OPML and Atom;
  9. * RDF/XML data documents using vocabularies like FOAF, SIOC and DOAP;
  10. * JSON data documents in plain JSON or in a format like MIT Simile/Exhibit;
  11. * XHTML data documents using microformat like hCard and hCalendar
  12. The project consists of 4 Views style plugins:
  13. * views_xml - Output as raw XML, OPML, and Atom;
  14. * views_json - Output as simple JSON, Simile/Exhibit JSON and JqGrid;
  15. * views_rdf - Output as FOAF, SIOC and DOAP;
  16. * views_xhtml - Output as hCard and hCalendar.
  17. In Drupal 7.x, to use these plugins you should:
  18. 1. Enable the module containing the format you want to render your views as.
  19. 2. In the Views UI set the view style (in Format section) to one of:
  20. * JSON data document (render as Simple JSON or Simile/Exhibit JSON)
  21. * XML data document (render as raw XML, OPML, or Atom)
  22. * RDF data document (render as a FOAF or SIOC or DOAP RDF/XML document)
  23. * XHTML data document (render as hCard or hCalendar XHTML)
  24. 3. In the view format settings choose the options or vocabulary for your format
  25. (like raw or the OPML or Atom vocabulary for XML rendering.)
  26. 4. Add the fields to your view that contain the information you want to be
  27. pulled into the format renderer. All formats will output the fields
  28. recognized as belonging to that format, and certain formats like Atom and
  29. SIOC require certain fields to be present (see below.)
  30. The SIOC format requires the fields: node id, type, title, body, posted date
  31. 5. That's it! The rendered view will be visible in the preview and at your
  32. view's page displaypath. When you create a page display for your view with a
  33. unique URL, no Drupal markup is emitted from this page, just the data for
  34. the particular content type with the proper Content-Type HTTP header (like
  35. text/xml or application/rdf+xml.)
  36. A JSON data document will render the nodes generated by a view as a
  37. serialization of an array of Javascript objects with each object's properties
  38. corresponding to a view field. Simple JSON is just plain-vanilla JSON
  39. serialization usable in most apps while Simile/Exhibit JSON is the serialization
  40. format used by the Exhibit web app - http://simile.mit.edu/exhibit/
  41. An XML data document with render the nodes generated by a view as XML. The raw
  42. XML format creates a root element called 'nodes' and then a 'node' child element
  43. for each node in the view, with each node's child elements corresponding to a
  44. view field. OPML is a very simple XML schema useful for generating simple lists
  45. (like lists of tracks in an music playlist.) Atom is a syndication schema with
  46. similar intents as RSS. The following fields will bviews_rdf will render
  47. the nodes generated by a view as an RDF/XML FOAF document with each
  48. element corresponding to a node in the view. To use just have
  49. fields in the view named as their equivalent FOAF properties - for example to
  50. have a or element, have a field named 'name' and 'nick'
  51. in your view. Similarly views_xhtml provides the hCard plugin which will render
  52. each node in the XHTML hCard format - just have fields corresponding to hCard
  53. properties defined in the view. For example to create an element inside
  54. the
    root element, just have one or more fields in the view
  55. containing the text 'email'.
  56. The FOAF and hCard renderers are most useful with view based on user profiles
  57. where you can create profile fields corresponding to properties defined in the
  58. FOAF (http://xmlns.com/foaf/spec/) or hCard
  59. (http://microformats.org/wiki/hcard-cheatsheet) spec. However any node type
  60. (like those created with nodeprofile or Bio or Advanced Profile or Content
  61. Profile) can be used in the view. It doesn't matter what data table the view
  62. is based on, only what fields are present in the view.
  63. CONFIGURATION
  64. -------------
  65. CORS headers can be added using the CORS module:
  66. https://www.drupal.org/project/cors
  67. Each style has a range of options you can use to customize the output.
  68. The following options are common to all plugins:
  69. * Field output: Normal or Raw
  70. This determines if each object in the view is displayed as normally
  71. rendered by Drupal, or as the raw result object. Raw is useful if
  72. you don't want any Drupal formatting applied to the view result, for
  73. example, if you have a field with a date and you just want the timestamp
  74. value from the database. Note that both a field's label and content are
  75. rendered as raw so XML element or attribute labels will have the internal
  76. field name - for example instead of 'Body' a raw field will have the
  77. label 'node_revisions_body'.
  78. * Plaintext output
  79. Selecting this means that all HTML markup will be stripped from the
  80. view result. This is useful, for example, if you are generating an
  81. XML document from nodes and you just want the plain text content
  82. of a node without markup tags mixing with the other XML elements.
  83. (Note that you can also escape XML content using CDATA sections,
  84. see below.)
  85. * Content-Type
  86. This determine the Content-Type header sent in a page display of
  87. a view. This header is necessary for most clients consuming data
  88. from the view. You can use the default Content-Type for the
  89. particular plugin or choose from alternate types.
  90. * Use Views API mode
  91. By default the plugins stop Drupal from doing any additional processing
  92. when a view is rendered, allowing the content to be output without any
  93. additional Drupal markup. However, if you are calling a view
  94. programatically then this will hlar your code prematurely. The solution
  95. is to use the Use Views API mode option if you are going to call
  96. the view from code. This option causes the plugin to not terminate
  97. Drupal execution.
  98. The following options are common to the views_xml, and views_xhtml plugins:
  99. * Escape row content as CDATA
  100. This option escapes all content from the result row using the ![CDATA[
  101. XML directive. This is useful if you want all content markup preserved,
  102. but kept separate from the other XML tags in the document. You will
  103. have to instruct your client that the data you are processing is
  104. in CDATA blocks, and different XML processors may handle these blocks
  105. differently.
  106. * XML document header
  107. This option lets you specify the XML document header which precedes the
  108. root XML element. If you specify a header here it will override any
  109. header generated automatically by the plugin.
  110. The views_json plugin has the following options:
  111. * Root object name
  112. This specifies the name of the top-level object in the JSON object. The
  113. default is the name of the view base table (nodes, users, etc.)
  114. * JSON data format
  115. This specifies the format of the JSON output - either simple,
  116. single simple object with key value properties, plain-
  117. vanilla JSON, or the JSON format compatible with the Simile/Exhibit
  118. application.
  119. * "Single Simple Object with key value properties" JSON data format
  120. It is useful when you want to return a single object just for one row,
  121. { title: "Example", status: "published" } instead of {[ ... ]}.
  122. This format available when you set "Items per page" views pager setting,
  123. that available on all pager formats except "Display all items".
  124. Also if you try to return more results than one, it will return only first row.
  125. This format ignores such options as: "Root object name" & "Top-level child object".
  126. The views_xml plugin has the following options:
  127. * XML schema:
  128. This specifies the XML schema the view will render.
  129. Raw simply renders each view field using the field name as
  130. a element/attribute label and the field content as the element/attribute
  131. value.
  132. OPML renders each field as an attribute-value pair in an
  133. element. The OPML schema requires at least one field labelled 'text' - or
  134. if this is not found it falls back to 'body' or 'node_revisions_body'.
  135. The following fields are recommended (fallback in brackets):
  136. type (node_type), created(published, node_created, Post date).
  137. Atom renderes a view using the Atom syndication schema. You can use this
  138. format to create an Atom syndication of the content in your view. Atom
  139. requires the following fields to be present (fields in bracket indicate
  140. what the plugin will fall back to if it can find the explicitly named
  141. Atom field):
  142. id (nid), title(node_title) updated(last_updated, Updated date, changed,
  143. Last updated/commented, Last comment time)
  144. The following fields are recommended: content(Body, node_body,
  145. node_revisions_body), link (nid {a link will be constructed from the
  146. Drupal path and the nid), summary author(uid).
  147. * Root element name:
  148. Only applies to the Raw XML schema. This specifies the root XML element
  149. in the document. All other elements will be children of this element.
  150. The default is the name of the view base table.
  151. * Element output:
  152. Only applies to the Raw XML schema. This specifies whether the view
  153. fields will be output as nested child elements or attributes. For example
  154. if Element output is set to Nested then a field labelled 'title' with
  155. content 'foo' will be output as foo If Element output
  156. is set to Attributes then this field will be output as title = "foo"
  157. for each row element. Note that the plugin automatically strips invalid
  158. XML element and attribute label characters (like spaces), so a field like
  159. 'Post date' will become 'postdate'.
  160. * View author:
  161. This is used by the Atom and OPML plugins to provide the author
  162. of the Atom or OPML document. It can be a valid Drupal user name,
  163. a Drupal user uid, or any name otherwise.
  164. The views_rdf plugin has the following options:
  165. * RDF vocabulary:
  166. This indicates what RDF vocabulary to use in the document: either
  167. FOAF or SIOC or DOAP . FOAF (Friend of a Friend) is useful for sharing a
  168. list of users or people, while SIOC
  169. (Semantically-Interlinked Online Communities Project) is most useful for
  170. describing a set of pages, stories, blogs,
  171. or forum posts with comments from different people. SIOC itself uses
  172. FOAF to describe the posts and comments from different people. DOAP
  173. (Description of a Project) is useful for - as the name suggests - projects.
  174. See these links for more info:
  175. http://www.foaf-project.org/
  176. http://sioc-project.org/
  177. http://trac.usefulinc.com/doap
  178. The following fields are recognized when using the FOAF vocabulary
  179. (fallbacks in brackets):
  180. name, firstname, surname, title, nick, mbox (mail, email), mbox_sha1sum,
  181. openid, workplacehomepage, homepage, weblog, img, depiction, member,
  182. phone, jabberID, msnChatID, aimChatID, yahooChatID.
  183. The following fields are required when using the SIOC vocabulary:
  184. id (nid), created(node_created, Post date, title, type (node_type),
  185. changed (node_changed, updated/commented date) last_updated(updated date),
  186. body(node_body, node_revisions_body), uid (users_uid).
  187. The following fields are recognized when using the DOAP vocabulary:
  188. (optional fields in square brackets)
  189. nid, name, homepage, [license], [shortdesc], [language], [repositories],
  190. [developers]
  191. The views_xhtml plugin has the following options:
  192. * Microformat
  193. This specifies the microformat to be rendered: hCard is most useful for a
  194. list of users or people. hCalendar can be used to describe a list of
  195. events.
  196. The following fields are recognized by hCard:
  197. Address Type, Post office box, Street Address, Extended Address, region,
  198. Locality. Postal Code, Country name, agent, bday, class, category, email,
  199. honorific prefix, Given name, Additional name, Family name, Honoric suffix,
  200. Nickname, Organization name, Organization unit, photo, tel.
  201. The following fields are recognized by hCalendar:
  202. class, category, description, summary, dtstart(Event start, event_start)
  203. dtend(Event end, event_end).
  204. TODO
  205. ----
  206. Proper date handling for each format
  207. Check for separator in profile fields
  208. Properly handle grouped multiple values in views_xhtml et. al
  209. Strict conformance with Atom spec
  210. Recognize when field rewriting rules are used
  211. Represent multiple-valued fields using nested child elements