Access to AFS Standard Reply Attributes - AFS

AFS Integration Guide

Product
AFS
AFS_Version
7.9
Category
Reference Guide

AFS Widgets use JSON to interact with AFS Query Manager, because web browsers can parse JSON very quickly.

Once parsed, AFS response becomes a JavaScript object. Each reply is a subobject of the global response. AFS replies have standard attributes such as title, abstract, uri. It is easy to access to these fields using the JSONPath syntax applied to the reply subobject. JSONPath is a syntax inspired from XPath that can be applied to JavaScript / JSON objects.

To insert a JSONPath expression, proceed as described below

jpath:JSONPathExpression

JSONPathExpression is the JSONPath expression that targets the property you want to read.

For more information, JSONPath syntax is described here: JSONPath.

The following example retrieves the reply URI:

jpath:$.uri

Some reply properties, such as title and abstract, are not simple string attributes, but described in the KWIC format

For more information about KWIC format, see Wikipedia - KWIC.

This format is a list of entries that are a succession of matching and not-matching strings. These properties are often used in expressions and cannot be displayed with the jpath expression. That is why a specific expression enables to access to these properties by joining them and decorating matches with a specific CSS class. This specific syntax is the following:

kwic:$.title

This will join the different parts of the title and decorate them. This is an output example (assuming that the reply title is AFS Back Office and the search expression is Back Office):

AFS <span  class="match">Back Office</span>

To write a JSONPath expression, it is necessary to know the AFS replies structure. See Dump expression for more information.

If namespaces are used in XPath queries, they must have been declared in the XML section of the global configuration. See XML Subobject for more information.