Loading TOC...

tde:node-data-extract

tde:node-data-extract(
   $documents as node()*,
   [$templates as element(tde:template)*]
) as map:map

Summary

Extracts row or triple data from a list of specified documents by applying extraction templates that are either stored in the schema database or provided as a second argument.

Parameters
$documents The sequence of input nodes from which row and triple data is extracted.
$templates The tde:templates to use on $documents. If not specified or if an empty sequence is provided, stored templates in the schema database are used.

Example

xquery version "1.0-ml";

let $doc1 :=
<Citation>
  <ID>69152893</ID>
  <Article>
    <Journal>
      <ISSN>0123-4567</ISSN>
      <Details>
        <Volume>118-119</Volume>
        <PubDate>
          <Year>1968</Year>
          <Month>Dec</Month>
          <Day>7</Day>
        </PubDate>
      </Details>
    </Journal>
    <Authors>
      <Author>
       <LastName>Doe</LastName>
       <ForeName>John</ForeName>
      </Author>
      <Author>
        <LastName>Smith</LastName>
        <ForeName>Jane</ForeName>
      </Author>
    </Authors>
  </Article>
</Citation>

let $rowtde1:=
<template xmlns="http://marklogic.com/xdmp/tde">
  <context>/Citation/Article/Journal/Details</context>
  <rows>
    <row>
      <schema-name>Medical</schema-name>
      <view-name>Publications</view-name>
      <columns>
        <column>
          <name>ID</name>
          <scalar-type>long</scalar-type>
          <val>../../../ID</val>
        </column>
        <column>
          <name>ISSN</name>
          <scalar-type>string</scalar-type>
          <val>../ISSN</val>
        </column>
        <column>
          <name>Volume</name>
          <scalar-type>string</scalar-type>
          <val>Volume</val>
        </column>
        <column>
          <name>Date</name>
          <scalar-type>string</scalar-type>
          <val>PubDate/Year||'-'||PubDate/Month||'-'||PubDate/Day</val>
        </column>
      </columns>
    </row>
  </rows>
</template>

let $tripletde1:=
<template xmlns="http://marklogic.com/xdmp/tde">
  <context>//Authors/Author</context>
  <vars>
    <var>
      <name>prefix1</name>
      <val>"http://marklogic.com/example/pubs/"</val>
    </var>
  </vars>
  <triples>
    <triple>
      <subject>
        <val>sem:iri($prefix1||'person/'||./ForeName||'_'||./LastName)</val>
        <invalid-values>reject</invalid-values>
      </subject>
      <predicate>
        <val>sem:iri($prefix1||'authored')</val>
      </predicate>
      <object>
        <val>xs:string(../../Journal/ISSN)</val>
      </object>
    </triple>
  </triples>
</template>

return tde:node-data-extract(($doc1),($rowtde1,$tripletde1))

=>

{
  "document1":[
    {
      "row":{
        "schema":"Medical",
        "view":"Publications",
        "data":{
          "rownum":"1",
          "ID":69152893,
          "ISSN":"0123-4567",
          "Volume":"118-119",
          "Date":"1968-Dec-7"
        }
      }
    },
    {
      "triple":{
        "subject":"http://marklogic.com/example/pubs/person/John_Doe",
        "predicate":"http://marklogic.com/example/pubs/authored",
        "object":{
          "datatype":"http://www.w3.org/2001/XMLSchema#string",
          "value":"0123-4567"
        }
      }
    },
    {
      "triple":{
        "subject":"http://marklogic.com/example/pubs/person/Jane_Smith",
        "predicate":"http://marklogic.com/example/pubs/authored",
        "object":{
          "datatype":"http://www.w3.org/2001/XMLSchema#string",
          "value":"0123-4567"
        }
      }
    }
  ]
}

Comments

    Powered by MarkLogic Server 7.0-4.1 and rundmc | Terms of Use | Privacy Policy