MarkLogic 10 Product Documentation
rdt:redact

rdt:redact(
   $doc as node()*,
   $rule-collection as xs:string*
) as node()*

Summary

Apply redaction rules to a set of XML and/or JSON documents, returning the resulting documents.

Parameters
doc The documents to which to apply redaction rules. Only XML and JSON documents can be redacted.
rule-collection The URIs of collections of redaction rules to apply to the input nodes. The collection(s) can contain XML rules, JSON rules, or both, but must not contain non-rule documents.

Required Privileges

This operation requires the redaction-user role or the following privilege:

http://marklogic.com/xdmp/privileges/redaction-user

Usage Notes

This function applies redaction rules to a set of input documents. If no rules match a node, the node is returned unchanged. The collections named in $rule-collections can only contain redaction rule definitions.

You should validate your rules before using them to redact content. An invalid rule will cause this function to throw an exception. Use rdt:rule-validate to validate a redaction rule collection.

Install rules in the schema database associated with your content database.

See Also

Example


(: Install a redaction rule using the built-in "redact-us-ssn" redaction 
 : function. The rule is installed in the "ssn-rules" collection. The 
 : context database for rule insertion must be the schema database. :)
xquery version "1.0-ml";
xdmp:document-insert("/redactionRules/ssn.xml", 
  <rule xml:lang="zxx" xmlns="http://marklogic.com/xdmp/redaction">
    <description>Stomp SSN</description>
    <path>//ssn</path>
    <method>
     <function>redact-us-ssn</function>
    </method>
    <options>
     <level>partial</level>
    </options>
  </rule>, xdmp:default-permissions(), "ssn-rules");

(: Redact all documents in the "people" collection, using the rules in the
 : "ssn-rules" collection. The context database is the content database. :)
xquery version "1.0-ml";
import module namespace rdt = "http://marklogic.com/xdmp/redaction"
    at "/MarkLogic/redaction.xqy";

rdt:redact(cts:search(fn:doc(), cts:collection-query("people")), "ssn-rules")
  
Powered by MarkLogic Server | Terms of Use | Privacy Policy