You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@daffodil.apache.org by GitBox <gi...@apache.org> on 2021/01/21 00:29:12 UTC

[GitHub] [incubator-daffodil] olabusayoT opened a new pull request #475: SAX API Refactoring

olabusayoT opened a new pull request #475:
URL: https://github.com/apache/incubator-daffodil/pull/475


   Some initial refactoring for the SAX features work
   
   - moved inner classes into classes of their own
   - some refactoring to remove duplicate code
   
   DAFFODIL-2422


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

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



[GitHub] [incubator-daffodil] tuxji commented on a change in pull request #475: SAX API Refactoring

Posted by GitBox <gi...@apache.org>.
tuxji commented on a change in pull request #475:
URL: https://github.com/apache/incubator-daffodil/pull/475#discussion_r561921741



##########
File path: daffodil-runtime1/src/main/scala/org/apache/daffodil/processors/DaffodilParseOutputStreamContentHandler.scala
##########
@@ -0,0 +1,139 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements.  See the NOTICE file distributed with
+ * this work for additional information regarding copyright ownership.
+ * The ASF licenses this file to You under the Apache License, Version 2.0
+ * (the "License"); you may not use this file except in compliance with
+ * the License.  You may obtain a copy of the License at
+ *
+ *     http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+package org.apache.daffodil.processors
+
+import java.io.OutputStream
+import java.io.OutputStreamWriter
+
+import scala.xml.NamespaceBinding
+
+import org.apache.daffodil.infoset.XMLInfosetOutputter
+import org.apache.daffodil.util.Indentable
+import org.apache.daffodil.util.MStackOfBoolean
+import org.xml.sax.Attributes
+import org.xml.sax.ContentHandler
+import org.xml.sax.Locator
+
+class DaffodilParseOutputStreamContentHandler(out: OutputStream, pretty: Boolean = false)
+  extends ContentHandler with Indentable with XMLInfosetOutputter {
+  private val writer = new OutputStreamWriter(out)
+  private var prefixMapping: NamespaceBinding = null
+  private val outputNewlineStack: MStackOfBoolean = {
+    val s = MStackOfBoolean()
+    s.push(false)
+    s
+  }
+
+  // if the top of the stack is true, we have guessed we should output a newline
+  private def outputNewline: Boolean = outputNewlineStack.top
+
+  def reset(): Unit = {
+    resetIndentation()
+    writer.flush()
+    prefixMapping = null
+    outputNewlineStack.clear()
+    outputNewlineStack.push(false) //to match initialization state
+    out.flush()
+  }
+
+  override def setDocumentLocator(locator: Locator): Unit = {
+    // do nothing
+  }
+
+  override def startDocument(): Unit = {
+    writer.write("""<?xml version="1.0" encoding="UTF-8"?>""")
+  }
+
+  override def endDocument(): Unit = {
+    writer.write(System.lineSeparator())
+    writer.flush()
+  }
+
+  override def startPrefixMapping(prefix: String, uri: String): Unit = {
+    val _prefix = if (prefix == "") null else prefix
+    prefixMapping = NamespaceBinding(_prefix, uri, prefixMapping)
+  }
+
+  override def endPrefixMapping(prefix: String): Unit = {
+    // do nothing
+  }
+
+  override def startElement(
+    uri: String, localName: String, qName: String, atts: Attributes): Unit = {
+    // the pop/true removes whatever is on the stack which is our previous guess for whether we
+    // would need a newline after the previous end tag. As we are currently at the start of a new
+    // tag, we want to correct that assumption (in case it was false)
+    outputNewlineStack.pop()
+    outputNewlineStack.push(true)
+    if (pretty) {
+      writer.write(System.lineSeparator())
+      outputIndentation(writer)
+    }
+    // handle start of tag
+    writer.write("<")
+    writer.write(qName)
+    // handle attributes
+    for (i <- 0 until atts.getLength) {
+      val attsValue = atts.getValue(i)
+      val attsQName = atts.getQName(i)
+      writer.write(s""" $attsQName="$attsValue"""")
+    }
+    // handle namespaces
+    if (prefixMapping != null) {
+      val pm = prefixMapping.toString()
+      writer.write(pm)
+      prefixMapping = null
+    }
+    // handle end of tag
+    writer.write(">")
+    incrementIndentation()
+    // this push makes the assumption that we would not need to output a newline after this end
+    // tag is complete
+    outputNewlineStack.push(false)
+  }
+
+  override def endElement(uri: String, localName: String, qName: String): Unit = {
+    decrementIndentation()
+    if (outputNewline) {
+      if (pretty) {
+        writer.write(System.lineSeparator())
+        outputIndentation(writer)
+      }
+    }
+    writer.write("</")
+    writer.write(qName)
+    writer.write(">")
+    outputNewlineStack.pop()
+  }
+
+  override def characters(ch: Array[Char], start: Int, length: Int): Unit = {
+    writer.write(ch, start, length)
+  }
+
+  override def ignorableWhitespace(ch: Array[Char], start: Int, length: Int): Unit = {
+    // do nothing
+  }
+
+  override def processingInstruction(target: String, data: String): Unit = {
+    // do nothing
+  }
+
+  override def skippedEntity(name: String): Unit = {
+    // do nothing

Review comment:
       Interesting, I'm surprised codecov didn't ignore these noop functions without any testable code inside them.  Code coverage is still excellent anyway.

##########
File path: daffodil-runtime1/src/main/scala/org/apache/daffodil/processors/DaffodilParseOutputStreamContentHandler.scala
##########
@@ -0,0 +1,139 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements.  See the NOTICE file distributed with
+ * this work for additional information regarding copyright ownership.
+ * The ASF licenses this file to You under the Apache License, Version 2.0
+ * (the "License"); you may not use this file except in compliance with
+ * the License.  You may obtain a copy of the License at
+ *
+ *     http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+package org.apache.daffodil.processors
+
+import java.io.OutputStream
+import java.io.OutputStreamWriter
+
+import scala.xml.NamespaceBinding
+
+import org.apache.daffodil.infoset.XMLInfosetOutputter
+import org.apache.daffodil.util.Indentable
+import org.apache.daffodil.util.MStackOfBoolean
+import org.xml.sax.Attributes
+import org.xml.sax.ContentHandler
+import org.xml.sax.Locator
+
+class DaffodilParseOutputStreamContentHandler(out: OutputStream, pretty: Boolean = false)
+  extends ContentHandler with Indentable with XMLInfosetOutputter {
+  private val writer = new OutputStreamWriter(out)
+  private var prefixMapping: NamespaceBinding = null
+  private val outputNewlineStack: MStackOfBoolean = {
+    val s = MStackOfBoolean()
+    s.push(false)
+    s
+  }

Review comment:
       Oh, this is nice coding, creating a member field with a stack and initializing the stack with its first element in one place instead of two different places.

##########
File path: daffodil-cli/src/main/scala/org/apache/daffodil/Main.scala
##########
@@ -783,11 +781,7 @@ object Main extends Logging {
    */
   def infosetDataToInputterData(infosetType: String, data: Either[Array[Byte],InputStream]): AnyRef = {
     infosetType match {
-      case "xml" => data match {
-        case Left(bytes) => bytes
-        case Right(is) => is
-      }
-      case "json" => data match {
+      case "xml" | "json" | "sax" => data match {

Review comment:
       Nice improvement!




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

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



[GitHub] [incubator-daffodil] mbeckerle commented on a change in pull request #475: SAX API Refactoring

Posted by GitBox <gi...@apache.org>.
mbeckerle commented on a change in pull request #475:
URL: https://github.com/apache/incubator-daffodil/pull/475#discussion_r561931640



##########
File path: daffodil-runtime1/src/main/scala/org/apache/daffodil/processors/DaffodilParseOutputStreamContentHandler.scala
##########
@@ -0,0 +1,139 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements.  See the NOTICE file distributed with
+ * this work for additional information regarding copyright ownership.
+ * The ASF licenses this file to You under the Apache License, Version 2.0
+ * (the "License"); you may not use this file except in compliance with
+ * the License.  You may obtain a copy of the License at
+ *
+ *     http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+package org.apache.daffodil.processors
+
+import java.io.OutputStream
+import java.io.OutputStreamWriter
+
+import scala.xml.NamespaceBinding
+
+import org.apache.daffodil.infoset.XMLInfosetOutputter
+import org.apache.daffodil.util.Indentable
+import org.apache.daffodil.util.MStackOfBoolean
+import org.xml.sax.Attributes
+import org.xml.sax.ContentHandler
+import org.xml.sax.Locator
+
+class DaffodilParseOutputStreamContentHandler(out: OutputStream, pretty: Boolean = false)
+  extends ContentHandler with Indentable with XMLInfosetOutputter {
+  private val writer = new OutputStreamWriter(out)
+  private var prefixMapping: NamespaceBinding = null
+  private val outputNewlineStack: MStackOfBoolean = {
+    val s = MStackOfBoolean()
+    s.push(false)
+    s
+  }
+
+  // if the top of the stack is true, we have guessed we should output a newline
+  private def outputNewline: Boolean = outputNewlineStack.top
+
+  def reset(): Unit = {
+    resetIndentation()
+    writer.flush()
+    prefixMapping = null
+    outputNewlineStack.clear()
+    outputNewlineStack.push(false) //to match initialization state
+    out.flush()
+  }
+
+  override def setDocumentLocator(locator: Locator): Unit = {
+    // do nothing
+  }
+
+  override def startDocument(): Unit = {
+    writer.write("""<?xml version="1.0" encoding="UTF-8"?>""")
+  }
+
+  override def endDocument(): Unit = {
+    writer.write(System.lineSeparator())
+    writer.flush()
+  }
+
+  override def startPrefixMapping(prefix: String, uri: String): Unit = {
+    val _prefix = if (prefix == "") null else prefix
+    prefixMapping = NamespaceBinding(_prefix, uri, prefixMapping)
+  }
+
+  override def endPrefixMapping(prefix: String): Unit = {
+    // do nothing
+  }
+
+  override def startElement(
+    uri: String, localName: String, qName: String, atts: Attributes): Unit = {
+    // the pop/true removes whatever is on the stack which is our previous guess for whether we
+    // would need a newline after the previous end tag. As we are currently at the start of a new
+    // tag, we want to correct that assumption (in case it was false)
+    outputNewlineStack.pop()
+    outputNewlineStack.push(true)
+    if (pretty) {
+      writer.write(System.lineSeparator())
+      outputIndentation(writer)
+    }
+    // handle start of tag
+    writer.write("<")
+    writer.write(qName)
+    // handle attributes
+    for (i <- 0 until atts.getLength) {
+      val attsValue = atts.getValue(i)
+      val attsQName = atts.getQName(i)
+      writer.write(s""" $attsQName="$attsValue"""")
+    }
+    // handle namespaces
+    if (prefixMapping != null) {
+      val pm = prefixMapping.toString()
+      writer.write(pm)
+      prefixMapping = null
+    }
+    // handle end of tag
+    writer.write(">")
+    incrementIndentation()
+    // this push makes the assumption that we would not need to output a newline after this end
+    // tag is complete
+    outputNewlineStack.push(false)
+  }
+
+  override def endElement(uri: String, localName: String, qName: String): Unit = {
+    decrementIndentation()
+    if (outputNewline) {
+      if (pretty) {
+        writer.write(System.lineSeparator())
+        outputIndentation(writer)
+      }
+    }
+    writer.write("</")
+    writer.write(qName)
+    writer.write(">")
+    outputNewlineStack.pop()
+  }
+
+  override def characters(ch: Array[Char], start: Int, length: Int): Unit = {
+    writer.write(ch, start, length)
+  }
+
+  override def ignorableWhitespace(ch: Array[Char], start: Int, length: Int): Unit = {
+    // do nothing
+  }
+
+  override def processingInstruction(target: String, data: String): Unit = {
+    // do nothing
+  }
+
+  override def skippedEntity(name: String): Unit = {
+    // do nothing

Review comment:
       Codecov shows warnings on each of these noop functions for me. 




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

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



[GitHub] [incubator-daffodil] mbeckerle commented on a change in pull request #475: SAX API Refactoring

Posted by GitBox <gi...@apache.org>.
mbeckerle commented on a change in pull request #475:
URL: https://github.com/apache/incubator-daffodil/pull/475#discussion_r561931640



##########
File path: daffodil-runtime1/src/main/scala/org/apache/daffodil/processors/DaffodilParseOutputStreamContentHandler.scala
##########
@@ -0,0 +1,139 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements.  See the NOTICE file distributed with
+ * this work for additional information regarding copyright ownership.
+ * The ASF licenses this file to You under the Apache License, Version 2.0
+ * (the "License"); you may not use this file except in compliance with
+ * the License.  You may obtain a copy of the License at
+ *
+ *     http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+package org.apache.daffodil.processors
+
+import java.io.OutputStream
+import java.io.OutputStreamWriter
+
+import scala.xml.NamespaceBinding
+
+import org.apache.daffodil.infoset.XMLInfosetOutputter
+import org.apache.daffodil.util.Indentable
+import org.apache.daffodil.util.MStackOfBoolean
+import org.xml.sax.Attributes
+import org.xml.sax.ContentHandler
+import org.xml.sax.Locator
+
+class DaffodilParseOutputStreamContentHandler(out: OutputStream, pretty: Boolean = false)
+  extends ContentHandler with Indentable with XMLInfosetOutputter {
+  private val writer = new OutputStreamWriter(out)
+  private var prefixMapping: NamespaceBinding = null
+  private val outputNewlineStack: MStackOfBoolean = {
+    val s = MStackOfBoolean()
+    s.push(false)
+    s
+  }
+
+  // if the top of the stack is true, we have guessed we should output a newline
+  private def outputNewline: Boolean = outputNewlineStack.top
+
+  def reset(): Unit = {
+    resetIndentation()
+    writer.flush()
+    prefixMapping = null
+    outputNewlineStack.clear()
+    outputNewlineStack.push(false) //to match initialization state
+    out.flush()
+  }
+
+  override def setDocumentLocator(locator: Locator): Unit = {
+    // do nothing
+  }
+
+  override def startDocument(): Unit = {
+    writer.write("""<?xml version="1.0" encoding="UTF-8"?>""")
+  }
+
+  override def endDocument(): Unit = {
+    writer.write(System.lineSeparator())
+    writer.flush()
+  }
+
+  override def startPrefixMapping(prefix: String, uri: String): Unit = {
+    val _prefix = if (prefix == "") null else prefix
+    prefixMapping = NamespaceBinding(_prefix, uri, prefixMapping)
+  }
+
+  override def endPrefixMapping(prefix: String): Unit = {
+    // do nothing
+  }
+
+  override def startElement(
+    uri: String, localName: String, qName: String, atts: Attributes): Unit = {
+    // the pop/true removes whatever is on the stack which is our previous guess for whether we
+    // would need a newline after the previous end tag. As we are currently at the start of a new
+    // tag, we want to correct that assumption (in case it was false)
+    outputNewlineStack.pop()
+    outputNewlineStack.push(true)
+    if (pretty) {
+      writer.write(System.lineSeparator())
+      outputIndentation(writer)
+    }
+    // handle start of tag
+    writer.write("<")
+    writer.write(qName)
+    // handle attributes
+    for (i <- 0 until atts.getLength) {
+      val attsValue = atts.getValue(i)
+      val attsQName = atts.getQName(i)
+      writer.write(s""" $attsQName="$attsValue"""")
+    }
+    // handle namespaces
+    if (prefixMapping != null) {
+      val pm = prefixMapping.toString()
+      writer.write(pm)
+      prefixMapping = null
+    }
+    // handle end of tag
+    writer.write(">")
+    incrementIndentation()
+    // this push makes the assumption that we would not need to output a newline after this end
+    // tag is complete
+    outputNewlineStack.push(false)
+  }
+
+  override def endElement(uri: String, localName: String, qName: String): Unit = {
+    decrementIndentation()
+    if (outputNewline) {
+      if (pretty) {
+        writer.write(System.lineSeparator())
+        outputIndentation(writer)
+      }
+    }
+    writer.write("</")
+    writer.write(qName)
+    writer.write(">")
+    outputNewlineStack.pop()
+  }
+
+  override def characters(ch: Array[Char], start: Int, length: Int): Unit = {
+    writer.write(ch, start, length)
+  }
+
+  override def ignorableWhitespace(ch: Array[Char], start: Int, length: Int): Unit = {
+    // do nothing
+  }
+
+  override def processingInstruction(target: String, data: String): Unit = {
+    // do nothing
+  }
+
+  override def skippedEntity(name: String): Unit = {
+    // do nothing

Review comment:
       Codecov shows warnings on each of these noop functions for me. 




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

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



[GitHub] [incubator-daffodil] olabusayoT merged pull request #475: SAX API Refactoring

Posted by GitBox <gi...@apache.org>.
olabusayoT merged pull request #475:
URL: https://github.com/apache/incubator-daffodil/pull/475


   


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

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



[GitHub] [incubator-daffodil] tuxji commented on a change in pull request #475: SAX API Refactoring

Posted by GitBox <gi...@apache.org>.
tuxji commented on a change in pull request #475:
URL: https://github.com/apache/incubator-daffodil/pull/475#discussion_r561921741



##########
File path: daffodil-runtime1/src/main/scala/org/apache/daffodil/processors/DaffodilParseOutputStreamContentHandler.scala
##########
@@ -0,0 +1,139 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements.  See the NOTICE file distributed with
+ * this work for additional information regarding copyright ownership.
+ * The ASF licenses this file to You under the Apache License, Version 2.0
+ * (the "License"); you may not use this file except in compliance with
+ * the License.  You may obtain a copy of the License at
+ *
+ *     http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+package org.apache.daffodil.processors
+
+import java.io.OutputStream
+import java.io.OutputStreamWriter
+
+import scala.xml.NamespaceBinding
+
+import org.apache.daffodil.infoset.XMLInfosetOutputter
+import org.apache.daffodil.util.Indentable
+import org.apache.daffodil.util.MStackOfBoolean
+import org.xml.sax.Attributes
+import org.xml.sax.ContentHandler
+import org.xml.sax.Locator
+
+class DaffodilParseOutputStreamContentHandler(out: OutputStream, pretty: Boolean = false)
+  extends ContentHandler with Indentable with XMLInfosetOutputter {
+  private val writer = new OutputStreamWriter(out)
+  private var prefixMapping: NamespaceBinding = null
+  private val outputNewlineStack: MStackOfBoolean = {
+    val s = MStackOfBoolean()
+    s.push(false)
+    s
+  }
+
+  // if the top of the stack is true, we have guessed we should output a newline
+  private def outputNewline: Boolean = outputNewlineStack.top
+
+  def reset(): Unit = {
+    resetIndentation()
+    writer.flush()
+    prefixMapping = null
+    outputNewlineStack.clear()
+    outputNewlineStack.push(false) //to match initialization state
+    out.flush()
+  }
+
+  override def setDocumentLocator(locator: Locator): Unit = {
+    // do nothing
+  }
+
+  override def startDocument(): Unit = {
+    writer.write("""<?xml version="1.0" encoding="UTF-8"?>""")
+  }
+
+  override def endDocument(): Unit = {
+    writer.write(System.lineSeparator())
+    writer.flush()
+  }
+
+  override def startPrefixMapping(prefix: String, uri: String): Unit = {
+    val _prefix = if (prefix == "") null else prefix
+    prefixMapping = NamespaceBinding(_prefix, uri, prefixMapping)
+  }
+
+  override def endPrefixMapping(prefix: String): Unit = {
+    // do nothing
+  }
+
+  override def startElement(
+    uri: String, localName: String, qName: String, atts: Attributes): Unit = {
+    // the pop/true removes whatever is on the stack which is our previous guess for whether we
+    // would need a newline after the previous end tag. As we are currently at the start of a new
+    // tag, we want to correct that assumption (in case it was false)
+    outputNewlineStack.pop()
+    outputNewlineStack.push(true)
+    if (pretty) {
+      writer.write(System.lineSeparator())
+      outputIndentation(writer)
+    }
+    // handle start of tag
+    writer.write("<")
+    writer.write(qName)
+    // handle attributes
+    for (i <- 0 until atts.getLength) {
+      val attsValue = atts.getValue(i)
+      val attsQName = atts.getQName(i)
+      writer.write(s""" $attsQName="$attsValue"""")
+    }
+    // handle namespaces
+    if (prefixMapping != null) {
+      val pm = prefixMapping.toString()
+      writer.write(pm)
+      prefixMapping = null
+    }
+    // handle end of tag
+    writer.write(">")
+    incrementIndentation()
+    // this push makes the assumption that we would not need to output a newline after this end
+    // tag is complete
+    outputNewlineStack.push(false)
+  }
+
+  override def endElement(uri: String, localName: String, qName: String): Unit = {
+    decrementIndentation()
+    if (outputNewline) {
+      if (pretty) {
+        writer.write(System.lineSeparator())
+        outputIndentation(writer)
+      }
+    }
+    writer.write("</")
+    writer.write(qName)
+    writer.write(">")
+    outputNewlineStack.pop()
+  }
+
+  override def characters(ch: Array[Char], start: Int, length: Int): Unit = {
+    writer.write(ch, start, length)
+  }
+
+  override def ignorableWhitespace(ch: Array[Char], start: Int, length: Int): Unit = {
+    // do nothing
+  }
+
+  override def processingInstruction(target: String, data: String): Unit = {
+    // do nothing
+  }
+
+  override def skippedEntity(name: String): Unit = {
+    // do nothing

Review comment:
       Interesting, I'm surprised codecov didn't ignore these noop functions without any testable code inside them.  Code coverage is still excellent anyway.

##########
File path: daffodil-runtime1/src/main/scala/org/apache/daffodil/processors/DaffodilParseOutputStreamContentHandler.scala
##########
@@ -0,0 +1,139 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements.  See the NOTICE file distributed with
+ * this work for additional information regarding copyright ownership.
+ * The ASF licenses this file to You under the Apache License, Version 2.0
+ * (the "License"); you may not use this file except in compliance with
+ * the License.  You may obtain a copy of the License at
+ *
+ *     http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+package org.apache.daffodil.processors
+
+import java.io.OutputStream
+import java.io.OutputStreamWriter
+
+import scala.xml.NamespaceBinding
+
+import org.apache.daffodil.infoset.XMLInfosetOutputter
+import org.apache.daffodil.util.Indentable
+import org.apache.daffodil.util.MStackOfBoolean
+import org.xml.sax.Attributes
+import org.xml.sax.ContentHandler
+import org.xml.sax.Locator
+
+class DaffodilParseOutputStreamContentHandler(out: OutputStream, pretty: Boolean = false)
+  extends ContentHandler with Indentable with XMLInfosetOutputter {
+  private val writer = new OutputStreamWriter(out)
+  private var prefixMapping: NamespaceBinding = null
+  private val outputNewlineStack: MStackOfBoolean = {
+    val s = MStackOfBoolean()
+    s.push(false)
+    s
+  }

Review comment:
       Oh, this is nice coding, creating a member field with a stack and initializing the stack with its first element in one place instead of two different places.

##########
File path: daffodil-cli/src/main/scala/org/apache/daffodil/Main.scala
##########
@@ -783,11 +781,7 @@ object Main extends Logging {
    */
   def infosetDataToInputterData(infosetType: String, data: Either[Array[Byte],InputStream]): AnyRef = {
     infosetType match {
-      case "xml" => data match {
-        case Left(bytes) => bytes
-        case Right(is) => is
-      }
-      case "json" => data match {
+      case "xml" | "json" | "sax" => data match {

Review comment:
       Nice improvement!




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

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



[GitHub] [incubator-daffodil] olabusayoT merged pull request #475: SAX API Refactoring

Posted by GitBox <gi...@apache.org>.
olabusayoT merged pull request #475:
URL: https://github.com/apache/incubator-daffodil/pull/475


   


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

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