davsclaus commented on code in PR #25977:
URL: https://github.com/apache/camel/pull/25977#discussion_r3897632922
##########
components/camel-stax/src/main/docs/xtokenize-language.adoc:
##########
@@ -25,4 +44,100 @@ include::partial$language-options.adoc[]
== Example
-See xref:eips:split-eip.adoc[Split EIP], which has examples using the XML
Tokenize language.
+Suppose the input XML contains multiple orders:
+
+[source,xml]
+----
+<?xml version="1.0" encoding="UTF-8"?>
+<orders xmlns="urn:shop">
+ <order>
+ <id>1001</id>
+ <customer>John</customer>
+ </order>
+ <order>
+ <id>1002</id>
+ <customer>Jane</customer>
+ </order>
+</orders>
+----
+
+The XML Tokenize language can be used with the Split EIP to split the document
+into one message for each `order` element.
+
+[tabs]
+====
+Java::
++
+[source,java]
+----
+var ns = new org.apache.camel.support.builder.Namespaces("shop", "urn:shop");
+
+from("direct:start")
+ .split()
+ .xtokenize("//shop:order", 'i', ns)
+ .streaming()
+ .to("mock:order");
+----
+
+XML::
++
+[source,xml]
+----
+<route>
+ <from uri="direct:start"/>
+ <split streaming="true">
+ <xtokenize>//shop:order
+ <namespace key="shop" value="urn:shop"/>
+ </xtokenize>
+ <to uri="mock:order"/>
+ </split>
+</route>
+----
+
+YAML::
++
+[source,yaml]
+----
+- route:
+ from:
+ uri: 'direct:start'
+ steps:
+ - split:
+ streaming: 'true'
+ expression:
+ xtokenize:
+ expression: '//shop:order'
+ namespace:
+ ns1: 'urn:shop'
Review Comment:
This YAML is not valid for the actual schema and would fail validation if a
user copy-pasted it. Per the generated YAML DSL schema (`camelYamlDsl.json`),
`XMLTokenizerExpression.namespace` is an **array** of `{key, value}` objects,
not a map — and `additionalProperties: false` means a bare map like `ns1:
'urn:shop'` will be rejected.
Also, for consistency with the Java/XML examples above (which both use
prefix `shop`, matching the `//shop:order` expression), this should use `shop`
rather than `ns1` — otherwise the XPath prefix in the expression won't resolve
against the declared namespace.
```suggestion
namespace:
- key: shop
value: 'urn:shop'
```
--
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]