stevedlawrence commented on a change in pull request #654:
URL: https://github.com/apache/daffodil/pull/654#discussion_r732794748



##########
File path: 
daffodil-runtime1/src/main/scala/org/apache/daffodil/infoset/SAXInfosetOutputter.scala
##########
@@ -180,14 +180,50 @@ class SAXInfosetOutputter(xmlReader: 
DFDL.DaffodilParseXMLReader,
     attrs
   }
 
+  /**
+   * Copied (with slight modification) from Scala-XML NamespaceBinding.scala to
+   * ensure we use the same logic to convert NamespaceBindings to mappings as
+   * other InfosetOutputters that use NamespaceBinding.buildString(stop)
+   */
+  private def shadowRedefined(start: NamespaceBinding, stop: 
NamespaceBinding): NamespaceBinding = {
+    def prefixList(x: NamespaceBinding): List[String] =
+      if ((x == null) || (x eq stop)) Nil
+      else x.prefix :: prefixList(x.parent)
+    def fromPrefixList(l: List[String]): NamespaceBinding = l match {
+      case Nil     => stop
+      case x :: xs => new NamespaceBinding(x, start.getURI(x), 
fromPrefixList(xs))
+    }
+    val ps0 = prefixList(start).reverse
+    val ps = ps0.distinct
+    if (ps.size == ps0.size) start
+    else fromPrefixList(ps)

Review comment:
       I think I've determined that this is in fact dead code that cannot be 
hit. The only case when `fromPrefixList` is called is when `ps.size != 
ps0.size`, and since `ps = ps0.distinct` that only happens when there there are 
duplicate prefixes in the namespace bindings. Our minimizedScope logic should 
remove duplicate namespace prefix bindings, and so this shouldn't be 
possible--`ps.size` will always equal `ps0.size` so fromPrefixList is never 
called.
   
   I think it's worth keeping this code to make it clear this is unaltered from 
Scala XML, but I'll update this to add a comment that mentions why this is dead 
code and disable the code coverage check on these lines. 




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