简体   繁体   中英

How to create a Template using TDE in MarkLogic to generate Triples

I need to create a Template using TDE in MarkLogic. And this template will generate triples from the exiting XML documents. Where the subject is the URI of the doc, the predicate is the name of the element and the Object is the value of the element.

The Semantics guide has examples. For what you ask, you could do something like this, but note that context paths like that could potentially degrade ingest performance considerably (depending on size of your input data):

<template xmlns="http://marklogic.com/xdmp/tde">
  <context>//*[text()]</context>
    <vars>
      <var>
        <name>EX</name>
        <val>"http://example.org/ex#"</val>
      </var>
    </vars>
  <triples>
    <triple>
      <subject>
        <val>sem:iri( fn:base-uri(.) )</val>
      </subject>
      <predicate>
        <val>sem:iri( $EX || fn:name(.) )</val>
      </predicate>
      <object>
        <val>fn:data( . )</val>
      </object>
    </triple>
  </triples>
</template>

HTH!

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM