Symbian3/SDK/Source/GUID-49A7E8FD-72DA-5D56-86BE-74AA9AAF7C02.dita
author Dominic Pinkman <dominic.pinkman@nokia.com>
Tue, 20 Jul 2010 12:00:49 +0100
changeset 13 48780e181b38
parent 0 89d6a7a84779
permissions -rw-r--r--
Week 28 contribution of SDK documentation content. See release notes for details. Fixes bugs Bug 1897 and Bug 1522.

<?xml version="1.0" encoding="utf-8"?>
<!-- Copyright (c) 2007-2010 Nokia Corporation and/or its subsidiary(-ies) All rights reserved. -->
<!-- This component and the accompanying materials are made available under the terms of the License 
"Eclipse Public License v1.0" which accompanies this distribution, 
and is available at the URL "http://www.eclipse.org/legal/epl-v10.html". -->
<!-- Initial Contributors:
    Nokia Corporation - initial contribution.
Contributors: 
-->
<!DOCTYPE task
  PUBLIC "-//OASIS//DTD DITA Task//EN" "task.dtd">
<task id="GUID-49A7E8FD-72DA-5D56-86BE-74AA9AAF7C02" xml:lang="en"><title>Using
XPath Extension Function</title><shortdesc>This topic explains how to use the XPath Extension Function API
to implement XPath functions and register them with the XML DOM Engine. </shortdesc><prolog><metadata><keywords/></metadata></prolog><taskbody>
<prereq><p>Before you start, you must: </p> <ul>
<li id="GUID-6FEBC3D4-5972-52C8-AE2D-DC10960E7CB9"><p>understand <xref href="http://www.w3schools.com/XPath/xpath_syntax.asp" scope="external">XPath syntax</xref> and the concept of <xref href="http://www.w3.org/DOM/" scope="external">Document Object Model (DOM)</xref>. </p> </li>
<li id="GUID-5AB869C6-6DC3-5434-8A96-F1FBC23391EB"><p>understand the architecture
and classes of the <xref href="GUID-5ACFA8E4-3C4B-5851-A43E-9FA72D0B8403.dita">XML
DOM Engine</xref> component. </p> </li>
</ul> </prereq>
<context><p>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. </p> </context>
<steps id="GUID-78E28A2F-8B09-5B02-BF61-1C83927423FF">
<step id="GUID-D11FCC80-B452-591E-8674-245755847629"><cmd>Write a new class
that implements the <xref href="GUID-5748D958-9480-3358-A399-6B92293B86D9.dita"><apiname>MXmlEngXPathEvaluationContext</apiname></xref> interface. </cmd>
<info>This class represents the evaluation context. It processes the arguments
of the extension function and stores the result of the evaluation. <p/></info>
</step>
<step id="GUID-B6848240-EE53-5677-A75B-F0741FC60764"><cmd>Write a new class
that implements the <xref href="GUID-5748D958-9480-3358-A399-6B92293B86D9.dita"><apiname>MXPathExtensionFunction</apiname></xref> interface. </cmd>
<info>This class represents the new extension function. The <xref href="GUID-5748D958-9480-3358-A399-6B92293B86D9.dita"><apiname>MXPathExtensionFunction::Evaluate()</apiname></xref> function
uses its <xref href="GUID-5748D958-9480-3358-A399-6B92293B86D9.dita"><apiname>MXmlEngXPathEvaluationContext</apiname></xref> parameter
to process input arguments and return a result. This result can be a set of
nodes, a number, a boolean or a string.<p/> </info>
</step>
<step id="GUID-7061B984-982E-54A6-9915-D0BB73E412BC"><cmd>Create an instance
of the new extension function class. </cmd>
</step>
<step id="GUID-F5AC95C9-B770-5484-BDA3-9F3A0C806EC7"><cmd>Create a <xref href="GUID-5748D958-9480-3358-A399-6B92293B86D9.dita"><apiname>TXmlEngExtensionFunctionDescriptor</apiname></xref> structure. </cmd>
<info>This structure contains a pointer to the new extension function, the
name of the function, and the optional namespace URI. <p/></info>
</step>
<step id="GUID-A230F1A0-AEEF-594A-93C5-29349322BD73"><cmd>Register this instance
by calling the static <xref href="GUID-5748D958-9480-3358-A399-6B92293B86D9.dita"><apiname>TXmlEngXPathConfiguration::AddExtensionFunctionL()</apiname></xref> function. </cmd>
</step>
<step id="GUID-5B333061-45E5-5288-95D8-801D468AB065"><cmd>Use the new extension
function in an XPath query.</cmd>
</step>
<step id="GUID-F314293B-69F9-5A54-963C-7EBA3AA67129"><cmd>Free your resources
as necessary.</cmd>
</step>
</steps>
</taskbody><related-links>
<link href="GUID-92C2317A-57B8-558E-984B-B10FD0404981.dita"><linktext>Searching
a DOM Tree using XPath</linktext></link>
</related-links></task>