MarkLogic 10 Product Documentation
cts.entityWalk

cts.entityWalk(
   node as Node,
   callback as function,
   [dict as cts.entityDictionary]
) as null

Summary

Walk an XML document or element node, evaluating a callback function against any matching entities. This functions is similar to cts.entityHighlight in how it processes matched entities, but it differs in what it returns.

Parameters
node A node to walk. The node must be either an XML document node or an XML element node; it cannot be a text node.
callback A callback function that is invoked on each match. See the Usage Notes for details.
dict The entity dictionary to use for matching entities in the text of the input node. If you omit this parameter, the default entity dictionary is used. (No default dictionaries currently exist.) See the Usage Notes for details.

Usage Notes

The callback function can use variables in scope to accumulate results. The callback function returns an action string that specifies what happens next.

Your callback function must have the following signature:


function(text, node, entityType, entityId, normText, start)
      

Where the parameters have the following semantics:

text
A string containing the matched text. In the case of overlapping matches, this value may not encompass the entirety of the entity match string. Instead, it contains only the non-overlapping part of the text, to prevent introduction of duplicate text in the final result.
node
The text node containing the match.
entityType
The type of the entity, as defined in the type field of the matched cts.entity in the entity dictionary.
entityId
The ID of the entity, as defined in the id field of the matched entity in the entity dictionary.
normText
The normalized label of the entity, as defined in the normalized field of the matched entity in the entity dictionary.
start
The offset (in codepoints) of the start of text in the matched text node.

Your callback function should return one of the following values to indicate what should happen next:

Powered by MarkLogic Server | Terms of Use | Privacy Policy