Antidot PHP API  version 0.16.0
##PHP API to simplify integration of Antidot components
 All Classes Files Functions Variables Groups Pages
Public Member Functions | List of all members
AfsXmlClientDataHelper Class Reference

XML client data helper. More...

Inheritance diagram for AfsXmlClientDataHelper:
AfsClientDataHelperBase AfsClientDataHelperInterface AfsHelperBase

Public Member Functions

 __construct ($client_data)
 Construct new instance of XML helper.
 get_value ($path=null, $nsmap=array(), $callbacks=null)
 Retrieves text from XML node.
 get_values ($path=null, $nsmap=array(), $callbacks=null)
 Retrieves array of texts from XML node.
 get_node ($xpath=null, $context=array())
 Retrieves full client data node (value and attributes)
 get_nodes ($xpath=null, $nsmap=array())
 Retrieves full client data nodes (value and attributes)
 get_mime_type ()
 Retrieve client data's mime type.
- Public Member Functions inherited from AfsClientDataHelperBase
 get_id ()
 Retrieve client data id.
- Public Member Functions inherited from AfsHelperBase
 __get ($name)
 Simple property helper.

Detailed Description

XML client data helper.

Constructor & Destructor Documentation

__construct (   $client_data)

Construct new instance of XML helper.

Parameters
$client_data[in] input data used to initialize the instance.

Reimplemented from AfsClientDataHelperBase.

Member Function Documentation

get_mime_type ( )

Retrieve client data's mime type.

Returns
application/xml mime type.

Implements AfsClientDataHelperInterface.

get_node (   $xpath = null,
  $context = array() 
)

Retrieves full client data node (value and attributes)

Parameters
$xpath[in] node name to be extracted
$nsmap[in] namespace used for looking for node with specified name.
Returns
first occurrence of node as array
Exceptions
AfsNoResultException
Usage example:
Input XML client data:
*  <clientData>
*      <data1 attr='foo'>value1</data1>
*      <data2><k>v</k></data2>
*   </clientData>
* 

Call to get_node() will return

   array   (
               [clientData] => Array
                   (
                       [data1] => Array
                           (
                               [attributes] => Array
                                   (
                                       [attr] => foo
                                   )

                               [0] => value1
                           )

                       [data2] => Array
                           (
                               [data1] => value2
                           )

                   )

           )

Call to get_node('/clientData/data1') will return

   array (
       [data1] => Array
           (
               [attributes] => Array
                   (
                       [attr] => foo
                   )

               [0] => value1
           )
       )

Call to get_node('//data1/@attr') will return

   Array
       (
           [attr] => foo
       )

Implements AfsClientDataHelperInterface.

get_nodes (   $xpath = null,
  $nsmap = array() 
)

Retrieves full client data nodes (value and attributes)

Parameters
$name[in] node name to be extracted
$nsmap[in] namespace used for looking for node with specified name.
Returns
all occurrences as array
Exceptions
AfsNoResultException
Usage example:
Input XML client data:
 *  <clientData>
 *      <data1 attr='foo'>value1</data1>
 *      <data2><data1>value2</data1></data2>
 *   </clientData>
 * 

Call to get_nodes() will return

    array
(
    [0] => Array
        (
            [clientData] => Array
                (
                    [data1] => Array
                        (
                            [attributes] => Array
                                (
                                    [attr] => foo
                                )

                            [0] => value1
                        )

                    [data2] => Array
                        (
                            [data1] => value2
                        )

                )

        )

)

Call to get_nodes('//data1') will return

array (
        array (
            [data1] => Array
                (
                    [attributes] => Array
                        (
                            [attr] => foo
                        )
                    [0] => value1
                )
            )
        array (
            [data1] => value2
        )
    )

Call to get_nodes('//data1/') will return

     Array
        (
            [attr] => foo
        )

Implements AfsClientDataHelperInterface.

get_value (   $path = null,
  $nsmap = array(),
  $callbacks = null 
)

Retrieves text from XML node.

Remarks
afs prefix should never be used in provided XPath.
Parameters
$path[in] XPath to apply (default=null, retrieve all content as text). Has client data is override by the clientData node, all XPaths should begin with '/clientData/...'
$nsmap[in] prefix/uri mapping to use along with provided XPath.
$callbacks[in] list of callbacks to emphase text when highlight of client data is activated or when client data text is truncated. It should be list of FilterNode type (default=null, default instances of FilterNode are used).
Returns
text of first specific node(s) depending on parameters.
Exceptions
AfsInvalidQueryExceptionwhen provided XPath is invalid.
AfsNoResultExceptionwhen provided XPath returns no value/node.

Implements AfsClientDataHelperInterface.

get_values (   $path = null,
  $nsmap = array(),
  $callbacks = null 
)

Retrieves array of texts from XML node.

Remarks
afs prefix should never be used in provided XPath.
Parameters
$path[in] XPath to apply (default=null, retrieve all content as text).
$nsmap[in] prefix/uri mapping to use along with provided XPath.
$callbacks[in] list of callbacks to emphase text when highlight of client data is activated or when client data text is truncated. It should be list of FilterNode type (default=null, default instances of FilterNode are used).
Returns
text of first specific node(s) depending on parameters.
Exceptions
AfsInvalidQueryExceptionwhen provided XPath is invalid.
AfsNoResultExceptionwhen provided XPath returns no value/node.

Implements AfsClientDataHelperInterface.