register Custom XPath Function
Type: Function
How to get registerCustomXPathFunction?
JavaScript
import registerCustomXPathFunction from 'fontoxml-selectors/src/registerCustomXPathFunction.js'
Add a custom function for use in XPath expressions and XQuery scripts. This function needs to be annotated using types from the XPath/XQuery Data Model (XDM).
Please refer to Extensibility for more details on writing custom XPath functions.
Other
registerCustomXPathFunction(
{
namespaceURI: 'http://www.my-app-namespace',
localName: 'test'
},
['xs:boolean', 'xs:number*'],
'xs:string?',
function (dynamicContext, aSingleBoolean, anArrayOfNumbers) {
// We should return a string, or null
return aSingleBoolean ? anArrayOfNumbers.length + '' ? null;
});
Arguments
name
(Required)
Type: Object | String
The name of this test. This can have one of two forms: a tuple of a namespaceURI and a localname, or a prefixed name. The prefix of a name will be resolved using the namespace manager. If this can not be found, a console warning will appear.
signature
(Required)
Type: Array<String>
The signature of the test, as array of strings (e.g.
['item()', 'node()?', 'xs:numeric']
)return
Type (Required)
Type: String
The return type of the test, as sequence type (e.g. 'xs:boolean')
callback
(Required)
Type: Function
The function itself, which gets the dynamicContext and arguments passed
Arguments
Returns
Returns
Type: void