This topic explains how to use the XPath Extension Function API to implement XPath functions and register them with the XML DOM Engine.
XPath is a query language for exploring XML documents. You can extend it with domain-specific functions or with general utility functions, to add functionality to XPath queries.
Before you start, you must:
understand XPath syntax and the concept of Document Object Model (DOM).
understand the architecture and classes of the XML DOM Engine component.
Write a new class that implements the [[[ERROR: [NOKX000E] Unable to find definition for key reference 'XML']]]MXmlEngXPathEvaluationContext interface.
This class represents the evaluation context. It processes the arguments of the extension function and stores the result of the evaluation.Write a new class that implements the [[[ERROR: [NOKX000E] Unable to find definition for key reference 'XML']]]MXPathExtensionFunction interface.
This class represents the new extension function. The [[[ERROR: [NOKX000E] Unable to find definition for key reference 'XML']]]MXPathExtensionFunction::Evaluate() function uses its [[[ERROR: [NOKX000E] Unable to find definition for key reference 'XML']]]MXmlEngXPathEvaluationContext parameter to process input arguments and return a result. This result can be a set of nodes, a number, a boolean or a string.Create an instance of the new extension function class.
Create a [[[ERROR: [NOKX000E] Unable to find definition for key reference 'XML']]]TXmlEngExtensionFunctionDescriptor structure.
This structure contains a pointer to the new extension function, the name of the function, and the optional namespace URI.Register this instance by calling the static [[[ERROR: [NOKX000E] Unable to find definition for key reference 'XML']]]TXmlEngXPathConfiguration::AddExtensionFunctionL() function.
Use the new extension function in an XPath query.
Free your resources as necessary.