20
Ceri Binding Hypermedia Research Unit, University of Glamorgan, Wales http://hypermedia.research.glam.ac.uk/kos/STELLAR/

Ceri Binding Hypermedia Research Unit, University of Glamorgan, Wales

Embed Size (px)

Citation preview

Ceri BindingHypermedia Research Unit, University of Glamorgan, Wales

http://hypermedia.research.glam.ac.uk/kos/STELLAR/

CSV2DB TAB2DB

DatabaseDatabase

SQL2CSV SQL2TAB

Delimited DataDelimited Data

SQL2STG

User-defined template

User-defined template

RDFRDF [other textualformats]

[other textualformats]

CSV2STG TAB2STG

DELIM2STG

SQLEXECUTE

STELLAR Data Conversions

XMLXML

User Defined Templates STELLAR uses the “StringTemplate” engine

http://www.stringtemplate.org/ String Template Group - text files (*.stg) Textual templates with named placeholders,

populated by data at runtime User defined vs. inbuilt templates:

Advantage - more flexibility in output format Disadvantage - no validation of output format

String Template Group – layout Delimiters

Define characters that will be used to identify start & end of named placeholders within the template

Imports Import externally defined templates

Dictionaries Define lookup dictionaries

Templates Define templates

String Template Group - example// Define delimiters (if not defined, default is "$") delimiters "$", "$"

// Import external templates (allows template libraries)import "myGroup.stg"

// Define a lookup dictionary. Usage: my_dictionary.(“EBA”)my_dictionary ::= [

"EBA" : "Early Bronze Age", "MBA" : "Middle Bronze Age", "LBA" : "Late Bronze Age", default : key // Unknown value passed through

]

// Define a template my_template1(period) ::= "Period is $my_dictionary.(period)$" // e.g. my_template("EBA")$ => "Period is Early Bronze Age"

STELLAR.Console looks for 3 key templates: HEADER, RECORD & FOOTER

delimiters "$", "$" // define delimiter character to use for data ‘placeholders’

import "MyTemplates.stg" // import to use templates held in other *.stg files

// 1. HEADER is written first (if the template exists)

HEADER(options) ::= "List of $options.site_name$ finds"

// 2. RECORD is written once per row of input data

RECORD(options, data) ::= <<

Find Number : $data.id$ // “id” here is the column name from the input data

Find Type : $data.type$ // the placeholders get replaced by the actual data values

Description : $data.desc$

$write_some_stars()$ // example of calling another user defined template

>>

// 3. FOOTER is written last (if the template exists)

FOOTER(options) ::= "End of list"

// other templates can be defined and called from main templates

write_some_stars() ::= "*************"

STELLAR-Specific Templates

(delimited CSV data input):

id, type, desc

12345, ”hobnail”, ”Rusted nail shaft, possibly a hobnail?”

23456, ”brooch”, ”Gold brooch with inlaid mother of pearl”

34567, ”cleat”, “Heavily corroded”

(template output):

List of South Downs finds

Find Number : 12345

Find Type : hobnail

Description : Rusted nail shaft, possibly a hobnail?

*************

Find Number : 23456

Find Type : brooch

Description : Gold brooch with inlaid mother of pearl

*************

Find Number : 34567

Find Type : cleat

Description : Heavily corroded

*************

End of list

(HEADER)“List of $options.site_name$ finds”(HEADER)“List of $options.site_name$ finds”

(RECORD)

Find Number : $data.id$

Find Type : $data.type$

Description : $data.desc$

write_some_stars()

(RECORD)

Find Number : $data.id$

Find Type : $data.type$

Description : $data.desc$

write_some_stars()

(FOOTER)“End of list”(FOOTER)“End of list”

(write_some_stars)“*************”(write_some_stars)“*************”

Example template input & output

delimiters "$", "$”

// write RDF header

HEADER(options) ::= <<

<?xml version="1.0" encoding="UTF-8"?>

<rdf:RDF

xmlns:rdf="http://www.w3.org/1999/02/22-rdf-syntax-ns#"

xmlns:rdfs="http://www.w3.org/2000/01/rdf-schema#">

>>

// write RDF entities and properties based on each data row

RECORD(options, data) ::= <<

<rdf:Description rdf:about="http://tmp/$data.id$">

<rdfs:label>$data.title$</rdfs:label>

</rdf:Description>

>>

// write RDF footer – closure of RDF element from header

FOOTER(options) ::= "</rdf:RDF>"

Using templates to produce RDF

Template Dependencies

RDF.stgRDF.stg

CRM.stgCRM.stg

CRMEH.stgCRMEH.stg

CRMEH_GROUPS.stg CRMEH_CONTEXTS.stg CRMEH_Etc.

Imports

Imports

ImportsImports Imports

User Defined Template Fields

Consistent URIs - Convention Namespace prefix

E.g. “http://stellar/silchester/” Entity type

E.g. “EHE0007” (i.e. Context) Identifier (data value)

E.g. “1015” URI pattern: {prefix}{entity type}_{value}

E.g. “http://stellar/silchester/EHE0007_1015” Consistent identifiers facilitate incremental

enrichment of data

CRM-EH entity / CRM property chain

Context A stratigraphically below Context B: crmeh:EHE0007_Context [EHE0007_A] crm:P7i_witnessed crmeh:EHE1001_ContextEvent [EHE1001_A] crm:P120_occurs_before crmeh:EHE1001_ContextEvent [EHE1001_B] crm:P7_took_place_at crmeh:EHE0007_Context [EHE0007_B]

ecrm:P7_took_place_at

ecrm:P120i_occurs_after

crmeh:EHE1001_ContextEventdata:EHE1001_123

crmeh:EHE1001_ContextEventdata:EHE1001_123

ecrm:P7_took_place_atecrm:P7i_witnessed

crmeh:EHE1001_ContextEventdata:EHE1001_456

crmeh:EHE1001_ContextEventdata:EHE1001_456

ecrm:P7i_witnessed

ecrm:P120_occurs_before

crmeh:EHE0007_Contextdata:EHE0007_123

crmeh:EHE0007_Contextdata:EHE0007_123

crmeh:EHE0007_Contextdata:EHE0007_456

crmeh:EHE0007_Contextdata:EHE0007_456

Example: CRMEH_CONTEXTS: strat_lower_id

Resultant template output

Example template input

Data model

Browsing RDF Data (“Gruff” tool)

Import, consolidation, browsing & querying of RDF data

Querying RDF Data - SPARQL

Structured semantic queries Similar(ish) syntax to SQL Use same query across multiple datasets Possibly develop templates to build queries?

XML encoding / URL Encoding / MD5 encoding

Body text

Issues

Validation of output

Versioning of templates

STELLAR.Win

Ceri BindingHypermedia Research Unit, University of Glamorgan, Wales

http://hypermedia.research.glam.ac.uk/kos/STELLAR/