Permalink
Branch: master
Find file Copy path
Fetching contributors…
Cannot retrieve contributors at this time
158 lines (149 sloc) 6.11 KB
<?xml-stylesheet href="xsltforms/xsltforms/xsltforms.xsl" type="text/xsl"?>
<?xsltforms-options debug="no" lang="en"?>
<html
xmlns="http://www.w3.org/1999/xhtml"
xmlns:xf="http://www.w3.org/2002/xforms"
xmlns:ev="http://www.w3.org/2001/xml-events"
xmlns:xs="http://www.w3.org/2001/XMLSchema"
xmlns:rdf="http://www.w3.org/1999/02/22-rdf-syntax-ns#"
xmlns:skos="http://www.w3.org/2004/02/skos/core#"
rdf:dummy=""
skos:dummy="">
<head>
<link type="text/css" rel="stylesheet" href="/css/linked-data.css"/>
<style type="text/css">
#vocabulary-uri-widget input {
width: 40em;
}
body {
padding: 1em;
}
div.concept {
background-color: #F5F5F5;
padding-left: 0.5em;
padding-right: 0.5em;
margin-bottom: 0.5em;
}
</style>
<title>Manage vocabulary</title>
<!-- The "Model" defines variables, and loading and saving data over the network -->
<xf:model id="vocabulary-model">
<!-- Instances (variables -->
<!-- The SKOS Vocabulary being edited (in RDF/XML format) -->
<xf:instance id="vocabulary">
<!-- initially an empty RDF graph -->
<rdf:RDF>
<!-- sample data
<rdf:Description rdf:about="http://corbicula.huni.net.au/data/adb/occupation/chairman_of_the_British_Tobacco_Company">
<skos:altLabel>chairman of the British Tobacco Company</skos:altLabel>
<skos:inScheme rdf:resource="http://corbicula.huni.net.au/data/adb/occupation/"/>
<rdf:type rdf:resource="http://www.w3.org/2004/02/skos/core#Concept"/>
</rdf:Description>
-->
</rdf:RDF>
</xf:instance>
<!-- The HTTP query parameters for requesting a SKOS vocabulary from the server -->
<xf:instance id="load-vocabulary-uri-parameters">
<parameters xmlns="">
<query>sparql query text goes here</query>
<output>xml</output>
</parameters>
</xf:instance>
<!-- binding to the "query" parameter within the above HTTP URI parameter list -->
<xf:bind id="sparql-query" nodeset="instance('load-vocabulary-uri-parameters')/query"/>
<!-- THe SPARQL query with parameter placeholders -->
<xf:instance id="sparql-query-template">
<sparql-query xmlns="">
<query>
prefix skos: &lt;http://www.w3.org/2004/02/skos/core#&gt;
construct {
?vocabulary a skos:ConceptScheme ;
skos:prefLabel ?vocabularyLabel.
?term a skos:Concept ;
skos:inScheme ?vocabulary ;
skos:prefLabel ?prefLabel .
?subject ?predicate ?object .
} where {
bind(&lt;<vocabulary-uri><!--http://corbicula.huni.net.au/data/adb/occupation/--></vocabulary-uri>&gt; as ?vocabulary)
{
optional {?vocabulary skos:prefLabel ?existingVocabularyLabel}
bind("Vocabulary Name" as ?vocabularyLabel)
filter(!bound(?existingVocabularyLabel))
} union {
?subject ?predicate ?term .
bind(
replace(substr(str(?term), strlen(str(?vocabulary)) + 1), "_", " ") as ?prefLabel
)
optional {?term skos:prefLabel ?existingPrefLabel}
filter(!bound(?existingPrefLabel))
filter(strstarts(str(?term), str(?vocabulary)))
filter(?term != ?vocabulary)
} union {
graph ?vocabulary {
?subject ?predicate ?object
}
}
}
</query>
</sparql-query>
</xf:instance>
<!-- Binding to the vocabulary URI placeholder within the above SPARQL query template -->
<xf:bind id="vocabulary-uri" nodeset="instance('sparql-query-template')/query/vocabulary-uri"/>
<!-- Submissions (connect local variables to HTTP resources) -->
<!-- HTTP request for a vocabulary, submitting a form and loading results into "vocabulary" instance -->
<xf:submission id="load-vocabulary"
resource="http://corbicula.huni.net.au/dataset/query"
method="get"
ref="instance('load-vocabulary-uri-parameters')"
replace="instance"
instance="vocabulary">
<xf:dispatch name="xforms-refresh"/>
</xf:submission>
<xf:submission id="save-vocabulary"
method="put"
ref="instance('vocabulary')"
replace="none"
mediatype="application/rdf+xml; charset=UTF-8">
<xf:resource value="concat('http://corbicula.huni.net.au/dataset/graph-store?graph=', instance('sparql-query-template')/query/vocabulary-uri)"/>
</xf:submission>
</xf:model>
</head>
<body>
<!-- User interface -->
<h1>Concept Scheme Editor</h1>
<p>This tool provides the ability to create a SKOS Concept Scheme (i.e. a thesaurus in SKOS format).</p>
<p>The tool searches for URIs which begin with a common prefix, defines each one as a SKOS Concept, and bundles them together into a Concept Scheme
which can then be edited and saved.</p>
<p>NB this process can be quite slow; be prepared to wait a minute while the Concept Scheme is created.</p>
<p>To do: allow hierarchical relationships between Concepts, definitions and scope notes.</p>
<xf:input model="vocabulary-model" bind="vocabulary-uri" id="vocabulary-uri-widget">
<xf:label>Concept Scheme URI</xf:label>
<xf:hint>URI of the Concept Scheme (use the common prefix shared by the URIs of all terms you want to include in the Concept Scheme)</xf:hint>
</xf:input>
<br/>
<xf:trigger id="load">
<xf:label>Load</xf:label>
<xf:action ev:event="DOMActivate">
<!-- copy the string value of the (now filled-in) SPARQL query template into the HTTP request -->
<xf:setvalue bind="sparql-query" value="string(instance('sparql-query-template'))"/>
<!-- make HTTP request server (invoking xf:submission[@id='get-vocabulary']) -->
<xf:send ev:event="DOMActivate" submission="load-vocabulary"/>
</xf:action>
</xf:trigger>
<xf:submit id="save" submission="save-vocabulary">
<xf:label>Save</xf:label>
</xf:submit>
<p>
<xf:input ref="instance('vocabulary')/rdf:Description[rdf:type/@rdf:resource='http://www.w3.org/2004/02/skos/core#ConceptScheme']/skos:prefLabel">
<xf:label>Vocabulary Name</xf:label>
</xf:input>
</p>
<xf:repeat id="description" model="vocabulary-model"
nodeset="instance('vocabulary')/rdf:Description[rdf:type/@rdf:resource='http://www.w3.org/2004/02/skos/core#Concept']">
<div class="concept">
<p><xf:output ref="@rdf:about"/></p>
<p><xf:input ref="skos:prefLabel"/></p>
</div>
</xf:repeat>
</body>
</html>