Copyright © 2008 Model Driven Solutions EKB XML Interface Jim Logan September 2008 Formerly Data...

15
Copyright © 2008 Model Driven Solutions EKB XML Interface Jim Logan September 2008 Formerly Data Access Technologies

Transcript of Copyright © 2008 Model Driven Solutions EKB XML Interface Jim Logan September 2008 Formerly Data...

Page 1: Copyright © 2008 Model Driven Solutions EKB XML Interface Jim Logan September 2008 Formerly Data Access Technologies.

Copyright © 2008 Model Driven Solutions

EKB XML Interface

Jim LoganSeptember 2008

Formerly Data Access Technologies

Page 2: Copyright © 2008 Model Driven Solutions EKB XML Interface Jim Logan September 2008 Formerly Data Access Technologies.

Page 2

EKB XML Interface Rationale

• Business systems are increasingly using XML interfaces

• It would be nice to have one XML interface for systems and UI

• Challenges with this approach are:– Our EKB data is represented as a virtual graph of RDF triples– How do we get from triples to XML and back again?– Popular UI technologies require lots of code to bridge browsers and

XML– Is there a UI technology where the widgets are tied directly to XML

data?

Copyright © 2008 Model Driven Solutions.March 2008

Page 3: Copyright © 2008 Model Driven Solutions EKB XML Interface Jim Logan September 2008 Formerly Data Access Technologies.

Page 3

From RDF Graph to XML: Overview

• Our EKB data is represented as a virtual graph

• We need to somehow transform that to XML and back again

• There is a W3C recommendation called RDF/XML that helps, but:– The graph has no real “root”, so it walks the graph in an

unpredictable order– If an instance has multiple types, the type used as the XML element

name is unpredictable

Copyright © 2008 Model Driven Solutions.March 2008

Page 4: Copyright © 2008 Model Driven Solutions EKB XML Interface Jim Logan September 2008 Formerly Data Access Technologies.

Page 4

From Triples to XML: Virtual Graph

• Our EKB data is represented as RDF triples in a special repository

• Each triple represents {subject, predicate, object}

• The subject and predicate is always a URI

• The object can be either a URI or a literal value

• These triples form a virtual graph

Copyright © 2008 Model Driven Solutions.March 2008

#p1

#p2

“John”

“Jeff”

name

knows

name

#Person

type

type

Page 5: Copyright © 2008 Model Driven Solutions EKB XML Interface Jim Logan September 2008 Formerly Data Access Technologies.

Page 5

From Triples to XML: RDF/XML

<Person>

<name> John </name>

<knows>

<Person>

<name> Jeff </name>

</Person>

</knows>

</Person>

Copyright © 2008 Model Driven Solutions.March 2008

• Striped RDF/XML is a W3C recommendation that almost works

• This is a bit oversimplified*, but roughly:

• The black-on-tan elements represent subjects and objects

• The blue elements represent properties (kinds of predicates)

Person

Person

“John”

“Jeff”

name

knows

name

* This is oversimplified because each Person node actually represents an additional node and an arc:

This turns into an XML element for the type name and an XML attribute for the ID / URI

#p1 #Persontype

Page 6: Copyright © 2008 Model Driven Solutions EKB XML Interface Jim Logan September 2008 Formerly Data Access Technologies.

Page 6

From Triples to XML: Solution

• RDF/XML is really close, but:– It walks the graph in an unpredictable order, since there is no “root”– It uses unpredictable XML element names when several types exist– We only use it as a guide

• The EKB provides a REST service that produces XML instance documents, given:– A “viewpoint”– The “root” (i.e., subject) of the graph, so the structure is predictable

Copyright © 2008 Model Driven Solutions.March 2008

Page 7: Copyright © 2008 Model Driven Solutions EKB XML Interface Jim Logan September 2008 Formerly Data Access Technologies.

Page 7

From Triples to XML: Viewpoint

• A “viewpoint” is expressed in an ontology and specifies:– What types of properties to traverse– How deep to traverse– Which type name to use for polymorphic traversals

• The UI tells the service:– Which viewpoint to use– The subject, as either:

• A specific URI, or• A query-by-example in XML

– The context (i.e., ontology file), as either:• The REST URL, or• An attribute in the XML query-by-example

Copyright © 2008 Model Driven Solutions.March 2008

Page 8: Copyright © 2008 Model Driven Solutions EKB XML Interface Jim Logan September 2008 Formerly Data Access Technologies.

Page 8

• Both examples will return an XML instance document:– HTTP POST to http://ekb.modeldriven.org/.../directory

– HTTP GET from http://ekb.modeldriven.org/.../directory?viewpoint=escaped-viewpoint-uri&id=&23p1

From Triples to XML: HTTP Examples

Copyright © 2008 Model Driven Solutions.March 2008

<XXMLStructures:data_asset_editing_struct><Versioning:Data_asset action=“query">

<rdf-schema:label select=“matches">Actors.owl</rdf-schema:label>< /Versioning:Data_asset>

</XXMLStructures:data_asset_editing_struct>

Viewpoint

Property / predicate

Type

Page 9: Copyright © 2008 Model Driven Solutions EKB XML Interface Jim Logan September 2008 Formerly Data Access Technologies.

Page 9

From Triples to XML: Instance Example

Copyright © 2008 Model Driven Solutions.March 2008

<XXMLStructures:data_asset_editing_struct><Versioning:Data_asset

rdf:about="http://ekb.osera.gov/asset/head/root/asserted/SC/Ontologies/ArchitectureOntology/Actors.owl">

<Authority:responsible_party><Authority:Authority

rdf:about="http://www.modeldriven.org/2008/ArchitectureOntology/Libraries/Authorities.owl#cory-c"><rdf-schema:label>Cory Casanave</rdf-schema:label>

</Authority:Authority></Authority:responsible_party>

<rdf-schema:label>Actors.owl</rdf-schema:label>

< /Versioning:Data_asset></XXMLStructures:data_asset_editing_struct>

Viewpoint

Subject

Property / predicateType

Object

Page 10: Copyright © 2008 Model Driven Solutions EKB XML Interface Jim Logan September 2008 Formerly Data Access Technologies.

Page 10

From Triples to XML: Interface Specifics

• The service requires:– The name of the structure, called the viewpoint, either as:

• A URL query parameter• The outermost XML element in a POSTed query

– The name of the containing ontology file, called the context, either as:

• The URL of the GET or POST• An asset attribute in the outermost XML element in a POSTed query• A GET from the special “global asset URL”:

“.../asset/head/root/asserted/RDFS/*”

– The subject of interest within that ontology file or one of the files it includes, either as:

• A full URI (e.g., “about=http://ekb.modeldriven.org/.../example.owl#p1”)• An abbreviated URI (e.g., “id=#p1”)• A query-by example

Copyright © 2008 Model Driven Solutions.March 2008

Page 11: Copyright © 2008 Model Driven Solutions EKB XML Interface Jim Logan September 2008 Formerly Data Access Technologies.

Page 11

MVC

• In one sense:– The model is the RDF triples– The view is what the service generates algorithmically from the

viewpoint– The controller is the service

• In another sense:– The model is the XML instance document– The view is the UI controls– The controller is the UI

• In a unified sense:– The model is the RDF triples– The view is the UI controls– The controller is the UI and the service

Copyright © 2008 Model Driven Solutions.March 2008

Page 12: Copyright © 2008 Model Driven Solutions EKB XML Interface Jim Logan September 2008 Formerly Data Access Technologies.

Page 12

From XML to RDF Triples: Overview

• The outside world interacts with the EKB using XML

• The EKB data is represented as a virtual graph

• We need to somehow transform the XML into RDF triples

• We need concurrency:– No locking– No stomping– Minimal rollback

• We need value-level provenance (e.g., who set this value when?)

Copyright © 2008 Model Driven Solutions.March 2008

Page 13: Copyright © 2008 Model Driven Solutions EKB XML Interface Jim Logan September 2008 Formerly Data Access Technologies.

Page 13

From XML to RDF Triples: The UI

• The UI requests an XML instance document from the EKB

• The user changes the XML instance document, as the UI marks up the XML instance

• The UI sends the marked-up XML instance document back to the EKB

• EKB uses this XML instance document to change the RDF triples

Copyright © 2008 Model Driven Solutions.March 2008

Page 14: Copyright © 2008 Model Driven Solutions EKB XML Interface Jim Logan September 2008 Formerly Data Access Technologies.

Page 14

From XML to RDF Triples: Edited XML

Copyright © 2008 Model Driven Solutions.September 2008

<XXMLStructures:data_asset_editing_struct><Versioning:Data_asset

rdf:about="http://ekb.osera.gov/asset/head/root/asserted/SC/Ontologies/ArchitectureOntology/Actors.owl"action="edit">

<Authority:responsible_party action="remove"><Authority:Authority

rdf:about="http://www.modeldriven.org/2008/ArchitectureOntology/Libraries/Authorities.owl#cory-c"><rdf-schema:label>Cory Casanave</rdf-schema:label>

</Authority:Authority></Authority:responsible_party>

<auth:responsible_party action="insert"><Authority:Authority

rdf:about="http://www.modeldriven.org/2008/ArchitectureOntology/Libraries/Authorities.owl#jim-l"><rdf-schema:label>Jim Logan</rdf-schema:label>

</Authority:Authority></auth:responsible_party>

<rdf-schema:label action="remove">Actors.owl</rdf-schema:label><rdf-schema:label action="insert">Changed Actors.owl</rdf-schema:label>

< /Versioning:Data_asset></XXMLStructures:data_asset_editing_struct>

Viewpoint

Subject

Page 15: Copyright © 2008 Model Driven Solutions EKB XML Interface Jim Logan September 2008 Formerly Data Access Technologies.

Page 15

From XML to RDF Triples: EKB Service

• Provides a REST service that consumes a marked-up XML instance document containing:– The “viewpoint”– The subject– Actions

• Starts a transaction

• Ensures that the removed values are still the current values

• Deletes the corresponding triples

• Adds the new triples

• Ends the transaction

• Unimplemented: if any rules are violated, the transaction should fail and the service should send back a report

Copyright © 2008 Model Driven Solutions.March 2008