You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@daffodil.apache.org by sl...@apache.org on 2021/11/22 17:55:45 UTC
[daffodil] branch main updated: Remove duplicate prefix mapping check in SAX infosets
This is an automated email from the ASF dual-hosted git repository.
slawrence pushed a commit to branch main
in repository https://gitbox.apache.org/repos/asf/daffodil.git
The following commit(s) were added to refs/heads/main by this push:
new c8d7d1e Remove duplicate prefix mapping check in SAX infosets
c8d7d1e is described below
commit c8d7d1e3082815e33690d8ace2943123fab0f943
Author: Steve Lawrence <sl...@apache.org>
AuthorDate: Thu Nov 4 09:51:04 2021 -0400
Remove duplicate prefix mapping check in SAX infosets
When converting SAX events to text using our built-in ContentHandler, we
intentionally do not output namespace prefix mappings if a prefix has
already been mapped to the same namespace. This differs from the
XMLTextInfosetOutputter behavior, which does not do this duplicate
removal. So for example, the XMLTextInfosetOutputter might output an
infoset like this with duplicate namespace mappings:
<ns:a xmlns:ns="foo">
<ns:b xmlns:ns="foo">test</ns:b>
</ns:a>
But when using SAX we would output this, with the duplicate mapping
removed:
<ns:a xmlns:ns="foo">
<ns:b>test</ns:b>
</ns:a>
Although these two infosets are functionally the same, our TDMLRunner
requires that they be exactly the same, including the namespace prefix
mappings on every element. Otherwise the TDMLRunner throws an exception
and the test fails.
Ideally, these two infoset outputters would always have the same output.
Also, one could argue that our SAX ContentHandler should more closely
match the SAX events, so if we get events with duplicate mappings, the
ContentHandler should output duplicate mappings. So this modifies the
ContentHandler so that it does not remove duplicate mappings, and it
matches the XMLTextInfosetOutputter behavior/output, allowing tests to
pass.
DAFFODIL-2568
---
.../processors/DaffodilParseOutputStreamContentHandler.scala | 8 +-------
1 file changed, 1 insertion(+), 7 deletions(-)
diff --git a/daffodil-runtime1/src/main/scala/org/apache/daffodil/processors/DaffodilParseOutputStreamContentHandler.scala b/daffodil-runtime1/src/main/scala/org/apache/daffodil/processors/DaffodilParseOutputStreamContentHandler.scala
index 12a9069..fc639c1 100644
--- a/daffodil-runtime1/src/main/scala/org/apache/daffodil/processors/DaffodilParseOutputStreamContentHandler.scala
+++ b/daffodil-runtime1/src/main/scala/org/apache/daffodil/processors/DaffodilParseOutputStreamContentHandler.scala
@@ -214,13 +214,7 @@ class DaffodilParseOutputStreamContentHandler(out: OutputStream, pretty: Boolean
while (currentElementPrefixMapping != null) {
val prefix = currentElementPrefixMapping.prefix
val uri = currentElementPrefixMapping.uri
-
- // check to see if the prefix is already mapped to the same URI. If it
- // is, ignore this mapping since it adds nothing new
- val maybeUri = XMLUtils.maybeURI(activePrefixMapping, prefix)
- if (maybeUri.isEmpty || maybeUri.get != uri) {
- activePrefixMapping = NamespaceBinding(prefix, uri, activePrefixMapping)
- }
+ activePrefixMapping = NamespaceBinding(prefix, uri, activePrefixMapping)
currentElementPrefixMapping = currentElementPrefixMapping.parent
}