TILE JSON

TILE JSON

The TILE JSON is the core of the TILE interface. It is a data structure written in Javascript code that contains the necessary data about the images and text used in the interface. Each page in the structure represents a different image, with the lines array within each page containing the text from that page.

It is important to understand the TILE JSON structure if you wish to develop more plugins for the TILE interface. Learning this structure helps tremendously with understanding how the interface is set up and how data is added to images and text.

Basic Structure:

{

sourceFile:”NameOfXMLFile.xml”,

pages:[...],

< Extra Data From Plugins >

}

Taking it step by step:

sourceFile

The XML file that you may or may not include for this JSON session. If you want your data to be saved back into your original XML file using an exporter script of your own, you will need this element to give the path to your XML file. The path can be either online or on your machine.

pages

This is an array for each page in your manuscript/collection/comic book/magazine/whatever. An element in the pages array is called a page. A page combines an image with its transcript lines, along with any other data that yours or someone else’s plugin wants to add to a page. It is made up like so:

PAGE

{

id: “IMG001”,

url: “http://myimages.com/myimage1.jpg”,

info: “Xpath goes here”,

lines: [ Array of lines: line1, line2, lineN ],

< More data can be appended here >

}

id

A unique identifier for this particular page.

url

A string that gives the full path to an image for whatever you are going to mark up.

info

This space is used for an associative array that you can add to/not bother with.

lines

An array of transcript lines for this image. A line is made up of:

LINE

{

id: Unique ID,

text: “String”,

info: “Xpath info”,

< More data can be appended here >

}

id

Unique ID for this particular transcript line.

info

A string representing XPath information for this particular line. May have future uses.

text

String for whatever you want this transcript line to be.

A Note on IDs

In TILE, everything that is linked together has to have an ID associated with it. In abstract terms, this means that if obj1 is linked with obj2, then this means obj1 has to have a unique obj1.id, and so does obj2. Otherwise TILE can’t tell the two objects apart and therefore aborts the linking operation.

All objects are expected to have unique IDs coming into TILE. If you write your own JSON or own import and export script, you’ll need to generate IDs for every line, page, selection, etc. being fed into the TILE JSON. Previously, this was done for certain objects automatically on the client side, but that service has been taken out.

MORE DATA COULD BE APPENDED HERE

This section describes adding data to any JSON object that is currently in the JSON library of objects that are used in TILE. For the basic TILE experience, a JSON would look like this:

{

sourceFile:”hamlet.xml”,

pages:[

{"id":"IMG001",url:”http://host.com/image1”,info:”TEI/text/div1/l”,

lines:[

{"id":”line1”,text:”te . Factum est autem cum essent ibi . impleti sunt dies ”,info:”lb[12]>text>body[1]>p[2]>lb[29]”}

]

},

{“id”:”IMG002″,url:”http://host.com/image1”,info:”TEI/text/div1/l”,

lines:[

{id:”line2”,text:”quia natus est uobis hodie saluator qui est christus dominus in”,info:”lb[5]>text>body[1]>p[2]>lb[15]”}

]

},

]

}

Now lets add data for shapes, text selections, and labels.

{

sourceFile:”hamlet.xml”,

pages:[

{"id":"IMG001",url:”http://host.com/image1”,info:”TEI/text/div1/l”,

lines:[

{id:”line1”,text:”te . Factum est autem cum essent ibi . impleti sunt dies ”,info:”lb[12]>text>body[1]>p[2]>lb[29]”}

]

},

{“id”:”IMG002″,url:”http://host.com/image1”,info:”TEI/text/div1/l”,

lines:[

{id:”line2”,text:”quia natus est uobis hodie saluator qui est christus dominus in”,info:”lb[5]>text>body[1]>p[2]>lb[15]”,shapes:["1297358780274_0"]}

]

},

shapes:[{"id":"1297358780274_0","type":"rect","_scale":1,"color":"#000000","posInfo":{"x":209.4000244140625,"y":151,"width":158,"height":115}}],

selections:[{"id":"anno_1n6WkJCq","StartParent":"div#line_1766","StartOffset":51,"StartChild":0,"EndParent":"div#line_1766","EndOffset":59,"EndChild":0,"color":"#FDFF00", labels:[“lbl_141”]}]

],

labels:[{“id”:”lbl_141”,”name”:”Word”,selections:[“anno_1n6WkJCq”]},{“id”:”lbl_171”,”name”:”Location”}

}

Take note that there are new array stacks added to the JSON. Whenever an object is connected in TILE, it’s representation is located both as an ID reference in another object and as an object in an array stack with its >type as the array name. Not all data may be connected, some items may just be inserted inside the JSON. Whatever output script a user creates should take into consideration whether it wants to show all data or just data that represents connections.>

One Comment

  1. Aja Teehan
    Posted August 15, 2011 at 7:00 am | Permalink

    Hi. I have not been able to upload valid TEI P5, or .json files to the sandbox. Do you know if this feature is working? If so, would it please be possible for the team to supply two example files that do successfully upload: one TEI P5 and a .json file? Though the developers’ documentation details the .json format, the TEI format is not documented. Without example files to compare to my own, I cannot be sure that I have not introduced an error. Many thanks for your time – looking forward to using the tool! Aja.

Post a Comment

You must be logged in to post a comment.