# mulesoft XML Module - Full Documentation --- product: XML Module version: 1.3 --- # Troubleshooting XML Module > For the full documentation index, see: https://docs.mulesoft.com/llms.txt To troubleshoot XML module, become familiar with the information about enabling verbose logging and interpreting commonly thrown messages. ## Enable Verbose Logging To get a better understanding of why an application’s interaction with the XML Module is failing, temporarily enable verbose logging for XML module. Remember to always disable the enhanced verbosity after troubleshooting because it affects your Mule application performance. To enable verbose logging: 1. Access Anypoint Studio and navigate to the **Package Explorer** view. 2. Open your application’s project name. 3. Open the `src/main/resources` path folder. 4. Open the `log4j2.xml` file inside the folder. 5. Add an `` tag inside the `` tag: ```xml ... ... ``` 6. Save your application changes. 7. Click the project name in **Package Explorer** and then click **Run** > **Run As** > **Mule Application**. ## Troubleshoot Validation Against Schema Issues When using the XML module to validate against a schema that has references to other local schema files, the validation can fail with the error: ```none The supplied schemas were not valid. schema_reference: Failed to read schema document schemadocumentname.xsd, because file access is not allowed due to restriction set by the accessExternalSchema property ``` In the Studio Console, the error looks like this: ```none ERROR 2021-03-25 18:42:34,499 [[MuleRuntime].uber.03: [bug-xsd-schema-not-found-support].bug-xsd-schema-not-foundFlow.CPU_INTENSIVE @52ec9ec0] [processor: ; event: 026a10a0-8db3-11eb-80a6-3c22fb270222] org.mule.runtime.core.internal.exception.DefaultSystemExceptionStrategy: ******************************************************************************** Message : The supplied schemas were not valid. schema_reference: Failed to read schema document 'schemadocumentname.xsd', because 'file' access is not allowed due to restriction set by the accessExternalSchema property. Element : bug-xsd-schema-not-foundFlow/processors/2 @ bug-xsd-schema-not-found-support:main.xml:16 (Validate schema) Element DSL : Error type : XML-MODULE:INVALID_SCHEMA FlowStack : at bug-xsd-schema-not-foundFlow(bug-xsd-schema-not-foundFlow/processors/2 @ bug-xsd-schema-not-found-support:main.xml:16 (Validate schema)) (set debug level logging or '-Dmule.verbose.exceptions=true' for everything) ******************************************************************************** ``` This error occurs because the access was restricted in the XML module global element configuration by setting the **Expand entities** field to the default value of **NEVER**. This value prevents XXE (XML External Entity) and DoS (Denial of Service) attacks. To resolve this issue, set the **Expand entities** field to **INTERNAL**: 1. In Studio, open your project and access your Mule app flow. 2. Navigate to the **Global Element** tab. 3. Select the **XML Config** configuration and click **Edit**. 4. In the **Global Element Properties** window, set the **Expand entities** field to **INTERNAL**. 5. Click **OK**. ![XML module global configuration Expand entities field](/mulesoft/current/en-us/xml-module/1.3/_images/xml-validate-schema-4.png) In the **Configuration XML** editor, the `` configuration looks like this: ```xml ``` ## Understand Common Throws Here is a list of common throw messages and how to interpret them: - XML-MODULE:INVALID\_INPUT\_XML The input document is not a valid XML. - XML-MODULE:INVALID\_SCHEMA The supplied schema is invalid. - XML-MODULE:INVALID\_XPATH\_EXPRESSION The supplied XPath expression is invalid. - XML-MODULE:NULL\_CONTEXT\_PROPERTY A context property with a null value was supplied. - XML-MODULE:SCHEMA\_NOT\_HONOURED The input XML document does not honor its schema. - XML-MODULE:SCHEMA\_NOT\_FOUND The schema could not be found. - XML-MODULE:TRANSFORMATION There was an error transforming an XML document. ## See Also - [Salesforce Help](https://help.salesforce.com) - [XML Module Reference](https://docs.mulesoft.com/xml-module/1.3/xml-reference) --- product: XML Module version: 1.4 is-latest-version: true --- # Troubleshooting XML Module > For the full documentation index, see: https://docs.mulesoft.com/llms.txt To troubleshoot XML module, become familiar with the information about enabling verbose logging and interpreting commonly thrown messages. ## Enable Verbose Logging To get a better understanding of why an application’s interaction with the XML Module is failing, temporarily enable verbose logging for XML module. Remember to always disable the enhanced verbosity after troubleshooting because it affects your Mule application performance. To enable verbose logging: 1. Access Anypoint Studio and navigate to the **Package Explorer** view. 2. Open your application’s project name. 3. Open the `src/main/resources` path folder. 4. Open the `log4j2.xml` file inside the folder. 5. Add an `` tag inside the `` tag: ```xml ... ... ``` 6. Save your application changes. 7. Click the project name in **Package Explorer** and then click **Run** > **Run As** > **Mule Application**. ## Troubleshoot Validation Against Schema Issues When using the XML module to validate against a schema that has references to other local schema files, the validation can fail with the error: ```none The supplied schemas were not valid. schema_reference: Failed to read schema document schemadocumentname.xsd, because file access is not allowed due to restriction set by the accessExternalSchema property ``` In the Studio Console, the error looks like this: ```none ERROR 2021-03-25 18:42:34,499 [[MuleRuntime].uber.03: [bug-xsd-schema-not-found-support].bug-xsd-schema-not-foundFlow.CPU_INTENSIVE @52ec9ec0] [processor: ; event: 026a10a0-8db3-11eb-80a6-3c22fb270222] org.mule.runtime.core.internal.exception.DefaultSystemExceptionStrategy: ******************************************************************************** Message : The supplied schemas were not valid. schema_reference: Failed to read schema document 'schemadocumentname.xsd', because 'file' access is not allowed due to restriction set by the accessExternalSchema property. Element : bug-xsd-schema-not-foundFlow/processors/2 @ bug-xsd-schema-not-found-support:main.xml:16 (Validate schema) Element DSL : Error type : XML-MODULE:INVALID_SCHEMA FlowStack : at bug-xsd-schema-not-foundFlow(bug-xsd-schema-not-foundFlow/processors/2 @ bug-xsd-schema-not-found-support:main.xml:16 (Validate schema)) (set debug level logging or '-Dmule.verbose.exceptions=true' for everything) ******************************************************************************** ``` This error occurs because the access was restricted in the XML module global element configuration by setting the **Expand entities** field to the default value of **NEVER**. This value prevents XXE (XML External Entity) and DoS (Denial of Service) attacks. To resolve this issue, set the **Expand entities** field to **INTERNAL**: 1. In Studio, open your project and access your Mule app flow. 2. Navigate to the **Global Element** tab. 3. Select the **XML Config** configuration and click **Edit**. 4. In the **Global Element Properties** window, set the **Expand entities** field to **INTERNAL**. 5. Click **OK**. ![XML module global configuration Expand entities field](/mulesoft/current/en-us/xml-module/latest/_images/xml-validate-schema-4.png) In the **Configuration XML** editor, the `` configuration looks like this: ```xml ``` ## Understand Common Throws Here is a list of common throw messages and how to interpret them: - XML-MODULE:INVALID\_INPUT\_XML The input document is not a valid XML. - XML-MODULE:INVALID\_SCHEMA The supplied schema is invalid. - XML-MODULE:INVALID\_XPATH\_EXPRESSION The supplied XPath expression is invalid. - XML-MODULE:NULL\_CONTEXT\_PROPERTY A context property with a null value was supplied. - XML-MODULE:SCHEMA\_NOT\_HONOURED The input XML document does not honor its schema. - XML-MODULE:SCHEMA\_NOT\_FOUND The schema could not be found. - XML-MODULE:TRANSFORMATION There was an error transforming an XML document. - XML-MODULE:SCHEMA\_INPUT\_ERROR The Validate schema operation failed because both the Schema and the Schema Content fields were used at the same time during the operation’s execution. You can only use one of these fields to validate schema XSD content. ## See Also - [XML Module Reference](https://docs.mulesoft.com/xml-module/latest/xml-reference) - [Salesforce Help](https://help.salesforce.com) - [Known Issues](https://help.salesforce.com/s/issues) --- product: XML Module version: 1.2 --- # Using XPath with the XML Module > For the full documentation index, see: https://docs.mulesoft.com/llms.txt The `` operation supports the evaluation of XPath expressions. Because XPath expressions can match any number of individual elements, this operation returns a list of Strings. If no element matches the expression, the operation returns an empty list. XPath expressions are also namespace-aware, so this operation allows namespace mappings. These mappings are merged with any `namespaces` defined in the referenced `namespace-directory`, meaning that the evaluation combines both sets of namespace mappings. Note that though MuleSoft supports the XPath standard, DataWeave is capable of achieving the same use cases and is the recommended tool for extracting and transforming XML documents. This example shows how to work with XML that contains the script of the play Othello by William Shakespeare. The XML file looks like this: ```xml The Tragedy of Othello, the Moor of Venice

Text placed in the public domain by Moby Lexical Tools, 1992.

SGML markup by Jon Bosak, 1992-1994.

XML version by Jon Bosak, 1996-1998.

This work may be freely copied and distributed worldwide.

Dramatis Personae DUKE OF VENICE BRABANTIO, a senator. Other Senators. GRATIANO, brother to Brabantio. LODOVICO, kinsman to Brabantio. OTHELLO, a noble Moor in the service of the Venetian state. CASSIO, his lieutenant. IAGO, his ancient. RODERIGO, a Venetian gentleman. MONTANO, Othello's predecessor in the government of Cyprus. Clown, servant to Othello. DESDEMONA, daughter to Brabantio and wife to Othello. EMILIA, wife to Iago. BIANCA, mistress to Cassio. Sailor, Messenger, Herald, Officers, Gentlemen, Musicians, and Attendants. SCENE Venice: a Sea-port in Cyprus. OTHELLO ACT I SCENE I. Venice. A street. Enter RODERIGO and IAGO RODERIGO Tush! never tell me; I take it much unkindly That thou, Iago, who hast had my purse As if the strings were thine, shouldst know of this. ..... ``` Now assume that you have the text of the entire play in the format shown above. You can use this script to extract all the lines that contain the word `handkerchief`: XPath Script ```xml (1) #[{'word': 'handkerchief'}] (2) ```
1Provides an XPath expression that uses the $ prefix to reference context properties.
2Uses DataWeave in the context-properties parameter to produce the context properties.
The XPath script above outputs the following List of Strings, where each `LINE` is a different item in the list: Output ```xml For the same handkerchief? What handkerchief? What handkerchief? Have you not sometimes seen a handkerchief I know not that; but such a handkerchief-- Where should I lose that handkerchief, Emilia? Lend me thy handkerchief. That handkerchief Fetch me the handkerchief: my mind misgives. The handkerchief! The handkerchief! The handkerchief! Sure, there's some wonder in this handkerchief: But if I give my wife a handkerchief,-- But, for the handkerchief,-- Boding to all--he had my handkerchief. --Handkerchief--confessions--handkerchief!--To --Is't possible?--Confess--handkerchief!--O devil!-- mean by that same handkerchief you gave me even now? By heaven, that should be my handkerchief! And did you see the handkerchief? That handkerchief which I so loved and gave thee By heaven, I saw my handkerchief in's hand. I saw the handkerchief. It was a handkerchief, an antique token O thou dull Moor! that handkerchief thou speak'st of How came you, Cassio, by that handkerchief ``` By default, the operation attempts to transform an XML document at the message payload level. However, you can use the `content` parameter to supply the input document: ```xml #[vars.othello] #[{'word': 'handkerchief'}] ``` The example above gets the content from elsewhere (in this case, from a file in the filesystem) and then references it using a simple expression. ## Mapping Namespaces There are cases in which the input XML document contains elements with different namespaces, for example: ```xml Hello! ``` The following example maps each `prefix` used in the XPath expressions to the corresponding namespace `uri`. ```xml ``` But what happens if you need to execute several XPath expressions that use the same namespaces? To avoid performing the mapping each time, you can create a `namespace-directory` for the mappings and then reference that directory, for example: ```xml (1) (2)(3) ```
1The namespace-directory element is used to map prefixes to the actual namespace URIs. Notice these prefixes should match those used in the input document.
2You can then reference those prefixes in your XPath expression.
3Finally, use the namespaceDirectory parameter to reference the mapping created in step 1.
Finally, you can combine use cases. For example, you can have a global `namespaceDirectory` that contains some mappings and then add additional ones at the operation level. This combination is useful if you have a lot of documents that all contain the `soap` namespace but only one of them contains the `mule` namespace: ```xml (1) (2) (3) (4) ```
1As you did previously, declare a namespace-directory, but supply only the common namespaces.
2Provide your XPath expression.
3Reference the partial namespace directory.
4Provide the additional mapping.
It is important to note that the prefixes used in the mappings and XPath expressions must match the ones used in the input document. ## Using XPath as a Function The XML module provides a DataWeave function for extracting values using XPath. This is useful in cases such as a `` or `` routers. Note that you can also use this function inside any DataWeave transformation. ## Using the XPath Function with In the following example, `` is used to iterate over all the lines in the previous [Othello lines](#othello_lines) example, and process them separately: ```xml ``` - The first argument is the XPath expression. - The second argument is the input document, which, in this case, is the message payload. - The third argument is the context properties, which, in this case, are not required, so the function passes an empty object (`{}`). ## Using XPath Function with Returning to the [Othello lines](#othello_lines) example, suppose you want to do something if the input document does not contain the word `handkerchief`. ```xml ``` - Since the `XmlModule::xpath` function returns a list, the previous example uses the DataWeave `isEmpty()` function to test whether or not the output is empty. - The first argument of the XPath function is an expression that uses the `$word` context property. - The second argument is the input document within a variable. - The third argument provides the context properties values. ## See Also [XML Module Overview](https://docs.mulesoft.com/xml-module/1.2/) --- product: XML Module version: 1.3 --- # Using XPath with the XML Module > For the full documentation index, see: https://docs.mulesoft.com/llms.txt The `` operation supports the evaluation of XPath expressions. Because XPath expressions can match any number of individual elements, this operation returns a list of Strings. If no element matches the expression, the operation returns an empty list. XPath expressions are also namespace-aware, so this operation allows namespace mappings. These mappings are merged with any `namespaces` defined in the referenced `namespace-directory`, meaning that the evaluation combines both sets of namespace mappings. Although MuleSoft supports the XPath standard, DataWeave is capable of achieving the same use cases and is the recommended tool for extracting and transforming XML documents. This example shows how to work with XML that contains the script of the play Othello by William Shakespeare. The XML file looks like this: ```xml The Tragedy of Othello, the Moor of Venice

Text placed in the public domain by Moby Lexical Tools, 1992.

SGML markup by Jon Bosak, 1992-1994.

XML version by Jon Bosak, 1996-1998.

This work may be freely copied and distributed worldwide.

Dramatis Personae DUKE OF VENICE BRABANTIO, a senator. Other Senators. GRATIANO, brother to Brabantio. LODOVICO, kinsman to Brabantio. OTHELLO, a noble Moor in the service of the Venetian state. CASSIO, his lieutenant. IAGO, his ancient. RODERIGO, a Venetian gentleman. MONTANO, Othello's predecessor in the government of Cyprus. Clown, servant to Othello. DESDEMONA, daughter to Brabantio and wife to Othello. EMILIA, wife to Iago. BIANCA, mistress to Cassio. Sailor, Messenger, Herald, Officers, Gentlemen, Musicians, and Attendants. SCENE Venice: a Sea-port in Cyprus. OTHELLO ACT I SCENE I. Venice. A street. Enter RODERIGO and IAGO RODERIGO Tush! never tell me; I take it much unkindly That thou, Iago, who hast had my purse As if the strings were thine, shouldst know of this. ..... ``` Assumethat you have the text of the entire play in the format shown above. You can use this script to extract all lines that contain the word `handkerchief`: XPath Script ```xml (1) #[{'word': 'handkerchief'}] (2) ```
1Provides an XPath expression that uses the $ prefix to reference context properties.
2Uses DataWeave in the context-properties parameter to produce the context properties.
The XPath script above outputs the following List of Strings, where each `LINE` is a different item in the list: Output ```xml For the same handkerchief? What handkerchief? What handkerchief? Have you not sometimes seen a handkerchief I know not that; but such a handkerchief-- Where should I lose that handkerchief, Emilia? Lend me thy handkerchief. That handkerchief Fetch me the handkerchief: my mind misgives. The handkerchief! The handkerchief! The handkerchief! Sure, there's some wonder in this handkerchief: But if I give my wife a handkerchief,-- But, for the handkerchief,-- Boding to all--he had my handkerchief. --Handkerchief--confessions--handkerchief!--To --Is't possible?--Confess--handkerchief!--O devil!-- mean by that same handkerchief you gave me even now? By heaven, that should be my handkerchief! And did you see the handkerchief? That handkerchief which I so loved and gave thee By heaven, I saw my handkerchief in's hand. I saw the handkerchief. It was a handkerchief, an antique token O thou dull Moor! that handkerchief thou speak'st of How came you, Cassio, by that handkerchief ``` By default, the operation attempts to transform an XML document at the message payload level. However, you can use the `content` parameter to supply the input document: ```xml #[vars.othello] #[{'word': 'handkerchief'}] ``` The example above gets the content from elsewhere (in this case, from a file in the filesystem) and then references it using a simple expression. ## Mapping Namespaces There are cases in which the input XML document contains elements with different namespaces, for example: ```xml Hello! ``` The following example maps each `prefix` used in the XPath expressions to the corresponding namespace `uri`. ```xml ``` But what happens if you need to execute several XPath expressions that use the same namespaces? To avoid performing the mapping each time, you can create a `namespace-directory` for the mappings and then reference that directory, for example: ```xml (1) (2)(3) ```
1The namespace-directory element is used to map prefixes to the actual namespace URIs. Notice these prefixes should match those used in the input document.
2You can then reference those prefixes in your XPath expression.
3Finally, use the namespaceDirectory parameter to reference the mapping created in step 1.
Finally, you can combine use cases. For example, you can have a global `namespaceDirectory` that contains some mappings and then add additional ones at the operation level. This combination is useful if you have a lot of documents that all contain the `soap` namespace but only one of them contains the `mule` namespace: ```xml (1) (2) (3) (4) ```
1As you did previously, declare a namespace-directory, but supply only the common namespaces.
2Provide your XPath expression.
3Reference the partial namespace directory.
4Provide the additional mapping.
It is important to note that the prefixes used in the mappings and XPath expressions must match the ones used in the input document. ## Using XPath as a Function The XML module provides a DataWeave function for extracting values using XPath. This is useful in cases such as a `` or `` routers. Note that you can also use this function inside any DataWeave transformation. ## Using the XPath Function with In the following example, `` is used to iterate over all the lines in the previous [Othello lines](#othello_lines) example, and process them separately: ```xml ``` - The first argument is the XPath expression. - The second argument is the input document, which, in this case, is the message payload. - The third argument is the context properties, which, in this case, are not required, so the function passes an empty object (`{}`). - The fourth argument is **optional** and provides the namespaces to evaluate the expression xpath. ## Using XPath Function with Returning to the [Othello lines](#othello_lines) example, suppose you want to do something if the input document does not contain the word `handkerchief`. ```xml ``` - Since the `XmlModule::xpath` function returns a list, the previous example uses the DataWeave `isEmpty()` function to test whether or not the output is empty. - The first argument of the XPath function is an expression that uses the `$word` context property. - The second argument is the input document within a variable. - The third argument provides the context properties values. - The fourth argument is **optional** and provides the namespaces to evaluate the expression xpath. ## Using XPath Function with Namespaces When the input document has XML namespaces, the XPath function needs that information to perform the evaluation. In the following examples, you use the `set-payload` component to get the book’s title, author’s name and book’s year tag from an input document. The document has an explicit default `xmlns` attribute and other `xmlns` attributes for languages and author: ```xml Fundamentals 2001 David Mills English ``` In the first example, in order to get the book’s title, configure the `set-payload` component as follows: ```xml ``` The result output is `Fundamentals`. In the second example, to get the author’s name, configure the `set-payload` component as follows: ```xml ``` The result output is `David Mills`. In the third example, to get the book’s year tag, configure the `set-payload` component as follows: ```xml ``` The result output that contains the `xmlns` attribute is `2001`. ## See Also [XML Module Overview](https://docs.mulesoft.com/xml-module/1.3/) --- product: XML Module version: 1.4 is-latest-version: true --- # Using XPath with the XML Module > For the full documentation index, see: https://docs.mulesoft.com/llms.txt The `` operation supports the evaluation of XPath expressions. Because XPath expressions can match any number of individual elements, this operation returns a list of Strings. If no element matches the expression, the operation returns an empty list. XPath expressions are also namespace-aware, so this operation allows namespace mappings. These mappings are merged with any `namespaces` defined in the referenced `namespace-directory`, meaning that the evaluation combines both sets of namespace mappings. Although MuleSoft supports the XPath standard, DataWeave is capable of achieving the same use cases and is the recommended tool for extracting and transforming XML documents. This example shows how to work with XML that contains the script of the play Othello by William Shakespeare. The XML file looks like this: ```xml The Tragedy of Othello, the Moor of Venice

Text placed in the public domain by Moby Lexical Tools, 1992.

SGML markup by Jon Bosak, 1992-1994.

XML version by Jon Bosak, 1996-1998.

This work may be freely copied and distributed worldwide.

Dramatis Personae DUKE OF VENICE BRABANTIO, a senator. Other Senators. GRATIANO, brother to Brabantio. LODOVICO, kinsman to Brabantio. OTHELLO, a noble Moor in the service of the Venetian state. CASSIO, his lieutenant. IAGO, his ancient. RODERIGO, a Venetian gentleman. MONTANO, Othello's predecessor in the government of Cyprus. Clown, servant to Othello. DESDEMONA, daughter to Brabantio and wife to Othello. EMILIA, wife to Iago. BIANCA, mistress to Cassio. Sailor, Messenger, Herald, Officers, Gentlemen, Musicians, and Attendants. SCENE Venice: a Sea-port in Cyprus. OTHELLO ACT I SCENE I. Venice. A street. Enter RODERIGO and IAGO RODERIGO Tush! never tell me; I take it much unkindly That thou, Iago, who hast had my purse As if the strings were thine, shouldst know of this. ..... ``` Assumethat you have the text of the entire play in the format shown above. You can use this script to extract all lines that contain the word `handkerchief`: XPath Script ```xml (1) #[{'word': 'handkerchief'}] (2) ```
1Provides an XPath expression that uses the $ prefix to reference context properties.
2Uses DataWeave in the context-properties parameter to produce the context properties.
The XPath script above outputs the following List of Strings, where each `LINE` is a different item in the list: Output ```xml For the same handkerchief? What handkerchief? What handkerchief? Have you not sometimes seen a handkerchief I know not that; but such a handkerchief-- Where should I lose that handkerchief, Emilia? Lend me thy handkerchief. That handkerchief Fetch me the handkerchief: my mind misgives. The handkerchief! The handkerchief! The handkerchief! Sure, there's some wonder in this handkerchief: But if I give my wife a handkerchief,-- But, for the handkerchief,-- Boding to all--he had my handkerchief. --Handkerchief--confessions--handkerchief!--To --Is't possible?--Confess--handkerchief!--O devil!-- mean by that same handkerchief you gave me even now? By heaven, that should be my handkerchief! And did you see the handkerchief? That handkerchief which I so loved and gave thee By heaven, I saw my handkerchief in's hand. I saw the handkerchief. It was a handkerchief, an antique token O thou dull Moor! that handkerchief thou speak'st of How came you, Cassio, by that handkerchief ``` By default, the operation attempts to transform an XML document at the message payload level. However, you can use the `content` parameter to supply the input document: ```xml #[vars.othello] #[{'word': 'handkerchief'}] ``` The example above gets the content from elsewhere (in this case, from a file in the filesystem) and then references it using a simple expression. ## Mapping Namespaces There are cases in which the input XML document contains elements with different namespaces, for example: ```xml Hello! ``` The following example maps each `prefix` used in the XPath expressions to the corresponding namespace `uri`. ```xml ``` But what happens if you need to execute several XPath expressions that use the same namespaces? To avoid performing the mapping each time, you can create a `namespace-directory` for the mappings and then reference that directory, for example: ```xml (1) (2)(3) ```
1The namespace-directory element is used to map prefixes to the actual namespace URIs. Notice these prefixes should match those used in the input document.
2You can then reference those prefixes in your XPath expression.
3Finally, use the namespaceDirectory parameter to reference the mapping created in step 1.
Finally, you can combine use cases. For example, you can have a global `namespaceDirectory` that contains some mappings and then add additional ones at the operation level. This combination is useful if you have a lot of documents that all contain the `soap` namespace but only one of them contains the `mule` namespace: ```xml (1) (2) (3) (4) ```
1As you did previously, declare a namespace-directory, but supply only the common namespaces.
2Provide your XPath expression.
3Reference the partial namespace directory.
4Provide the additional mapping.
It is important to note that the prefixes used in the mappings and XPath expressions must match the ones used in the input document. ## Using XPath as a Function The XML module provides a DataWeave function for extracting values using XPath. This is useful in cases such as a `` or `` routers. Note that you can also use this function inside any DataWeave transformation. ## Using the XPath Function with In the following example, `` is used to iterate over all the lines in the previous [Othello lines](#othello_lines) example, and process them separately: ```xml ``` - The first argument is the XPath expression. - The second argument is the input document, which, in this case, is the message payload. - The third argument is the context properties, which, in this case, are not required, so the function passes an empty object (`{}`). - The fourth argument is **optional** and provides the namespaces to evaluate the expression xpath. ## Using XPath Function with Returning to the [Othello lines](#othello_lines) example, suppose you want to do something if the input document does not contain the word `handkerchief`. ```xml ``` - Since the `XmlModule::xpath` function returns a list, the previous example uses the DataWeave `isEmpty()` function to test whether or not the output is empty. - The first argument of the XPath function is an expression that uses the `$word` context property. - The second argument is the input document within a variable. - The third argument provides the context properties values. - The fourth argument is **optional** and provides the namespaces to evaluate the expression xpath. ## Using XPath Function with Namespaces When the input document has XML namespaces, the XPath function needs that information to perform the evaluation. In the following examples, you use the `set-payload` component to get the book’s title, author’s name and book’s year tag from an input document. The document has an explicit default `xmlns` attribute and other `xmlns` attributes for languages and author: ```xml Fundamentals 2001 David Mills English ``` In the first example, in order to get the book’s title, configure the `set-payload` component as follows: ```xml ``` The result output is `Fundamentals`. In the second example, to get the author’s name, configure the `set-payload` component as follows: ```xml ``` The result output is `David Mills`. In the third example, to get the book’s year tag, configure the `set-payload` component as follows: ```xml ``` The result output that contains the `xmlns` attribute is `2001`. ## See Also [XML Module Overview](https://docs.mulesoft.com/xml-module/latest/) --- product: XML Module version: 1.2 --- # Using XQuery with the XML Module > For the full documentation index, see: https://docs.mulesoft.com/llms.txt The `` operation supports the evaluation of XQuery expressions. Because XQuery expressions can match any number of individual elements, this operation returns a List of Strings. If no element matches the expression, the operation returns an empty list. Note that though MuleSoft supports the XQuery standard, DataWeave is capable of achieving the same use cases and is the recommended tool for extracting and transforming XML documents. This example shows how to use XQuery to manipulate a list of books: Input: Book List ```xml Pride and Prejudice Jane Austen Modern Library 2002-12-31 English 9 187 0679601686 352 8.3 5.7 1.1 6.1 Wuthering Heights Charlotte Bronte Penguin Classics 2002-12-31 English 9.040000000000001 113 0141439556 430 1.0 5.2 7.8 11.2 Tess of the d'Urbervilles Thomas Hardy Bantam Classics 1984-05-01 English 12.5 85 0553211684 480 6.8 4.2 0.8 7.7 Jude the Obscure Thomas Hardy Penguin Classics 1998-09-01 English 7 129 0140435387 528 7.8 5.2 0.9 10.9 The Big Over Easy Jasper Fforde Hodder & Stoughton 2005-07-11 English 14.55 129 0340835672 346 22.5 18.0 3.5 390 The Eyre Affair Jasper Fforde Penguin 2003-02-25 English 15 129 0142001805 384 7.8 5.0 0.9 9.0 ``` This example uses XQuery to transform the book list above: XQuery Transformation Script ```xml { $b/AUTHOR } { $b/TITLE } ]]> ``` The XQuery transformation produces a List of Strings in which each entry corresponds to each of the following `` elements: Output XML ```xml Jasper Fforde <TITLE>The Eyre Affair Thomas Hardy <TITLE>Jude the Obscure Charlotte Bronte <TITLE>Wuthering Heights Jasper Fforde <TITLE>The Big Over Easy Jane Austen <TITLE>Pride and Prejudice Thomas Hardy <TITLE>Tess of the d'Urbervilles ``` By default, the operation attempts to transform an XML document at the message payload level. However, you can use the `content` parameter to supply the input document: Example: Using the content Parameter ```xml #[vars.books] { $b/AUTHOR } { $b/TITLE } ]]> ``` The example above gets the content from elsewhere (in this case, from a file in the filesystem) and then references it through a simple expression. ## Externalizing the XQuery Script to a Separate File To avoid embedding the XQuery script in your Mule app, you can pass it to the module through a file, for example: Example ```xml ${file::scripts/books.xquery} ``` In a more complex use case, the script you use might depend on some external condition. For example, imagine a multi-tenant integration in which the actual transformation to use depends on a `userID`: Complex Example ```xml (1) (2) #[vars.xquery] ``` 1. This flow is triggered through an HTTP request. 2. Assuming that the `userID` is provided as a query parameter, the example uses the File connector read the correct XQuery script and store it in a variable. 3. The module executes a transformation using an expression that points to the XQuery script retrieved through the Read operation. Note that the HTTP and File connectors are simply used as examples. They are not required to perform similar use cases. ## Using Context Properties and Multiple Inputs Like its `xpath` and `xslt` counterparts, the `xquery` operation supports context parameters that can pass arguments to the transformation. For example, assume that you want to combine the `books` XML above with the following `cities` XML document: Input ```xml ``` Let’s look at an example for this use case: XQuery Transformation Script ```xml (1) { for $b in fn:doc($books)/BOOKLIST/BOOKS/ITEM, $c in fn:doc($cities)/cities/city (4) return (5) } ]]> #[{'books' : vars.books, 'cities': vars.cities}] (6) ```
1Read the input documents, and store the contents in variables. This example uses the File connector, but any data source is acceptable.
2Declare the $cities variable in the XQuery script.
3Declare the $books variable in the XQuery script.
4Reference both documents using the $ prefix, and iterate both of them.
5Produce the output elements.
6Use DataWeave and the <xml-module:context-properties> parameter to bind the properties.
The script will output a List of Strings with only one item: Output ```xml ``` ## See Also [XML Module Overview](https://docs.mulesoft.com/xml-module/1.2/) --- product: XML Module version: 1.3 --- # Using XQuery with the XML Module > For the full documentation index, see: https://docs.mulesoft.com/llms.txt The `` operation supports the evaluation of XQuery expressions. Because XQuery expressions can match any number of individual elements, this operation returns a List of Strings. If no element matches the expression, the operation returns an empty list. Note that though MuleSoft supports the XQuery standard, DataWeave is capable of achieving the same use cases and is the recommended tool for extracting and transforming XML documents. This example shows how to use XQuery to manipulate a list of books: Input: Book List ```xml Pride and Prejudice Jane Austen Modern Library 2002-12-31 English 9 187 0679601686 352 8.3 5.7 1.1 6.1 Wuthering Heights Charlotte Bronte Penguin Classics 2002-12-31 English 9.040000000000001 113 0141439556 430 1.0 5.2 7.8 11.2 Tess of the d'Urbervilles Thomas Hardy Bantam Classics 1984-05-01 English 12.5 85 0553211684 480 6.8 4.2 0.8 7.7 Jude the Obscure Thomas Hardy Penguin Classics 1998-09-01 English 7 129 0140435387 528 7.8 5.2 0.9 10.9 The Big Over Easy Jasper Fforde Hodder & Stoughton 2005-07-11 English 14.55 129 0340835672 346 22.5 18.0 3.5 390 The Eyre Affair Jasper Fforde Penguin 2003-02-25 English 15 129 0142001805 384 7.8 5.0 0.9 9.0 ``` This example uses XQuery to transform the book list above: XQuery Transformation Script ```xml { $b/AUTHOR } { $b/TITLE } ]]> ``` The XQuery transformation produces a List of Strings in which each entry corresponds to each of the following `` elements: Output XML ```xml Jasper Fforde <TITLE>The Eyre Affair Thomas Hardy <TITLE>Jude the Obscure Charlotte Bronte <TITLE>Wuthering Heights Jasper Fforde <TITLE>The Big Over Easy Jane Austen <TITLE>Pride and Prejudice Thomas Hardy <TITLE>Tess of the d'Urbervilles ``` By default, the operation attempts to transform an XML document at the message payload level. However, you can use the `content` parameter to supply the input document: Example: Using the content Parameter ```xml #[vars.books] { $b/AUTHOR } { $b/TITLE } ]]> ``` The example above gets the content from elsewhere (in this case, from a file in the filesystem) and then references it through a simple expression. ## Externalizing the XQuery Script to a Separate File To avoid embedding the XQuery script in your Mule app, you can pass it to the module through a file, for example: Example ```xml ${file::scripts/books.xquery} ``` In a more complex use case, the script you use might depend on some external condition. For example, imagine a multi-tenant integration in which the actual transformation to use depends on a `userID`: Complex Example ```xml (1) (2) #[vars.xquery] ``` 1. This flow is triggered through an HTTP request. 2. Assuming that the `userID` is provided as a query parameter, the example uses the File connector read the correct XQuery script and store it in a variable. 3. The module executes a transformation using an expression that points to the XQuery script retrieved through the Read operation. Note that the HTTP and File connectors are simply used as examples. They are not required to perform similar use cases. ## Using Context Properties and Multiple Inputs Like its `xpath` and `xslt` counterparts, the `xquery` operation supports context parameters that can pass arguments to the transformation. For example, assume that you want to combine the `books` XML above with the following `cities` XML document: Input ```xml ``` Let’s look at an example for this use case: XQuery Transformation Script ```xml (1) { for $b in fn:doc($books)/BOOKLIST/BOOKS/ITEM, $c in fn:doc($cities)/cities/city (4) return (5) } ]]> #[{'books' : vars.books, 'cities': vars.cities}] (6) ```
1Read the input documents, and store the contents in variables. This example uses the File connector, but any data source is acceptable.
2Declare the $cities variable in the XQuery script.
3Declare the $books variable in the XQuery script.
4Reference both documents using the $ prefix, and iterate both of them.
5Produce the output elements.
6Use DataWeave and the <xml-module:context-properties> parameter to bind the properties.
The script will output a List of Strings with only one item: Output ```xml ``` ## See Also [XML Module Overview](https://docs.mulesoft.com/xml-module/1.3/) --- product: XML Module version: 1.4 is-latest-version: true --- # Using XQuery with the XML Module > For the full documentation index, see: https://docs.mulesoft.com/llms.txt The `` operation supports the evaluation of XQuery expressions. Because XQuery expressions can match any number of individual elements, this operation returns a List of Strings. If no element matches the expression, the operation returns an empty list. Note that though MuleSoft supports the XQuery standard, DataWeave is capable of achieving the same use cases and is the recommended tool for extracting and transforming XML documents. This example shows how to use XQuery to manipulate a list of books: Input: Book List ```xml Pride and Prejudice Jane Austen Modern Library 2002-12-31 English 9 187 0679601686 352 8.3 5.7 1.1 6.1 Wuthering Heights Charlotte Bronte Penguin Classics 2002-12-31 English 9.040000000000001 113 0141439556 430 1.0 5.2 7.8 11.2 Tess of the d'Urbervilles Thomas Hardy Bantam Classics 1984-05-01 English 12.5 85 0553211684 480 6.8 4.2 0.8 7.7 Jude the Obscure Thomas Hardy Penguin Classics 1998-09-01 English 7 129 0140435387 528 7.8 5.2 0.9 10.9 The Big Over Easy Jasper Fforde Hodder & Stoughton 2005-07-11 English 14.55 129 0340835672 346 22.5 18.0 3.5 390 The Eyre Affair Jasper Fforde Penguin 2003-02-25 English 15 129 0142001805 384 7.8 5.0 0.9 9.0 ``` This example uses XQuery to transform the book list above: XQuery Transformation Script ```xml { $b/AUTHOR } { $b/TITLE } ]]> ``` The XQuery transformation produces a List of Strings in which each entry corresponds to each of the following `` elements: Output XML ```xml Jasper Fforde <TITLE>The Eyre Affair Thomas Hardy <TITLE>Jude the Obscure Charlotte Bronte <TITLE>Wuthering Heights Jasper Fforde <TITLE>The Big Over Easy Jane Austen <TITLE>Pride and Prejudice Thomas Hardy <TITLE>Tess of the d'Urbervilles ``` By default, the operation attempts to transform an XML document at the message payload level. However, you can use the `content` parameter to supply the input document: Example: Using the content Parameter ```xml #[vars.books] { $b/AUTHOR } { $b/TITLE } ]]> ``` The example above gets the content from elsewhere (in this case, from a file in the filesystem) and then references it through a simple expression. ## Externalizing the XQuery Script to a Separate File To avoid embedding the XQuery script in your Mule app, you can pass it to the module through a file, for example: Example ```xml ${file::scripts/books.xquery} ``` In a more complex use case, the script you use might depend on some external condition. For example, imagine a multi-tenant integration in which the actual transformation to use depends on a `userID`: Complex Example ```xml (1) (2) #[vars.xquery] ``` 1. This flow is triggered through an HTTP request. 2. Assuming that the `userID` is provided as a query parameter, the example uses the File connector read the correct XQuery script and store it in a variable. 3. The module executes a transformation using an expression that points to the XQuery script retrieved through the Read operation. Note that the HTTP and File connectors are simply used as examples. They are not required to perform similar use cases. ## Using Context Properties and Multiple Inputs Like its `xpath` and `xslt` counterparts, the `xquery` operation supports context parameters that can pass arguments to the transformation. For example, assume that you want to combine the `books` XML above with the following `cities` XML document: Input ```xml ``` Let’s look at an example for this use case: XQuery Transformation Script ```xml (1) { for $b in fn:doc($books)/BOOKLIST/BOOKS/ITEM, $c in fn:doc($cities)/cities/city (4) return (5) } ]]> #[{'books' : vars.books, 'cities': vars.cities}] (6) ```
1Read the input documents, and store the contents in variables. This example uses the File connector, but any data source is acceptable.
2Declare the $cities variable in the XQuery script.
3Declare the $books variable in the XQuery script.
4Reference both documents using the $ prefix, and iterate both of them.
5Produce the output elements.
6Use DataWeave and the <xml-module:context-properties> parameter to bind the properties.
The script will output a List of Strings with only one item: Output ```xml ``` ## See Also [XML Module Overview](https://docs.mulesoft.com/xml-module/latest/) --- product: XML Module version: 1.3 --- # Validate Documents Against an XSD Schema with the XML Module > For the full documentation index, see: https://docs.mulesoft.com/llms.txt The XML module **Validate schema** operation validates that the input content is compliant with a given XSD schema. The operation supports referencing many schemas, using a comma (`,`) as a separator. By default, this operation looks for the input document at the message payload level, but you can supply your own input as well. Note that you can use the **Validate schema** operation inside the Validation module **All** scope. ## Configure the Validation Schema Operation in Studio In the following example, you validate XML schemas that contain a script: 1. In Studio, drag the **Validate schema** operation to your flow. In the **Schemas** field, add your schema files, separating filenames by using a comma, for example, `schema1.xsd, schema2.xsd`. 2. Drag a **Flow Reference** component to the right of the **Validate schema** operation. 3. Set **Flow name** to `processValidDocument`. ![In the Schemas field](/mulesoft/current/en-us/xml-module/1.3/_images/xml-validate-schema-1.png) In the **Configuration XML** editor, the `` configuration looks like this: ```xml ``` In the following example, you configure the **Validate schema** operation by supplying your own input: 1. In Studio, drag the File **Read** operation to your flow. 2. In the configuration screen, set **File Path** to `document.xml`. 3. In the **Advanced** tab, set **Target Variable** to `xmlDoc`. 4. Drag the XML module **Validate schema** operation to the right of the **Read** operation. 5. In the **Schemas** field, add your schemas and separate their names by using commas, for example, `schema1.xsd, schema2.xsd`. 6. Set the **Content** field to the XML content to validate, for example, `#[vars.xmlDoc]`. 7. Drag a **Flow Reference** component to the right of the **Validate schema** operation. 8. Set **Flow name** to `processValidDocument`. ![In the Content field](/mulesoft/current/en-us/xml-module/1.3/_images/xml-validate-schema-2.png) In the **Configuration XML** editor, the `` and `` configurations look like this: ```xml #[vars.xmlDoc] ``` ## Manage the Validation Error If the validation is successful, the flow continues to the next operation. However, if the validation fails, an `XML-MODULE:SCHEMA_NOT_HONOURED` error is raised. Because the validation can fail for more than one reason, the error description contains a list of messages. Each message contains a `SchemaViolation` object that has the following structure: ```yaml { lineNumber: Number, columnNumber: Number, description: String } ``` In the following example, you configure the **Validate schema** operation and the `XML-MODULE:SCHEMA_NOT_HONOURED` error in the Error Handler component: 1. In Studio, drag the **Try** scope component to your flow. 2. Drag the XML module **Validate schema** operation into the **Try** scope component. 3. In the **Schemas** field, add your schema, for example, `schema.xsd`. 4. In your flow, click the **Error handling** arrow to expand the error-handling section. 5. Drag the **On Error Propagate** component into the **Error handling** section. 6. Set the **Type** field to the Mule error handled by this on-error strategy, for example, `XML-MODULE:SCHEMA_NOT_HONOURED`. 7. Deselect **Enable Notifications** and **Log Exception** fields. 8. Drag a **For Each** scope component into the **On Error Propagate** component to iterate over each `errorMessage.payload`. 9. Set the **Collection** field to the expression that splits the payload into individual pieces, for example, `#[error.errorMessage.payload]`. 10. Drag a **Logger** component into the **For Each** scope component to log the XML module error. 11. Set the **Message** field to the expression that contains the `SchemaViolation` objects that describe the message, for example, `#['At line: $(payload.lineNumber), column: $(payload.columnNumber) → $(payload.description)']`. 12. Save your changes. 13. Click the project name in **Package Explorer** and then click **Run > Run As > Mule Application**. 14. Navigate to the Console view to read the logger message: ```none ERROR 2018-02-16 14:35:45,722 [[MuleRuntime].cpuIntensive.01: [SchemaValidationTestCase#extractErrorsUsingExpressions].extractErrorsFromException.CPU_INTENSIVE @411e886b] org.mule.runtime.core.internal.processor.LoggerMessageProcessor: At line: -1, column: -1 -> cvc-complex-type.2.4.a: Invalid content was found starting with element 'fail'. One of '{used}' is expected. ``` ![The XML module manage validation error flow](/mulesoft/current/en-us/xml-module/1.3/_images/xml-validate-schema-3.png) In the **Configuration XML** editor, the `` configuration looks like this: ```xml ``` ## See Also - [XML Module Examples](https://docs.mulesoft.com/xml-module/1.3/xml-module-examples) - [XML Module Overview](https://docs.mulesoft.com/xml-module/1.3/) --- product: XML Module version: 1.4 is-latest-version: true --- # Validate Documents Against an XSD Schema with the XML Module > For the full documentation index, see: https://docs.mulesoft.com/llms.txt The XML module **Validate schema** operation validates that the input content is compliant with a given XSD schema. The operation supports referencing many schemas, using a comma (`,`) as a separator. By default, this operation looks for the input document at the message payload level, but you can supply your own input as well. Note that you can use the **Validate schema** operation inside the Validation module **All** scope. ## Configure the Validation Schema Operation in Studio In the following example, you validate XML schemas that contain a script: 1. In Studio, drag the **Validate schema** operation to your flow. In the **Schemas** field, add your schema files, separating filenames by using a comma, for example, `schema1.xsd, schema2.xsd`. 2. Drag a **Flow Reference** component to the right of the **Validate schema** operation. 3. Set **Flow name** to `processValidDocument`. ![In the Schemas field](/mulesoft/current/en-us/xml-module/latest/_images/xml-validate-schema-1.png) In the **Configuration XML** editor, the `` configuration looks like this: ```xml ``` In the following example, you configure the **Validate schema** operation by supplying your own input: 1. In Studio, drag the File **Read** operation to your flow. 2. In the configuration screen, set **File Path** to `document.xml`. 3. In the **Advanced** tab, set **Target Variable** to `xmlDoc`. 4. Drag the XML module **Validate schema** operation to the right of the **Read** operation. 5. In the **Schemas** field, add your schemas and separate their names by using commas, for example, `schema1.xsd, schema2.xsd`. 6. Set the **Content** field to the XML content to validate, for example, `#[vars.xmlDoc]`. 7. Drag a **Flow Reference** component to the right of the **Validate schema** operation. 8. Set **Flow name** to `processValidDocument`. ![In the Content field](/mulesoft/current/en-us/xml-module/latest/_images/xml-validate-schema-2.png) In the **Configuration XML** editor, the `` and `` configurations look like this: ```xml #[vars.xmlDoc] ``` ## Manage the Validation Error If the validation is successful, the flow continues to the next operation. However, if the validation fails, an `XML-MODULE:SCHEMA_NOT_HONOURED` error is raised. Because the validation can fail for more than one reason, the error description contains a list of messages. Each message contains a `SchemaViolation` object that has the following structure: ```yaml { lineNumber: Number, columnNumber: Number, description: String } ``` In the following example, you configure the **Validate schema** operation and the `XML-MODULE:SCHEMA_NOT_HONOURED` error in the Error Handler component: 1. In Studio, drag the **Try** scope component to your flow. 2. Drag the XML module **Validate schema** operation into the **Try** scope component. 3. In the **Schemas** field, add your schema, for example, `schema.xsd`. 4. In your flow, click the **Error handling** arrow to expand the error-handling section. 5. Drag the **On Error Propagate** component into the **Error handling** section. 6. Set the **Type** field to the Mule error handled by this on-error strategy, for example, `XML-MODULE:SCHEMA_NOT_HONOURED`. 7. Deselect **Enable Notifications** and **Log Exception** fields. 8. Drag a **For Each** scope component into the **On Error Propagate** component to iterate over each `errorMessage.payload`. 9. Set the **Collection** field to the expression that splits the payload into individual pieces, for example, `#[error.errorMessage.payload]`. 10. Drag a **Logger** component into the **For Each** scope component to log the XML module error. 11. Set the **Message** field to the expression that contains the `SchemaViolation` objects that describe the message, for example, `#['At line: $(payload.lineNumber), column: $(payload.columnNumber) → $(payload.description)']`. 12. Save your changes. 13. Click the project name in **Package Explorer** and then click **Run > Run As > Mule Application**. 14. Navigate to the Console view to read the logger message: ```none ERROR 2018-02-16 14:35:45,722 [[MuleRuntime].cpuIntensive.01: [SchemaValidationTestCase#extractErrorsUsingExpressions].extractErrorsFromException.CPU_INTENSIVE @411e886b] org.mule.runtime.core.internal.processor.LoggerMessageProcessor: At line: -1, column: -1 -> cvc-complex-type.2.4.a: Invalid content was found starting with element 'fail'. One of '{used}' is expected. ``` ![The XML module manage validation error flow](/mulesoft/current/en-us/xml-module/latest/_images/xml-validate-schema-3.png) In the **Configuration XML** editor, the `` configuration looks like this: ```xml ``` ## Configure Schema Text Content In the following example, you configure the **Schema contents** field of the **Validate schema** operation. Enter the schema text into this field to perform a schema validation. > [!NOTE] To add your schema content, you only provide either schema or schema content, but not > both. You can either upload your file in the **Schemas** field, or manually add the direct schema > text content in the **Schema contents** field. 1. In Studio, select the **Validate schema** operation from your flow. 2. In the **Validate schema** operation configuration screen, set **Schema contents** to **Edit inline**. ![Schema content field set to Edit inline in the Validate schema configuration screen](/mulesoft/current/en-us/xml-module/latest/_images/xml-schema-content-1.png) 3. Click the plus sign to add a schema name and text. 4. In the **Schema content** window’s **Schema name** field, enter a schema name, for example, `schema1.xsd`. 5. In the **Schema text** field, enter the schema text content, for example: ```xml ``` ![Schema content window with the Schema name and Schema text fields](/mulesoft/current/en-us/xml-module/latest/_images/xml-schema-content-2.png) 6. Click **Finish**. ## See Also - [XML Module Examples](https://docs.mulesoft.com/xml-module/latest/xml-module-examples) - [XML Module Overview](https://docs.mulesoft.com/xml-module/latest/) --- product: XML Module version: 1.2 --- # Validating Documents against an XSD Schema with the XML Module > For the full documentation index, see: https://docs.mulesoft.com/llms.txt The `` operation validates that the input content is compliant with a given schema. This operation supports referencing many schemas (using comma as a separator) that include each other. This example shows how to work with XML that contains the script of the play Othello by William Shakespeare. The XML file looks something like this: ```xml ``` By default, this operation looks for the input document at the message payload level. However, you can supply your own input, for example: ```xml #[vars.xmlDoc] ``` Note that you can use the `` component inside a `` element. ## Handling the Validation Error If the validation is successful, nothing happens, and the flow continues to the next operation. If it fails, an `XML-MODULE:SCHEMA_NOT_HONOURED` error is raised. The `XML-MODULE:SCHEMA_NOT_HONOURED` error is a complex one. Because the validation can fail for any number of reasons, the error contains a list of Messages. Each message contains a `SchemaViolation` object, which has the following structure: SchemaViolation Object ```yaml { lineNumber: Number, columnNumber: Number, description: String } ``` Consider the following example: ```xml (1) (2) (3) ``` ```none ERROR 2018-02-16 14:35:45,722 [[MuleRuntime].cpuIntensive.01: [SchemaValidationTestCase#extractErrorsUsingExpressions].extractErrorsFromException.CPU_INTENSIVE @411e886b] org.mule.runtime.core.internal.processor.LoggerMessageProcessor: At line: -1, column: -1 -> cvc-complex-type.2.4.a: Invalid content was found starting with element 'fail'. One of '{used}' is expected. ``` ## See Also [XML Module Overview](https://docs.mulesoft.com/xml-module/1.2/) --- product: XML Module version: 1.2 --- # XML Module > For the full documentation index, see: https://docs.mulesoft.com/llms.txt XML Module v1.2 The XML Module can process and extract data from an XML document. Although DataWeave is recommended for most XML-related use cases, the XML module should be used for cases that involve the use of XML standards such as XSLT, XPath and XQuery, or XSD. To use the XML module, you can add it to your Mule app through the Studio UI, or you can add the following dependency in your `pom.xml` file: ```xml org.mule.modules mule-xml-module x.x.x mule-plugin ``` Mule runtime engine (Mule) converts RELEASE to the latest version. Release Notes: [XML Module Release Notes](https://docs.mulesoft.com/release-notes/mule-runtime/module-xml) Exchange: [XML Module](https://www.mulesoft.com/exchange/org.mule.modules/mule-xml-module/) ## Validate Against a Schema When using the XML Module to validate against a schema that has references to other local schema files, validation can fail because the access was restricted by the `expandEntities` as it was using the default value of NEVER. The error message is: The supplied schemas were not valid. schema\_reference: Failed to read schema document `NMVS_Composite_Types.xsd`, because `file` access is not allowed due to restriction set by the accessExternalSchema property. You can eliminate this issue by adding `expandEntities="INTERNAL"` to the `xml-module:config` element. ## See Also - [Using XPath with the XML Module](https://docs.mulesoft.com/xml-module/1.2/xml-xpath) - [XSLT Transformations with the XML Module](https://docs.mulesoft.com/xml-module/1.2/xml-xslt) - [Validating Documents against an XSD Schema with the XML Module](https://docs.mulesoft.com/xml-module/1.2/xml-schema-validation) - [Using XQuery with the XML Module](https://docs.mulesoft.com/xml-module/1.2/xml-xquery) - [XML Module Documentation Reference](https://docs.mulesoft.com/xml-module/1.2/xml-reference) - [Salesforce Help](https://help.salesforce.com) --- product: XML Module version: 1.3 --- # XML Module 1.3 > For the full documentation index, see: https://docs.mulesoft.com/llms.txt The XML Module process and extracts data from an XML document. Although DataWeave is recommended for most XML-related cases, use the XML Module for cases that involve the usage of XML standards such as XSLT, XPath, and XQuery, or XSD. For compatibility information and fixed issues, see the XML Module Release Notes. ## Before You Begin To use this connector, you must be familiar with: - Anypoint Connectors - Mule runtime engine (Mule) - Elements and global elements in a Mule flow - Creating a Mule app using Anypoint Studio or Anypoint Code Builder Before creating an app, you must have access to Anypoint Platform and Anypoint Studio. ## Common Use Cases for the Connector Common use cases for XML Module include the following: - Validate documents against an XSD schema - Take XML input and transform it using an XSL style sheet - Evaluate Xpath expressions in XML input content and extract the result - Take XML input content and transform it based on XQuery expressions ## See Also - [Introduction to Anypoint Connectors](https://docs.mulesoft.com/connectors/introduction/introduction-to-anypoint-connectors) - [Use Exchange to Discover Connectors, Templates, and Examples](https://docs.mulesoft.com/connectors/introduction/intro-use-exchange) - [Salesforce Help](https://help.salesforce.com) --- product: XML Module version: 1.4 is-latest-version: true --- # XML Module 1.3 > For the full documentation index, see: https://docs.mulesoft.com/llms.txt The XML Module process and extracts data from an XML document. Although DataWeave is recommended for most XML-related cases, use the XML Module for cases that involve the usage of XML standards such as XSLT, XPath, and XQuery, or XSD. For compatibility information and fixed issues, see the XML Module Release Notes. ## Before You Begin To use this connector, you must be familiar with: - Anypoint Connectors - Mule runtime engine (Mule) - Elements and global elements in a Mule flow - Creating a Mule app using Anypoint Studio or Anypoint Code Builder Before creating an app, you must have access to Anypoint Platform and Anypoint Studio. ## Common Use Cases for the Connector Common use cases for XML Module include the following: - Validate documents against an XSD schema - Take XML input and transform it using an XSL style sheet - Evaluate Xpath expressions in XML input content and extract the result - Take XML input content and transform it based on XQuery expressions ## See Also - [Introduction to Anypoint Connectors](https://docs.mulesoft.com/connectors/introduction/introduction-to-anypoint-connectors) - [Use Exchange to Discover Connectors, Templates, and Examples](https://docs.mulesoft.com/connectors/introduction/intro-use-exchange) - [Salesforce Help](https://help.salesforce.com) --- product: XML Module version: 1.2 --- # XML Module Examples > For the full documentation index, see: https://docs.mulesoft.com/llms.txt To fully benefit from using XML module, see the following examples of configuring the module operations: - [Configure XQuery Transformations](https://docs.mulesoft.com/xml-module/1.2/xml-xquery) Configure the **Xquery transform** operation to take XML input content and transform it based on XQuery expressions. - [Configure XPath Extractions](https://docs.mulesoft.com/xml-module/1.2/xml-xpath) Configure the **Xpath extract** operation to evaluate Xpath expressions in XML input content and extract the result. The operation also enables you to set namespace mapping. - [Configure Xslt Transformations](https://docs.mulesoft.com/xml-module/1.2/xml-xslt) Configure the **Xslt transform** operation to take XML input and transform it using an XSL style sheet. - [Validate Documents against an XSD Schema](https://docs.mulesoft.com/xml-module/1.2/xml-xslt) Configure the **Validate schema** operation to validate documents against an XSD schema. ## See Also - [Introduction to Anypoint Connectors](https://docs.mulesoft.com/connectors/introduction/introduction-to-anypoint-connectors) - [Salesforce Help](https://help.salesforce.com) --- product: XML Module version: 1.3 --- # XML Module Examples > For the full documentation index, see: https://docs.mulesoft.com/llms.txt To fully benefit from using XML module, see the following examples of configuring the module operations: - [Configure XQuery Transformations](https://docs.mulesoft.com/xml-module/1.3/xml-xquery) Configure the **Xquery transform** operation to take XML input content and transform it based on XQuery expressions. - [Configure XPath Extractions](https://docs.mulesoft.com/xml-module/1.3/xml-xpath) Configure the **Xpath extract** operation to evaluate Xpath expressions in XML input content and extract the result. The operation also enables you to set namespace mapping. - [Configure Xslt Transformations](https://docs.mulesoft.com/xml-module/1.3/xml-xslt) Configure the **Xslt transform** operation to take XML input and transform it using an XSL style sheet. - [Validate Documents against an XSD Schema](https://docs.mulesoft.com/xml-module/1.3/xml-xslt) Configure the **Validate schema** operation to validate documents against an XSD schema. ## See Also - [Introduction to Anypoint Connectors](https://docs.mulesoft.com/connectors/introduction/introduction-to-anypoint-connectors) - [Salesforce Help](https://help.salesforce.com) --- product: XML Module version: 1.4 is-latest-version: true --- # XML Module Examples > For the full documentation index, see: https://docs.mulesoft.com/llms.txt To fully benefit from using XML module, see the following examples of configuring the module operations: - [Configure XQuery Transformations](https://docs.mulesoft.com/xml-module/latest/xml-xquery) Configure the **Xquery transform** operation to take XML input content and transform it based on XQuery expressions. - [Configure XPath Extractions](https://docs.mulesoft.com/xml-module/latest/xml-xpath) Configure the **Xpath extract** operation to evaluate Xpath expressions in XML input content and extract the result. The operation also enables you to set namespace mapping. - [Configure Xslt Transformations](https://docs.mulesoft.com/xml-module/latest/xml-xslt) Configure the **Xslt transform** operation to take XML input and transform it using an XSL style sheet. - [Validate Documents against an XSD Schema](https://docs.mulesoft.com/xml-module/latest/xml-xslt) Configure the **Validate schema** operation to validate documents against an XSD schema. ## See Also - [Introduction to Anypoint Connectors](https://docs.mulesoft.com/connectors/introduction/introduction-to-anypoint-connectors) - [Salesforce Help](https://help.salesforce.com) --- product: XML Module version: 1.2 --- # XML Module Reference > For the full documentation index, see: https://docs.mulesoft.com/llms.txt XML Module v1.2 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](https://docs.mulesoft.com/release-notes/mule-runtime/module-xml) ## Configurations --- ### Default Configuration Default configuration #### Parameters
NameTypeDescriptionDefault ValueRequired

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](#validateSchema) - [XPath Extract](#xpathExtract) - [XQuery Transform](#xqueryTransform) - [XSLT Transform](#xsltTransform) ### 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
NameTypeDescriptionDefault ValueRequired

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 [Default Configuration](#config) #### 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 `` Evaluates an XPath expression the input content and returns the result.

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.

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
NameTypeDescriptionDefault ValueRequired

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 [Default Configuration](#config) #### Throws - XML-MODULE:INVALID\_INPUT\_XML - XML-MODULE:INVALID\_XPATH\_EXPRESSION - XML-MODULE:NULL\_CONTEXT\_PROPERTY - XML-MODULE:TRANSFORMATION ### 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
NameTypeDescriptionDefault ValueRequired

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 [Default Configuration](#config) #### Throws - XML-MODULE:INVALID\_INPUT\_XML - XML-MODULE:NULL\_CONTEXT\_PROPERTY - XML-MODULE:TRANSFORMATION ### XSLT Transform `` Uses XSLT to transform the input content. You can set transformation context properties which will be made available on the stylesheet. #### Parameters
NameTypeDescriptionDefault ValueRequired

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 [Default Configuration](#config) #### Throws - XML-MODULE:INVALID\_INPUT\_XML - XML-MODULE:NULL\_CONTEXT\_PROPERTY - XML-MODULE:TRANSFORMATION ## Types ### Namespace
FieldTypeDescriptionDefault ValueRequired

Prefix

String

The prefix used in the XML document

x

Uri

String

The namespace URI

x

### Expiration Policy
FieldTypeDescriptionDefault ValueRequired

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
FieldTypeDescriptionDefault ValueRequired

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

## See Also [Salesforce Help](https://help.salesforce.com) --- product: XML Module version: 1.3 --- # XML Module Reference > For the full documentation index, see: https://docs.mulesoft.com/llms.txt 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](https://docs.mulesoft.com/release-notes/mule-runtime/module-xml) ## Configurations --- ### Default Configuration Default configuration #### Parameters
NameTypeDescriptionDefault ValueRequired

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](#validateSchema) - [XPath Extract](#xpathExtract) - [XQuery Transform](#xqueryTransform) - [XSLT Transform](#xsltTransform) ### 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
NameTypeDescriptionDefault ValueRequired

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 [Default Configuration](#config) #### 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 `` Evaluates an XPath expression the input content and returns the result.

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.

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
NameTypeDescriptionDefault ValueRequired

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 [Default Configuration](#config) #### Throws - XML-MODULE:INVALID\_INPUT\_XML - XML-MODULE:INVALID\_XPATH\_EXPRESSION - XML-MODULE:NULL\_CONTEXT\_PROPERTY - XML-MODULE:TRANSFORMATION ### 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
NameTypeDescriptionDefault ValueRequired

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 [Default Configuration](#config) #### Throws - XML-MODULE:INVALID\_INPUT\_XML - XML-MODULE:NULL\_CONTEXT\_PROPERTY - XML-MODULE:TRANSFORMATION ### XSLT Transform `` Uses XSLT to transform the input content. You can set transformation context properties which will be made available on the stylesheet. #### Parameters
NameTypeDescriptionDefault ValueRequired

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 [Default Configuration](#config) #### Throws - XML-MODULE:INVALID\_INPUT\_XML - XML-MODULE:NULL\_CONTEXT\_PROPERTY - XML-MODULE:TRANSFORMATION ## Types ### Namespace
FieldTypeDescriptionDefault ValueRequired

Prefix

String

The prefix used in the XML document

x

Uri

String

The namespace URI

x

### Expiration Policy
FieldTypeDescriptionDefault ValueRequired

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
FieldTypeDescriptionDefault ValueRequired

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

## See Also [Salesforce Help](https://help.salesforce.com) --- product: XML Module version: 1.4 is-latest-version: true --- # XML Module Reference > For the full documentation index, see: https://docs.mulesoft.com/llms.txt XML Module v1.4 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](https://docs.mulesoft.com/release-notes/mule-runtime/module-xml) ## Configurations --- ### Default Configuration Default configuration #### Parameters
NameTypeDescriptionDefault ValueRequired

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](#validateSchema) - [XPath Extract](#xpathExtract) - [XQuery Transform](#xqueryTransform) - [XSLT Transform](#xsltTransform) ### 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. > [!NOTE] To add your schema content, you only provide either schema or schema content, but not > both. You can either upload your file in the **Schemas** field, or manually add the direct schema > text content in the **Schema contents** field. #### Parameters
NameTypeDescriptionDefault ValueRequired

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 Contents

Schema text content for performing a schema validation.

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 [Default Configuration](#config) #### Throws - XML-MODULE:INVALID\_INPUT\_XML - XML-MODULE:INVALID\_SCHEMA - XML-MODULE:SCHEMA\_NOT\_FOUND - XML-MODULE:SCHEMA\_NOT\_HONOURED - XML-MODULE:TRANSFORMATION - XML-MODULE:SCHEMA\_INPUT\_ERROR ### XPath Extract `` Evaluates an XPath expression the input content and returns the result.

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.

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
NameTypeDescriptionDefault ValueRequired

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 [Default Configuration](#config) #### Throws - XML-MODULE:INVALID\_INPUT\_XML - XML-MODULE:INVALID\_XPATH\_EXPRESSION - XML-MODULE:NULL\_CONTEXT\_PROPERTY - XML-MODULE:TRANSFORMATION ### 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
NameTypeDescriptionDefault ValueRequired

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 [Default Configuration](#config) #### Throws - XML-MODULE:INVALID\_INPUT\_XML - XML-MODULE:NULL\_CONTEXT\_PROPERTY - XML-MODULE:TRANSFORMATION ### XSLT Transform `` Uses XSLT to transform the input content. You can set transformation context properties which will be made available on the stylesheet. #### Parameters
NameTypeDescriptionDefault ValueRequired

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 [Default Configuration](#config) #### Throws - XML-MODULE:INVALID\_INPUT\_XML - XML-MODULE:NULL\_CONTEXT\_PROPERTY - XML-MODULE:TRANSFORMATION ## Types ### Namespace
FieldTypeDescriptionDefault ValueRequired

Prefix

String

The prefix used in the XML document

x

Uri

String

The namespace URI

x

### Expiration Policy
FieldTypeDescriptionDefault ValueRequired

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

### Schema Content
FieldTypeDescriptionDefault ValueRequired

Schema Name

String

Schema name content to define.

x

Schema Text

String

Schema text content to define.

x

### Namespace Directory
FieldTypeDescriptionDefault ValueRequired

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

## See Also [Salesforce Help](https://help.salesforce.com) --- product: XML Module version: 1.2 --- # XML Module XML and Maven Support > For the full documentation index, see: https://docs.mulesoft.com/llms.txt Although you can manually code a Mule app in XML, it is more efficient to use Anypoint Studio. If you manually code a Mule runtime engine (Mule) app in XML, either from the Anypoint Studio XML editor or from a text editor, you can get access to the connector in your app by adding reference statements to both your XML Mule flow and the Apache Maven `pom.xml` file. When you add the connector in Studio, Studio automatically populates the XML code with the connector’s namespace and schema location. It also adds a dependency to the `pom.xml` file. ## Add a Namespace for the Connector Paste the following code inside the `` tag of the header of your configuration XML: ```xml http://www.mulesoft.org/schema/mule/xml-module http://www.mulesoft.org/schema/mule/xml-module/current/mule-xml-module.xsd ``` This example shows how the namespace statements are placed in the `` XML block: ```xml ="http://www.mulesoft.org/schema/mule/xml-module" xmlns:ee="http://www.mulesoft.org/schema/mule/ee/core" xmlns:http="http://www.mulesoft.org/schema/mule/http" xmlns:file="http://www.mulesoft.org/schema/mule/file" xmlns="http://www.mulesoft.org/schema/mule/core" xmlns:doc="http://www.mulesoft.org/schema/mule/documentation" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:schemaLocation="http://www.mulesoft.org/schema/mule/core http://www.mulesoft.org/schema/mule/core/current/mule.xsd http://www.mulesoft.org/schema/mule/file http://www.mulesoft.org/schema/mule/file/current/mule-file.xsd http://www.mulesoft.org/schema/mule/http http://www.mulesoft.org/schema/mule/http/current/mule-http.xsd http://www.mulesoft.org/schema/mule/ee/core http://www.mulesoft.org/schema/mule/ee/core/current/mule-ee.xsd http://www.mulesoft.org/schema/mule/xml-module http://www.mulesoft.org/schema/mule/xml-module/current/mule-xml-module.xsd"> ``` ## Add a POM File Dependency The Apache Maven `pom.xml` file generated by Anypoint Studio contains dependencies for a Mule app. If you code a Mule app manually, include this XML snippet in your `pom.xml` file to enable access to this connector: ```xml org.mule.modules mule-xml-module x.x.x mule-plugin ``` Replace `x.x.x` with the version that corresponds to the connector you are using. To obtain the most up-to-date `pom.xml` file information: 1. Go to [Anypoint Exchange](https://www.mulesoft.com/exchange/). 2. In Exchange, click **Login** and supply your Anypoint Platform username and password. 3. In Exchange, search for `xml module`. 4. Select the connector. 5. Click **Dependency Snippets** near the upper right of the screen. ## See Also - [Introduction to Anypoint Connectors](https://docs.mulesoft.com/connectors/introduction/introduction-to-anypoint-connectors) - [Salesforce Help](https://help.salesforce.com) --- product: XML Module version: 1.3 --- # XML Module XML and Maven Support > For the full documentation index, see: https://docs.mulesoft.com/llms.txt Although you can manually code a Mule app in XML, it is more efficient to use Anypoint Studio. If you manually code a Mule runtime engine (Mule) app in XML, either from the Anypoint Studio XML editor or from a text editor, you can get access to the connector in your app by adding reference statements to both your XML Mule flow and the Apache Maven `pom.xml` file. When you add the connector in Studio, Studio automatically populates the XML code with the connector’s namespace and schema location. It also adds a dependency to the `pom.xml` file. ## Add a Namespace for the Connector Paste the following code inside the `` tag of the header of your configuration XML: ```xml http://www.mulesoft.org/schema/mule/xml-module http://www.mulesoft.org/schema/mule/xml-module/current/mule-xml-module.xsd ``` This example shows how the namespace statements are placed in the `` XML block: ```xml ="http://www.mulesoft.org/schema/mule/xml-module" xmlns:ee="http://www.mulesoft.org/schema/mule/ee/core" xmlns:http="http://www.mulesoft.org/schema/mule/http" xmlns:file="http://www.mulesoft.org/schema/mule/file" xmlns="http://www.mulesoft.org/schema/mule/core" xmlns:doc="http://www.mulesoft.org/schema/mule/documentation" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:schemaLocation="http://www.mulesoft.org/schema/mule/core http://www.mulesoft.org/schema/mule/core/current/mule.xsd http://www.mulesoft.org/schema/mule/file http://www.mulesoft.org/schema/mule/file/current/mule-file.xsd http://www.mulesoft.org/schema/mule/http http://www.mulesoft.org/schema/mule/http/current/mule-http.xsd http://www.mulesoft.org/schema/mule/ee/core http://www.mulesoft.org/schema/mule/ee/core/current/mule-ee.xsd http://www.mulesoft.org/schema/mule/xml-module http://www.mulesoft.org/schema/mule/xml-module/current/mule-xml-module.xsd"> ``` ## Add a POM File Dependency The Apache Maven `pom.xml` file generated by Anypoint Studio contains dependencies for a Mule app. If you code a Mule app manually, include this XML snippet in your `pom.xml` file to enable access to this connector: ```xml org.mule.modules mule-xml-module x.x.x mule-plugin ``` Replace `x.x.x` with the version that corresponds to the connector you are using. To obtain the most up-to-date `pom.xml` file information: 1. Go to [Anypoint Exchange](https://www.mulesoft.com/exchange/). 2. In Exchange, click **Login** and supply your Anypoint Platform username and password. 3. In Exchange, search for `xml module`. 4. Select the connector. 5. Click **Dependency Snippets** near the upper right of the screen. ## See Also - [Introduction to Anypoint Connectors](https://docs.mulesoft.com/connectors/introduction/introduction-to-anypoint-connectors) - [Salesforce Help](https://help.salesforce.com) --- product: XML Module version: 1.4 is-latest-version: true --- # XML Module XML and Maven Support > For the full documentation index, see: https://docs.mulesoft.com/llms.txt Although you can manually code a Mule app in XML, it is more efficient to use Anypoint Studio. If you manually code a Mule runtime engine (Mule) app in XML, either from the Anypoint Studio XML editor or from a text editor, you can get access to the connector in your app by adding reference statements to both your XML Mule flow and the Apache Maven `pom.xml` file. When you add the connector in Studio, Studio automatically populates the XML code with the connector’s namespace and schema location. It also adds a dependency to the `pom.xml` file. ## Add a Namespace for the Connector Paste the following code inside the `` tag of the header of your configuration XML: ```xml http://www.mulesoft.org/schema/mule/xml-module http://www.mulesoft.org/schema/mule/xml-module/current/mule-xml-module.xsd ``` This example shows how the namespace statements are placed in the `` XML block: ```xml ="http://www.mulesoft.org/schema/mule/xml-module" xmlns:ee="http://www.mulesoft.org/schema/mule/ee/core" xmlns:http="http://www.mulesoft.org/schema/mule/http" xmlns:file="http://www.mulesoft.org/schema/mule/file" xmlns="http://www.mulesoft.org/schema/mule/core" xmlns:doc="http://www.mulesoft.org/schema/mule/documentation" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:schemaLocation="http://www.mulesoft.org/schema/mule/core http://www.mulesoft.org/schema/mule/core/current/mule.xsd http://www.mulesoft.org/schema/mule/file http://www.mulesoft.org/schema/mule/file/current/mule-file.xsd http://www.mulesoft.org/schema/mule/http http://www.mulesoft.org/schema/mule/http/current/mule-http.xsd http://www.mulesoft.org/schema/mule/ee/core http://www.mulesoft.org/schema/mule/ee/core/current/mule-ee.xsd http://www.mulesoft.org/schema/mule/xml-module http://www.mulesoft.org/schema/mule/xml-module/current/mule-xml-module.xsd"> ``` ## Add a POM File Dependency The Apache Maven `pom.xml` file generated by Anypoint Studio contains dependencies for a Mule app. If you code a Mule app manually, include this XML snippet in your `pom.xml` file to enable access to this connector: ```xml org.mule.modules mule-xml-module x.x.x mule-plugin ``` Replace `x.x.x` with the version that corresponds to the connector you are using. To obtain the most up-to-date `pom.xml` file information: 1. Go to [Anypoint Exchange](https://www.mulesoft.com/exchange/). 2. In Exchange, click **Login** and supply your Anypoint Platform username and password. 3. In Exchange, search for `xml module`. 4. Select the connector. 5. Click **Dependency Snippets** near the upper right of the screen. ## See Also - [Introduction to Anypoint Connectors](https://docs.mulesoft.com/connectors/introduction/introduction-to-anypoint-connectors) - [Salesforce Help](https://help.salesforce.com) --- product: XML Module version: 1.2 --- # XSLT Transformations with the XML Module > For the full documentation index, see: https://docs.mulesoft.com/llms.txt The `` element can take an input XML document and transform it using an XSL style sheet. Although MuleSoft supports the XSLT standard, DataWeave is the recommended tool for extracting and transforming XML documents. This is an example XML input document: ```xml ``` You can transform the XML input document like this: ```xml
Country City List Population
]]>
``` This script outputs the following document: ```xml
Country City List Population
italy milan, venice 6
france paris, lyon 9
germany munich 4
``` Although this operation looks for the input document at the message payload level by default, you can supply your own input. For example, imagine that the cities are a JSON array inside the payload. You could then first transform the JSON to XML, and then run the XSL transformation: ```xml ``` ## Externalizing the XSL Style Sheet to a Separate File To avoid embedding the XSLT script in your Mule app, you can pass it to the module through a file, for example: ```xml ${file::xslt/cities.xslt} ``` In a more complex use case, the script you use might depend on some external condition. For example, imagine a multi-tenant integration in which the transformation to use depends on a `userId`: ```xml // 1 #[vars.xslt] ``` 1. The example flow is triggered through an HTTP request. 2. The example is based on the `userId` value being provided as a query parameter and the File Connector being used to read the file that contains the correct XSL and store it in a variable. 3. The example then executes a transformation using an expression to point to the XSL sheet obtained through the `Read` operation. The HTTP and File Connectors are used as examples and are not required to perform similar use cases. ## Using Context Properties The XML module, like the XSL language, provides context properties that can pass parameters to the transformation. In this example, the `` element contains a DataWeave expression that constructs an arguments map. ```xml (1) (2) ]]> #[{'vtn' : 'some value'}] (3) ``` 1. The XSL style sheet declares a `param` called `vtn`. 2. The style sheet references the assigned value of the `param` using the `$` prefix. 3. The example uses the `context-properties` parameter to pass in the values. ## Output MIME Type The most common use case for XSLT is to output a new XML document. However, XSLT can produce documents in other formats, such as JSON, CSV, or a text or number value, which means that the produced value does not have any specific MIME type assigned. You should specify a MIME type using the `outputMimeType` parameter. ## See Also [XML Module Overview](https://docs.mulesoft.com/xml-module/1.2/) --- product: XML Module version: 1.3 --- # XSLT Transformations with the XML Module > For the full documentation index, see: https://docs.mulesoft.com/llms.txt The `` element can take an input XML document and transform it using an XSL style sheet. Although MuleSoft supports the XSLT standard, DataWeave is the recommended tool for extracting and transforming XML documents. This is an example XML input document: ```xml ``` You can transform the XML input document like this: ```xml
Country City List Population
]]>
``` This script outputs the following document: ```xml
Country City List Population
italy milan, venice 6
france paris, lyon 9
germany munich 4
``` Although this operation looks for the input document at the message payload level by default, you can supply your own input. For example, imagine that the cities are a JSON array inside the payload. You could then first transform the JSON to XML, and then run the XSL transformation: ```xml ``` ## Externalizing the XSL Style Sheet to a Separate File To avoid embedding the XSLT script in your Mule app, you can pass it to the module through a file, for example: ```xml ${file::xslt/cities.xslt} ``` In a more complex use case, the script you use might depend on some external condition. For example, imagine a multi-tenant integration in which the transformation to use depends on a `userId`: ```xml // 1 #[vars.xslt] ``` 1. The example flow is triggered through an HTTP request. 2. The example is based on the `userId` value being provided as a query parameter and the File Connector being used to read the file that contains the correct XSL and store it in a variable. 3. The example then executes a transformation using an expression to point to the XSL sheet obtained through the `Read` operation. The HTTP and File Connectors are used as examples and are not required to perform similar use cases. ## Using Context Properties The XML module, like the XSL language, provides context properties that can pass parameters to the transformation. In this example, the `` element contains a DataWeave expression that constructs an arguments map. ```xml (1) (2) ]]> #[{'vtn' : 'some value'}] (3) ``` 1. The XSL style sheet declares a `param` called `vtn`. 2. The style sheet references the assigned value of the `param` using the `$` prefix. 3. The example uses the `context-properties` parameter to pass in the values. ## Output MIME Type The most common use case for XSLT is to output a new XML document. However, XSLT can produce documents in other formats, such as JSON, CSV, or a text or number value, which means that the produced value does not have any specific MIME type assigned. You should specify a MIME type using the `outputMimeType` parameter. ## See Also [XML Module Overview](https://docs.mulesoft.com/xml-module/1.3/) --- product: XML Module version: 1.4 is-latest-version: true --- # XSLT Transformations with the XML Module > For the full documentation index, see: https://docs.mulesoft.com/llms.txt The `` element can take an input XML document and transform it using an XSL style sheet. Although MuleSoft supports the XSLT standard, DataWeave is the recommended tool for extracting and transforming XML documents. This is an example XML input document: ```xml ``` You can transform the XML input document like this: ```xml
Country City List Population
]]>
``` This script outputs the following document: ```xml
Country City List Population
italy milan, venice 6
france paris, lyon 9
germany munich 4
``` Although this operation looks for the input document at the message payload level by default, you can supply your own input. For example, imagine that the cities are a JSON array inside the payload. You could then first transform the JSON to XML, and then run the XSL transformation: ```xml ``` ## Externalizing the XSL Style Sheet to a Separate File To avoid embedding the XSLT script in your Mule app, you can pass it to the module through a file, for example: ```xml ${file::xslt/cities.xslt} ``` In a more complex use case, the script you use might depend on some external condition. For example, imagine a multi-tenant integration in which the transformation to use depends on a `userId`: ```xml // 1 #[vars.xslt] ``` 1. The example flow is triggered through an HTTP request. 2. The example is based on the `userId` value being provided as a query parameter and the File Connector being used to read the file that contains the correct XSL and store it in a variable. 3. The example then executes a transformation using an expression to point to the XSL sheet obtained through the `Read` operation. The HTTP and File Connectors are used as examples and are not required to perform similar use cases. ## Using Context Properties The XML module, like the XSL language, provides context properties that can pass parameters to the transformation. In this example, the `` element contains a DataWeave expression that constructs an arguments map. ```xml (1) (2) ]]> #[{'vtn' : 'some value'}] (3) ``` 1. The XSL style sheet declares a `param` called `vtn`. 2. The style sheet references the assigned value of the `param` using the `$` prefix. 3. The example uses the `context-properties` parameter to pass in the values. ## Output MIME Type The most common use case for XSLT is to output a new XML document. However, XSLT can produce documents in other formats, such as JSON, CSV, or a text or number value, which means that the produced value does not have any specific MIME type assigned. You should specify a MIME type using the `outputMimeType` parameter. ## See Also [XML Module](https://docs.mulesoft.com/xml-module/latest/)