Contact Us 1-800-596-4880

XML Module Reference - Mule 4

XML Module v1.3

The XML Module can process and extract data from an XML document. This module should be used for advanced use cases or use cases associated with XML standards such as XSLT, XPath, and XQuery or XSD. DataWeave is not only perfectly capable to handle most of those use cases and can replace those standards the majority of the times, but it’s also our recommended approach.

Release Notes: XML Module Release Notes

Configurations


Default Configuration

Default configuration

Parameters

Name Type Description Default Value Required

Name

String

The name for this configuration. Connectors reference the configuration with this name.

x

Namespaces

Array of Namespace

Allows to globally map prefixes to namespace URIs. On this version, the xpath-extract operation is the only one to consume these mappings

Expand Entities

Enumeration, one of:

  • NEVER

  • INTERNAL

  • ALL

Defines how to treat entity expansion. Setting a value different than NEVER renders the application vulnerable to XXE and/or DoS attacks

NEVER

Expiration Policy

Configures the minimum amount of time that a dynamic configuration instance can remain idle before the runtime considers it eligible for expiration. This does not mean that the platform expires the instance at the exact moment that it becomes eligible. The runtime actually purges the instances when it sees fit.

Operations

Validate Schema

<xml-module:validate-schema>

Validates that the input content is compliant with a given schema. This operation supports referencing many schemas (using comma as a separator) which include each other.

Parameters

Name Type Description Default Value Required

Configuration

String

The name of the configuration to use.

x

Schemas

String

The path to the schema file. You can specify multiple schema locations by using a comma separator

x

Schema Language

Enumeration, one of:

  • W3C

  • RELAXNG

The schema language to use.

W3C

Content

Binary

the XML content to validate

#[payload]

Expand Entities

Enumeration, one of:

  • NEVER

  • INTERNAL

  • ALL

Set to NEVER to prevent XXE and DoS attacks

For Configurations

Throws

  • XML-MODULE:INVALID_INPUT_XML

  • XML-MODULE:INVALID_SCHEMA

  • XML-MODULE:SCHEMA_NOT_FOUND

  • XML-MODULE:SCHEMA_NOT_HONOURED

  • XML-MODULE:TRANSFORMATION

XPath Extract

<xml-module:xpath-extract>

Evaluates an XPath expression the input content and returns the result. <p> Because XPath expressions can match any number of individual elements, this operation returns a List of Strings. If no element matched the expression, an empty list will be returned. <p> XPath expressions are also namespace aware, which is why this operation allows setting namespace mappings. These mappings will be merged with those optionally defined in the referenced namespace-directory, meaning that the evaluation will combine both sets of namespace mappings.

Parameters

Name Type Description Default Value Required

Configuration

String

The name of the configuration to use.

x

Content

Binary

the XML content on which the XPath is evaluated

#[payload]

Xpath

String

the XPath script

x

Context Properties

Object

Properties that will be made available to the transform context.

Namespaces

Array of Namespace

namespace mappings that will be used in this evaluation. They will be combined with the ones in the config element

Namespace Directory

the namespace directory from which take base namespace mappings

Expand Entities

Enumeration, one of:

  • NEVER

  • INTERNAL

  • ALL

Set to NEVER to prevent XXE and DoS attacks

Target Variable

String

The name of a variable on which the operation’s output will be placed

Target Value

String

An expression that will be evaluated against the operation’s output and the outcome of that expression will be stored in the target variable

#[payload]

Output

Type

Array of String

For Configurations

Throws

  • XML-MODULE:INVALID_INPUT_XML

  • XML-MODULE:INVALID_XPATH_EXPRESSION

  • XML-MODULE:NULL_CONTEXT_PROPERTY

  • XML-MODULE:TRANSFORMATION

XQuery Transform

<xml-module:xquery-transform>

Uses XQuery to transform the input content. You can set transformation context properties which will be made available on the XQuery execution

Parameters

Name Type Description Default Value Required

Configuration

String

The name of the configuration to use.

x

Content

Binary

the XML content to transform

#[payload]

Xquery

String

The XQuery script definition

x

Context Properties

Object

Properties that will be made available to the transform context.

Expand Entities

Enumeration, one of:

  • NEVER

  • INTERNAL

  • ALL

Set to NEVER to prevent XXE and DoS attacks

Target Variable

String

The name of a variable on which the operation’s output will be placed

Target Value

String

An expression that will be evaluated against the operation’s output and the outcome of that expression will be stored in the target variable

#[payload]

Output

Type

Array of String

For Configurations

Throws

  • XML-MODULE:INVALID_INPUT_XML

  • XML-MODULE:NULL_CONTEXT_PROPERTY

  • XML-MODULE:TRANSFORMATION

XSLT Transform

<xml-module:xslt-transform>

Uses XSLT to transform the input content. You can set transformation context properties which will be made available on the stylesheet.

Parameters

Name Type Description Default Value Required

Configuration

String

The name of the configuration to use.

x

Content

Binary

the XML content to transform

#[payload]

Xslt

String

the XSLT script definition

x

Context Properties

Object

Properties that will be made available to the transform context.

Expand Entities

Enumeration, one of:

  • NEVER

  • INTERNAL

  • ALL

Set to NEVER to prevent XXE and DoS attacks

Output Mime Type

String

The mime type of the payload that this operation outputs.

Target Variable

String

The name of a variable on which the operation’s output will be placed

Target Value

String

An expression that will be evaluated against the operation’s output and the outcome of that expression will be stored in the target variable

#[payload]

Output

Type

String

For Configurations

Throws

  • XML-MODULE:INVALID_INPUT_XML

  • XML-MODULE:NULL_CONTEXT_PROPERTY

  • XML-MODULE:TRANSFORMATION

Types

Namespace

Field Type Description Default Value Required

Prefix

String

The prefix used in the XML document

x

Uri

String

The namespace URI

x

Expiration Policy

Field Type Description Default Value Required

Max Idle Time

Number

A scalar time value for the maximum amount of time a dynamic configuration instance should be allowed to be idle before it’s considered eligible for expiration

Time Unit

Enumeration, one of:

  • NANOSECONDS

  • MICROSECONDS

  • MILLISECONDS

  • SECONDS

  • MINUTES

  • HOURS

  • DAYS

A time unit that qualifies the maxIdleTime attribute

Namespace Directory

Field Type Description Default Value Required

Namespaces

Array of Namespace

Globally maps prefixes to namespace uris. On this version, the xpath-extract operation is the only one to consume these mappings

View on GitHub