elharo commented on code in PR #21:
URL: 
https://github.com/apache/maven-xinclude-extension/pull/21#discussion_r2014903731


##########
src/main/java/org/apache/maven/xinclude/stax/XIncludeStreamReader.java:
##########
@@ -266,9 +275,25 @@ private void processInclude() throws XMLStreamException {
                         p = np instanceof Element ? (Element) np : null;
                     }
                     if (!Objects.equals(curLang, impLang)) {
-                        resNode.setAttributeNS(XML_NS_URI, "xml:lang", 
impLang);
+                        resNode.setAttributeNS(XML_NS_URI, XML_NS_PREFIX + 
":lang", impLang);
+                    }
+                    resNode.setAttributeNS(XML_NS_URI, XML_NS_PREFIX + 
":base", input.getSystemId());
+
+                    NamespaceContext context =
+                            
this.contextStack.peek().getReader().getNamespaceContext();
+                    Map<String, String> namespaces = 
getAllNamespaces(resNode.getParentNode());
+                    for (Map.Entry<String, String> entry : 
namespaces.entrySet()) {
+                        String prefix = entry.getKey();
+                        String uri = entry.getValue();
+                        if (context != null
+                                && context.getNamespaceURI(prefix) != null
+                                && 
!uri.equals(context.getNamespaceURI(prefix))) {
+                            resNode.setAttributeNS(
+                                    XMLNS_ATTRIBUTE_NS_URI,
+                                    prefix.isEmpty() ? XMLNS_ATTRIBUTE : 
XMLNS_NS_PREFIX + ":" + prefix,

Review Comment:
   This would be easier to follow with string constants:
   
   ```
   prefix.isEmpty() ? "xmlns" :  "xmlns:" + prefix,
   ```
   
   



##########
src/main/java/org/apache/maven/xinclude/stax/XIncludeStreamReader.java:
##########
@@ -283,7 +308,7 @@ private void processInclude() throws XMLStreamException {
                         }
                     }
                     if (setXmlId != null) {
-                        resNode.setAttributeNS(XML_NS_URI, "xml:id", setXmlId);
+                        resNode.setAttributeNS(XML_NS_URI, XML_NS_PREFIX + 
":id", setXmlId);

Review Comment:
   This would be clearer as just "xml:id".



-- 
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: issues-unsubscr...@maven.apache.org

For queries about this service, please contact Infrastructure at:
us...@infra.apache.org

Reply via email to