[
https://issues.apache.org/jira/browse/CAMEL-25481?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel&focusedCommentId=18125384#comment-18125384
]
Claus Ibsen commented on CAMEL-25481:
-------------------------------------
Analysis (measured with the DataWeave CLI 2.12 and the DataSonnet XML plugin):
XML output already fails at conversion (attributes key @(...), namespaces). XML
input is silently wrong today:
* payload.Envelope.Body... on prefixed elements (SOAP) gives null: the
DataSonnet reader keeps prefixed keys (soapenv:Envelope), DataWeave selectors
match the local name.
* writing an element (or the payload) as JSON leaks the DataSonnet XML model ($
text, ~ order, @ attributes) instead of DataWeave's
{"item":"apple","item":"pear","empty":null,...}.
* an empty element is "" instead of null; keysOf/sizeOf/mapObject/pluck on an
element see the @ and ~ keys.
Plan:
Phase 1 (dataweave library, at runtime, keyed on the ~ element marker so JSON
input is unaffected): selectors match the local name of prefixed elements (and
ns-qualified selectors by namespace URI), empty text is null, CDATA is text,
element-aware object functions (attributes and order keys skipped, repeated
elements as separate entries, text unwrapped), and a non-XML output turns XML
elements into the DataWeave shape.
Phase 2 (converter): output attributes key @(a: v) as "@a" keys, namespaces ns
p uri / p#name as prefixed keys with an @xmlns declaration on the root,
writeDeclaration=false as omitxmldeclaration=true, and nullasemptyelement=true
so null is written as an empty element as in DataWeave.
Phase 3 (stays TODO at conversion): .@ all attributes, .*@, ..*, .^ metadata,
mixed content order.
Not removable: DataWeave writes duplicate JSON keys for repeated elements, the
converted script gives an array.
_Claude Code on behalf of davsclaus_
> camel-dataweave - XML fidelity (design spike)
> ---------------------------------------------
>
> Key: CAMEL-25481
> URL: https://issues.apache.org/jira/browse/CAMEL-25481
> Project: Camel
> Issue Type: Sub-task
> Reporter: Claus Ibsen
> Assignee: Claus Ibsen
> Priority: Major
>
> Align DataWeave XML semantics with DataSonnet's XML model: element text,
> attributes @(..) on output, namespaces ns#, repeated elements, .* on XML
> input; writer properties such as skipNullOn.
--
This message was sent by Atlassian Jira
(v8.20.10#820010)