...
In the variable definition, it is possible to specify just a "literal" value or an XPath expression
over the payload or even specify a registry key or a registry key combined with an XPath expression that selects the value of the variable. Using key
attribute of the variable, it is possible to bind an XML document located in the registry so that in the transformation that too can be used. The name of the variable corresponds to the name of variable declaration in the XQuery script. The type
of the variable must be a valid type defined by the JSR-000225 (XQJ API).
...
Table of Contents | ||||||||||||
---|---|---|---|---|---|---|---|---|---|---|---|---|
|
...
Syntax
Code Block |
---|
<xquery key="string" [target="xpath"]>
<variable name="string" type="string" [key="string"] [expression="xpath"] [value="string"]/>?
</xquery>
|
...
- Key - The key that represent the XQuery transformation. It can be chosen either from Configuration Registry or Governance Registry. See more information about the Registry Browser in Registry Browser and Namespace.
Target - Specify the node of the message that should be transformed using an XPath expression.
Info title Tip Default to the first child of the SOAP body.
Info title Tip You can follow this link to add namespaces if you are providing an expression. You will be provided another panel named "Namespace Editor," where you can provide any number of namespace prefixes and URL that you have used in the XPath expression. See Common Screens and Dialog Boxes.
- Variables for the XQuery Mediator - Defines values/expressions that could be bound to the dynamic context of the XQuery engine in order to access those variables through the XQuery script.
- Variable Type - The "type" of the variable must be a valid type defined by the JSR-000225 (XQJ API). Supported Types:
- XQItemType.XQBASETYPE_INT -> INT
- XQItemType.XQBASETYPE_INTEGER -> INTEGER
- XQItemType.XQBASETYPE_BOOLEAN -> BOOLEAN
- XQItemType.XQBASETYPE_BYTE - > BYTE
- XQItemType.XQBASETYPE_DOUBLE -> DOUBLE
- XQItemType.XQBASETYPE_SHORT -> SHORT
- XQItemType.XQBASETYPE_LONG -> LONG
- XQItemType.XQBASETYPE_FLOAT -> FLOAT
- XQItemType.XQBASETYPE_STRING -> STRING
- XQItemType.XQITEMKIND_DOCUMENT -> DOCUMENT
- XQItemType.XQITEMKIND_DOCUMENT_ELEMENT -> DOCUMENT_ELEMENT
- XQItemType.XQITEMKIND_ELEMENT -> ELEMENT
- Variable Name - The name of the variable. It should correspond to the name of variable declaration in the XQuery script.
- Value Type - Whether the value of the variable is a static value or an expression.
- Value / Expression - Static value or the expression.
- Action - Deletes the variable.
- Variable Type - The "type" of the variable must be a valid type defined by the JSR-000225 (XQJ API). Supported Types:
Info | ||
---|---|---|
| ||
You can configure the Mediator using XML. Click on "switch to source view" in the "Mediator" window. |
...
Examples
1.
Code Block |
---|
<xquery key="xquery\example.xq">
<variable name="payload" type="ELEMENT"/>
</xquery>
|
...
A variable definitions that pick a XML resource from the registry using key misc/commission.xml
and bind in to XQuery Runtime so that it can be accessed with in XQuery script.
3.
Code Block |
---|
<variable name="price" type="DOUBLE" expression="self::node()//m0:return/m0:last/child::text()" xmlns:m0="http://services.samples/xsd"/>
|
A variable that value is calculated from current message SOAP Payload using an expression. Value is a type of double in this case.
Excerpt | ||
---|---|---|
| ||
Description of the XQuery Mediator in WSO2 ESB. |