This is an automated email from the ASF dual-hosted git repository.
davsclaus pushed a commit to branch main
in repository https://gitbox.apache.org/repos/asf/camel.git
The following commit(s) were added to refs/heads/main by this push:
new 1340c1cfcc95 CAMEL-27486: camel-core-model - xpath, xquery and
xtokenize get a namespaceMappings option, for several namespaces inline in one
string (#30693)
1340c1cfcc95 is described below
commit 1340c1cfcc9534164d3633465de573098a6009b2
Author: Claus Ibsen <[email protected]>
AuthorDate: Tue Nov 24 09:54:45 2026 +0100
CAMEL-27486: camel-core-model - xpath, xquery and xtokenize get a
namespaceMappings option, for several namespaces inline in one string (#30693)
New namespaceMappings option on xpath, xquery and xtokenize: several
namespaces in one string (comma or new line separated, prefix=uri), with
property placeholders resolved when the route is created, so a Kamelet's
{{namespaces}} works. A namespace entry wins over a mapping for the same
prefix; namespacesRef is only used when neither is given. An invalid mapping
fails the route.
Co-Authored-By: Claude Opus 5.5 <[email protected]>
---
.../apache/camel/catalog/docs/xpath-language.adoc | 42 ++++++--
.../apache/camel/catalog/docs/xquery-language.adoc | 4 +
.../camel/catalog/docs/xtokenize-language.adoc | 4 +
.../org/apache/camel/catalog/languages/xpath.json | 11 +-
.../org/apache/camel/catalog/languages/xquery.json | 11 +-
.../apache/camel/catalog/languages/xtokenize.json | 11 +-
.../org/apache/camel/catalog/models/xpath.json | 11 +-
.../org/apache/camel/catalog/models/xquery.json | 11 +-
.../org/apache/camel/catalog/models/xtokenize.json | 11 +-
.../apache/camel/catalog/schemas/camel-spring.xsd | 11 ++
.../apache/camel/catalog/schemas/camel-xml-io.xsd | 11 ++
.../camel/catalog/schemas/camelYamlDsl-model.json | 15 +++
.../org/apache/camel/language/xquery/xquery.json | 11 +-
.../camel-saxon/src/main/docs/xquery-language.adoc | 4 +
.../xquery/XQueryNamespaceMappingsTest.java | 85 +++++++++++++++
.../camel/language/xtokenizer/xtokenize.json | 11 +-
.../src/main/docs/xtokenize-language.adoc | 4 +
.../XMLTokenizeNamespaceMappingsTest.java | 101 ++++++++++++++++++
.../org/apache/camel/language/xpath/xpath.json | 11 +-
.../camel-xpath/src/main/docs/xpath-language.adoc | 42 ++++++--
.../org/apache/camel/model/language/xpath.json | 11 +-
.../org/apache/camel/model/language/xquery.json | 11 +-
.../org/apache/camel/model/language/xtokenize.json | 11 +-
.../model/language/NamespaceAwareExpression.java | 28 +++++
.../language/XMLTokenizerExpressionReifier.java | 13 ++-
.../reifier/language/XPathExpressionReifier.java | 13 ++-
.../reifier/language/XQueryExpressionReifier.java | 13 ++-
.../builder/xml/XPathNamespaceMappingsTest.java | 116 +++++++++++++++++++++
.../apache/camel/java/out/JavaDslModelWriter.java | 1 +
.../java/org/apache/camel/xml/in/ModelParser.java | 1 +
.../java/org/apache/camel/xml/out/ModelWriter.java | 1 +
.../org/apache/camel/yaml/out/YamlModelWriter.java | 1 +
.../dsl/yaml/deserializers/ModelDeserializers.java | 18 ++++
.../resources/schema/camelYamlDsl-canonical.json | 15 +++
.../resources/schema/camelYamlDsl-model.json | 15 +++
.../generated/resources/schema/camelYamlDsl.json | 15 +++
.../dsl/yaml/XPathNamespacesRefYamlDslTest.java | 40 +++++++
37 files changed, 670 insertions(+), 75 deletions(-)
diff --git
a/catalog/camel-catalog/src/generated/resources/org/apache/camel/catalog/docs/xpath-language.adoc
b/catalog/camel-catalog/src/generated/resources/org/apache/camel/catalog/docs/xpath-language.adoc
index dc8399a6d2bb..7f461a33f068 100644
---
a/catalog/camel-catalog/src/generated/resources/org/apache/camel/catalog/docs/xpath-language.adoc
+++
b/catalog/camel-catalog/src/generated/resources/org/apache/camel/catalog/docs/xpath-language.adoc
@@ -107,10 +107,43 @@ If an expression declares namespaces inline as well, then
the inline namespaces
The `namespacesRef` option is also available on the
xref:xquery-language.adoc[XQuery] and
xref:xtokenize-language.adoc[XML Tokenize] languages.
-=== Several namespaces from one string
+=== Several namespaces in one string
-A `Namespaces` bean can also be created from a single string of `prefix=uri`
mappings, separated by commas or new
-lines. This lets one property, such as a Kamelet option, carry any number of
namespaces:
+The `namespaceMappings` option takes the namespaces inline, as one string of
`prefix=uri` mappings separated by commas
+or new lines. The prefix ends at the first `=`. As one string, it can come
from a property placeholder, such as a Kamelet
+option:
+
+[tabs]
+====
+XML::
++
+[source,xml]
+----
+<filter>
+ <xpath
namespaceMappings="c=http://acme.com/cheese,w=http://acme.com/wine">/c:order/w:wine
= 'Rioja'</xpath>
+ <to uri="mock:rioja"/>
+</filter>
+----
+
+YAML::
++
+[source,yaml]
+----
+- filter:
+ xpath:
+ expression: "/c:order/w:wine = 'Rioja'"
+ namespaceMappings: "{{namespaces}}"
+ steps:
+ - to: "mock:rioja"
+----
+====
+
+The mappings are read when the route is created, after the property
placeholders are resolved, and a mapping without
+a prefix or a URI fails the route. When `namespace` entries are given as well,
an entry wins over a mapping for the same
+prefix. `namespacesRef` is only used when neither is given.
+
+To share the mappings of one string between several expressions, a
`Namespaces` bean can be created from the same
+string, and referred to with `namespacesRef`:
[source,yaml]
----
@@ -121,9 +154,6 @@ lines. This lets one property, such as a Kamelet option,
carry any number of nam
0: "{{namespaces}}"
----
-With `namespaces=c=http://acme.com/cheese,w=http://acme.com/wine`, an xpath
with `namespacesRef: "myNamespaces"` can
-use both the `c` and the `w` prefix. A mapping without a prefix or a URI fails
when the bean is created.
-
== Variables
Variables in XPath are defined in different namespaces.
diff --git
a/catalog/camel-catalog/src/generated/resources/org/apache/camel/catalog/docs/xquery-language.adoc
b/catalog/camel-catalog/src/generated/resources/org/apache/camel/catalog/docs/xquery-language.adoc
index a716d8d299ea..8059cffeef3e 100644
---
a/catalog/camel-catalog/src/generated/resources/org/apache/camel/catalog/docs/xquery-language.adoc
+++
b/catalog/camel-catalog/src/generated/resources/org/apache/camel/catalog/docs/xquery-language.adoc
@@ -234,6 +234,10 @@ in the line with `xmlns:foo="http://example.com/person"`:
This namespace uses `foo` as prefix, so the `<xquery>` expression uses `foo:`
to use this namespace.
+Several namespaces can also be given inline in one string, with the
`namespaceMappings` option, such as
+`namespaceMappings: "c=http://acme.com/cheese,w=http://acme.com/wine"`. See the
+xref:xpath-language.adoc#_several_namespaces_in_one_string[XPath] language for
the syntax.
+
=== Sharing namespaces via a registry bean
Declaring the prefixes on the XML root tag only works when the route itself is
written in XML.
diff --git
a/catalog/camel-catalog/src/generated/resources/org/apache/camel/catalog/docs/xtokenize-language.adoc
b/catalog/camel-catalog/src/generated/resources/org/apache/camel/catalog/docs/xtokenize-language.adoc
index dc07cc5f373e..9b69f7e05780 100644
---
a/catalog/camel-catalog/src/generated/resources/org/apache/camel/catalog/docs/xtokenize-language.adoc
+++
b/catalog/camel-catalog/src/generated/resources/org/apache/camel/catalog/docs/xtokenize-language.adoc
@@ -115,6 +115,10 @@ URI as the value.
If the expression declares namespaces inline as well, then the inline
namespaces win and
`namespacesRef` is ignored.
+Instead of a bean, several namespaces can also be given inline in one string,
with the `namespaceMappings` option,
+such as `namespaceMappings:
"c=http://acme.com/cheese,w=http://acme.com/wine"`. See the
+xref:xpath-language.adoc#_several_namespaces_in_one_string[XPath] language for
the syntax.
+
== Example
Suppose the input XML contains multiple orders:
diff --git
a/catalog/camel-catalog/src/generated/resources/org/apache/camel/catalog/languages/xpath.json
b/catalog/camel-catalog/src/generated/resources/org/apache/camel/catalog/languages/xpath.json
index 08eca5964c1f..44908116d101 100644
---
a/catalog/camel-catalog/src/generated/resources/org/apache/camel/catalog/languages/xpath.json
+++
b/catalog/camel-catalog/src/generated/resources/org/apache/camel/catalog/languages/xpath.json
@@ -41,10 +41,11 @@
"threadSafety": { "index": 8, "kind": "attribute", "displayName": "Thread
Safety", "group": "advanced", "label": "advanced", "required": false, "type":
"boolean", "javaType": "java.lang.Boolean", "deprecated": false, "autowired":
false, "secret": false, "defaultValue": false, "description": "Whether to
enable thread-safety for the returned result of the xpath expression. This
applies to when using NODESET as the result type, and the returned set has
multiple elements." },
"preCompile": { "index": 9, "kind": "attribute", "displayName": "Pre
Compile", "group": "advanced", "label": "advanced", "required": false, "type":
"boolean", "javaType": "java.lang.Boolean", "deprecated": false, "autowired":
false, "secret": false, "defaultValue": true, "description": "Whether to enable
pre-compiling the xpath expression during initialization phase. pre-compile is
enabled by default." },
"namespace": { "index": 10, "kind": "element", "displayName": "Namespace",
"group": "common", "label": "common", "required": false, "type": "array",
"javaType": "java.util.List<org.apache.camel.model.PropertyDefinition>",
"deprecated": false, "autowired": false, "secret": false, "description":
"Injects the XML Namespaces of prefix to uri mappings." },
- "namespacesRef": { "index": 11, "kind": "attribute", "displayName":
"Namespaces Ref", "group": "advanced", "label": "advanced", "required": false,
"type": "string", "javaType": "java.lang.String", "deprecated": false,
"autowired": false, "secret": false, "description": "Reference to a
org.apache.camel.support.builder.Namespaces bean in the registry to use for the
XML Namespaces of prefix to uri mappings." },
- "source": { "index": 12, "kind": "attribute", "displayName": "Source",
"group": "common", "required": false, "type": "string", "javaType":
"java.lang.String", "deprecated": false, "autowired": false, "secret": false,
"description": "Source to use, instead of message body. You can prefix with
variable:, header:, or property: to specify kind of source. Otherwise, the
source is assumed to be a variable. Use empty or null to use default source,
which is the message body." },
- "resultType": { "index": 13, "kind": "attribute", "displayName": "Result
Type", "group": "common", "required": false, "type": "string", "javaType":
"java.lang.String", "deprecated": false, "autowired": false, "secret": false,
"description": "The class of the result type (type from output)." },
- "trim": { "index": 14, "kind": "attribute", "displayName": "Trim",
"group": "advanced", "label": "advanced", "required": false, "type": "boolean",
"javaType": "java.lang.Boolean", "deprecated": false, "autowired": false,
"secret": false, "defaultValue": true, "description": "Whether to trim the
source code to remove leading and trailing whitespaces and line breaks." },
- "resolveResource": { "index": 15, "kind": "attribute", "displayName":
"Resolve Resource", "group": "advanced", "label": "advanced", "required":
false, "type": "boolean", "javaType": "java.lang.Boolean", "deprecated": false,
"autowired": false, "secret": false, "defaultValue": false, "description":
"Whether a result of the expression that is a String starting with resource: is
loaded as a resource and its content becomes the result, e.g. a script that
returns resource:templates\/order [...]
+ "namespaceMappings": { "index": 11, "kind": "attribute", "displayName":
"Namespace Mappings", "group": "common", "label": "common", "required": false,
"type": "string", "javaType": "java.lang.String", "deprecated": false,
"autowired": false, "secret": false, "description": "The XML Namespaces of
prefix to uri mappings in one string, such as p1=uri1,p2=uri2. The mappings are
separated by commas or new lines, and the prefix and the uri by the first =.
This allows to configure several n [...]
+ "namespacesRef": { "index": 12, "kind": "attribute", "displayName":
"Namespaces Ref", "group": "advanced", "label": "advanced", "required": false,
"type": "string", "javaType": "java.lang.String", "deprecated": false,
"autowired": false, "secret": false, "description": "Reference to a
org.apache.camel.support.builder.Namespaces bean in the registry to use for the
XML Namespaces of prefix to uri mappings." },
+ "source": { "index": 13, "kind": "attribute", "displayName": "Source",
"group": "common", "required": false, "type": "string", "javaType":
"java.lang.String", "deprecated": false, "autowired": false, "secret": false,
"description": "Source to use, instead of message body. You can prefix with
variable:, header:, or property: to specify kind of source. Otherwise, the
source is assumed to be a variable. Use empty or null to use default source,
which is the message body." },
+ "resultType": { "index": 14, "kind": "attribute", "displayName": "Result
Type", "group": "common", "required": false, "type": "string", "javaType":
"java.lang.String", "deprecated": false, "autowired": false, "secret": false,
"description": "The class of the result type (type from output)." },
+ "trim": { "index": 15, "kind": "attribute", "displayName": "Trim",
"group": "advanced", "label": "advanced", "required": false, "type": "boolean",
"javaType": "java.lang.Boolean", "deprecated": false, "autowired": false,
"secret": false, "defaultValue": true, "description": "Whether to trim the
source code to remove leading and trailing whitespaces and line breaks." },
+ "resolveResource": { "index": 16, "kind": "attribute", "displayName":
"Resolve Resource", "group": "advanced", "label": "advanced", "required":
false, "type": "boolean", "javaType": "java.lang.Boolean", "deprecated": false,
"autowired": false, "secret": false, "defaultValue": false, "description":
"Whether a result of the expression that is a String starting with resource: is
loaded as a resource and its content becomes the result, e.g. a script that
returns resource:templates\/order [...]
}
}
diff --git
a/catalog/camel-catalog/src/generated/resources/org/apache/camel/catalog/languages/xquery.json
b/catalog/camel-catalog/src/generated/resources/org/apache/camel/catalog/languages/xquery.json
index 81ccc9a861d9..d6f129d85f4a 100644
---
a/catalog/camel-catalog/src/generated/resources/org/apache/camel/catalog/languages/xquery.json
+++
b/catalog/camel-catalog/src/generated/resources/org/apache/camel/catalog/languages/xquery.json
@@ -27,10 +27,11 @@
"expression": { "index": 1, "kind": "value", "displayName": "Expression",
"group": "common", "required": true, "type": "string", "javaType":
"java.lang.String", "deprecated": false, "autowired": false, "secret": false,
"description": "The expression value in your chosen language syntax." },
"configurationRef": { "index": 2, "kind": "attribute", "displayName":
"Configuration Ref", "group": "advanced", "label": "advanced", "required":
false, "type": "string", "javaType": "java.lang.String", "deprecated": false,
"autowired": false, "secret": false, "description": "Reference to a saxon
configuration instance in the registry to use for xquery (requires
camel-saxon)." },
"namespace": { "index": 3, "kind": "element", "displayName": "Namespace",
"group": "common", "label": "common", "required": false, "type": "array",
"javaType": "java.util.List<org.apache.camel.model.PropertyDefinition>",
"deprecated": false, "autowired": false, "secret": false, "description":
"Injects the XML Namespaces of prefix to uri mappings." },
- "namespacesRef": { "index": 4, "kind": "attribute", "displayName":
"Namespaces Ref", "group": "advanced", "label": "advanced", "required": false,
"type": "string", "javaType": "java.lang.String", "deprecated": false,
"autowired": false, "secret": false, "description": "Reference to a
org.apache.camel.support.builder.Namespaces bean in the registry to use for the
XML Namespaces of prefix to uri mappings." },
- "source": { "index": 5, "kind": "attribute", "displayName": "Source",
"group": "common", "required": false, "type": "string", "javaType":
"java.lang.String", "deprecated": false, "autowired": false, "secret": false,
"description": "Source to use, instead of message body. You can prefix with
variable:, header:, or property: to specify kind of source. Otherwise, the
source is assumed to be a variable. Use empty or null to use default source,
which is the message body." },
- "resultType": { "index": 6, "kind": "attribute", "displayName": "Result
Type", "group": "common", "required": false, "type": "string", "javaType":
"java.lang.String", "deprecated": false, "autowired": false, "secret": false,
"description": "The class of the result type (type from output)." },
- "trim": { "index": 7, "kind": "attribute", "displayName": "Trim", "group":
"advanced", "label": "advanced", "required": false, "type": "boolean",
"javaType": "java.lang.Boolean", "deprecated": false, "autowired": false,
"secret": false, "defaultValue": true, "description": "Whether to trim the
source code to remove leading and trailing whitespaces and line breaks." },
- "resolveResource": { "index": 8, "kind": "attribute", "displayName":
"Resolve Resource", "group": "advanced", "label": "advanced", "required":
false, "type": "boolean", "javaType": "java.lang.Boolean", "deprecated": false,
"autowired": false, "secret": false, "defaultValue": false, "description":
"Whether a result of the expression that is a String starting with resource: is
loaded as a resource and its content becomes the result, e.g. a script that
returns resource:templates\/order. [...]
+ "namespaceMappings": { "index": 4, "kind": "attribute", "displayName":
"Namespace Mappings", "group": "common", "label": "common", "required": false,
"type": "string", "javaType": "java.lang.String", "deprecated": false,
"autowired": false, "secret": false, "description": "The XML Namespaces of
prefix to uri mappings in one string, such as p1=uri1,p2=uri2. The mappings are
separated by commas or new lines, and the prefix and the uri by the first =.
This allows to configure several na [...]
+ "namespacesRef": { "index": 5, "kind": "attribute", "displayName":
"Namespaces Ref", "group": "advanced", "label": "advanced", "required": false,
"type": "string", "javaType": "java.lang.String", "deprecated": false,
"autowired": false, "secret": false, "description": "Reference to a
org.apache.camel.support.builder.Namespaces bean in the registry to use for the
XML Namespaces of prefix to uri mappings." },
+ "source": { "index": 6, "kind": "attribute", "displayName": "Source",
"group": "common", "required": false, "type": "string", "javaType":
"java.lang.String", "deprecated": false, "autowired": false, "secret": false,
"description": "Source to use, instead of message body. You can prefix with
variable:, header:, or property: to specify kind of source. Otherwise, the
source is assumed to be a variable. Use empty or null to use default source,
which is the message body." },
+ "resultType": { "index": 7, "kind": "attribute", "displayName": "Result
Type", "group": "common", "required": false, "type": "string", "javaType":
"java.lang.String", "deprecated": false, "autowired": false, "secret": false,
"description": "The class of the result type (type from output)." },
+ "trim": { "index": 8, "kind": "attribute", "displayName": "Trim", "group":
"advanced", "label": "advanced", "required": false, "type": "boolean",
"javaType": "java.lang.Boolean", "deprecated": false, "autowired": false,
"secret": false, "defaultValue": true, "description": "Whether to trim the
source code to remove leading and trailing whitespaces and line breaks." },
+ "resolveResource": { "index": 9, "kind": "attribute", "displayName":
"Resolve Resource", "group": "advanced", "label": "advanced", "required":
false, "type": "boolean", "javaType": "java.lang.Boolean", "deprecated": false,
"autowired": false, "secret": false, "defaultValue": false, "description":
"Whether a result of the expression that is a String starting with resource: is
loaded as a resource and its content becomes the result, e.g. a script that
returns resource:templates\/order. [...]
}
}
diff --git
a/catalog/camel-catalog/src/generated/resources/org/apache/camel/catalog/languages/xtokenize.json
b/catalog/camel-catalog/src/generated/resources/org/apache/camel/catalog/languages/xtokenize.json
index c794e93c823c..1bc1a6b8bd7e 100644
---
a/catalog/camel-catalog/src/generated/resources/org/apache/camel/catalog/languages/xtokenize.json
+++
b/catalog/camel-catalog/src/generated/resources/org/apache/camel/catalog/languages/xtokenize.json
@@ -28,10 +28,11 @@
"mode": { "index": 2, "kind": "attribute", "displayName": "Mode", "group":
"common", "required": false, "type": "enum", "javaType": "java.lang.String",
"enum": [ "i", "w", "u", "t" ], "deprecated": false, "autowired": false,
"secret": false, "defaultValue": "i", "description": "The extraction mode. The
available extraction modes are: i - injecting the contextual namespace bindings
into the extracted token (default), w - wrapping the extracted token in its
ancestor context, u - unwrap [...]
"group": { "index": 3, "kind": "attribute", "displayName": "Group",
"group": "common", "required": false, "type": "integer", "javaType":
"java.lang.Integer", "deprecated": false, "autowired": false, "secret": false,
"description": "To group N parts together." },
"namespace": { "index": 4, "kind": "element", "displayName": "Namespace",
"group": "common", "label": "common", "required": false, "type": "array",
"javaType": "java.util.List<org.apache.camel.model.PropertyDefinition>",
"deprecated": false, "autowired": false, "secret": false, "description":
"Injects the XML Namespaces of prefix to uri mappings." },
- "namespacesRef": { "index": 5, "kind": "attribute", "displayName":
"Namespaces Ref", "group": "advanced", "label": "advanced", "required": false,
"type": "string", "javaType": "java.lang.String", "deprecated": false,
"autowired": false, "secret": false, "description": "Reference to a
org.apache.camel.support.builder.Namespaces bean in the registry to use for the
XML Namespaces of prefix to uri mappings." },
- "source": { "index": 6, "kind": "attribute", "displayName": "Source",
"group": "common", "required": false, "type": "string", "javaType":
"java.lang.String", "deprecated": false, "autowired": false, "secret": false,
"description": "Source to use, instead of message body. You can prefix with
variable:, header:, or property: to specify kind of source. Otherwise, the
source is assumed to be a variable. Use empty or null to use default source,
which is the message body." },
- "resultType": { "index": 7, "kind": "attribute", "displayName": "Result
Type", "group": "common", "required": false, "type": "string", "javaType":
"java.lang.String", "deprecated": false, "autowired": false, "secret": false,
"description": "The class of the result type (type from output)." },
- "trim": { "index": 8, "kind": "attribute", "displayName": "Trim", "group":
"advanced", "label": "advanced", "required": false, "type": "boolean",
"javaType": "java.lang.Boolean", "deprecated": false, "autowired": false,
"secret": false, "defaultValue": true, "description": "Whether to trim the
source code to remove leading and trailing whitespaces and line breaks." },
- "resolveResource": { "index": 9, "kind": "attribute", "displayName":
"Resolve Resource", "group": "advanced", "label": "advanced", "required":
false, "type": "boolean", "javaType": "java.lang.Boolean", "deprecated": false,
"autowired": false, "secret": false, "defaultValue": false, "description":
"Whether a result of the expression that is a String starting with resource: is
loaded as a resource and its content becomes the result, e.g. a script that
returns resource:templates\/order. [...]
+ "namespaceMappings": { "index": 5, "kind": "attribute", "displayName":
"Namespace Mappings", "group": "common", "label": "common", "required": false,
"type": "string", "javaType": "java.lang.String", "deprecated": false,
"autowired": false, "secret": false, "description": "The XML Namespaces of
prefix to uri mappings in one string, such as p1=uri1,p2=uri2. The mappings are
separated by commas or new lines, and the prefix and the uri by the first =.
This allows to configure several na [...]
+ "namespacesRef": { "index": 6, "kind": "attribute", "displayName":
"Namespaces Ref", "group": "advanced", "label": "advanced", "required": false,
"type": "string", "javaType": "java.lang.String", "deprecated": false,
"autowired": false, "secret": false, "description": "Reference to a
org.apache.camel.support.builder.Namespaces bean in the registry to use for the
XML Namespaces of prefix to uri mappings." },
+ "source": { "index": 7, "kind": "attribute", "displayName": "Source",
"group": "common", "required": false, "type": "string", "javaType":
"java.lang.String", "deprecated": false, "autowired": false, "secret": false,
"description": "Source to use, instead of message body. You can prefix with
variable:, header:, or property: to specify kind of source. Otherwise, the
source is assumed to be a variable. Use empty or null to use default source,
which is the message body." },
+ "resultType": { "index": 8, "kind": "attribute", "displayName": "Result
Type", "group": "common", "required": false, "type": "string", "javaType":
"java.lang.String", "deprecated": false, "autowired": false, "secret": false,
"description": "The class of the result type (type from output)." },
+ "trim": { "index": 9, "kind": "attribute", "displayName": "Trim", "group":
"advanced", "label": "advanced", "required": false, "type": "boolean",
"javaType": "java.lang.Boolean", "deprecated": false, "autowired": false,
"secret": false, "defaultValue": true, "description": "Whether to trim the
source code to remove leading and trailing whitespaces and line breaks." },
+ "resolveResource": { "index": 10, "kind": "attribute", "displayName":
"Resolve Resource", "group": "advanced", "label": "advanced", "required":
false, "type": "boolean", "javaType": "java.lang.Boolean", "deprecated": false,
"autowired": false, "secret": false, "defaultValue": false, "description":
"Whether a result of the expression that is a String starting with resource: is
loaded as a resource and its content becomes the result, e.g. a script that
returns resource:templates\/order [...]
}
}
diff --git
a/catalog/camel-catalog/src/generated/resources/org/apache/camel/catalog/models/xpath.json
b/catalog/camel-catalog/src/generated/resources/org/apache/camel/catalog/models/xpath.json
index ce872db26e9e..bcd5485bf17a 100644
---
a/catalog/camel-catalog/src/generated/resources/org/apache/camel/catalog/models/xpath.json
+++
b/catalog/camel-catalog/src/generated/resources/org/apache/camel/catalog/models/xpath.json
@@ -24,10 +24,11 @@
"threadSafety": { "index": 8, "kind": "attribute", "displayName": "Thread
Safety", "group": "advanced", "label": "advanced", "required": false, "type":
"boolean", "javaType": "java.lang.Boolean", "deprecated": false, "autowired":
false, "secret": false, "defaultValue": false, "description": "Whether to
enable thread-safety for the returned result of the xpath expression. This
applies to when using NODESET as the result type, and the returned set has
multiple elements." },
"preCompile": { "index": 9, "kind": "attribute", "displayName": "Pre
Compile", "group": "advanced", "label": "advanced", "required": false, "type":
"boolean", "javaType": "java.lang.Boolean", "deprecated": false, "autowired":
false, "secret": false, "defaultValue": true, "description": "Whether to enable
pre-compiling the xpath expression during initialization phase. pre-compile is
enabled by default." },
"namespace": { "index": 10, "kind": "element", "displayName": "Namespace",
"group": "common", "label": "common", "required": false, "type": "array",
"javaType": "java.util.List<org.apache.camel.model.PropertyDefinition>",
"deprecated": false, "autowired": false, "secret": false, "description":
"Injects the XML Namespaces of prefix to uri mappings." },
- "namespacesRef": { "index": 11, "kind": "attribute", "displayName":
"Namespaces Ref", "group": "advanced", "label": "advanced", "required": false,
"type": "string", "javaType": "java.lang.String", "deprecated": false,
"autowired": false, "secret": false, "description": "Reference to a
org.apache.camel.support.builder.Namespaces bean in the registry to use for the
XML Namespaces of prefix to uri mappings." },
- "source": { "index": 12, "kind": "attribute", "displayName": "Source",
"group": "common", "required": false, "type": "string", "javaType":
"java.lang.String", "deprecated": false, "autowired": false, "secret": false,
"description": "Source to use, instead of message body. You can prefix with
variable:, header:, or property: to specify kind of source. Otherwise, the
source is assumed to be a variable. Use empty or null to use default source,
which is the message body." },
- "resultType": { "index": 13, "kind": "attribute", "displayName": "Result
Type", "group": "common", "required": false, "type": "string", "javaType":
"java.lang.String", "deprecated": false, "autowired": false, "secret": false,
"description": "The class of the result type (type from output)." },
- "trim": { "index": 14, "kind": "attribute", "displayName": "Trim",
"group": "advanced", "label": "advanced", "required": false, "type": "boolean",
"javaType": "java.lang.Boolean", "deprecated": false, "autowired": false,
"secret": false, "defaultValue": true, "description": "Whether to trim the
source code to remove leading and trailing whitespaces and line breaks." },
- "resolveResource": { "index": 15, "kind": "attribute", "displayName":
"Resolve Resource", "group": "advanced", "label": "advanced", "required":
false, "type": "boolean", "javaType": "java.lang.Boolean", "deprecated": false,
"autowired": false, "secret": false, "defaultValue": false, "description":
"Whether a result of the expression that is a String starting with resource: is
loaded as a resource and its content becomes the result, e.g. a script that
returns resource:templates\/order [...]
+ "namespaceMappings": { "index": 11, "kind": "attribute", "displayName":
"Namespace Mappings", "group": "common", "label": "common", "required": false,
"type": "string", "javaType": "java.lang.String", "deprecated": false,
"autowired": false, "secret": false, "description": "The XML Namespaces of
prefix to uri mappings in one string, such as p1=uri1,p2=uri2. The mappings are
separated by commas or new lines, and the prefix and the uri by the first =.
This allows to configure several n [...]
+ "namespacesRef": { "index": 12, "kind": "attribute", "displayName":
"Namespaces Ref", "group": "advanced", "label": "advanced", "required": false,
"type": "string", "javaType": "java.lang.String", "deprecated": false,
"autowired": false, "secret": false, "description": "Reference to a
org.apache.camel.support.builder.Namespaces bean in the registry to use for the
XML Namespaces of prefix to uri mappings." },
+ "source": { "index": 13, "kind": "attribute", "displayName": "Source",
"group": "common", "required": false, "type": "string", "javaType":
"java.lang.String", "deprecated": false, "autowired": false, "secret": false,
"description": "Source to use, instead of message body. You can prefix with
variable:, header:, or property: to specify kind of source. Otherwise, the
source is assumed to be a variable. Use empty or null to use default source,
which is the message body." },
+ "resultType": { "index": 14, "kind": "attribute", "displayName": "Result
Type", "group": "common", "required": false, "type": "string", "javaType":
"java.lang.String", "deprecated": false, "autowired": false, "secret": false,
"description": "The class of the result type (type from output)." },
+ "trim": { "index": 15, "kind": "attribute", "displayName": "Trim",
"group": "advanced", "label": "advanced", "required": false, "type": "boolean",
"javaType": "java.lang.Boolean", "deprecated": false, "autowired": false,
"secret": false, "defaultValue": true, "description": "Whether to trim the
source code to remove leading and trailing whitespaces and line breaks." },
+ "resolveResource": { "index": 16, "kind": "attribute", "displayName":
"Resolve Resource", "group": "advanced", "label": "advanced", "required":
false, "type": "boolean", "javaType": "java.lang.Boolean", "deprecated": false,
"autowired": false, "secret": false, "defaultValue": false, "description":
"Whether a result of the expression that is a String starting with resource: is
loaded as a resource and its content becomes the result, e.g. a script that
returns resource:templates\/order [...]
}
}
diff --git
a/catalog/camel-catalog/src/generated/resources/org/apache/camel/catalog/models/xquery.json
b/catalog/camel-catalog/src/generated/resources/org/apache/camel/catalog/models/xquery.json
index 4c83578b070a..9976406163bb 100644
---
a/catalog/camel-catalog/src/generated/resources/org/apache/camel/catalog/models/xquery.json
+++
b/catalog/camel-catalog/src/generated/resources/org/apache/camel/catalog/models/xquery.json
@@ -17,10 +17,11 @@
"expression": { "index": 1, "kind": "value", "displayName": "Expression",
"group": "common", "required": true, "type": "string", "javaType":
"java.lang.String", "deprecated": false, "autowired": false, "secret": false,
"description": "The expression value in your chosen language syntax." },
"configurationRef": { "index": 2, "kind": "attribute", "displayName":
"Configuration Ref", "group": "advanced", "label": "advanced", "required":
false, "type": "string", "javaType": "java.lang.String", "deprecated": false,
"autowired": false, "secret": false, "description": "Reference to a saxon
configuration instance in the registry to use for xquery (requires
camel-saxon)." },
"namespace": { "index": 3, "kind": "element", "displayName": "Namespace",
"group": "common", "label": "common", "required": false, "type": "array",
"javaType": "java.util.List<org.apache.camel.model.PropertyDefinition>",
"deprecated": false, "autowired": false, "secret": false, "description":
"Injects the XML Namespaces of prefix to uri mappings." },
- "namespacesRef": { "index": 4, "kind": "attribute", "displayName":
"Namespaces Ref", "group": "advanced", "label": "advanced", "required": false,
"type": "string", "javaType": "java.lang.String", "deprecated": false,
"autowired": false, "secret": false, "description": "Reference to a
org.apache.camel.support.builder.Namespaces bean in the registry to use for the
XML Namespaces of prefix to uri mappings." },
- "source": { "index": 5, "kind": "attribute", "displayName": "Source",
"group": "common", "required": false, "type": "string", "javaType":
"java.lang.String", "deprecated": false, "autowired": false, "secret": false,
"description": "Source to use, instead of message body. You can prefix with
variable:, header:, or property: to specify kind of source. Otherwise, the
source is assumed to be a variable. Use empty or null to use default source,
which is the message body." },
- "resultType": { "index": 6, "kind": "attribute", "displayName": "Result
Type", "group": "common", "required": false, "type": "string", "javaType":
"java.lang.String", "deprecated": false, "autowired": false, "secret": false,
"description": "The class of the result type (type from output)." },
- "trim": { "index": 7, "kind": "attribute", "displayName": "Trim", "group":
"advanced", "label": "advanced", "required": false, "type": "boolean",
"javaType": "java.lang.Boolean", "deprecated": false, "autowired": false,
"secret": false, "defaultValue": true, "description": "Whether to trim the
source code to remove leading and trailing whitespaces and line breaks." },
- "resolveResource": { "index": 8, "kind": "attribute", "displayName":
"Resolve Resource", "group": "advanced", "label": "advanced", "required":
false, "type": "boolean", "javaType": "java.lang.Boolean", "deprecated": false,
"autowired": false, "secret": false, "defaultValue": false, "description":
"Whether a result of the expression that is a String starting with resource: is
loaded as a resource and its content becomes the result, e.g. a script that
returns resource:templates\/order. [...]
+ "namespaceMappings": { "index": 4, "kind": "attribute", "displayName":
"Namespace Mappings", "group": "common", "label": "common", "required": false,
"type": "string", "javaType": "java.lang.String", "deprecated": false,
"autowired": false, "secret": false, "description": "The XML Namespaces of
prefix to uri mappings in one string, such as p1=uri1,p2=uri2. The mappings are
separated by commas or new lines, and the prefix and the uri by the first =.
This allows to configure several na [...]
+ "namespacesRef": { "index": 5, "kind": "attribute", "displayName":
"Namespaces Ref", "group": "advanced", "label": "advanced", "required": false,
"type": "string", "javaType": "java.lang.String", "deprecated": false,
"autowired": false, "secret": false, "description": "Reference to a
org.apache.camel.support.builder.Namespaces bean in the registry to use for the
XML Namespaces of prefix to uri mappings." },
+ "source": { "index": 6, "kind": "attribute", "displayName": "Source",
"group": "common", "required": false, "type": "string", "javaType":
"java.lang.String", "deprecated": false, "autowired": false, "secret": false,
"description": "Source to use, instead of message body. You can prefix with
variable:, header:, or property: to specify kind of source. Otherwise, the
source is assumed to be a variable. Use empty or null to use default source,
which is the message body." },
+ "resultType": { "index": 7, "kind": "attribute", "displayName": "Result
Type", "group": "common", "required": false, "type": "string", "javaType":
"java.lang.String", "deprecated": false, "autowired": false, "secret": false,
"description": "The class of the result type (type from output)." },
+ "trim": { "index": 8, "kind": "attribute", "displayName": "Trim", "group":
"advanced", "label": "advanced", "required": false, "type": "boolean",
"javaType": "java.lang.Boolean", "deprecated": false, "autowired": false,
"secret": false, "defaultValue": true, "description": "Whether to trim the
source code to remove leading and trailing whitespaces and line breaks." },
+ "resolveResource": { "index": 9, "kind": "attribute", "displayName":
"Resolve Resource", "group": "advanced", "label": "advanced", "required":
false, "type": "boolean", "javaType": "java.lang.Boolean", "deprecated": false,
"autowired": false, "secret": false, "defaultValue": false, "description":
"Whether a result of the expression that is a String starting with resource: is
loaded as a resource and its content becomes the result, e.g. a script that
returns resource:templates\/order. [...]
}
}
diff --git
a/catalog/camel-catalog/src/generated/resources/org/apache/camel/catalog/models/xtokenize.json
b/catalog/camel-catalog/src/generated/resources/org/apache/camel/catalog/models/xtokenize.json
index bd2f5eeeea5d..74bc029039e0 100644
---
a/catalog/camel-catalog/src/generated/resources/org/apache/camel/catalog/models/xtokenize.json
+++
b/catalog/camel-catalog/src/generated/resources/org/apache/camel/catalog/models/xtokenize.json
@@ -18,10 +18,11 @@
"mode": { "index": 2, "kind": "attribute", "displayName": "Mode", "group":
"common", "required": false, "type": "enum", "javaType": "java.lang.String",
"enum": [ "i", "w", "u", "t" ], "deprecated": false, "autowired": false,
"secret": false, "defaultValue": "i", "description": "The extraction mode. The
available extraction modes are: i - injecting the contextual namespace bindings
into the extracted token (default), w - wrapping the extracted token in its
ancestor context, u - unwrap [...]
"group": { "index": 3, "kind": "attribute", "displayName": "Group",
"group": "common", "required": false, "type": "integer", "javaType":
"java.lang.Integer", "deprecated": false, "autowired": false, "secret": false,
"description": "To group N parts together." },
"namespace": { "index": 4, "kind": "element", "displayName": "Namespace",
"group": "common", "label": "common", "required": false, "type": "array",
"javaType": "java.util.List<org.apache.camel.model.PropertyDefinition>",
"deprecated": false, "autowired": false, "secret": false, "description":
"Injects the XML Namespaces of prefix to uri mappings." },
- "namespacesRef": { "index": 5, "kind": "attribute", "displayName":
"Namespaces Ref", "group": "advanced", "label": "advanced", "required": false,
"type": "string", "javaType": "java.lang.String", "deprecated": false,
"autowired": false, "secret": false, "description": "Reference to a
org.apache.camel.support.builder.Namespaces bean in the registry to use for the
XML Namespaces of prefix to uri mappings." },
- "source": { "index": 6, "kind": "attribute", "displayName": "Source",
"group": "common", "required": false, "type": "string", "javaType":
"java.lang.String", "deprecated": false, "autowired": false, "secret": false,
"description": "Source to use, instead of message body. You can prefix with
variable:, header:, or property: to specify kind of source. Otherwise, the
source is assumed to be a variable. Use empty or null to use default source,
which is the message body." },
- "resultType": { "index": 7, "kind": "attribute", "displayName": "Result
Type", "group": "common", "required": false, "type": "string", "javaType":
"java.lang.String", "deprecated": false, "autowired": false, "secret": false,
"description": "The class of the result type (type from output)." },
- "trim": { "index": 8, "kind": "attribute", "displayName": "Trim", "group":
"advanced", "label": "advanced", "required": false, "type": "boolean",
"javaType": "java.lang.Boolean", "deprecated": false, "autowired": false,
"secret": false, "defaultValue": true, "description": "Whether to trim the
source code to remove leading and trailing whitespaces and line breaks." },
- "resolveResource": { "index": 9, "kind": "attribute", "displayName":
"Resolve Resource", "group": "advanced", "label": "advanced", "required":
false, "type": "boolean", "javaType": "java.lang.Boolean", "deprecated": false,
"autowired": false, "secret": false, "defaultValue": false, "description":
"Whether a result of the expression that is a String starting with resource: is
loaded as a resource and its content becomes the result, e.g. a script that
returns resource:templates\/order. [...]
+ "namespaceMappings": { "index": 5, "kind": "attribute", "displayName":
"Namespace Mappings", "group": "common", "label": "common", "required": false,
"type": "string", "javaType": "java.lang.String", "deprecated": false,
"autowired": false, "secret": false, "description": "The XML Namespaces of
prefix to uri mappings in one string, such as p1=uri1,p2=uri2. The mappings are
separated by commas or new lines, and the prefix and the uri by the first =.
This allows to configure several na [...]
+ "namespacesRef": { "index": 6, "kind": "attribute", "displayName":
"Namespaces Ref", "group": "advanced", "label": "advanced", "required": false,
"type": "string", "javaType": "java.lang.String", "deprecated": false,
"autowired": false, "secret": false, "description": "Reference to a
org.apache.camel.support.builder.Namespaces bean in the registry to use for the
XML Namespaces of prefix to uri mappings." },
+ "source": { "index": 7, "kind": "attribute", "displayName": "Source",
"group": "common", "required": false, "type": "string", "javaType":
"java.lang.String", "deprecated": false, "autowired": false, "secret": false,
"description": "Source to use, instead of message body. You can prefix with
variable:, header:, or property: to specify kind of source. Otherwise, the
source is assumed to be a variable. Use empty or null to use default source,
which is the message body." },
+ "resultType": { "index": 8, "kind": "attribute", "displayName": "Result
Type", "group": "common", "required": false, "type": "string", "javaType":
"java.lang.String", "deprecated": false, "autowired": false, "secret": false,
"description": "The class of the result type (type from output)." },
+ "trim": { "index": 9, "kind": "attribute", "displayName": "Trim", "group":
"advanced", "label": "advanced", "required": false, "type": "boolean",
"javaType": "java.lang.Boolean", "deprecated": false, "autowired": false,
"secret": false, "defaultValue": true, "description": "Whether to trim the
source code to remove leading and trailing whitespaces and line breaks." },
+ "resolveResource": { "index": 10, "kind": "attribute", "displayName":
"Resolve Resource", "group": "advanced", "label": "advanced", "required":
false, "type": "boolean", "javaType": "java.lang.Boolean", "deprecated": false,
"autowired": false, "secret": false, "defaultValue": false, "description":
"Whether a result of the expression that is a String starting with resource: is
loaded as a resource and its content becomes the result, e.g. a script that
returns resource:templates\/order [...]
}
}
diff --git
a/catalog/camel-catalog/src/generated/resources/org/apache/camel/catalog/schemas/camel-spring.xsd
b/catalog/camel-catalog/src/generated/resources/org/apache/camel/catalog/schemas/camel-spring.xsd
index e1a0ab687ab8..c8be2f34a644 100644
---
a/catalog/camel-catalog/src/generated/resources/org/apache/camel/catalog/schemas/camel-spring.xsd
+++
b/catalog/camel-catalog/src/generated/resources/org/apache/camel/catalog/schemas/camel-spring.xsd
@@ -16740,6 +16740,17 @@ Whether to validate the bean has the configured
method. Default value: true
<xs:complexType abstract="true" name="namespaceAwareExpression">
<xs:simpleContent>
<xs:extension base="tns:singleInputTypedExpressionDefinition">
+ <xs:attribute name="namespaceMappings" type="xs:string">
+ <xs:annotation>
+ <xs:documentation xml:lang="en">
+<![CDATA[
+The XML Namespaces of prefix to uri mappings in one string, such as
p1=uri1,p2=uri2. The mappings are separated by
+commas or new lines, and the prefix and the uri by the first =. This allows to
configure several namespaces from one
+property placeholder.
+]]>
+ </xs:documentation>
+ </xs:annotation>
+ </xs:attribute>
<xs:attribute name="namespacesRef" type="xs:string">
<xs:annotation>
<xs:documentation xml:lang="en">
diff --git
a/catalog/camel-catalog/src/generated/resources/org/apache/camel/catalog/schemas/camel-xml-io.xsd
b/catalog/camel-catalog/src/generated/resources/org/apache/camel/catalog/schemas/camel-xml-io.xsd
index 7a7cb4aa5b04..b7b5d82c3b59 100644
---
a/catalog/camel-catalog/src/generated/resources/org/apache/camel/catalog/schemas/camel-xml-io.xsd
+++
b/catalog/camel-catalog/src/generated/resources/org/apache/camel/catalog/schemas/camel-xml-io.xsd
@@ -15879,6 +15879,17 @@ Whether to validate the bean has the configured
method. Default value: true
<xs:complexType abstract="true" name="namespaceAwareExpression">
<xs:simpleContent>
<xs:extension base="tns:singleInputTypedExpressionDefinition">
+ <xs:attribute name="namespaceMappings" type="xs:string">
+ <xs:annotation>
+ <xs:documentation xml:lang="en">
+<![CDATA[
+The XML Namespaces of prefix to uri mappings in one string, such as
p1=uri1,p2=uri2. The mappings are separated by
+commas or new lines, and the prefix and the uri by the first =. This allows to
configure several namespaces from one
+property placeholder.
+]]>
+ </xs:documentation>
+ </xs:annotation>
+ </xs:attribute>
<xs:attribute name="namespacesRef" type="xs:string">
<xs:annotation>
<xs:documentation xml:lang="en">
diff --git
a/catalog/camel-catalog/src/generated/resources/org/apache/camel/catalog/schemas/camelYamlDsl-model.json
b/catalog/camel-catalog/src/generated/resources/org/apache/camel/catalog/schemas/camelYamlDsl-model.json
index 8b724bfdacdf..9c703d567124 100644
---
a/catalog/camel-catalog/src/generated/resources/org/apache/camel/catalog/schemas/camelYamlDsl-model.json
+++
b/catalog/camel-catalog/src/generated/resources/org/apache/camel/catalog/schemas/camelYamlDsl-model.json
@@ -16422,6 +16422,11 @@
"ref" : "property",
"description" : "Injects the XML Namespaces of prefix to uri
mappings.",
"title" : "Namespace"
+ }, {
+ "name" : "namespaceMappings",
+ "type" : "string",
+ "description" : "The XML Namespaces of prefix to uri mappings in one
string, such as p1=uri1,p2=uri2. The mappings are separated by commas or new
lines, and the prefix and the uri by the first =. This allows to configure
several namespaces from one property placeholder.",
+ "title" : "Namespace Mappings"
}, {
"name" : "namespacesRef",
"type" : "string",
@@ -16487,6 +16492,11 @@
"ref" : "property",
"description" : "Injects the XML Namespaces of prefix to uri
mappings.",
"title" : "Namespace"
+ }, {
+ "name" : "namespaceMappings",
+ "type" : "string",
+ "description" : "The XML Namespaces of prefix to uri mappings in one
string, such as p1=uri1,p2=uri2. The mappings are separated by commas or new
lines, and the prefix and the uri by the first =. This allows to configure
several namespaces from one property placeholder.",
+ "title" : "Namespace Mappings"
}, {
"name" : "namespacesRef",
"type" : "string",
@@ -16571,6 +16581,11 @@
"ref" : "property",
"description" : "Injects the XML Namespaces of prefix to uri
mappings.",
"title" : "Namespace"
+ }, {
+ "name" : "namespaceMappings",
+ "type" : "string",
+ "description" : "The XML Namespaces of prefix to uri mappings in one
string, such as p1=uri1,p2=uri2. The mappings are separated by commas or new
lines, and the prefix and the uri by the first =. This allows to configure
several namespaces from one property placeholder.",
+ "title" : "Namespace Mappings"
}, {
"name" : "namespacesRef",
"type" : "string",
diff --git
a/components/camel-saxon/src/generated/resources/META-INF/org/apache/camel/language/xquery/xquery.json
b/components/camel-saxon/src/generated/resources/META-INF/org/apache/camel/language/xquery/xquery.json
index 81ccc9a861d9..d6f129d85f4a 100644
---
a/components/camel-saxon/src/generated/resources/META-INF/org/apache/camel/language/xquery/xquery.json
+++
b/components/camel-saxon/src/generated/resources/META-INF/org/apache/camel/language/xquery/xquery.json
@@ -27,10 +27,11 @@
"expression": { "index": 1, "kind": "value", "displayName": "Expression",
"group": "common", "required": true, "type": "string", "javaType":
"java.lang.String", "deprecated": false, "autowired": false, "secret": false,
"description": "The expression value in your chosen language syntax." },
"configurationRef": { "index": 2, "kind": "attribute", "displayName":
"Configuration Ref", "group": "advanced", "label": "advanced", "required":
false, "type": "string", "javaType": "java.lang.String", "deprecated": false,
"autowired": false, "secret": false, "description": "Reference to a saxon
configuration instance in the registry to use for xquery (requires
camel-saxon)." },
"namespace": { "index": 3, "kind": "element", "displayName": "Namespace",
"group": "common", "label": "common", "required": false, "type": "array",
"javaType": "java.util.List<org.apache.camel.model.PropertyDefinition>",
"deprecated": false, "autowired": false, "secret": false, "description":
"Injects the XML Namespaces of prefix to uri mappings." },
- "namespacesRef": { "index": 4, "kind": "attribute", "displayName":
"Namespaces Ref", "group": "advanced", "label": "advanced", "required": false,
"type": "string", "javaType": "java.lang.String", "deprecated": false,
"autowired": false, "secret": false, "description": "Reference to a
org.apache.camel.support.builder.Namespaces bean in the registry to use for the
XML Namespaces of prefix to uri mappings." },
- "source": { "index": 5, "kind": "attribute", "displayName": "Source",
"group": "common", "required": false, "type": "string", "javaType":
"java.lang.String", "deprecated": false, "autowired": false, "secret": false,
"description": "Source to use, instead of message body. You can prefix with
variable:, header:, or property: to specify kind of source. Otherwise, the
source is assumed to be a variable. Use empty or null to use default source,
which is the message body." },
- "resultType": { "index": 6, "kind": "attribute", "displayName": "Result
Type", "group": "common", "required": false, "type": "string", "javaType":
"java.lang.String", "deprecated": false, "autowired": false, "secret": false,
"description": "The class of the result type (type from output)." },
- "trim": { "index": 7, "kind": "attribute", "displayName": "Trim", "group":
"advanced", "label": "advanced", "required": false, "type": "boolean",
"javaType": "java.lang.Boolean", "deprecated": false, "autowired": false,
"secret": false, "defaultValue": true, "description": "Whether to trim the
source code to remove leading and trailing whitespaces and line breaks." },
- "resolveResource": { "index": 8, "kind": "attribute", "displayName":
"Resolve Resource", "group": "advanced", "label": "advanced", "required":
false, "type": "boolean", "javaType": "java.lang.Boolean", "deprecated": false,
"autowired": false, "secret": false, "defaultValue": false, "description":
"Whether a result of the expression that is a String starting with resource: is
loaded as a resource and its content becomes the result, e.g. a script that
returns resource:templates\/order. [...]
+ "namespaceMappings": { "index": 4, "kind": "attribute", "displayName":
"Namespace Mappings", "group": "common", "label": "common", "required": false,
"type": "string", "javaType": "java.lang.String", "deprecated": false,
"autowired": false, "secret": false, "description": "The XML Namespaces of
prefix to uri mappings in one string, such as p1=uri1,p2=uri2. The mappings are
separated by commas or new lines, and the prefix and the uri by the first =.
This allows to configure several na [...]
+ "namespacesRef": { "index": 5, "kind": "attribute", "displayName":
"Namespaces Ref", "group": "advanced", "label": "advanced", "required": false,
"type": "string", "javaType": "java.lang.String", "deprecated": false,
"autowired": false, "secret": false, "description": "Reference to a
org.apache.camel.support.builder.Namespaces bean in the registry to use for the
XML Namespaces of prefix to uri mappings." },
+ "source": { "index": 6, "kind": "attribute", "displayName": "Source",
"group": "common", "required": false, "type": "string", "javaType":
"java.lang.String", "deprecated": false, "autowired": false, "secret": false,
"description": "Source to use, instead of message body. You can prefix with
variable:, header:, or property: to specify kind of source. Otherwise, the
source is assumed to be a variable. Use empty or null to use default source,
which is the message body." },
+ "resultType": { "index": 7, "kind": "attribute", "displayName": "Result
Type", "group": "common", "required": false, "type": "string", "javaType":
"java.lang.String", "deprecated": false, "autowired": false, "secret": false,
"description": "The class of the result type (type from output)." },
+ "trim": { "index": 8, "kind": "attribute", "displayName": "Trim", "group":
"advanced", "label": "advanced", "required": false, "type": "boolean",
"javaType": "java.lang.Boolean", "deprecated": false, "autowired": false,
"secret": false, "defaultValue": true, "description": "Whether to trim the
source code to remove leading and trailing whitespaces and line breaks." },
+ "resolveResource": { "index": 9, "kind": "attribute", "displayName":
"Resolve Resource", "group": "advanced", "label": "advanced", "required":
false, "type": "boolean", "javaType": "java.lang.Boolean", "deprecated": false,
"autowired": false, "secret": false, "defaultValue": false, "description":
"Whether a result of the expression that is a String starting with resource: is
loaded as a resource and its content becomes the result, e.g. a script that
returns resource:templates\/order. [...]
}
}
diff --git a/components/camel-saxon/src/main/docs/xquery-language.adoc
b/components/camel-saxon/src/main/docs/xquery-language.adoc
index a716d8d299ea..8059cffeef3e 100644
--- a/components/camel-saxon/src/main/docs/xquery-language.adoc
+++ b/components/camel-saxon/src/main/docs/xquery-language.adoc
@@ -234,6 +234,10 @@ in the line with `xmlns:foo="http://example.com/person"`:
This namespace uses `foo` as prefix, so the `<xquery>` expression uses `foo:`
to use this namespace.
+Several namespaces can also be given inline in one string, with the
`namespaceMappings` option, such as
+`namespaceMappings: "c=http://acme.com/cheese,w=http://acme.com/wine"`. See the
+xref:xpath-language.adoc#_several_namespaces_in_one_string[XPath] language for
the syntax.
+
=== Sharing namespaces via a registry bean
Declaring the prefixes on the XML root tag only works when the route itself is
written in XML.
diff --git
a/components/camel-saxon/src/test/java/org/apache/camel/language/xquery/XQueryNamespaceMappingsTest.java
b/components/camel-saxon/src/test/java/org/apache/camel/language/xquery/XQueryNamespaceMappingsTest.java
new file mode 100644
index 000000000000..ab3f327d8fb4
--- /dev/null
+++
b/components/camel-saxon/src/test/java/org/apache/camel/language/xquery/XQueryNamespaceMappingsTest.java
@@ -0,0 +1,85 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements. See the NOTICE file distributed with
+ * this work for additional information regarding copyright ownership.
+ * The ASF licenses this file to You under the Apache License, Version 2.0
+ * (the "License"); you may not use this file except in compliance with
+ * the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+package org.apache.camel.language.xquery;
+
+import org.apache.camel.Exchange;
+import org.apache.camel.Predicate;
+import org.apache.camel.model.language.XQueryExpression;
+import org.apache.camel.spi.Registry;
+import org.apache.camel.support.DefaultExchange;
+import org.apache.camel.support.builder.Namespaces;
+import org.apache.camel.test.junit6.CamelTestSupport;
+import org.junit.jupiter.api.Test;
+
+import static org.junit.jupiter.api.Assertions.assertFalse;
+import static org.junit.jupiter.api.Assertions.assertTrue;
+
+/**
+ * An xquery expression with its namespaces inline in one string, the
namespaceMappings option.
+ */
+class XQueryNamespaceMappingsTest extends CamelTestSupport {
+
+ private static final String MAPPINGS =
"c=http://acme.com/cheese,w=http://acme.com/wine";
+
+ @Override
+ protected void bindToRegistry(Registry registry) {
+ registry.bind("otherNamespaces", new Namespaces("c",
"http://acme.com/other").add("w", "http://acme.com/other"));
+ }
+
+ @Test
+ void usesTheMappingsOfTheString() {
+ Predicate cheese = predicate("/c:person[@name='James']", MAPPINGS);
+ Predicate wine = predicate("/w:person[@name='James']", MAPPINGS);
+
+ assertTrue(cheese.matches(exchange("<person
xmlns=\"http://acme.com/cheese\" name=\"James\"/>")));
+ assertTrue(wine.matches(exchange("<person
xmlns=\"http://acme.com/wine\" name=\"James\"/>")));
+
+ // correct value, wrong namespace URI
+ assertFalse(wine.matches(exchange("<person
xmlns=\"http://acme.com/water\" name=\"James\"/>")));
+ }
+
+ @Test
+ void resolvesAPropertyPlaceholder() {
+ context.getPropertiesComponent().addOverrideProperty("namespaces",
MAPPINGS);
+
+ Predicate wine = predicate("/w:person[@name='James']",
"{{namespaces}}");
+
+ assertTrue(wine.matches(exchange("<person
xmlns=\"http://acme.com/wine\" name=\"James\"/>")));
+ }
+
+ @Test
+ void winsOverNamespacesRef() {
+ XQueryExpression definition = new
XQueryExpression("/w:person[@name='James']");
+ definition.setNamespaceMappings(MAPPINGS);
+ definition.setNamespacesRef("otherNamespaces");
+ Predicate wine = definition.createPredicate(context);
+
+ assertTrue(wine.matches(exchange("<person
xmlns=\"http://acme.com/wine\" name=\"James\"/>")));
+ }
+
+ private Predicate predicate(String expression, String namespaceMappings) {
+ XQueryExpression definition = new XQueryExpression(expression);
+ definition.setNamespaceMappings(namespaceMappings);
+ return definition.createPredicate(context);
+ }
+
+ private Exchange exchange(String body) {
+ Exchange exchange = new DefaultExchange(context);
+ exchange.getIn().setBody(body);
+ return exchange;
+ }
+}
diff --git
a/components/camel-stax/src/generated/resources/META-INF/org/apache/camel/language/xtokenizer/xtokenize.json
b/components/camel-stax/src/generated/resources/META-INF/org/apache/camel/language/xtokenizer/xtokenize.json
index c794e93c823c..1bc1a6b8bd7e 100644
---
a/components/camel-stax/src/generated/resources/META-INF/org/apache/camel/language/xtokenizer/xtokenize.json
+++
b/components/camel-stax/src/generated/resources/META-INF/org/apache/camel/language/xtokenizer/xtokenize.json
@@ -28,10 +28,11 @@
"mode": { "index": 2, "kind": "attribute", "displayName": "Mode", "group":
"common", "required": false, "type": "enum", "javaType": "java.lang.String",
"enum": [ "i", "w", "u", "t" ], "deprecated": false, "autowired": false,
"secret": false, "defaultValue": "i", "description": "The extraction mode. The
available extraction modes are: i - injecting the contextual namespace bindings
into the extracted token (default), w - wrapping the extracted token in its
ancestor context, u - unwrap [...]
"group": { "index": 3, "kind": "attribute", "displayName": "Group",
"group": "common", "required": false, "type": "integer", "javaType":
"java.lang.Integer", "deprecated": false, "autowired": false, "secret": false,
"description": "To group N parts together." },
"namespace": { "index": 4, "kind": "element", "displayName": "Namespace",
"group": "common", "label": "common", "required": false, "type": "array",
"javaType": "java.util.List<org.apache.camel.model.PropertyDefinition>",
"deprecated": false, "autowired": false, "secret": false, "description":
"Injects the XML Namespaces of prefix to uri mappings." },
- "namespacesRef": { "index": 5, "kind": "attribute", "displayName":
"Namespaces Ref", "group": "advanced", "label": "advanced", "required": false,
"type": "string", "javaType": "java.lang.String", "deprecated": false,
"autowired": false, "secret": false, "description": "Reference to a
org.apache.camel.support.builder.Namespaces bean in the registry to use for the
XML Namespaces of prefix to uri mappings." },
- "source": { "index": 6, "kind": "attribute", "displayName": "Source",
"group": "common", "required": false, "type": "string", "javaType":
"java.lang.String", "deprecated": false, "autowired": false, "secret": false,
"description": "Source to use, instead of message body. You can prefix with
variable:, header:, or property: to specify kind of source. Otherwise, the
source is assumed to be a variable. Use empty or null to use default source,
which is the message body." },
- "resultType": { "index": 7, "kind": "attribute", "displayName": "Result
Type", "group": "common", "required": false, "type": "string", "javaType":
"java.lang.String", "deprecated": false, "autowired": false, "secret": false,
"description": "The class of the result type (type from output)." },
- "trim": { "index": 8, "kind": "attribute", "displayName": "Trim", "group":
"advanced", "label": "advanced", "required": false, "type": "boolean",
"javaType": "java.lang.Boolean", "deprecated": false, "autowired": false,
"secret": false, "defaultValue": true, "description": "Whether to trim the
source code to remove leading and trailing whitespaces and line breaks." },
- "resolveResource": { "index": 9, "kind": "attribute", "displayName":
"Resolve Resource", "group": "advanced", "label": "advanced", "required":
false, "type": "boolean", "javaType": "java.lang.Boolean", "deprecated": false,
"autowired": false, "secret": false, "defaultValue": false, "description":
"Whether a result of the expression that is a String starting with resource: is
loaded as a resource and its content becomes the result, e.g. a script that
returns resource:templates\/order. [...]
+ "namespaceMappings": { "index": 5, "kind": "attribute", "displayName":
"Namespace Mappings", "group": "common", "label": "common", "required": false,
"type": "string", "javaType": "java.lang.String", "deprecated": false,
"autowired": false, "secret": false, "description": "The XML Namespaces of
prefix to uri mappings in one string, such as p1=uri1,p2=uri2. The mappings are
separated by commas or new lines, and the prefix and the uri by the first =.
This allows to configure several na [...]
+ "namespacesRef": { "index": 6, "kind": "attribute", "displayName":
"Namespaces Ref", "group": "advanced", "label": "advanced", "required": false,
"type": "string", "javaType": "java.lang.String", "deprecated": false,
"autowired": false, "secret": false, "description": "Reference to a
org.apache.camel.support.builder.Namespaces bean in the registry to use for the
XML Namespaces of prefix to uri mappings." },
+ "source": { "index": 7, "kind": "attribute", "displayName": "Source",
"group": "common", "required": false, "type": "string", "javaType":
"java.lang.String", "deprecated": false, "autowired": false, "secret": false,
"description": "Source to use, instead of message body. You can prefix with
variable:, header:, or property: to specify kind of source. Otherwise, the
source is assumed to be a variable. Use empty or null to use default source,
which is the message body." },
+ "resultType": { "index": 8, "kind": "attribute", "displayName": "Result
Type", "group": "common", "required": false, "type": "string", "javaType":
"java.lang.String", "deprecated": false, "autowired": false, "secret": false,
"description": "The class of the result type (type from output)." },
+ "trim": { "index": 9, "kind": "attribute", "displayName": "Trim", "group":
"advanced", "label": "advanced", "required": false, "type": "boolean",
"javaType": "java.lang.Boolean", "deprecated": false, "autowired": false,
"secret": false, "defaultValue": true, "description": "Whether to trim the
source code to remove leading and trailing whitespaces and line breaks." },
+ "resolveResource": { "index": 10, "kind": "attribute", "displayName":
"Resolve Resource", "group": "advanced", "label": "advanced", "required":
false, "type": "boolean", "javaType": "java.lang.Boolean", "deprecated": false,
"autowired": false, "secret": false, "defaultValue": false, "description":
"Whether a result of the expression that is a String starting with resource: is
loaded as a resource and its content becomes the result, e.g. a script that
returns resource:templates\/order [...]
}
}
diff --git a/components/camel-stax/src/main/docs/xtokenize-language.adoc
b/components/camel-stax/src/main/docs/xtokenize-language.adoc
index dc07cc5f373e..9b69f7e05780 100644
--- a/components/camel-stax/src/main/docs/xtokenize-language.adoc
+++ b/components/camel-stax/src/main/docs/xtokenize-language.adoc
@@ -115,6 +115,10 @@ URI as the value.
If the expression declares namespaces inline as well, then the inline
namespaces win and
`namespacesRef` is ignored.
+Instead of a bean, several namespaces can also be given inline in one string,
with the `namespaceMappings` option,
+such as `namespaceMappings:
"c=http://acme.com/cheese,w=http://acme.com/wine"`. See the
+xref:xpath-language.adoc#_several_namespaces_in_one_string[XPath] language for
the syntax.
+
== Example
Suppose the input XML contains multiple orders:
diff --git
a/components/camel-stax/src/test/java/org/apache/camel/language/xtokenizer/XMLTokenizeNamespaceMappingsTest.java
b/components/camel-stax/src/test/java/org/apache/camel/language/xtokenizer/XMLTokenizeNamespaceMappingsTest.java
new file mode 100644
index 000000000000..015dce5be1df
--- /dev/null
+++
b/components/camel-stax/src/test/java/org/apache/camel/language/xtokenizer/XMLTokenizeNamespaceMappingsTest.java
@@ -0,0 +1,101 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements. See the NOTICE file distributed with
+ * this work for additional information regarding copyright ownership.
+ * The ASF licenses this file to You under the Apache License, Version 2.0
+ * (the "License"); you may not use this file except in compliance with
+ * the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+package org.apache.camel.language.xtokenizer;
+
+import java.util.Iterator;
+
+import org.apache.camel.Exchange;
+import org.apache.camel.Expression;
+import org.apache.camel.model.language.XMLTokenizerExpression;
+import org.apache.camel.spi.Registry;
+import org.apache.camel.support.DefaultExchange;
+import org.apache.camel.support.builder.Namespaces;
+import org.apache.camel.test.junit6.CamelTestSupport;
+import org.junit.jupiter.api.Test;
+
+import static org.junit.jupiter.api.Assertions.assertFalse;
+import static org.junit.jupiter.api.Assertions.assertInstanceOf;
+import static org.junit.jupiter.api.Assertions.assertTrue;
+
+/**
+ * An xtokenize expression with its namespaces inline in one string, the
namespaceMappings option.
+ */
+class XMLTokenizeNamespaceMappingsTest extends CamelTestSupport {
+
+ private static final String MAPPINGS =
"c=http://acme.com/cheese,w=http://acme.com/wine";
+
+ @Override
+ protected void bindToRegistry(Registry registry) {
+ registry.bind("otherNamespaces", new Namespaces("c",
"http://acme.com/other").add("w", "http://acme.com/other"));
+ }
+
+ @Test
+ void usesTheMappingsOfTheString() {
+ Iterator<?> cheese = tokenize(definition("//c:order", MAPPINGS),
+ "<orders
xmlns:c=\"http://acme.com/cheese\"><c:order>one</c:order></orders>");
+ Iterator<?> wine = tokenize(definition("//w:order", MAPPINGS),
+ "<orders
xmlns:w=\"http://acme.com/wine\"><w:order>two</w:order></orders>");
+
+ assertTrue(cheese.hasNext());
+ assertTrue(String.valueOf(cheese.next()).contains("one"));
+ assertTrue(wine.hasNext());
+ assertTrue(String.valueOf(wine.next()).contains("two"));
+
+ // matching local name, wrong namespace URI
+ Iterator<?> water = tokenize(definition("//c:order", MAPPINGS),
+ "<orders
xmlns:c=\"http://acme.com/water\"><c:order>three</c:order></orders>");
+ assertFalse(water.hasNext());
+ }
+
+ @Test
+ void resolvesAPropertyPlaceholder() {
+ context.getPropertiesComponent().addOverrideProperty("namespaces",
MAPPINGS);
+
+ Iterator<?> wine = tokenize(definition("//w:order", "{{namespaces}}"),
+ "<orders
xmlns:w=\"http://acme.com/wine\"><w:order>two</w:order></orders>");
+
+ assertTrue(wine.hasNext());
+ assertTrue(String.valueOf(wine.next()).contains("two"));
+ }
+
+ @Test
+ void winsOverNamespacesRef() {
+ XMLTokenizerExpression definition = definition("//w:order", MAPPINGS);
+ definition.setNamespacesRef("otherNamespaces");
+
+ Iterator<?> wine = tokenize(definition,
+ "<orders
xmlns:w=\"http://acme.com/wine\"><w:order>two</w:order></orders>");
+
+ assertTrue(wine.hasNext());
+ assertTrue(String.valueOf(wine.next()).contains("two"));
+ }
+
+ private static XMLTokenizerExpression definition(String expression, String
namespaceMappings) {
+ XMLTokenizerExpression definition = new
XMLTokenizerExpression(expression);
+ definition.setNamespaceMappings(namespaceMappings);
+ return definition;
+ }
+
+ private Iterator<?> tokenize(XMLTokenizerExpression definition, String
body) {
+ Expression exp = definition.createExpression(context);
+
+ Exchange exchange = new DefaultExchange(context);
+ exchange.getIn().setBody(body);
+
+ return assertInstanceOf(Iterator.class, exp.evaluate(exchange,
Object.class));
+ }
+}
diff --git
a/components/camel-xpath/src/generated/resources/META-INF/org/apache/camel/language/xpath/xpath.json
b/components/camel-xpath/src/generated/resources/META-INF/org/apache/camel/language/xpath/xpath.json
index 08eca5964c1f..44908116d101 100644
---
a/components/camel-xpath/src/generated/resources/META-INF/org/apache/camel/language/xpath/xpath.json
+++
b/components/camel-xpath/src/generated/resources/META-INF/org/apache/camel/language/xpath/xpath.json
@@ -41,10 +41,11 @@
"threadSafety": { "index": 8, "kind": "attribute", "displayName": "Thread
Safety", "group": "advanced", "label": "advanced", "required": false, "type":
"boolean", "javaType": "java.lang.Boolean", "deprecated": false, "autowired":
false, "secret": false, "defaultValue": false, "description": "Whether to
enable thread-safety for the returned result of the xpath expression. This
applies to when using NODESET as the result type, and the returned set has
multiple elements." },
"preCompile": { "index": 9, "kind": "attribute", "displayName": "Pre
Compile", "group": "advanced", "label": "advanced", "required": false, "type":
"boolean", "javaType": "java.lang.Boolean", "deprecated": false, "autowired":
false, "secret": false, "defaultValue": true, "description": "Whether to enable
pre-compiling the xpath expression during initialization phase. pre-compile is
enabled by default." },
"namespace": { "index": 10, "kind": "element", "displayName": "Namespace",
"group": "common", "label": "common", "required": false, "type": "array",
"javaType": "java.util.List<org.apache.camel.model.PropertyDefinition>",
"deprecated": false, "autowired": false, "secret": false, "description":
"Injects the XML Namespaces of prefix to uri mappings." },
- "namespacesRef": { "index": 11, "kind": "attribute", "displayName":
"Namespaces Ref", "group": "advanced", "label": "advanced", "required": false,
"type": "string", "javaType": "java.lang.String", "deprecated": false,
"autowired": false, "secret": false, "description": "Reference to a
org.apache.camel.support.builder.Namespaces bean in the registry to use for the
XML Namespaces of prefix to uri mappings." },
- "source": { "index": 12, "kind": "attribute", "displayName": "Source",
"group": "common", "required": false, "type": "string", "javaType":
"java.lang.String", "deprecated": false, "autowired": false, "secret": false,
"description": "Source to use, instead of message body. You can prefix with
variable:, header:, or property: to specify kind of source. Otherwise, the
source is assumed to be a variable. Use empty or null to use default source,
which is the message body." },
- "resultType": { "index": 13, "kind": "attribute", "displayName": "Result
Type", "group": "common", "required": false, "type": "string", "javaType":
"java.lang.String", "deprecated": false, "autowired": false, "secret": false,
"description": "The class of the result type (type from output)." },
- "trim": { "index": 14, "kind": "attribute", "displayName": "Trim",
"group": "advanced", "label": "advanced", "required": false, "type": "boolean",
"javaType": "java.lang.Boolean", "deprecated": false, "autowired": false,
"secret": false, "defaultValue": true, "description": "Whether to trim the
source code to remove leading and trailing whitespaces and line breaks." },
- "resolveResource": { "index": 15, "kind": "attribute", "displayName":
"Resolve Resource", "group": "advanced", "label": "advanced", "required":
false, "type": "boolean", "javaType": "java.lang.Boolean", "deprecated": false,
"autowired": false, "secret": false, "defaultValue": false, "description":
"Whether a result of the expression that is a String starting with resource: is
loaded as a resource and its content becomes the result, e.g. a script that
returns resource:templates\/order [...]
+ "namespaceMappings": { "index": 11, "kind": "attribute", "displayName":
"Namespace Mappings", "group": "common", "label": "common", "required": false,
"type": "string", "javaType": "java.lang.String", "deprecated": false,
"autowired": false, "secret": false, "description": "The XML Namespaces of
prefix to uri mappings in one string, such as p1=uri1,p2=uri2. The mappings are
separated by commas or new lines, and the prefix and the uri by the first =.
This allows to configure several n [...]
+ "namespacesRef": { "index": 12, "kind": "attribute", "displayName":
"Namespaces Ref", "group": "advanced", "label": "advanced", "required": false,
"type": "string", "javaType": "java.lang.String", "deprecated": false,
"autowired": false, "secret": false, "description": "Reference to a
org.apache.camel.support.builder.Namespaces bean in the registry to use for the
XML Namespaces of prefix to uri mappings." },
+ "source": { "index": 13, "kind": "attribute", "displayName": "Source",
"group": "common", "required": false, "type": "string", "javaType":
"java.lang.String", "deprecated": false, "autowired": false, "secret": false,
"description": "Source to use, instead of message body. You can prefix with
variable:, header:, or property: to specify kind of source. Otherwise, the
source is assumed to be a variable. Use empty or null to use default source,
which is the message body." },
+ "resultType": { "index": 14, "kind": "attribute", "displayName": "Result
Type", "group": "common", "required": false, "type": "string", "javaType":
"java.lang.String", "deprecated": false, "autowired": false, "secret": false,
"description": "The class of the result type (type from output)." },
+ "trim": { "index": 15, "kind": "attribute", "displayName": "Trim",
"group": "advanced", "label": "advanced", "required": false, "type": "boolean",
"javaType": "java.lang.Boolean", "deprecated": false, "autowired": false,
"secret": false, "defaultValue": true, "description": "Whether to trim the
source code to remove leading and trailing whitespaces and line breaks." },
+ "resolveResource": { "index": 16, "kind": "attribute", "displayName":
"Resolve Resource", "group": "advanced", "label": "advanced", "required":
false, "type": "boolean", "javaType": "java.lang.Boolean", "deprecated": false,
"autowired": false, "secret": false, "defaultValue": false, "description":
"Whether a result of the expression that is a String starting with resource: is
loaded as a resource and its content becomes the result, e.g. a script that
returns resource:templates\/order [...]
}
}
diff --git a/components/camel-xpath/src/main/docs/xpath-language.adoc
b/components/camel-xpath/src/main/docs/xpath-language.adoc
index dc8399a6d2bb..7f461a33f068 100644
--- a/components/camel-xpath/src/main/docs/xpath-language.adoc
+++ b/components/camel-xpath/src/main/docs/xpath-language.adoc
@@ -107,10 +107,43 @@ If an expression declares namespaces inline as well, then
the inline namespaces
The `namespacesRef` option is also available on the
xref:xquery-language.adoc[XQuery] and
xref:xtokenize-language.adoc[XML Tokenize] languages.
-=== Several namespaces from one string
+=== Several namespaces in one string
-A `Namespaces` bean can also be created from a single string of `prefix=uri`
mappings, separated by commas or new
-lines. This lets one property, such as a Kamelet option, carry any number of
namespaces:
+The `namespaceMappings` option takes the namespaces inline, as one string of
`prefix=uri` mappings separated by commas
+or new lines. The prefix ends at the first `=`. As one string, it can come
from a property placeholder, such as a Kamelet
+option:
+
+[tabs]
+====
+XML::
++
+[source,xml]
+----
+<filter>
+ <xpath
namespaceMappings="c=http://acme.com/cheese,w=http://acme.com/wine">/c:order/w:wine
= 'Rioja'</xpath>
+ <to uri="mock:rioja"/>
+</filter>
+----
+
+YAML::
++
+[source,yaml]
+----
+- filter:
+ xpath:
+ expression: "/c:order/w:wine = 'Rioja'"
+ namespaceMappings: "{{namespaces}}"
+ steps:
+ - to: "mock:rioja"
+----
+====
+
+The mappings are read when the route is created, after the property
placeholders are resolved, and a mapping without
+a prefix or a URI fails the route. When `namespace` entries are given as well,
an entry wins over a mapping for the same
+prefix. `namespacesRef` is only used when neither is given.
+
+To share the mappings of one string between several expressions, a
`Namespaces` bean can be created from the same
+string, and referred to with `namespacesRef`:
[source,yaml]
----
@@ -121,9 +154,6 @@ lines. This lets one property, such as a Kamelet option,
carry any number of nam
0: "{{namespaces}}"
----
-With `namespaces=c=http://acme.com/cheese,w=http://acme.com/wine`, an xpath
with `namespacesRef: "myNamespaces"` can
-use both the `c` and the `w` prefix. A mapping without a prefix or a URI fails
when the bean is created.
-
== Variables
Variables in XPath are defined in different namespaces.
diff --git
a/core/camel-core-model/src/generated/resources/META-INF/org/apache/camel/model/language/xpath.json
b/core/camel-core-model/src/generated/resources/META-INF/org/apache/camel/model/language/xpath.json
index ce872db26e9e..bcd5485bf17a 100644
---
a/core/camel-core-model/src/generated/resources/META-INF/org/apache/camel/model/language/xpath.json
+++
b/core/camel-core-model/src/generated/resources/META-INF/org/apache/camel/model/language/xpath.json
@@ -24,10 +24,11 @@
"threadSafety": { "index": 8, "kind": "attribute", "displayName": "Thread
Safety", "group": "advanced", "label": "advanced", "required": false, "type":
"boolean", "javaType": "java.lang.Boolean", "deprecated": false, "autowired":
false, "secret": false, "defaultValue": false, "description": "Whether to
enable thread-safety for the returned result of the xpath expression. This
applies to when using NODESET as the result type, and the returned set has
multiple elements." },
"preCompile": { "index": 9, "kind": "attribute", "displayName": "Pre
Compile", "group": "advanced", "label": "advanced", "required": false, "type":
"boolean", "javaType": "java.lang.Boolean", "deprecated": false, "autowired":
false, "secret": false, "defaultValue": true, "description": "Whether to enable
pre-compiling the xpath expression during initialization phase. pre-compile is
enabled by default." },
"namespace": { "index": 10, "kind": "element", "displayName": "Namespace",
"group": "common", "label": "common", "required": false, "type": "array",
"javaType": "java.util.List<org.apache.camel.model.PropertyDefinition>",
"deprecated": false, "autowired": false, "secret": false, "description":
"Injects the XML Namespaces of prefix to uri mappings." },
- "namespacesRef": { "index": 11, "kind": "attribute", "displayName":
"Namespaces Ref", "group": "advanced", "label": "advanced", "required": false,
"type": "string", "javaType": "java.lang.String", "deprecated": false,
"autowired": false, "secret": false, "description": "Reference to a
org.apache.camel.support.builder.Namespaces bean in the registry to use for the
XML Namespaces of prefix to uri mappings." },
- "source": { "index": 12, "kind": "attribute", "displayName": "Source",
"group": "common", "required": false, "type": "string", "javaType":
"java.lang.String", "deprecated": false, "autowired": false, "secret": false,
"description": "Source to use, instead of message body. You can prefix with
variable:, header:, or property: to specify kind of source. Otherwise, the
source is assumed to be a variable. Use empty or null to use default source,
which is the message body." },
- "resultType": { "index": 13, "kind": "attribute", "displayName": "Result
Type", "group": "common", "required": false, "type": "string", "javaType":
"java.lang.String", "deprecated": false, "autowired": false, "secret": false,
"description": "The class of the result type (type from output)." },
- "trim": { "index": 14, "kind": "attribute", "displayName": "Trim",
"group": "advanced", "label": "advanced", "required": false, "type": "boolean",
"javaType": "java.lang.Boolean", "deprecated": false, "autowired": false,
"secret": false, "defaultValue": true, "description": "Whether to trim the
source code to remove leading and trailing whitespaces and line breaks." },
- "resolveResource": { "index": 15, "kind": "attribute", "displayName":
"Resolve Resource", "group": "advanced", "label": "advanced", "required":
false, "type": "boolean", "javaType": "java.lang.Boolean", "deprecated": false,
"autowired": false, "secret": false, "defaultValue": false, "description":
"Whether a result of the expression that is a String starting with resource: is
loaded as a resource and its content becomes the result, e.g. a script that
returns resource:templates\/order [...]
+ "namespaceMappings": { "index": 11, "kind": "attribute", "displayName":
"Namespace Mappings", "group": "common", "label": "common", "required": false,
"type": "string", "javaType": "java.lang.String", "deprecated": false,
"autowired": false, "secret": false, "description": "The XML Namespaces of
prefix to uri mappings in one string, such as p1=uri1,p2=uri2. The mappings are
separated by commas or new lines, and the prefix and the uri by the first =.
This allows to configure several n [...]
+ "namespacesRef": { "index": 12, "kind": "attribute", "displayName":
"Namespaces Ref", "group": "advanced", "label": "advanced", "required": false,
"type": "string", "javaType": "java.lang.String", "deprecated": false,
"autowired": false, "secret": false, "description": "Reference to a
org.apache.camel.support.builder.Namespaces bean in the registry to use for the
XML Namespaces of prefix to uri mappings." },
+ "source": { "index": 13, "kind": "attribute", "displayName": "Source",
"group": "common", "required": false, "type": "string", "javaType":
"java.lang.String", "deprecated": false, "autowired": false, "secret": false,
"description": "Source to use, instead of message body. You can prefix with
variable:, header:, or property: to specify kind of source. Otherwise, the
source is assumed to be a variable. Use empty or null to use default source,
which is the message body." },
+ "resultType": { "index": 14, "kind": "attribute", "displayName": "Result
Type", "group": "common", "required": false, "type": "string", "javaType":
"java.lang.String", "deprecated": false, "autowired": false, "secret": false,
"description": "The class of the result type (type from output)." },
+ "trim": { "index": 15, "kind": "attribute", "displayName": "Trim",
"group": "advanced", "label": "advanced", "required": false, "type": "boolean",
"javaType": "java.lang.Boolean", "deprecated": false, "autowired": false,
"secret": false, "defaultValue": true, "description": "Whether to trim the
source code to remove leading and trailing whitespaces and line breaks." },
+ "resolveResource": { "index": 16, "kind": "attribute", "displayName":
"Resolve Resource", "group": "advanced", "label": "advanced", "required":
false, "type": "boolean", "javaType": "java.lang.Boolean", "deprecated": false,
"autowired": false, "secret": false, "defaultValue": false, "description":
"Whether a result of the expression that is a String starting with resource: is
loaded as a resource and its content becomes the result, e.g. a script that
returns resource:templates\/order [...]
}
}
diff --git
a/core/camel-core-model/src/generated/resources/META-INF/org/apache/camel/model/language/xquery.json
b/core/camel-core-model/src/generated/resources/META-INF/org/apache/camel/model/language/xquery.json
index 4c83578b070a..9976406163bb 100644
---
a/core/camel-core-model/src/generated/resources/META-INF/org/apache/camel/model/language/xquery.json
+++
b/core/camel-core-model/src/generated/resources/META-INF/org/apache/camel/model/language/xquery.json
@@ -17,10 +17,11 @@
"expression": { "index": 1, "kind": "value", "displayName": "Expression",
"group": "common", "required": true, "type": "string", "javaType":
"java.lang.String", "deprecated": false, "autowired": false, "secret": false,
"description": "The expression value in your chosen language syntax." },
"configurationRef": { "index": 2, "kind": "attribute", "displayName":
"Configuration Ref", "group": "advanced", "label": "advanced", "required":
false, "type": "string", "javaType": "java.lang.String", "deprecated": false,
"autowired": false, "secret": false, "description": "Reference to a saxon
configuration instance in the registry to use for xquery (requires
camel-saxon)." },
"namespace": { "index": 3, "kind": "element", "displayName": "Namespace",
"group": "common", "label": "common", "required": false, "type": "array",
"javaType": "java.util.List<org.apache.camel.model.PropertyDefinition>",
"deprecated": false, "autowired": false, "secret": false, "description":
"Injects the XML Namespaces of prefix to uri mappings." },
- "namespacesRef": { "index": 4, "kind": "attribute", "displayName":
"Namespaces Ref", "group": "advanced", "label": "advanced", "required": false,
"type": "string", "javaType": "java.lang.String", "deprecated": false,
"autowired": false, "secret": false, "description": "Reference to a
org.apache.camel.support.builder.Namespaces bean in the registry to use for the
XML Namespaces of prefix to uri mappings." },
- "source": { "index": 5, "kind": "attribute", "displayName": "Source",
"group": "common", "required": false, "type": "string", "javaType":
"java.lang.String", "deprecated": false, "autowired": false, "secret": false,
"description": "Source to use, instead of message body. You can prefix with
variable:, header:, or property: to specify kind of source. Otherwise, the
source is assumed to be a variable. Use empty or null to use default source,
which is the message body." },
- "resultType": { "index": 6, "kind": "attribute", "displayName": "Result
Type", "group": "common", "required": false, "type": "string", "javaType":
"java.lang.String", "deprecated": false, "autowired": false, "secret": false,
"description": "The class of the result type (type from output)." },
- "trim": { "index": 7, "kind": "attribute", "displayName": "Trim", "group":
"advanced", "label": "advanced", "required": false, "type": "boolean",
"javaType": "java.lang.Boolean", "deprecated": false, "autowired": false,
"secret": false, "defaultValue": true, "description": "Whether to trim the
source code to remove leading and trailing whitespaces and line breaks." },
- "resolveResource": { "index": 8, "kind": "attribute", "displayName":
"Resolve Resource", "group": "advanced", "label": "advanced", "required":
false, "type": "boolean", "javaType": "java.lang.Boolean", "deprecated": false,
"autowired": false, "secret": false, "defaultValue": false, "description":
"Whether a result of the expression that is a String starting with resource: is
loaded as a resource and its content becomes the result, e.g. a script that
returns resource:templates\/order. [...]
+ "namespaceMappings": { "index": 4, "kind": "attribute", "displayName":
"Namespace Mappings", "group": "common", "label": "common", "required": false,
"type": "string", "javaType": "java.lang.String", "deprecated": false,
"autowired": false, "secret": false, "description": "The XML Namespaces of
prefix to uri mappings in one string, such as p1=uri1,p2=uri2. The mappings are
separated by commas or new lines, and the prefix and the uri by the first =.
This allows to configure several na [...]
+ "namespacesRef": { "index": 5, "kind": "attribute", "displayName":
"Namespaces Ref", "group": "advanced", "label": "advanced", "required": false,
"type": "string", "javaType": "java.lang.String", "deprecated": false,
"autowired": false, "secret": false, "description": "Reference to a
org.apache.camel.support.builder.Namespaces bean in the registry to use for the
XML Namespaces of prefix to uri mappings." },
+ "source": { "index": 6, "kind": "attribute", "displayName": "Source",
"group": "common", "required": false, "type": "string", "javaType":
"java.lang.String", "deprecated": false, "autowired": false, "secret": false,
"description": "Source to use, instead of message body. You can prefix with
variable:, header:, or property: to specify kind of source. Otherwise, the
source is assumed to be a variable. Use empty or null to use default source,
which is the message body." },
+ "resultType": { "index": 7, "kind": "attribute", "displayName": "Result
Type", "group": "common", "required": false, "type": "string", "javaType":
"java.lang.String", "deprecated": false, "autowired": false, "secret": false,
"description": "The class of the result type (type from output)." },
+ "trim": { "index": 8, "kind": "attribute", "displayName": "Trim", "group":
"advanced", "label": "advanced", "required": false, "type": "boolean",
"javaType": "java.lang.Boolean", "deprecated": false, "autowired": false,
"secret": false, "defaultValue": true, "description": "Whether to trim the
source code to remove leading and trailing whitespaces and line breaks." },
+ "resolveResource": { "index": 9, "kind": "attribute", "displayName":
"Resolve Resource", "group": "advanced", "label": "advanced", "required":
false, "type": "boolean", "javaType": "java.lang.Boolean", "deprecated": false,
"autowired": false, "secret": false, "defaultValue": false, "description":
"Whether a result of the expression that is a String starting with resource: is
loaded as a resource and its content becomes the result, e.g. a script that
returns resource:templates\/order. [...]
}
}
diff --git
a/core/camel-core-model/src/generated/resources/META-INF/org/apache/camel/model/language/xtokenize.json
b/core/camel-core-model/src/generated/resources/META-INF/org/apache/camel/model/language/xtokenize.json
index bd2f5eeeea5d..74bc029039e0 100644
---
a/core/camel-core-model/src/generated/resources/META-INF/org/apache/camel/model/language/xtokenize.json
+++
b/core/camel-core-model/src/generated/resources/META-INF/org/apache/camel/model/language/xtokenize.json
@@ -18,10 +18,11 @@
"mode": { "index": 2, "kind": "attribute", "displayName": "Mode", "group":
"common", "required": false, "type": "enum", "javaType": "java.lang.String",
"enum": [ "i", "w", "u", "t" ], "deprecated": false, "autowired": false,
"secret": false, "defaultValue": "i", "description": "The extraction mode. The
available extraction modes are: i - injecting the contextual namespace bindings
into the extracted token (default), w - wrapping the extracted token in its
ancestor context, u - unwrap [...]
"group": { "index": 3, "kind": "attribute", "displayName": "Group",
"group": "common", "required": false, "type": "integer", "javaType":
"java.lang.Integer", "deprecated": false, "autowired": false, "secret": false,
"description": "To group N parts together." },
"namespace": { "index": 4, "kind": "element", "displayName": "Namespace",
"group": "common", "label": "common", "required": false, "type": "array",
"javaType": "java.util.List<org.apache.camel.model.PropertyDefinition>",
"deprecated": false, "autowired": false, "secret": false, "description":
"Injects the XML Namespaces of prefix to uri mappings." },
- "namespacesRef": { "index": 5, "kind": "attribute", "displayName":
"Namespaces Ref", "group": "advanced", "label": "advanced", "required": false,
"type": "string", "javaType": "java.lang.String", "deprecated": false,
"autowired": false, "secret": false, "description": "Reference to a
org.apache.camel.support.builder.Namespaces bean in the registry to use for the
XML Namespaces of prefix to uri mappings." },
- "source": { "index": 6, "kind": "attribute", "displayName": "Source",
"group": "common", "required": false, "type": "string", "javaType":
"java.lang.String", "deprecated": false, "autowired": false, "secret": false,
"description": "Source to use, instead of message body. You can prefix with
variable:, header:, or property: to specify kind of source. Otherwise, the
source is assumed to be a variable. Use empty or null to use default source,
which is the message body." },
- "resultType": { "index": 7, "kind": "attribute", "displayName": "Result
Type", "group": "common", "required": false, "type": "string", "javaType":
"java.lang.String", "deprecated": false, "autowired": false, "secret": false,
"description": "The class of the result type (type from output)." },
- "trim": { "index": 8, "kind": "attribute", "displayName": "Trim", "group":
"advanced", "label": "advanced", "required": false, "type": "boolean",
"javaType": "java.lang.Boolean", "deprecated": false, "autowired": false,
"secret": false, "defaultValue": true, "description": "Whether to trim the
source code to remove leading and trailing whitespaces and line breaks." },
- "resolveResource": { "index": 9, "kind": "attribute", "displayName":
"Resolve Resource", "group": "advanced", "label": "advanced", "required":
false, "type": "boolean", "javaType": "java.lang.Boolean", "deprecated": false,
"autowired": false, "secret": false, "defaultValue": false, "description":
"Whether a result of the expression that is a String starting with resource: is
loaded as a resource and its content becomes the result, e.g. a script that
returns resource:templates\/order. [...]
+ "namespaceMappings": { "index": 5, "kind": "attribute", "displayName":
"Namespace Mappings", "group": "common", "label": "common", "required": false,
"type": "string", "javaType": "java.lang.String", "deprecated": false,
"autowired": false, "secret": false, "description": "The XML Namespaces of
prefix to uri mappings in one string, such as p1=uri1,p2=uri2. The mappings are
separated by commas or new lines, and the prefix and the uri by the first =.
This allows to configure several na [...]
+ "namespacesRef": { "index": 6, "kind": "attribute", "displayName":
"Namespaces Ref", "group": "advanced", "label": "advanced", "required": false,
"type": "string", "javaType": "java.lang.String", "deprecated": false,
"autowired": false, "secret": false, "description": "Reference to a
org.apache.camel.support.builder.Namespaces bean in the registry to use for the
XML Namespaces of prefix to uri mappings." },
+ "source": { "index": 7, "kind": "attribute", "displayName": "Source",
"group": "common", "required": false, "type": "string", "javaType":
"java.lang.String", "deprecated": false, "autowired": false, "secret": false,
"description": "Source to use, instead of message body. You can prefix with
variable:, header:, or property: to specify kind of source. Otherwise, the
source is assumed to be a variable. Use empty or null to use default source,
which is the message body." },
+ "resultType": { "index": 8, "kind": "attribute", "displayName": "Result
Type", "group": "common", "required": false, "type": "string", "javaType":
"java.lang.String", "deprecated": false, "autowired": false, "secret": false,
"description": "The class of the result type (type from output)." },
+ "trim": { "index": 9, "kind": "attribute", "displayName": "Trim", "group":
"advanced", "label": "advanced", "required": false, "type": "boolean",
"javaType": "java.lang.Boolean", "deprecated": false, "autowired": false,
"secret": false, "defaultValue": true, "description": "Whether to trim the
source code to remove leading and trailing whitespaces and line breaks." },
+ "resolveResource": { "index": 10, "kind": "attribute", "displayName":
"Resolve Resource", "group": "advanced", "label": "advanced", "required":
false, "type": "boolean", "javaType": "java.lang.Boolean", "deprecated": false,
"autowired": false, "secret": false, "defaultValue": false, "description":
"Whether a result of the expression that is a String starting with resource: is
loaded as a resource and its content becomes the result, e.g. a script that
returns resource:templates\/order [...]
}
}
diff --git
a/core/camel-core-model/src/main/java/org/apache/camel/model/language/NamespaceAwareExpression.java
b/core/camel-core-model/src/main/java/org/apache/camel/model/language/NamespaceAwareExpression.java
index 4859617b74fe..0e5c88cdd011 100644
---
a/core/camel-core-model/src/main/java/org/apache/camel/model/language/NamespaceAwareExpression.java
+++
b/core/camel-core-model/src/main/java/org/apache/camel/model/language/NamespaceAwareExpression.java
@@ -46,6 +46,12 @@ public abstract class NamespaceAwareExpression extends
SingleInputTypedExpressio
@XmlTransient
private Map<String, String> namespaces;
@XmlAttribute
+ @Metadata(label = "common",
+ description = "The XML Namespaces of prefix to uri mappings in
one string, such as p1=uri1,p2=uri2. The mappings"
+ + " are separated by commas or new lines, and the
prefix and the uri by the first =. This allows"
+ + " to configure several namespaces from one
property placeholder.")
+ private String namespaceMappings;
+ @XmlAttribute
@Metadata(label = "advanced",
description = "Reference to a
org.apache.camel.support.builder.Namespaces bean in the registry to use for the
XML Namespaces of prefix to uri mappings.")
private String namespacesRef;
@@ -57,6 +63,7 @@ public abstract class NamespaceAwareExpression extends
SingleInputTypedExpressio
super(source);
this.namespace =
ProcessorDefinitionHelper.deepCopyDefinitions(source.namespace);
this.namespaces = source.namespaces != null ? new
LinkedHashMap<>(source.namespaces) : null;
+ this.namespaceMappings = source.namespaceMappings;
this.namespacesRef = source.namespacesRef;
}
@@ -68,6 +75,7 @@ public abstract class NamespaceAwareExpression extends
SingleInputTypedExpressio
super(builder);
this.namespace = builder.namespace;
this.namespaces = builder.namespaces;
+ this.namespaceMappings = builder.namespaceMappings;
this.namespacesRef = builder.namespacesRef;
}
@@ -93,6 +101,14 @@ public abstract class NamespaceAwareExpression extends
SingleInputTypedExpressio
this.namespace = namespace;
}
+ public String getNamespaceMappings() {
+ return namespaceMappings;
+ }
+
+ public void setNamespaceMappings(String namespaceMappings) {
+ this.namespaceMappings = namespaceMappings;
+ }
+
public String getNamespacesRef() {
return namespacesRef;
}
@@ -127,6 +143,7 @@ public abstract class NamespaceAwareExpression extends
SingleInputTypedExpressio
private List<PropertyDefinition> namespace;
private Map<String, String> namespaces;
+ private String namespaceMappings;
private String namespacesRef;
/**
@@ -157,6 +174,17 @@ public abstract class NamespaceAwareExpression extends
SingleInputTypedExpressio
return (T) this;
}
+ /**
+ * The XML Namespaces of prefix -> uri mappings in one string, such as
{@code p1=uri1,p2=uri2}, separated by
+ * commas or new lines.
+ *
+ * @param namespaceMappings the mappings, such as {@code
p1=uri1,p2=uri2}
+ */
+ public T namespaceMappings(String namespaceMappings) {
+ this.namespaceMappings = namespaceMappings;
+ return (T) this;
+ }
+
/**
* Reference to a {@link Namespaces} bean in the registry to use for
the XML Namespaces of prefix -> uri
* mappings
diff --git
a/core/camel-core-reifier/src/main/java/org/apache/camel/reifier/language/XMLTokenizerExpressionReifier.java
b/core/camel-core-reifier/src/main/java/org/apache/camel/reifier/language/XMLTokenizerExpressionReifier.java
index 883536f4300a..9ebb2ada7a7c 100644
---
a/core/camel-core-reifier/src/main/java/org/apache/camel/reifier/language/XMLTokenizerExpressionReifier.java
+++
b/core/camel-core-reifier/src/main/java/org/apache/camel/reifier/language/XMLTokenizerExpressionReifier.java
@@ -16,12 +16,14 @@
*/
package org.apache.camel.reifier.language;
+import java.util.LinkedHashMap;
import java.util.Map;
import org.apache.camel.CamelContext;
import org.apache.camel.model.language.ExpressionDefinition;
import org.apache.camel.model.language.XMLTokenizerExpression;
import org.apache.camel.support.builder.Namespaces;
+import org.apache.camel.util.ObjectHelper;
public class XMLTokenizerExpressionReifier extends
SingleInputTypedExpressionReifier<XMLTokenizerExpression> {
@@ -30,8 +32,17 @@ public class XMLTokenizerExpressionReifier extends
SingleInputTypedExpressionRei
}
private Map<String, String> resolveNamespaces() {
+ // the inline namespaces: the mappings of namespaceMappings, and the
namespace entries, which win for the same prefix
+ Map<String, String> inline = new LinkedHashMap<>();
+ String mappings = parseString(definition.getNamespaceMappings());
+ if (ObjectHelper.isNotEmpty(mappings)) {
+ inline.putAll(new Namespaces(mappings).getNamespaces());
+ }
if (definition.getNamespaces() != null &&
!definition.getNamespaces().isEmpty()) {
- return parseMap(definition.getNamespaces());
+ inline.putAll(parseMap(definition.getNamespaces()));
+ }
+ if (!inline.isEmpty()) {
+ return inline;
}
if (definition.getNamespacesRef() != null) {
return parseMap(mandatoryLookup(definition.getNamespacesRef(),
Namespaces.class).getNamespaces());
diff --git
a/core/camel-core-reifier/src/main/java/org/apache/camel/reifier/language/XPathExpressionReifier.java
b/core/camel-core-reifier/src/main/java/org/apache/camel/reifier/language/XPathExpressionReifier.java
index 904ea8d83222..c79fc61dd1fd 100644
---
a/core/camel-core-reifier/src/main/java/org/apache/camel/reifier/language/XPathExpressionReifier.java
+++
b/core/camel-core-reifier/src/main/java/org/apache/camel/reifier/language/XPathExpressionReifier.java
@@ -16,6 +16,7 @@
*/
package org.apache.camel.reifier.language;
+import java.util.LinkedHashMap;
import java.util.Map;
import javax.xml.xpath.XPathConstants;
@@ -27,6 +28,7 @@ import org.apache.camel.model.language.ExpressionDefinition;
import org.apache.camel.model.language.XPathExpression;
import org.apache.camel.spi.Language;
import org.apache.camel.support.builder.Namespaces;
+import org.apache.camel.util.ObjectHelper;
public class XPathExpressionReifier extends
SingleInputTypedExpressionReifier<XPathExpression> {
@@ -35,8 +37,17 @@ public class XPathExpressionReifier extends
SingleInputTypedExpressionReifier<XP
}
private Map<String, String> resolveNamespaces() {
+ // the inline namespaces: the mappings of namespaceMappings, and the
namespace entries, which win for the same prefix
+ Map<String, String> inline = new LinkedHashMap<>();
+ String mappings = parseString(definition.getNamespaceMappings());
+ if (ObjectHelper.isNotEmpty(mappings)) {
+ inline.putAll(new Namespaces(mappings).getNamespaces());
+ }
if (definition.getNamespaces() != null &&
!definition.getNamespaces().isEmpty()) {
- return parseMap(definition.getNamespaces());
+ inline.putAll(parseMap(definition.getNamespaces()));
+ }
+ if (!inline.isEmpty()) {
+ return inline;
}
if (definition.getNamespacesRef() != null) {
return parseMap(mandatoryLookup(definition.getNamespacesRef(),
Namespaces.class).getNamespaces());
diff --git
a/core/camel-core-reifier/src/main/java/org/apache/camel/reifier/language/XQueryExpressionReifier.java
b/core/camel-core-reifier/src/main/java/org/apache/camel/reifier/language/XQueryExpressionReifier.java
index a29d84563013..8e00d4094a33 100644
---
a/core/camel-core-reifier/src/main/java/org/apache/camel/reifier/language/XQueryExpressionReifier.java
+++
b/core/camel-core-reifier/src/main/java/org/apache/camel/reifier/language/XQueryExpressionReifier.java
@@ -16,6 +16,7 @@
*/
package org.apache.camel.reifier.language;
+import java.util.LinkedHashMap;
import java.util.Map;
import org.apache.camel.CamelContext;
@@ -23,6 +24,7 @@ import org.apache.camel.model.language.ExpressionDefinition;
import org.apache.camel.model.language.XQueryExpression;
import org.apache.camel.spi.Language;
import org.apache.camel.support.builder.Namespaces;
+import org.apache.camel.util.ObjectHelper;
public class XQueryExpressionReifier extends
SingleInputTypedExpressionReifier<XQueryExpression> {
@@ -31,8 +33,17 @@ public class XQueryExpressionReifier extends
SingleInputTypedExpressionReifier<X
}
private Map<String, String> resolveNamespaces() {
+ // the inline namespaces: the mappings of namespaceMappings, and the
namespace entries, which win for the same prefix
+ Map<String, String> inline = new LinkedHashMap<>();
+ String mappings = parseString(definition.getNamespaceMappings());
+ if (ObjectHelper.isNotEmpty(mappings)) {
+ inline.putAll(new Namespaces(mappings).getNamespaces());
+ }
if (definition.getNamespaces() != null &&
!definition.getNamespaces().isEmpty()) {
- return parseMap(definition.getNamespaces());
+ inline.putAll(parseMap(definition.getNamespaces()));
+ }
+ if (!inline.isEmpty()) {
+ return inline;
}
if (definition.getNamespacesRef() != null) {
return parseMap(mandatoryLookup(definition.getNamespacesRef(),
Namespaces.class).getNamespaces());
diff --git
a/core/camel-core/src/test/java/org/apache/camel/builder/xml/XPathNamespaceMappingsTest.java
b/core/camel-core/src/test/java/org/apache/camel/builder/xml/XPathNamespaceMappingsTest.java
new file mode 100644
index 000000000000..6df649860bbd
--- /dev/null
+++
b/core/camel-core/src/test/java/org/apache/camel/builder/xml/XPathNamespaceMappingsTest.java
@@ -0,0 +1,116 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements. See the NOTICE file distributed with
+ * this work for additional information regarding copyright ownership.
+ * The ASF licenses this file to You under the Apache License, Version 2.0
+ * (the "License"); you may not use this file except in compliance with
+ * the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+package org.apache.camel.builder.xml;
+
+import java.util.List;
+import java.util.Properties;
+
+import org.apache.camel.ContextTestSupport;
+import org.apache.camel.Predicate;
+import org.apache.camel.model.PropertyDefinition;
+import org.apache.camel.model.language.XPathExpression;
+import org.apache.camel.spi.Registry;
+import org.apache.camel.support.builder.Namespaces;
+import org.junit.jupiter.api.Test;
+
+import static org.assertj.core.api.Assertions.assertThat;
+import static org.assertj.core.api.Assertions.assertThatThrownBy;
+
+/**
+ * An xpath expression with its namespaces inline in one string, the
namespaceMappings option.
+ */
+class XPathNamespaceMappingsTest extends ContextTestSupport {
+
+ private static final String ORDER
+ = "<order xmlns=\"http://acme.com/cheese\"><wine
xmlns=\"http://acme.com/wine\">Rioja</wine></order>";
+
+ @Override
+ protected Properties useOverridePropertiesWithPropertiesComponent() {
+ Properties properties = new Properties();
+ properties.setProperty("namespaces",
"c=http://acme.com/cheese,w=http://acme.com/wine");
+ return properties;
+ }
+
+ @Override
+ protected void bindToRegistry(Registry registry) {
+ registry.bind("otherNamespaces", new Namespaces("c",
"http://acme.com/other").add("w", "http://acme.com/other"));
+ }
+
+ @Test
+ void usesTheMappingsOfTheString() {
+ XPathExpression definition = definition("/c:order/w:wine = 'Rioja'");
+
definition.setNamespaceMappings("c=http://acme.com/cheese,w=http://acme.com/wine");
+ Predicate predicate = definition.createPredicate(context);
+
+ assertThat(predicate.matches(createExchangeWithBody(ORDER))).isTrue();
+ // the wine element in the cheese namespace
+ assertThat(
+ predicate.matches(createExchangeWithBody("<order
xmlns=\"http://acme.com/cheese\"><wine>Rioja</wine></order>")))
+ .isFalse();
+ }
+
+ @Test
+ void resolvesAPropertyPlaceholder() {
+ XPathExpression definition = definition("/c:order/w:wine = 'Rioja'");
+ definition.setNamespaceMappings("{{namespaces}}");
+
+
assertThat(definition.createPredicate(context).matches(createExchangeWithBody(ORDER))).isTrue();
+ }
+
+ @Test
+ void aNamespaceEntryWinsForTheSamePrefix() {
+ XPathExpression definition = definition("/c:order/w:wine = 'Rioja'");
+
definition.setNamespaceMappings("c=http://acme.com/cheese,w=http://acme.com/other");
+ definition.setNamespace(List.of(new PropertyDefinition("w",
"http://acme.com/wine")));
+
+
assertThat(definition.createPredicate(context).matches(createExchangeWithBody(ORDER))).isTrue();
+ }
+
+ @Test
+ void winsOverNamespacesRef() {
+ XPathExpression definition = definition("/c:order/w:wine = 'Rioja'");
+
definition.setNamespaceMappings("c=http://acme.com/cheese,w=http://acme.com/wine");
+ definition.setNamespacesRef("otherNamespaces");
+
+
assertThat(definition.createPredicate(context).matches(createExchangeWithBody(ORDER))).isTrue();
+ }
+
+ @Test
+ void anEmptyStringFallsBackToNamespacesRef() {
+ XPathExpression definition = definition("/c:order/w:wine = 'Rioja'");
+ definition.setNamespaceMappings("");
+ definition.setNamespacesRef("otherNamespaces");
+
+ // the namespaces of the bean do not match the message
+
assertThat(definition.createPredicate(context).matches(createExchangeWithBody(ORDER))).isFalse();
+ }
+
+ @Test
+ void failsOnAnInvalidMapping() {
+ XPathExpression definition = definition("/c:order");
+ definition.setNamespaceMappings("http://acme.com/cheese");
+
+ assertThatThrownBy(() -> definition.createPredicate(context))
+ .hasStackTraceContaining("Invalid namespace mapping:
http://acme.com/cheese");
+ }
+
+ private static XPathExpression definition(String expression) {
+ XPathExpression definition = new XPathExpression(expression);
+ definition.setResultQName("BOOLEAN");
+ return definition;
+ }
+}
diff --git
a/core/camel-java-io/src/generated/java/org/apache/camel/java/out/JavaDslModelWriter.java
b/core/camel-java-io/src/generated/java/org/apache/camel/java/out/JavaDslModelWriter.java
index b3d22af73c31..77b35073b128 100644
---
a/core/camel-java-io/src/generated/java/org/apache/camel/java/out/JavaDslModelWriter.java
+++
b/core/camel-java-io/src/generated/java/org/apache/camel/java/out/JavaDslModelWriter.java
@@ -3598,6 +3598,7 @@ public class JavaDslModelWriter extends
JavaDslModelWriterSupport {
protected void doWriteNamespaceAwareExpressionAttributes(StringBuilder sb,
NamespaceAwareExpression def) {
doWriteSingleInputTypedExpressionDefinitionAttributes(sb, def);
doWriteAttribute(sb, "namespacesRef", def.getNamespacesRef(), null);
+ doWriteAttribute(sb, "namespaceMappings", def.getNamespaceMappings(),
null);
}
protected void doWriteNamespaceAwareExpressionElements(StringBuilder sb,
NamespaceAwareExpression def) {
doWriteChildList(sb, "namespace", def.getNamespace(),
this::doWritePropertyDefinition);
diff --git
a/core/camel-xml-io/src/generated/java/org/apache/camel/xml/in/ModelParser.java
b/core/camel-xml-io/src/generated/java/org/apache/camel/xml/in/ModelParser.java
index c6681ee220cb..93b56ceb4dea 100644
---
a/core/camel-xml-io/src/generated/java/org/apache/camel/xml/in/ModelParser.java
+++
b/core/camel-xml-io/src/generated/java/org/apache/camel/xml/in/ModelParser.java
@@ -2420,6 +2420,7 @@ public class ModelParser extends BaseParser {
}
protected <T extends NamespaceAwareExpression> AttributeHandler<T>
namespaceAwareExpressionAttributeHandler() {
return (def, key, val) -> switch (key) {
+ case "namespaceMappings": def.setNamespaceMappings(val); yield
true;
case "namespacesRef": def.setNamespacesRef(val); yield true;
default: yield
singleInputTypedExpressionDefinitionAttributeHandler().accept(def, key, val);
};
diff --git
a/core/camel-xml-io/src/generated/java/org/apache/camel/xml/out/ModelWriter.java
b/core/camel-xml-io/src/generated/java/org/apache/camel/xml/out/ModelWriter.java
index daaa5c16f110..510b0ab7d378 100644
---
a/core/camel-xml-io/src/generated/java/org/apache/camel/xml/out/ModelWriter.java
+++
b/core/camel-xml-io/src/generated/java/org/apache/camel/xml/out/ModelWriter.java
@@ -3055,6 +3055,7 @@ public class ModelWriter extends BaseWriter {
protected void
doWriteNamespaceAwareExpressionAttributes(NamespaceAwareExpression def) throws
IOException {
doWriteSingleInputTypedExpressionDefinitionAttributes(def);
doWriteAttribute("namespacesRef", def.getNamespacesRef(), null);
+ doWriteAttribute("namespaceMappings", def.getNamespaceMappings(),
null);
}
protected void
doWriteNamespaceAwareExpressionElements(NamespaceAwareExpression def) throws
IOException {
doWriteList(null, "namespace", def.getNamespace(),
this::doWritePropertyDefinition);
diff --git
a/core/camel-yaml-io/src/generated/java/org/apache/camel/yaml/out/YamlModelWriter.java
b/core/camel-yaml-io/src/generated/java/org/apache/camel/yaml/out/YamlModelWriter.java
index 1383061c3a13..a67448f00693 100644
---
a/core/camel-yaml-io/src/generated/java/org/apache/camel/yaml/out/YamlModelWriter.java
+++
b/core/camel-yaml-io/src/generated/java/org/apache/camel/yaml/out/YamlModelWriter.java
@@ -3057,6 +3057,7 @@ public class YamlModelWriter extends
YamlModelWriterSupport {
protected void doWriteNamespaceAwareExpressionAttributes(JsonObject jo,
NamespaceAwareExpression def) {
doWriteSingleInputTypedExpressionDefinitionAttributes(jo, def);
doWriteAttribute(jo, "namespacesRef", def.getNamespacesRef(), null);
+ doWriteAttribute(jo, "namespaceMappings", def.getNamespaceMappings(),
null);
}
protected void doWriteNamespaceAwareExpressionElements(JsonObject jo,
NamespaceAwareExpression def) {
doWriteChildList(jo, null, "namespace", def.getNamespace(),
this::doWritePropertyDefinition);
diff --git
a/dsl/camel-yaml-dsl/camel-yaml-dsl-deserializers/src/generated/java/org/apache/camel/dsl/yaml/deserializers/ModelDeserializers.java
b/dsl/camel-yaml-dsl/camel-yaml-dsl-deserializers/src/generated/java/org/apache/camel/dsl/yaml/deserializers/ModelDeserializers.java
index 3824e4012a03..9f6063ca362f 100644
---
a/dsl/camel-yaml-dsl/camel-yaml-dsl-deserializers/src/generated/java/org/apache/camel/dsl/yaml/deserializers/ModelDeserializers.java
+++
b/dsl/camel-yaml-dsl/camel-yaml-dsl-deserializers/src/generated/java/org/apache/camel/dsl/yaml/deserializers/ModelDeserializers.java
@@ -21344,6 +21344,7 @@ public final class ModelDeserializers extends
YamlDeserializerSupport {
@YamlProperty(name = "id", type = "string", description =
"The id of this node.", displayName = "Id"),
@YamlProperty(name = "mode", type = "enum:i,w,u,t",
defaultValue = "i", description = "The extraction mode. The available
extraction modes are: i - injecting the contextual namespace bindings into the
extracted token (default), w - wrapping the extracted token in its ancestor
context, u - unwrapping the extracted token to its child content, t -
extracting the text content of the specified element.", displayName = "Mode"),
@YamlProperty(name = "namespace", type =
"array:org.apache.camel.model.PropertyDefinition", description = "Injects the
XML Namespaces of prefix to uri mappings.", displayName = "Namespace"),
+ @YamlProperty(name = "namespaceMappings", type = "string",
description = "The XML Namespaces of prefix to uri mappings in one string, such
as p1=uri1,p2=uri2. The mappings are separated by commas or new lines, and the
prefix and the uri by the first =. This allows to configure several namespaces
from one property placeholder.", displayName = "Namespace Mappings"),
@YamlProperty(name = "namespacesRef", type = "string",
description = "Reference to a org.apache.camel.support.builder.Namespaces bean
in the registry to use for the XML Namespaces of prefix to uri mappings.",
displayName = "Namespaces Ref"),
@YamlProperty(name = "resolveResource", type = "boolean",
defaultValue = "false", description = "Whether a result of the expression that
is a String starting with resource: is loaded as a resource and its content
becomes the result, e.g. a script that returns resource:templates/order.json.
The name has no scheme and is loaded from the classpath: camel run puts the
files given on the command line on the classpath and export puts them in
src/main/resources, so the same [...]
@YamlProperty(name = "resultType", type = "string",
description = "The class of the result type (type from output).", displayName =
"Result Type"),
@@ -21396,6 +21397,11 @@ public final class ModelDeserializers extends
YamlDeserializerSupport {
target.setNamespace(val);
break;
}
+ case "namespaceMappings": {
+ String val = asText(node);
+ target.setNamespaceMappings(val);
+ break;
+ }
case "namespacesRef": {
String val = asText(node);
target.setNamespacesRef(val);
@@ -21454,6 +21460,7 @@ public final class ModelDeserializers extends
YamlDeserializerSupport {
@YamlProperty(name = "id", type = "string", description =
"The id of this node.", displayName = "Id"),
@YamlProperty(name = "logNamespaces", type = "boolean",
defaultValue = "false", description = "Whether to log namespaces which can
assist during troubleshooting.", displayName = "Log Namespaces"),
@YamlProperty(name = "namespace", type =
"array:org.apache.camel.model.PropertyDefinition", description = "Injects the
XML Namespaces of prefix to uri mappings.", displayName = "Namespace"),
+ @YamlProperty(name = "namespaceMappings", type = "string",
description = "The XML Namespaces of prefix to uri mappings in one string, such
as p1=uri1,p2=uri2. The mappings are separated by commas or new lines, and the
prefix and the uri by the first =. This allows to configure several namespaces
from one property placeholder.", displayName = "Namespace Mappings"),
@YamlProperty(name = "namespacesRef", type = "string",
description = "Reference to a org.apache.camel.support.builder.Namespaces bean
in the registry to use for the XML Namespaces of prefix to uri mappings.",
displayName = "Namespaces Ref"),
@YamlProperty(name = "objectModel", type = "string",
description = "The XPath object model to use.", displayName = "Object Model"),
@YamlProperty(name = "preCompile", type = "boolean",
defaultValue = "true", description = "Whether to enable pre-compiling the xpath
expression during initialization phase. pre-compile is enabled by default.",
displayName = "Pre Compile"),
@@ -21516,6 +21523,11 @@ public final class ModelDeserializers extends
YamlDeserializerSupport {
target.setNamespace(val);
break;
}
+ case "namespaceMappings": {
+ String val = asText(node);
+ target.setNamespaceMappings(val);
+ break;
+ }
case "namespacesRef": {
String val = asText(node);
target.setNamespacesRef(val);
@@ -21597,6 +21609,7 @@ public final class ModelDeserializers extends
YamlDeserializerSupport {
@YamlProperty(name = "expression", type = "string",
required = true, description = "The expression value in your chosen language
syntax.", displayName = "Expression"),
@YamlProperty(name = "id", type = "string", description =
"The id of this node.", displayName = "Id"),
@YamlProperty(name = "namespace", type =
"array:org.apache.camel.model.PropertyDefinition", description = "Injects the
XML Namespaces of prefix to uri mappings.", displayName = "Namespace"),
+ @YamlProperty(name = "namespaceMappings", type = "string",
description = "The XML Namespaces of prefix to uri mappings in one string, such
as p1=uri1,p2=uri2. The mappings are separated by commas or new lines, and the
prefix and the uri by the first =. This allows to configure several namespaces
from one property placeholder.", displayName = "Namespace Mappings"),
@YamlProperty(name = "namespacesRef", type = "string",
description = "Reference to a org.apache.camel.support.builder.Namespaces bean
in the registry to use for the XML Namespaces of prefix to uri mappings.",
displayName = "Namespaces Ref"),
@YamlProperty(name = "resolveResource", type = "boolean",
defaultValue = "false", description = "Whether a result of the expression that
is a String starting with resource: is loaded as a resource and its content
becomes the result, e.g. a script that returns resource:templates/order.json.
The name has no scheme and is loaded from the classpath: camel run puts the
files given on the command line on the classpath and export puts them in
src/main/resources, so the same [...]
@YamlProperty(name = "resultType", type = "string",
description = "The class of the result type (type from output).", displayName =
"Result Type"),
@@ -21644,6 +21657,11 @@ public final class ModelDeserializers extends
YamlDeserializerSupport {
target.setNamespace(val);
break;
}
+ case "namespaceMappings": {
+ String val = asText(node);
+ target.setNamespaceMappings(val);
+ break;
+ }
case "namespacesRef": {
String val = asText(node);
target.setNamespacesRef(val);
diff --git
a/dsl/camel-yaml-dsl/camel-yaml-dsl/src/generated/resources/schema/camelYamlDsl-canonical.json
b/dsl/camel-yaml-dsl/camel-yaml-dsl/src/generated/resources/schema/camelYamlDsl-canonical.json
index b9c86685e328..83f3fa43c2d1 100644
---
a/dsl/camel-yaml-dsl/camel-yaml-dsl/src/generated/resources/schema/camelYamlDsl-canonical.json
+++
b/dsl/camel-yaml-dsl/camel-yaml-dsl/src/generated/resources/schema/camelYamlDsl-canonical.json
@@ -10842,6 +10842,11 @@
"$ref" :
"#/items/definitions/org.apache.camel.model.PropertyDefinition"
}
},
+ "namespaceMappings" : {
+ "type" : "string",
+ "title" : "Namespace Mappings",
+ "description" : "The XML Namespaces of prefix to uri mappings in
one string, such as p1=uri1,p2=uri2. The mappings are separated by commas or
new lines, and the prefix and the uri by the first =. This allows to configure
several namespaces from one property placeholder."
+ },
"namespacesRef" : {
"type" : "string",
"title" : "Namespaces Ref",
@@ -10912,6 +10917,11 @@
"$ref" :
"#/items/definitions/org.apache.camel.model.PropertyDefinition"
}
},
+ "namespaceMappings" : {
+ "type" : "string",
+ "title" : "Namespace Mappings",
+ "description" : "The XML Namespaces of prefix to uri mappings in
one string, such as p1=uri1,p2=uri2. The mappings are separated by commas or
new lines, and the prefix and the uri by the first =. This allows to configure
several namespaces from one property placeholder."
+ },
"namespacesRef" : {
"type" : "string",
"title" : "Namespaces Ref",
@@ -11001,6 +11011,11 @@
"$ref" :
"#/items/definitions/org.apache.camel.model.PropertyDefinition"
}
},
+ "namespaceMappings" : {
+ "type" : "string",
+ "title" : "Namespace Mappings",
+ "description" : "The XML Namespaces of prefix to uri mappings in
one string, such as p1=uri1,p2=uri2. The mappings are separated by commas or
new lines, and the prefix and the uri by the first =. This allows to configure
several namespaces from one property placeholder."
+ },
"namespacesRef" : {
"type" : "string",
"title" : "Namespaces Ref",
diff --git
a/dsl/camel-yaml-dsl/camel-yaml-dsl/src/generated/resources/schema/camelYamlDsl-model.json
b/dsl/camel-yaml-dsl/camel-yaml-dsl/src/generated/resources/schema/camelYamlDsl-model.json
index 8b724bfdacdf..9c703d567124 100644
---
a/dsl/camel-yaml-dsl/camel-yaml-dsl/src/generated/resources/schema/camelYamlDsl-model.json
+++
b/dsl/camel-yaml-dsl/camel-yaml-dsl/src/generated/resources/schema/camelYamlDsl-model.json
@@ -16422,6 +16422,11 @@
"ref" : "property",
"description" : "Injects the XML Namespaces of prefix to uri
mappings.",
"title" : "Namespace"
+ }, {
+ "name" : "namespaceMappings",
+ "type" : "string",
+ "description" : "The XML Namespaces of prefix to uri mappings in one
string, such as p1=uri1,p2=uri2. The mappings are separated by commas or new
lines, and the prefix and the uri by the first =. This allows to configure
several namespaces from one property placeholder.",
+ "title" : "Namespace Mappings"
}, {
"name" : "namespacesRef",
"type" : "string",
@@ -16487,6 +16492,11 @@
"ref" : "property",
"description" : "Injects the XML Namespaces of prefix to uri
mappings.",
"title" : "Namespace"
+ }, {
+ "name" : "namespaceMappings",
+ "type" : "string",
+ "description" : "The XML Namespaces of prefix to uri mappings in one
string, such as p1=uri1,p2=uri2. The mappings are separated by commas or new
lines, and the prefix and the uri by the first =. This allows to configure
several namespaces from one property placeholder.",
+ "title" : "Namespace Mappings"
}, {
"name" : "namespacesRef",
"type" : "string",
@@ -16571,6 +16581,11 @@
"ref" : "property",
"description" : "Injects the XML Namespaces of prefix to uri
mappings.",
"title" : "Namespace"
+ }, {
+ "name" : "namespaceMappings",
+ "type" : "string",
+ "description" : "The XML Namespaces of prefix to uri mappings in one
string, such as p1=uri1,p2=uri2. The mappings are separated by commas or new
lines, and the prefix and the uri by the first =. This allows to configure
several namespaces from one property placeholder.",
+ "title" : "Namespace Mappings"
}, {
"name" : "namespacesRef",
"type" : "string",
diff --git
a/dsl/camel-yaml-dsl/camel-yaml-dsl/src/generated/resources/schema/camelYamlDsl.json
b/dsl/camel-yaml-dsl/camel-yaml-dsl/src/generated/resources/schema/camelYamlDsl.json
index 4b80c4f93513..44545ab78493 100644
---
a/dsl/camel-yaml-dsl/camel-yaml-dsl/src/generated/resources/schema/camelYamlDsl.json
+++
b/dsl/camel-yaml-dsl/camel-yaml-dsl/src/generated/resources/schema/camelYamlDsl.json
@@ -13237,6 +13237,11 @@
"$ref" :
"#/items/definitions/org.apache.camel.model.PropertyDefinition"
}
},
+ "namespaceMappings" : {
+ "type" : "string",
+ "title" : "Namespace Mappings",
+ "description" : "The XML Namespaces of prefix to uri mappings in
one string, such as p1=uri1,p2=uri2. The mappings are separated by commas or
new lines, and the prefix and the uri by the first =. This allows to configure
several namespaces from one property placeholder."
+ },
"namespacesRef" : {
"type" : "string",
"title" : "Namespaces Ref",
@@ -13311,6 +13316,11 @@
"$ref" :
"#/items/definitions/org.apache.camel.model.PropertyDefinition"
}
},
+ "namespaceMappings" : {
+ "type" : "string",
+ "title" : "Namespace Mappings",
+ "description" : "The XML Namespaces of prefix to uri mappings in
one string, such as p1=uri1,p2=uri2. The mappings are separated by commas or
new lines, and the prefix and the uri by the first =. This allows to configure
several namespaces from one property placeholder."
+ },
"namespacesRef" : {
"type" : "string",
"title" : "Namespaces Ref",
@@ -13404,6 +13414,11 @@
"$ref" :
"#/items/definitions/org.apache.camel.model.PropertyDefinition"
}
},
+ "namespaceMappings" : {
+ "type" : "string",
+ "title" : "Namespace Mappings",
+ "description" : "The XML Namespaces of prefix to uri mappings in
one string, such as p1=uri1,p2=uri2. The mappings are separated by commas or
new lines, and the prefix and the uri by the first =. This allows to configure
several namespaces from one property placeholder."
+ },
"namespacesRef" : {
"type" : "string",
"title" : "Namespaces Ref",
diff --git
a/dsl/camel-yaml-dsl/camel-yaml-dsl/src/test/java/org/apache/camel/dsl/yaml/XPathNamespacesRefYamlDslTest.java
b/dsl/camel-yaml-dsl/camel-yaml-dsl/src/test/java/org/apache/camel/dsl/yaml/XPathNamespacesRefYamlDslTest.java
index fdfc6f6a9967..16d496f5d0bb 100644
---
a/dsl/camel-yaml-dsl/camel-yaml-dsl/src/test/java/org/apache/camel/dsl/yaml/XPathNamespacesRefYamlDslTest.java
+++
b/dsl/camel-yaml-dsl/camel-yaml-dsl/src/test/java/org/apache/camel/dsl/yaml/XPathNamespacesRefYamlDslTest.java
@@ -143,4 +143,44 @@ class XPathNamespacesRefYamlDslTest {
match.assertIsSatisfied();
}
}
+
+ @Test
+ void loadsXPathWithNamespaceMappingsInline() throws Exception {
+ try (DefaultCamelContext context = new DefaultCamelContext()) {
+ // several namespaces in one property, inline in the xpath, as in
a Kamelet
+ Properties properties = new Properties();
+ properties.setProperty("namespaces",
"c=http://acme.com/cheese,w=http://acme.com/wine");
+ context.getPropertiesComponent().setInitialProperties(properties);
+
+ YamlRoutesBuilderLoader loader = new YamlRoutesBuilderLoader();
+ loader.setCamelContext(context);
+ RoutesBuilder routesBuilder
+ =
loader.loadRoutesBuilder(ResourceHelper.fromString("xpath-namespace-mappings.yaml",
"""
+ - route:
+ from:
+ uri: "direct:start"
+ steps:
+ - filter:
+ xpath:
+ expression: "/c:order/w:wine =
'Rioja'"
+ resultQName: "BOOLEAN"
+ namespaceMappings: "{{namespaces}}"
+ steps:
+ - to: "mock:match"
+ """));
+ context.addRoutes(routesBuilder);
+ context.start();
+
+ MockEndpoint match = context.getEndpoint("mock:match",
MockEndpoint.class);
+ match.expectedBodiesReceived(
+ "<order xmlns=\"http://acme.com/cheese\"><wine
xmlns=\"http://acme.com/wine\">Rioja</wine></order>");
+
+ context.createProducerTemplate().sendBody("direct:start",
+ "<order xmlns=\"http://acme.com/cheese\"><wine
xmlns=\"http://acme.com/wine\">Rioja</wine></order>");
+ context.createProducerTemplate().sendBody("direct:start",
+ "<order
xmlns=\"http://acme.com/cheese\"><wine>Rioja</wine></order>");
+
+ match.assertIsSatisfied();
+ }
+ }
}