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


##########
impl/maven-xml/src/main/java/org/apache/maven/internal/xml/DefaultXmlService.java:
##########


Review Comment:
   I'm not sure why you check lName == null here. It might be fine but naively 
I'd expect this to be set unconditionally on a startElement



##########
impl/maven-xml/src/main/java/org/apache/maven/internal/xml/DefaultXmlService.java:
##########
@@ -68,10 +69,14 @@ public XmlNode doRead(Reader reader, @Nullable 
XmlService.InputLocationBuilder l
     @Override
     public XmlNode doRead(XMLStreamReader parser, @Nullable 
XmlService.InputLocationBuilder locationBuilder)
             throws XMLStreamException {
-        return doBuild(parser, DEFAULT_TRIM, locationBuilder);
+        return doBuild(parser, DEFAULT_TRIM, locationBuilder, new HashMap<>());
     }
 
-    private XmlNode doBuild(XMLStreamReader parser, boolean trim, 
InputLocationBuilder locationBuilder)
+    private XmlNode doBuild(
+            XMLStreamReader parser,
+            boolean trim,
+            InputLocationBuilder locationBuilder,
+            Map<String, String> parentNamespaces)
             throws XMLStreamException {
         boolean spacePreserve = false;
         String lPrefix = null;

Review Comment:
   I'm  not sure what all these l's stand for. local? location? something else? 
Unabbreviated names for the win.



##########
impl/maven-xml/src/main/java/org/apache/maven/internal/xml/DefaultXmlService.java:
##########
@@ -93,6 +99,15 @@ private XmlNode doBuild(XMLStreamReader parser, boolean 
trim, InputLocationBuild
                     lNamespaceUri = parser.getNamespaceURI();
                     lName = parser.getLocalName();
                     location = locationBuilder != null ? 
locationBuilder.toInputLocation(parser) : null;
+                    // Build the namespace context: start with inherited, add 
local declarations
+                    nsContext = new HashMap<>(parentNamespaces);
+                    for (int i = 0; i < namespacesSize; i++) {
+                        String nsPrefix = parser.getNamespacePrefix(i);
+                        String nsUri = parser.getNamespaceURI(i);
+                        if (nsPrefix != null && !nsPrefix.isEmpty()) {

Review Comment:
   so you're not putting the default namespace in the map? That's fine as long 
as the calling code expects that



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