Selectors

Selectors provide a consistent way to work with information in a Kodexa Document

Working with a document in Kodexa you often want to select specific nodes on which to apply an action. This similar to how you might use an XPath to select content from an XML document.

We use a derivative of an XPath to allow you to do this directly against documents. The key here is that we do not try handle extracting specific information from a document, we use this form of path to allow you to select one or more nodes that you want to work with.

The reason for this is to ensure that you are always working with real nodes in the document.

Examples

Let's take a look at a few examples.

Path

Description

//*

All nodes in the document

.

Current node

//paragraph

Select all nodes of type paragraph

//*[hasFeature('spatial','bbox')]

Select all nodes with feature spatial:bbox

//*[hasTag('cheese')]

Select all nodes with tag cheese

//*[contentRegex('.*Hello World.*')]

Select all nodes where the content matches the regular expression '.*Hello World.*'

//page[contentRegex('.*Hello World.*', true)]

Select a page node whether the content of itself and all its children combined matches a regex

//*[content='Hello World']

Select all nodes where the content exactly matches 'Hello World'

//*[tagRegex('OR.*')]

Match all nodes where the tag name matches the regex

//*[typeRegex('column_.*')]

Match all nodes where the type of the node is limited by the type regex predicate

//*[uuid()='192-23-123-123']

Match the node with that UUID

//title | //header

Match all title type nodes and union with all header type nodes

//page intersect *[hasTag('ORG')]

Return a list of nodes that intersect the two selectors