Skip to content

Instantly share code, notes, and snippets.

@grechaw
Created August 23, 2016 17:41
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save grechaw/33870cf008735392e2dc00768ddede3a to your computer and use it in GitHub Desktop.
Save grechaw/33870cf008735392e2dc00768ddede3a to your computer and use it in GitHub Desktop.
Extraction template to assert a document as RDF instance data.
<?xml version="1.0" encoding="UTF-8"?>
<template xmlns="http://marklogic.com/xdmp/tde">
<description>
A custom TDE for tagging instances of Runner as instance of RDFS class Runner.
</description>
<context>//es:instance//Runner</context>
<path-namespaces>
<path-namespace>
<prefix>es</prefix>
<namespace-uri>http://marklogic.com/entity-services</namespace-uri>
</path-namespace>
</path-namespaces>
<templates>
<template xmlns:tde="http://marklogic.com/xdmp/tde">
<context>.</context>
<vars>
<var><name>RDF</name><val>"http://www.w3.org/1999/02/22-rdf-syntax-ns#"</val></var>
<var><name>RDF_TYPE</name><val>sem:iri(concat($RDF, "type"))</val></var>
</vars>
<triples>
<triple>
<subject><val>sem:iri(concat("http://grechaw.github.io/entity-types/Race-0.0.1/Runner/", fn:encode-for-uri(./name)))</val></subject>
<predicate><val>$RDF_TYPE</val></predicate>
<object><val>sem:iri("http://grechaw.github.io/entity-types/Race-0.0.1/Runner")</val></object>
</triple>
<triple>
<subject><val>sem:iri(concat("http://grechaw.github.io/entity-types/Race-0.0.1/Runner/", fn:encode-for-uri(./name)))</val></subject>
<predicate><val>sem:iri("http://www.w3.org/2000/01/rdf-schema#isDefinedBy")</val></predicate>
<object><val>fn:base-uri(.)</val></object>
</triple>
</triples>
</template>
</templates>
</template>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment