MarkLogic Server
XQUERY API DOCUMENTATION
3.2
This page was generated
January 5, 2009
5:42 PM
XQuery Built-In and Modules Function Reference

Module: Links

The links module is installed as part of the Content Processing Framework. These functions are used to manage the relationships among documents in the database, for example, as between a binary source document and an XML document generated by a conversion process from that source document. The Content Processing Framework will use links to determine if related documents should also be removed when a document is deleted from the database.

To use the links module as part of your own XQuery module, include the following line in your XQuery prolog:

import module namespace lnk = "http://marklogic.com/cpf/links" at "/MarkLogic/cpf/links.xqy"

The library namespace prefix lnk is not predefined in the server.

Function Summary
lnk:create Create a link between the two given documents with the given role labels and strength.
lnk:from Find and return all the links from the given document to some other.
lnk:get Find and return the link between the two documents, if any.
lnk:insert Insert the given link.
lnk:remove Remove the link between the two given documents and return the removed link.
lnk:to Find and return all the links to the given document from some other.
Function Detail
lnk:create(
$from as xs:string,
$to as xs:string,
$role as xs:string,
$rev-role as xs:string,
$strength as xs:string
)  as   empty()
Summary:

Create a link between the two given documents with the given role labels and strength. An error is raised if either of the documents involved does not exist or if the link would be invalid for some reason. This function will replace any existing link between those two documents with the new link.

Parameters:
$from : The URI of the document at the tail of the link.
$to : The URI of the document at the head of the link.
$role : A label for the relationship of the head of the link to the tail of the link, one of "source", "consumer", "container", "variant", and "related".
$rev-role : A label for the reverse relationship of the tail of the link to the head of the link.
$strength : An indicator of the strength of the relationship between the two documents, either "strong" or "weak".

Example:
  import module namespace lnk = "http://marklogic.com/cpf/links" 
		  at "/MarkLogic/cpf/links.xqy"

  lnk:create( "/myDocs/example.xhtml", "/myDocs/example.doc", 
              "source", "conversion", "strong" ) 
  

lnk:from(
$from as xs:string
)  as   element(lnk:link)*
Summary:

Find and return all the links from the given document to some other. This function will check the properties of the link and raise an error if they are inconsistent or incomplete in some way.

Parameters:
$from : The URI of the document at the tail of the link.

Example:
  import module namespace lnk = "http://marklogic.com/cpf/links" 
		  at "/MarkLogic/cpf/links.xqy"

  for $link in lnk:from( "/myDocs/example.xhtml" )
  return $link/@to
  

lnk:get(
$from as xs:string,
$to as xs:string
)  as   element(lnk:link)?
Summary:

Find and return the link between the two documents, if any. This function will check the properties of link and raise an error if they are inconsistent or incomplete in some way.

Parameters:
$from : The URI of the document at the tail of the link.
$to : The URI of the document at the head of the link.

Example:
  import module namespace lnk = "http://marklogic.com/cpf/links" 
		  at "/MarkLogic/cpf/links.xqy"

  lnk:get( "/myDocs/fr/example.xhtml", "/myDocs/example.xhtml" )
  

lnk:insert(
$link as element(lnk:link)
)  as   empty()
Summary:

Insert the given link. An error is raised if either of the documents involved does not exist or if the link is invalid in some way. This function will replace any existing link between those two documents.

Parameters:
$link : The link element.

Example:
  import module namespace lnk = "http://marklogic.com/cpf/links" 
		  at "/MarkLogic/cpf/links.xqy"

  lnk:insert( lnk:get( "/myDocs/fr/example.xhtml", "/myDocs/example.xhtml" ) )
  

lnk:remove(
$from as xs:string,
$to as xs:string
)  as   element(lnk:link)
Summary:

Remove the link between the two given documents and return the removed link. An error is raised if no such link exists.

Parameters:
$from : The URI of the document at the tail of the link.
$to : The URI of the document at the head of the link.

Example:
  import module namespace lnk = "http://marklogic.com/cpf/links" 
		  at "/MarkLogic/cpf/links.xqy"

  lnk:remove( "/myDocs/example.xhtml", "/myDocs/example.doc" )
  

lnk:to(
$to as xs:string
)  as   element(lnk:link)*
Summary:

Find and return all the links to the given document from some other. This function will check the properties of the link and raise an error if they are inconsistent or incomplete in some way.

Parameters:
$to : The URI of the document at the head of the link.

Example:
  import module namespace lnk = "http://marklogic.com/cpf/links" 
		  at "/MarkLogic/cpf/links.xqy"

  for $link in lnk:from( "/myDocs/example.xhtml" )
  return $link/@to