Access to Customer-Specific Reply Attributes - AFS

AFS Integration Guide

Product
AFS
AFS_Version
7.7
Category
Reference Guide

Most of the time, AFS replies contain customer-specific data, located in the client-data property.

  • Values to display in an AFS Widget integration can be located in these client-data. Even if the AFS output is set to JSON, they are in XML format. XPath language is used to access them simply, using this syntax:

xpath:XPathExpression

Where XPathExpression is the XPath expression.

Example of an XPath expression: xpath://url

  • The following syntax enables to access reply layer-specific client-data:

xpath@LAYER_NAME:XPathExpression

Example of layer-scoped XPath expression: xpath@USER_1://url


To use namespaces in such XPath expressions, they have to be declared in the global configuration (see XML Subobject).

For instance, to parse this XML document:

<foo:root xmlns:foo="urn:xml:foo"><foo:label>Foo bar</foo:label></foo:root>

The namespace whose prefix is foo in this document must be declared as following in the global configuration:

{
[..other configuration entries..],
"xml": {
"namespaces": [
{ "name": "foo", "uri": "urn:xml:foo" }
]
}
}

This configuration makes the /foo:root/foo:label XPath expression matches Foo bar.

Namespaces must be declared with the same prefix as they have in the XML document. In the previous example, declaring the bar namespace for the urn:xml:foo URI would not make the /bar:root/bar:label work even if it should work in the XML theory.


As for JSONPath expressions, it is necessary to know the XML structure to write the XPath expression.

See Dump expression. Notice that a clientData XML node is added by AFS Widgets and is the root of the client-data document.