W3C home > Mailing lists > Public > public-linked-json@w3.org > May 2015

RE: Can you provide some context?

From: Ron Siemens <rsiemens77@hotmail.com>
Date: Fri, 1 May 2015 15:54:03 -0700
Message-ID: <BAY177-W428C3DE237C2DFED810686D7D50@phx.gbl>
To: "public-linked-json@w3.org" <public-linked-json@w3.org>
These are the interfaces and JSON results I've been discussing, and below are my attempts at possible context for these to allow an off-the-shelf tool to query this tree.  Can anyone suggest improvements or better alternatives?  I don't think I'm finding the proper solution.

http://biohost1:3777/v1/growths9/tree/{tree_name}

http://biohost1:3777/v1/growths9/branch/{branch_name}

http://biohost1:3777/v1/growths9/leaf/{leaf_name}

tree
{
 "tree_id":"100",
 "tree_name":"maple",
 "root_branch":"root_branch"
}

branch
{
 "branch_id":"200",
 "branch_name":"root_branch",
 "branches":[ { "branch_id":"201", "branch_name":"sub1_branch" }, { "branch_id":"202", "branch_name":"sub2_branch" } ],
 "leaves":[ { "leaf_id":"500", "leaf_name":"leaf1" }, { "leaf_id":"501", "leaf_name":"leaf3" }, { "leaf_id":"502", "leaf_name":"leaf4" } ],
 "age":"20"
}

leaf
{
 "leaf_id":"500",
 "leaf_name":"leaf1",
 "area":"10",
 "age":"3"
}

-------------------------------------------------------------------------------
Attempt 1

I found I could use different "@base" by having different contexts, resulting in this context and associated expansion.  However, I'm not sure how to use a similar solution with a header-linked context: how could you have 2 contexts in that case applying to different parts of the object?

[
  {
  "@context":
  {
    "@vocab": "http://biohost1:3777/vocab#",
    "@base": "http://biohost1:3777/v1/growths9/branches/",
    "branch_name": {
      "@type":"@id"
    }
  },
 "id":"200",
 "branch_name":"root_branch"
 },
 {
   "@context":
  {
    "@vocab": "http://biohost1:3777/vocab#",
    "@base": "http://biohost1:3777/v1/growths9/leaves/",
    "leaf_name": {
      "@type":"@id"
    },
    "age":null
  },
 "branches":[ { "branch_id":"201", "branch_name":"sub1_branch" }, { "branch_id":"202", "branch_name":"sub2_branch" } ],
 "leaves":[ { "leaf_id":"500", "leaf_name":"leaf1" }, { "leaf_id":"501", "leaf_name":"leaf3" }, { "leaf_id":"502", "leaf_name":"leaf4" } ],
 "age":"20"
}
]

Expanding to:

[
  {
    "http://biohost1:3777/vocab#branch_name": [
      {
        "@id": "http://biohost1:3777/v1/growths9/branches/root_branch"
      }
    ],
    "http://biohost1:3777/vocab#id": [
      {
        "@value": "200"
      }
    ]
  },
  {
    "http://biohost1:3777/vocab#branches": [
      {
        "http://biohost1:3777/vocab#branch_id": [
          {
            "@value": "201"
          }
        ],
        "http://biohost1:3777/vocab#branch_name": [
          {
            "@value": "sub1_branch"
          }
        ]
      },
      {
        "http://biohost1:3777/vocab#branch_id": [
          {
            "@value": "202"
          }
        ],
        "http://biohost1:3777/vocab#branch_name": [
          {
            "@value": "sub2_branch"
          }
        ]
      }
    ],
    "http://biohost1:3777/vocab#leaves": [
      {
        "http://biohost1:3777/vocab#leaf_id": [
          {
            "@value": "500"
          }
        ],
        "http://biohost1:3777/vocab#leaf_name": [
          {
            "@id": "http://biohost1:3777/v1/growths9/leaves/leaf1"
          }
        ]
      },
      {
        "http://biohost1:3777/vocab#leaf_id": [
          {
            "@value": "501"
          }
        ],
        "http://biohost1:3777/vocab#leaf_name": [
          {
            "@id": "http://biohost1:3777/v1/growths9/leaves/leaf3"
          }
        ]
      },
      {
        "http://biohost1:3777/vocab#leaf_id": [
          {
            "@value": "502"
          }
        ],
        "http://biohost1:3777/vocab#leaf_name": [
          {
            "@id": "http://biohost1:3777/v1/growths9/leaves/leaf4"
          }
        ]
      }
    ]
  }
]

-------------------------------------------------------------------------------
Attempt 2

Curiously, I found it easier to get my desired link formats when playing with the @type as below.  I couldn't figure out a way to do this with the @id other than the dual contexts above.  Although the expansion below has the linking information I want, I imagine this isn't going to work with off-the-shelf browsing tools which probably expect to use @id.

{
  "@context":
  {
    "@vocab": "http://biohost1:3777/v1/growths9/",
    "@base": null,
    "branch_name": {
      "@type":"branches"
    },
    "leaf_name": {
      "@type":"leaves"
    },
    "branch_id":null,
    "age":null
  },
 "id":"200",
 "branch_name":"root_branch",
 "branches":[ { "branch_id":"201", "branch_name":"sub1_branch" }, { "branch_id":"202", "branch_name":"sub2_branch" } ],
 "leaves":[ { "leaf_id":"500", "leaf_name":"leaf1" }, { "leaf_id":"501", "leaf_name":"leaf3" }, { "leaf_id":"502", "leaf_name":"leaf4" } ],
 "age":"20"
}

Expanding to:

[
  {
    "http://biohost1:3777/v1/growths9/branch_name": [
      {
        "@type": "http://biohost1:3777/v1/growths9/branches",
        "@value": "root_branch"
      }
    ],
    "http://biohost1:3777/v1/growths9/branches": [
      {
        "http://biohost1:3777/v1/growths9/branch_name": [
          {
            "@type": "http://biohost1:3777/v1/growths9/branches",
            "@value": "sub1_branch"
          }
        ]
      },
      {
        "http://biohost1:3777/v1/growths9/branch_name": [
          {
            "@type": "http://biohost1:3777/v1/growths9/branches",
            "@value": "sub2_branch"
          }
        ]
      }
    ],
    "http://biohost1:3777/v1/growths9/id": [
      {
        "@value": "200"
      }
    ],
    "http://biohost1:3777/v1/growths9/leaves": [
      {
        "http://biohost1:3777/v1/growths9/leaf_id": [
          {
            "@value": "500"
          }
        ],
        "http://biohost1:3777/v1/growths9/leaf_name": [
          {
            "@type": "http://biohost1:3777/v1/growths9/leaves",
            "@value": "leaf1"
          }
        ]
      },
      {
        "http://biohost1:3777/v1/growths9/leaf_id": [
          {
            "@value": "501"
          }
        ],
        "http://biohost1:3777/v1/growths9/leaf_name": [
          {
            "@type": "http://biohost1:3777/v1/growths9/leaves",
            "@value": "leaf3"
          }
        ]
      },
      {
        "http://biohost1:3777/v1/growths9/leaf_id": [
          {
            "@value": "502"
          }
        ],
        "http://biohost1:3777/v1/growths9/leaf_name": [
          {
            "@type": "http://biohost1:3777/v1/growths9/leaves",
            "@value": "leaf4"
          }
        ]
      }
    ]
  }
]

 		 	   		  
Received on Friday, 1 May 2015 22:54:32 UTC

This archive was generated by hypermail 2.4.0 : Friday, 17 January 2020 16:18:45 UTC