davsclaus opened a new pull request, #30691:
URL: https://github.com/apache/camel/pull/30691

   _Claude Code on behalf of davsclaus_
   
   [CAMEL-27485](https://issues.apache.org/jira/browse/CAMEL-27485)
   
   ### Problem
   
   The XPath `namespace` of the DSL is a list of prefix/uri entries. A Kamelet 
option is a single string, so a Kamelet cannot pass a variable number of 
namespaces: xpath-filter-action (apache/camel-kamelets#3378) supports only one 
prefix.
   
   The XPath, XQuery and XML Tokenize model already has `namespacesRef`, a 
reference to an `org.apache.camel.support.builder.Namespaces` bean, and the 
YAML DSL supports it. What was missing is a way to build that bean from one 
string.
   
   ### Change
   
   - New constructor `Namespaces(String mappings)`: `p1=uri1,p2=uri2`, with 
mappings separated by commas or new lines. The prefix ends at the first `=`, so 
a URI may contain `=`. Whitespace is trimmed, and an empty string or `null` 
gives no mappings. A mapping without a prefix or URI throws 
`IllegalArgumentException`.
   - A Kamelet declares the bean from its property and uses `namespacesRef`:
     ```yaml
     - beans:
         - name: myNamespaces
           type: org.apache.camel.support.builder.Namespaces
           constructors:
             0: "{{namespaces}}"
     ```
   - No change to the model or the DSL schemas. This is the smaller alternative 
to a string form of `namespace` in the YAML DSL, chosen this close to the 
release.
   - xpath-language docs: new section "Several namespaces from one string".
   
   ### Tests
   
   - `NamespacesTest` (camel-support): the mappings, whitespace and new lines, 
`=` in a URI, empty input, invalid mappings.
   - `XPathNamespacesRefYamlDslTest#loadsXPathWithNamespacesFromOneString`: a 
YAML route whose Namespaces bean is built from a `{{namespaces}}` property with 
two prefixes, used in a filter with `namespacesRef`. It matches the message 
with both namespaces, and not the one where the inner element is in the wrong 
namespace.
   
   🤖 Generated with [Claude Code](https://claude.com/claude-code)
   


-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

To unsubscribe, e-mail: [email protected]

For queries about this service, please contact Infrastructure at:
[email protected]

Reply via email to