Changes between Initial Version and Version 1 of S3XRC/S3XML


Ignore:
Timestamp:
10/22/10 10:53:02 (11 years ago)
Author:
Dominic König
Comment:

--

Legend:

Unmodified
Added
Removed
Modified
  • S3XRC/S3XML

    v1 v1  
     1[[TOC]]
     2= S3XML - XML/JSON Format =
     3
     4  - see [wiki:S3XRC]
     5
     6== XML Format ==
     7
     8{{{
     9<s3xrc>
     10
     11  <resource                                                 <-- a record in the database -->
     12      created_on="2009-10-02 08:55:11"                      <-- date/time when the record was created -->
     13      modified_on="2009-10-02 08:56:03"                     <-- date/time when the record was last modified -->
     14      uuid="6e6e76dc-8ed7-408c-bb09-54476e3944ae"           <-- UUID of the record (if present in DB) -->
     15      created_by="None"                                     <-- Author -->
     16      modified_by="Dominic"                                 <-- Last Author -->
     17      name="pr_person">                                     <-- Resource Name -->
     18
     19    <reference                                              <-- Reference Field (foreign key) in the record -->
     20      field="pr_pe_id"                                      <-- Field name -->
     21      resource="pr_pentity"                                 <-- Name of the referenced resource -->
     22      uuid="6e6e76dc-8ed7-408c-bb09-54476e3944ae"/>         <-- UUID of the referenced entry -->
     23
     24    <data field="pr_pe_label">730421</data>                 <-- A field in the record -->
     25    <data field="first_name">Dominic</data>
     26    <data field="middle_name"/>
     27    <data field="last_name">König</data>
     28    <data field="preferred_name"/>
     29    <data field="local_name"/>
     30    <data field="opt_pr_gender" value="3">male</data>
     31    <data field="opt_pr_age_group" value="5">Adult (21-50)</data>
     32    <data field="email">dominic@nursix.org</data>
     33    <data field="mobile_phone"/>
     34    <data field="date_of_birth">1973-04-21</data>
     35    <data field="opt_pr_nationality" value="65">Germany</data>
     36    <data field="opt_pr_country" value="167">Sweden</data>
     37    <data field="opt_pr_religion" value="1">none</data>
     38    <data field="opt_pr_marital_status" value="3">married</data>
     39    <data field="occupation">Nurse</data>
     40    <data field="comment"/>
     41
     42    <resource                                               <-- A sub-resource (joined resource) of the record -->
     43      created_on="2009-10-02 11:34:34"
     44      modified_on="2009-10-02 11:34:34"
     45      uuid="89217054-3c10-4f5d-959a-420254243498"
     46      name="pr_address">
     47
     48      <data
     49        field="opt_pr_address_type"                         <-- field name -->
     50        value="1">                                          <-- original value in the database -->
     51          Home Address                                      <-- value represented for human readability -->
     52      </data>
     53      <data field="co_name"/>
     54      <data field="street1">Lundgatan</data>
     55      <data field="street2"/>
     56      <data field="postcode">38031</data>
     57      <data field="city">Läckeby</data>
     58      <data field="state"/>
     59      <data field="opt_pr_country" value="167">Sweden</data>
     60      <data field="lat">56.78042</data>
     61      <data field="lon">16.27914</data>
     62      <data field="comment"/>
     63    </resource>
     64  </resource>
     65</s3xrc>
     66}}}
     67
     68 * [wiki:UUID] - how we handle Unique IDs for records across heterogeneous systems
     69
     70== JSON Format ==
     71
     72The data structure of the JSON format is equivalent to the XML format (=element trees) - except that markup elements are represented by prefixes:
     73
     74{{{
     75{
     76    "@domain": "yana",                                             // Server name
     77    "@url": "http://127.0.0.1:8000/eden"                           // Server URL
     78    "$_pr_person": {                                               // Resource, prefix: $_
     79        "@uuid": "44fc762e-02df-44e0-8bd1-9b58e3132894",           // Resource attribute, prefix: @
     80        "@url": "http://127.0.0.1:8000/eden/pr/person/1",
     81        "@created_on": "2009-11-16 22:33:35",
     82        "@created_by": "None",
     83        "@modified_on": "2009-11-19 21:32:19",
     84        "@modified_by": "Dominic",
     85        "first_name": "Dominic",                                   // Data field, no prefix
     86        "last_name": "K\u00f6nig",
     87        "email": "dominic@nursix.org",
     88        "opt_pr_age_group": {"@value": "1", "$": "unknown"},       // Data field with textual representation:
     89        "opt_pr_religion": {"@value": "1", "$": "none"},           // @value=Value, $=TextualRepresentation
     90        "opt_pr_gender": {"@value": "1", "$": "unknown"},
     91        "opt_pr_nationality": {"@value": "999", "$": "unknown"},
     92        "opt_pr_country": {"@value": "999", "$": "unknown"},
     93        "opt_pr_marital_status": {"@value": "1", "$": "unknown"},
     94        "$k_pr_pe_id": {                                           // External Reference (Key), prefix: $k_
     95            "@resource": "pr_pentity",                             // Key resource name
     96            "@uuid": "a2a945bd-4f43-41da-bcdb-e2e638a987ea",       // UUID of the key record
     97            "$": "Dominic K\u00f6nig [no label] (Person)"          // Textual representation of the reference
     98        },
     99        "$_pr_presence": {                                         // Joined Resource (Component):
     100            "@uuid": "14af2751-7277-4e90-b42b-0d0430684561",       // appears as component within the resource
     101            "@created_on": "2009-11-19 19:42:46",
     102            "@modified_on": "2009-11-19 19:42:46"
     103            "@url": "http://127.0.0.1:8000/eden/pr/person/1/presence/1",
     104            "opt_pr_presence_condition": {"@value": "4", "$": "Found"},
     105            "time": {"@value": "2009-11-19 18:42:00 +0000", "$": "2009-11-19 20:42:00"},
     106            "$k_reporter": {
     107                "@resource": "pr_person",
     108                "@uuid": "44fc762e-02df-44e0-8bd1-9b58e3132894",
     109                "$": "Dominic K\u00f6nig"
     110            },
     111        }
     112    },
     113}
     114}}}
     115
     116'''JSON format characteristics:'''
     117
     118  * The JSON output contains _no_ whitespace between elements, it's just added here by hand for better readability
     119
     120  * The outermost structure is always a JSON object (not a list)
     121  * All data is represented as strings (for security reasons)
     122
     123  * If @value is sent for a field, it overrides the element text ($) at import
     124  * however, the use of @value is not mandatory, data can simply be placed instead of element text
     125  * Note that there is no automatic data encoding: data must be sent in DB-encoded format
     126  * @resource, @name and @uuid attributes are mandatory at input, other attributes can be omitted
     127
     128  * Multiple records of the same resource will be aggregated as lists like:
     129
     130{{{
     131{
     132    $_my_resource: [
     133        {
     134            // record1 of my_resource
     135        }
     136        {
     137            // record2 of my_resource
     138        }
     139    ]
     140}
     141}}}
     142
     143----
     144
     145DeveloperGuidelines