SreedharAvvari opened a new issue, #3957:
URL: https://github.com/apache/incubator-kie-tools/issues/3957

   ## Summary
   
   When `@kie-tools/dmn-marshaller` upgrades a DMN document, it can overwrite 
an occupied namespace prefix while adding the KIE extension namespace. 
QName-valued attributes are preserved lexically, so the resulting XML remains 
well-formed but the QNames resolve to a different namespace.
   
   The prefix `kie` is not reserved by XML or DMN and may legally be used by 
the source document.
   
   ## Reproduction
   
   Using `@kie-tools/dmn-marshaller` 10.2.0:
   
   ```ts
   import { getMarshaller } from "@kie-tools/dmn-marshaller";
   
   const xml = `<?xml version="1.0" encoding="UTF-8"?>
   <definitions xmlns="http://www.omg.org/spec/DMN/20180521/MODEL/";
                xmlns:dmndi="http://www.omg.org/spec/DMN/20180521/DMNDI/";
                xmlns:dc="http://www.omg.org/spec/DMN/20180521/DC/";
                xmlns:kie="urn:example:model"
                id="definitions_1"
                name="Prefix collision example"
                namespace="urn:example:model">
     <decision id="decision_1" name="Example decision" />
     <dmndi:DMNDI>
       <dmndi:DMNDiagram id="diagram_1">
         <dmndi:DMNShape id="shape_1" dmnElementRef="kie:decision_1">
           <dc:Bounds x="0" y="0" width="100" height="50" />
         </dmndi:DMNShape>
       </dmndi:DMNDiagram>
     </dmndi:DMNDI>
   </definitions>`;
   
   const marshaller = getMarshaller(xml, { upgradeTo: "1.5" });
   const output = marshaller.builder.build(marshaller.parser.parse());
   ```
   
   ## Actual result
   
   The source QName resolves to `{urn:example:model}decision_1`. After the 
upgrade, the relevant output is effectively:
   
   ```xml
   <definitions xmlns:kie="https://kie.org/dmn/extensions/1.0"; ...>
     ...
     <dmndi:DMNShape dmnElementRef="kie:decision_1" ... />
   </definitions>
   ```
   
   The unchanged lexical QName now resolves to 
`{https://kie.org/dmn/extensions/1.0}decision_1`, changing the reference's 
meaning.
   
   ## Expected result
   
   Namespace injection should never replace an existing prefix-to-URI binding. 
If the preferred KIE prefix is occupied, the marshaller should allocate another 
available prefix, such as `kie1`, while preserving the expanded names of all 
existing QName-valued content.
   
   ## Likely source
   
   The XML builder currently assigns generated namespace declarations without 
first checking whether the preferred prefix is already bound to another URI:
   
   
https://github.com/apache/incubator-kie-tools/blob/ac23a2262ba242e8357aac2924436f5fa3041ca9/packages/xml-parser-ts/src/index.ts#L161-L170
   
   ## Environment
   
   - `@kie-tools/dmn-marshaller`: 10.2.0
   - Node.js: 22.19.0
   - OS: macOS 26.5.2
   


-- 
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]


---------------------------------------------------------------------
To unsubscribe, e-mail: [email protected]
For additional commands, e-mail: [email protected]

Reply via email to