SlideShare une entreprise Scribd logo
1  sur  14
Motorbike & Sidecar

                XML DATABASES AND TRIPLESTORES

                      PETER WINSTANLEY

                  SCOTTISH GOVERNMENT




peter.winstanley@scotland.gsi.gov.uk
XML
                                    2


 There is a lot of it already available
 It has a structure
 People “out there” know how to use it
 There is a lot of great functionality in the
   XML stack




Dr Peter Winstanley: OKF meeting            5 March 2013
Native XML Databases
                                    3


 No longer something new and esoteric
 Schema-free, so you don‟t need to know
  what you are storing before you do so
 A bit like a file system
 Accessible via several modalities
  (Native protocols (xmldb), http REST
  and WebDAV)

Dr Peter Winstanley: OKF meeting                  5 March 2013
XPath & XQuery
                                         4


 2 ways of computing over XML
 XPath works over paths
  (facets/axis)
 XQuery works over sequences




Dr Peter Winstanley: OKF meeting                    5 March 2013
XPath
                                     5


 Used for querying:
  //xml/indicator[code=„ABC‟]
 ...and computing:
  distinct-values(
  //xml/indicator/code
  )
Dr Peter Winstanley: OKF meeting           5 March 2013
XQuery
                                     6


 XQuery example
   for $i in doc(„mydoc.xml‟)
   where $i//xml/indicator/code = „ABC‟
   return <result>{$i}</result>




Dr Peter Winstanley: OKF meeting            5 March 2013
RESTXQ
                                     7


 XQuery over http
 Parameterised (REST) URLs
 http://server/indicator/code/ABC




Dr Peter Winstanley: OKF meeting            5 March 2013
What about triplestores?
                                    8


 Store whatever RDF you give them
 So, how about:
   http://server/indicator/code/ABC
   a qb:Slice;
   skos:prefLabel „ABC‟ .



Dr Peter Winstanley: OKF meeting                    5 March 2013
The Plan
                                       9




                                                          H
                      H                                   T
                      T                                   T
                      T                                   P
                      P



                                    HTTP




  See also: http://www.xmltoday.org/content/fuseki-using-jena-
  semantic-web-platform-marklogic Kurt Cagle, June 2012
Dr Peter Winstanley: OKF meeting                                 5 March 2013
Motorbike & Sidecar
                                       10




Dr Peter Winstanley: OKF meeting                    5 March 2013
Demo
                                    11


 NXD = BaseX
  http://basex.org
 Triplestore = Fuseki
  http://jena.apache.org/
 Data = Scottish Neighborhood Stats
  http://www.sns.gov.uk/BulkDownloads
   /SNS_FullData_XML_20_2_2013.zip

Dr Peter Winstanley: OKF meeting          5 March 2013
General Instructions
                                       12

 Fuseki ; vanilla install. Startup – should be available on
    localhost:3030
   BaseX; install, edit the web.xml to allow rest, webdav and
    restxq. Create a database (“SNS_ALL”) and add the SNS
    data
   Put the restxq *.xqm module into the BaseX restxq
    directory
   Startup and check availability on localhost:8984
   Run the script to load the triplestore (can be done using
    XQDT in Eclipse)
   Query Fuseki ... select * {?s ?p ?o .}


Dr Peter Winstanley: OKF meeting                      5 March 2013
XQuery to construct and add RDF
                                                                                         13
xquery version "3.0";
(: XQuery main module to load Fuseki with some RDF derived from the SNS_ALL dataset :)

declare function local:load(){

let $i := distinct-values(collection("SNS_ALL")//code)

let $z := for $x in $i

       let $s :=     concat('prefix skos: <http://www.w3.org/2004/02/skos/core#> ',
              'prefix qb: <http://purl.org/linked-data/cube#> ',
              'insert data {<http://localhost:8984/restxq/sns/indicator/code/',
               $x,
              '> a qb:Slice; skos:prefLabel "',
               $x,
              '" .}'
       )

       let $request :=
            <http:request method="post" http-version="1.0">
            <http:body media-type="application/x-www-form-urlencoded">
            {
               concat("update=",
               encode-for-uri($s))
              }
            </http:body>
            </http:request>

       let $upd := http:send-request($request, "http://localhost:3030/DatabasePathname/update")

        return <ret>
            <x>{$x}</x>
            <resp>{$upd}</resp>
           </ret>
return
   <out>
   {$z}
   </out>
};

local:load()




Dr Peter Winstanley: OKF meeting                                                                  5 March 2013
RESTXQ counterpart for URI resolution
                                     14

xquery version "3.0";
(:~
a RESTXQ interface to the SNS data
:)
module namespace page = 'http://basex.org/modules/web-page';
declare namespace sns = "urn:sns-scotexec-gov-uk/schemas/indicators/0.1";


declare
%restxq:path("sns/indicator/code/{$code}")
 function page:indicator($code as xs:string) {
let $r := collection('SNS_ALL')//indicator[code=$code]
return
<SNS1>{$r}</SNS1>
};


Dr Peter Winstanley: OKF meeting                                5 March 2013

Contenu connexe

En vedette

Philippe. Chanson Et Laure Cazabat
Philippe. Chanson Et Laure CazabatPhilippe. Chanson Et Laure Cazabat
Philippe. Chanson Et Laure Cazabat
endocrinologie
 
MN5501 - Dissertation - 1124765 - Neal Coope
MN5501 - Dissertation - 1124765 - Neal CoopeMN5501 - Dissertation - 1124765 - Neal Coope
MN5501 - Dissertation - 1124765 - Neal Coope
Neal Coope
 
HOJA DE VIDA EFRAIN LAY 25agost15
HOJA DE VIDA EFRAIN LAY 25agost15HOJA DE VIDA EFRAIN LAY 25agost15
HOJA DE VIDA EFRAIN LAY 25agost15
Efrain Martin
 

En vedette (6)

Philippe. Chanson Et Laure Cazabat
Philippe. Chanson Et Laure CazabatPhilippe. Chanson Et Laure Cazabat
Philippe. Chanson Et Laure Cazabat
 
Hypophyse
HypophyseHypophyse
Hypophyse
 
Hoja de vida jonatan rivas octubre 2015
Hoja de vida jonatan rivas octubre  2015  Hoja de vida jonatan rivas octubre  2015
Hoja de vida jonatan rivas octubre 2015
 
MN5501 - Dissertation - 1124765 - Neal Coope
MN5501 - Dissertation - 1124765 - Neal CoopeMN5501 - Dissertation - 1124765 - Neal Coope
MN5501 - Dissertation - 1124765 - Neal Coope
 
HOJA DE VIDA EFRAIN LAY 25agost15
HOJA DE VIDA EFRAIN LAY 25agost15HOJA DE VIDA EFRAIN LAY 25agost15
HOJA DE VIDA EFRAIN LAY 25agost15
 
ادارة المعرفة للقيادات
  ادارة المعرفة للقيادات  ادارة المعرفة للقيادات
ادارة المعرفة للقيادات
 

Plus de PeterWinstanley1

Plus de PeterWinstanley1 (12)

W3C Data Exchange Working Group - an update
W3C Data Exchange Working Group - an updateW3C Data Exchange Working Group - an update
W3C Data Exchange Working Group - an update
 
2015-10-07 isko winstanley
2015-10-07 isko winstanley2015-10-07 isko winstanley
2015-10-07 isko winstanley
 
2015-10-07 isko winstanley
2015-10-07 isko winstanley2015-10-07 isko winstanley
2015-10-07 isko winstanley
 
2014 11-17 crichton institute talk on open data
2014 11-17 crichton institute talk on open data2014 11-17 crichton institute talk on open data
2014 11-17 crichton institute talk on open data
 
2014 11-17 crichton institute talk on open data
2014 11-17 crichton institute talk on open data2014 11-17 crichton institute talk on open data
2014 11-17 crichton institute talk on open data
 
ICEGOV 2014: introduction to "Data For Development" track
ICEGOV 2014: introduction to "Data For Development" trackICEGOV 2014: introduction to "Data For Development" track
ICEGOV 2014: introduction to "Data For Development" track
 
2014 09-10 Share PSI 2.0 talk: Scottish Linked Data Interest Group
2014 09-10 Share PSI 2.0 talk: Scottish Linked Data Interest Group2014 09-10 Share PSI 2.0 talk: Scottish Linked Data Interest Group
2014 09-10 Share PSI 2.0 talk: Scottish Linked Data Interest Group
 
Xml pres 1
Xml pres 1 Xml pres 1
Xml pres 1
 
Publishing "5 star" data: the case for RDF
Publishing "5 star" data: the case for RDFPublishing "5 star" data: the case for RDF
Publishing "5 star" data: the case for RDF
 
2013 08-27 okfn-glasgow_uk_gov_open_standards
2013 08-27 okfn-glasgow_uk_gov_open_standards2013 08-27 okfn-glasgow_uk_gov_open_standards
2013 08-27 okfn-glasgow_uk_gov_open_standards
 
Notes for talk on 12th June 2013 to Open Innovation meeting, Glasgow
Notes for talk on 12th June 2013 to Open Innovation meeting, GlasgowNotes for talk on 12th June 2013 to Open Innovation meeting, Glasgow
Notes for talk on 12th June 2013 to Open Innovation meeting, Glasgow
 
Interconnecting Belgian national and regional address data using EC ISA "Loca...
Interconnecting Belgian national and regional address data using EC ISA "Loca...Interconnecting Belgian national and regional address data using EC ISA "Loca...
Interconnecting Belgian national and regional address data using EC ISA "Loca...
 

Dernier

Cloud Frontiers: A Deep Dive into Serverless Spatial Data and FME
Cloud Frontiers:  A Deep Dive into Serverless Spatial Data and FMECloud Frontiers:  A Deep Dive into Serverless Spatial Data and FME
Cloud Frontiers: A Deep Dive into Serverless Spatial Data and FME
Safe Software
 
+971581248768>> SAFE AND ORIGINAL ABORTION PILLS FOR SALE IN DUBAI AND ABUDHA...
+971581248768>> SAFE AND ORIGINAL ABORTION PILLS FOR SALE IN DUBAI AND ABUDHA...+971581248768>> SAFE AND ORIGINAL ABORTION PILLS FOR SALE IN DUBAI AND ABUDHA...
+971581248768>> SAFE AND ORIGINAL ABORTION PILLS FOR SALE IN DUBAI AND ABUDHA...
?#DUbAI#??##{{(☎️+971_581248768%)**%*]'#abortion pills for sale in dubai@
 
Why Teams call analytics are critical to your entire business
Why Teams call analytics are critical to your entire businessWhy Teams call analytics are critical to your entire business
Why Teams call analytics are critical to your entire business
panagenda
 

Dernier (20)

Exploring Multimodal Embeddings with Milvus
Exploring Multimodal Embeddings with MilvusExploring Multimodal Embeddings with Milvus
Exploring Multimodal Embeddings with Milvus
 
Apidays New York 2024 - Passkeys: Developing APIs to enable passwordless auth...
Apidays New York 2024 - Passkeys: Developing APIs to enable passwordless auth...Apidays New York 2024 - Passkeys: Developing APIs to enable passwordless auth...
Apidays New York 2024 - Passkeys: Developing APIs to enable passwordless auth...
 
Artificial Intelligence Chap.5 : Uncertainty
Artificial Intelligence Chap.5 : UncertaintyArtificial Intelligence Chap.5 : Uncertainty
Artificial Intelligence Chap.5 : Uncertainty
 
Emergent Methods: Multi-lingual narrative tracking in the news - real-time ex...
Emergent Methods: Multi-lingual narrative tracking in the news - real-time ex...Emergent Methods: Multi-lingual narrative tracking in the news - real-time ex...
Emergent Methods: Multi-lingual narrative tracking in the news - real-time ex...
 
Cloud Frontiers: A Deep Dive into Serverless Spatial Data and FME
Cloud Frontiers:  A Deep Dive into Serverless Spatial Data and FMECloud Frontiers:  A Deep Dive into Serverless Spatial Data and FME
Cloud Frontiers: A Deep Dive into Serverless Spatial Data and FME
 
Polkadot JAM Slides - Token2049 - By Dr. Gavin Wood
Polkadot JAM Slides - Token2049 - By Dr. Gavin WoodPolkadot JAM Slides - Token2049 - By Dr. Gavin Wood
Polkadot JAM Slides - Token2049 - By Dr. Gavin Wood
 
Apidays New York 2024 - Accelerating FinTech Innovation by Vasa Krishnan, Fin...
Apidays New York 2024 - Accelerating FinTech Innovation by Vasa Krishnan, Fin...Apidays New York 2024 - Accelerating FinTech Innovation by Vasa Krishnan, Fin...
Apidays New York 2024 - Accelerating FinTech Innovation by Vasa Krishnan, Fin...
 
2024: Domino Containers - The Next Step. News from the Domino Container commu...
2024: Domino Containers - The Next Step. News from the Domino Container commu...2024: Domino Containers - The Next Step. News from the Domino Container commu...
2024: Domino Containers - The Next Step. News from the Domino Container commu...
 
Exploring the Future Potential of AI-Enabled Smartphone Processors
Exploring the Future Potential of AI-Enabled Smartphone ProcessorsExploring the Future Potential of AI-Enabled Smartphone Processors
Exploring the Future Potential of AI-Enabled Smartphone Processors
 
CNIC Information System with Pakdata Cf In Pakistan
CNIC Information System with Pakdata Cf In PakistanCNIC Information System with Pakdata Cf In Pakistan
CNIC Information System with Pakdata Cf In Pakistan
 
+971581248768>> SAFE AND ORIGINAL ABORTION PILLS FOR SALE IN DUBAI AND ABUDHA...
+971581248768>> SAFE AND ORIGINAL ABORTION PILLS FOR SALE IN DUBAI AND ABUDHA...+971581248768>> SAFE AND ORIGINAL ABORTION PILLS FOR SALE IN DUBAI AND ABUDHA...
+971581248768>> SAFE AND ORIGINAL ABORTION PILLS FOR SALE IN DUBAI AND ABUDHA...
 
Apidays New York 2024 - APIs in 2030: The Risk of Technological Sleepwalk by ...
Apidays New York 2024 - APIs in 2030: The Risk of Technological Sleepwalk by ...Apidays New York 2024 - APIs in 2030: The Risk of Technological Sleepwalk by ...
Apidays New York 2024 - APIs in 2030: The Risk of Technological Sleepwalk by ...
 
DBX First Quarter 2024 Investor Presentation
DBX First Quarter 2024 Investor PresentationDBX First Quarter 2024 Investor Presentation
DBX First Quarter 2024 Investor Presentation
 
Strategize a Smooth Tenant-to-tenant Migration and Copilot Takeoff
Strategize a Smooth Tenant-to-tenant Migration and Copilot TakeoffStrategize a Smooth Tenant-to-tenant Migration and Copilot Takeoff
Strategize a Smooth Tenant-to-tenant Migration and Copilot Takeoff
 
Apidays New York 2024 - The Good, the Bad and the Governed by David O'Neill, ...
Apidays New York 2024 - The Good, the Bad and the Governed by David O'Neill, ...Apidays New York 2024 - The Good, the Bad and the Governed by David O'Neill, ...
Apidays New York 2024 - The Good, the Bad and the Governed by David O'Neill, ...
 
TrustArc Webinar - Unlock the Power of AI-Driven Data Discovery
TrustArc Webinar - Unlock the Power of AI-Driven Data DiscoveryTrustArc Webinar - Unlock the Power of AI-Driven Data Discovery
TrustArc Webinar - Unlock the Power of AI-Driven Data Discovery
 
Cyberprint. Dark Pink Apt Group [EN].pdf
Cyberprint. Dark Pink Apt Group [EN].pdfCyberprint. Dark Pink Apt Group [EN].pdf
Cyberprint. Dark Pink Apt Group [EN].pdf
 
Corporate and higher education May webinar.pptx
Corporate and higher education May webinar.pptxCorporate and higher education May webinar.pptx
Corporate and higher education May webinar.pptx
 
Why Teams call analytics are critical to your entire business
Why Teams call analytics are critical to your entire businessWhy Teams call analytics are critical to your entire business
Why Teams call analytics are critical to your entire business
 
Strategies for Landing an Oracle DBA Job as a Fresher
Strategies for Landing an Oracle DBA Job as a FresherStrategies for Landing an Oracle DBA Job as a Fresher
Strategies for Landing an Oracle DBA Job as a Fresher
 

Open data edinburgh-napier-2013-03-05

  • 1. Motorbike & Sidecar XML DATABASES AND TRIPLESTORES PETER WINSTANLEY SCOTTISH GOVERNMENT peter.winstanley@scotland.gsi.gov.uk
  • 2. XML 2  There is a lot of it already available  It has a structure  People “out there” know how to use it  There is a lot of great functionality in the XML stack Dr Peter Winstanley: OKF meeting 5 March 2013
  • 3. Native XML Databases 3  No longer something new and esoteric  Schema-free, so you don‟t need to know what you are storing before you do so  A bit like a file system  Accessible via several modalities (Native protocols (xmldb), http REST and WebDAV) Dr Peter Winstanley: OKF meeting 5 March 2013
  • 4. XPath & XQuery 4  2 ways of computing over XML  XPath works over paths (facets/axis)  XQuery works over sequences Dr Peter Winstanley: OKF meeting 5 March 2013
  • 5. XPath 5  Used for querying: //xml/indicator[code=„ABC‟]  ...and computing: distinct-values( //xml/indicator/code ) Dr Peter Winstanley: OKF meeting 5 March 2013
  • 6. XQuery 6  XQuery example for $i in doc(„mydoc.xml‟) where $i//xml/indicator/code = „ABC‟ return <result>{$i}</result> Dr Peter Winstanley: OKF meeting 5 March 2013
  • 7. RESTXQ 7  XQuery over http  Parameterised (REST) URLs  http://server/indicator/code/ABC Dr Peter Winstanley: OKF meeting 5 March 2013
  • 8. What about triplestores? 8  Store whatever RDF you give them  So, how about: http://server/indicator/code/ABC a qb:Slice; skos:prefLabel „ABC‟ . Dr Peter Winstanley: OKF meeting 5 March 2013
  • 9. The Plan 9 H H T T T T P P HTTP See also: http://www.xmltoday.org/content/fuseki-using-jena- semantic-web-platform-marklogic Kurt Cagle, June 2012 Dr Peter Winstanley: OKF meeting 5 March 2013
  • 10. Motorbike & Sidecar 10 Dr Peter Winstanley: OKF meeting 5 March 2013
  • 11. Demo 11  NXD = BaseX http://basex.org  Triplestore = Fuseki http://jena.apache.org/  Data = Scottish Neighborhood Stats http://www.sns.gov.uk/BulkDownloads /SNS_FullData_XML_20_2_2013.zip Dr Peter Winstanley: OKF meeting 5 March 2013
  • 12. General Instructions 12  Fuseki ; vanilla install. Startup – should be available on localhost:3030  BaseX; install, edit the web.xml to allow rest, webdav and restxq. Create a database (“SNS_ALL”) and add the SNS data  Put the restxq *.xqm module into the BaseX restxq directory  Startup and check availability on localhost:8984  Run the script to load the triplestore (can be done using XQDT in Eclipse)  Query Fuseki ... select * {?s ?p ?o .} Dr Peter Winstanley: OKF meeting 5 March 2013
  • 13. XQuery to construct and add RDF 13 xquery version "3.0"; (: XQuery main module to load Fuseki with some RDF derived from the SNS_ALL dataset :) declare function local:load(){ let $i := distinct-values(collection("SNS_ALL")//code) let $z := for $x in $i let $s := concat('prefix skos: <http://www.w3.org/2004/02/skos/core#> ', 'prefix qb: <http://purl.org/linked-data/cube#> ', 'insert data {<http://localhost:8984/restxq/sns/indicator/code/', $x, '> a qb:Slice; skos:prefLabel "', $x, '" .}' ) let $request := <http:request method="post" http-version="1.0"> <http:body media-type="application/x-www-form-urlencoded"> { concat("update=", encode-for-uri($s)) } </http:body> </http:request> let $upd := http:send-request($request, "http://localhost:3030/DatabasePathname/update") return <ret> <x>{$x}</x> <resp>{$upd}</resp> </ret> return <out> {$z} </out> }; local:load() Dr Peter Winstanley: OKF meeting 5 March 2013
  • 14. RESTXQ counterpart for URI resolution 14 xquery version "3.0"; (:~ a RESTXQ interface to the SNS data :) module namespace page = 'http://basex.org/modules/web-page'; declare namespace sns = "urn:sns-scotexec-gov-uk/schemas/indicators/0.1"; declare %restxq:path("sns/indicator/code/{$code}") function page:indicator($code as xs:string) { let $r := collection('SNS_ALL')//indicator[code=$code] return <SNS1>{$r}</SNS1> }; Dr Peter Winstanley: OKF meeting 5 March 2013