gnodet commented on code in PR #11823:
URL: https://github.com/apache/maven/pull/11823#discussion_r2982265699


##########
impl/maven-xml/src/main/java/org/apache/maven/internal/xml/DefaultXmlService.java:
##########
@@ -178,6 +176,42 @@ private void writeNode(XMLStreamWriter xmlWriter, XmlNode 
node) throws XMLStream
         xmlWriter.writeEndElement();
     }
 
+    static void writeAttributes(XMLStreamWriter xmlWriter, Map<String, String> 
attributes) throws XMLStreamException {

Review Comment:
   _Claude Code on behalf of Guillaume Nodet_
   
   Good catch — made it `private`. It's not called from the generated template 
(which has its own copy of the logic).



##########
impl/maven-xml/src/main/java/org/apache/maven/internal/xml/DefaultXmlService.java:
##########
@@ -178,6 +176,42 @@ private void writeNode(XMLStreamWriter xmlWriter, XmlNode 
node) throws XMLStream
         xmlWriter.writeEndElement();
     }
 
+    static void writeAttributes(XMLStreamWriter xmlWriter, Map<String, String> 
attributes) throws XMLStreamException {
+        // Write namespace declarations first, then regular attributes
+        for (Map.Entry<String, String> attr : attributes.entrySet()) {

Review Comment:
   _Claude Code on behalf of Guillaume Nodet_
   
   Good point. Maven uses StAX (XMLStreamReader) for parsing. The namespace 
declarations are reported separately via 
`getNamespaceCount()`/`getNamespacePrefix()`/`getNamespaceURI()` — they are NOT 
included in the attribute list (`getAttributeCount()`). However, during parsing 
in `doBuild()`, we explicitly store them as `xmlns:prefix` entries in the 
attributes map (see line 99-103). So by the time we write, they are reliably 
present in the map if they were on the original element.



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