You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@daffodil.apache.org by "olabusayoT (via GitHub)" <gi...@apache.org> on 2026/10/06 16:38:13 UTC

[PR] Add CLI option to pass options to infoset inputters and outputters [daffodil]

olabusayoT opened a new pull request, #1743:
URL: https://github.com/apache/daffodil/pull/1743

   Add a --infoset-opts option to the parse and unparse commands that takes a comma separated list of key=value pairs, for example --infoset-opts=pretty=false,xmlTextEscape=CDATA. Pairs are validated against the selected infoset type and collected into an InfosetOptions object that is passed to the infoset handlers, so new options need only a key definition and a handler change. Pair splitting is a new Misc.parseKeyValuePairs utility.
   
   Initial keys are pretty (true or false, for xml, json, and sax infosets), which previously could not be turned off, xmlTextEscape (Standard or CDATA, for xml infosets), which exposes the existing XMLTextEscapeStyle, and exiCompression (true or false, for exi and exisa infosets), which selects EXI compression. Unknown keys, invalid values, and keys that do not apply to the infoset type are reported as usage errors. Each key's values, description, applicable infoset types, and default are generated into the command help from the key definitions.
   
   Library constructors are unchanged.
   
   DAFFODIL-2234


-- 
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: commits-unsubscribe@daffodil.apache.org

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


Re: [PR] Add CLI option to pass options to infoset inputters and outputters [daffodil]

Posted by "stevedlawrence (via GitHub)" <gi...@apache.org>.
stevedlawrence commented on code in PR #1743:
URL: https://github.com/apache/daffodil/pull/1743#discussion_r4250519615


##########
daffodil-cli/src/main/scala/org/apache/daffodil/cli/InfosetOptions.scala:
##########
@@ -0,0 +1,157 @@
+/*
+ * 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.cli
+
+import org.apache.daffodil.api.infoset.XMLTextEscapeStyle
+import org.apache.daffodil.lib.util.Misc
+
+/**
+ * Options for infoset inputters and outputters, given on the command line as a
+ * comma separated list of key=value pairs.
+ */
+final case class InfosetOptions(
+  pretty: Boolean = true,
+  xmlTextEscapeStyle: XMLTextEscapeStyle = XMLTextEscapeStyle.Standard,
+  exiCompression: Boolean = false
+)
+
+object InfosetOptions {
+
+  val Default: InfosetOptions = InfosetOptions()
+
+  /**
+   * One supported key: the infoset types it applies to, its allowed values and
+   * description for help text, how to get its default from the default options,
+   * and how it updates the options from the value text.
+   */
+  private case class InfosetOptionKey(
+    name: String,
+    applicableInfosetTypes: Set[InfosetType.Type],
+    valueDescription: String,
+    description: String,
+    defaultValue: InfosetOptions => Any,

Review Comment:
   Why is `defaultValue` a function, can it just be an `Any`. For example, instead of `defaultValue = _.pretty` we could just use `defaultValue = Default.pretty`?



##########
daffodil-cli/src/main/scala/org/apache/daffodil/cli/InfosetOptions.scala:
##########
@@ -0,0 +1,157 @@
+/*
+ * 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.cli
+
+import org.apache.daffodil.api.infoset.XMLTextEscapeStyle
+import org.apache.daffodil.lib.util.Misc
+
+/**
+ * Options for infoset inputters and outputters, given on the command line as a
+ * comma separated list of key=value pairs.
+ */
+final case class InfosetOptions(
+  pretty: Boolean = true,
+  xmlTextEscapeStyle: XMLTextEscapeStyle = XMLTextEscapeStyle.Standard,
+  exiCompression: Boolean = false
+)
+
+object InfosetOptions {
+
+  val Default: InfosetOptions = InfosetOptions()
+
+  /**
+   * One supported key: the infoset types it applies to, its allowed values and
+   * description for help text, how to get its default from the default options,
+   * and how it updates the options from the value text.
+   */
+  private case class InfosetOptionKey(
+    name: String,
+    applicableInfosetTypes: Set[InfosetType.Type],
+    valueDescription: String,
+    description: String,
+    defaultValue: InfosetOptions => Any,
+    update: (InfosetOptions, String) => Either[String, InfosetOptions]
+  )
+
+  private def enumValue[E <: java.lang.Enum[E]](
+    values: Array[E],
+    text: String
+  ): Either[String, E] =
+    values
+      .find(_.toString.equalsIgnoreCase(text))
+      .toRight("Must be one of " + values.mkString(", "))
+
+  private def booleanValue(text: String): Either[String, Boolean] =
+    text.toLowerCase match {
+      case "true" => Right(true)
+      case "false" => Right(false)
+      case _ => Left("Must be true or false")
+    }
+
+  private val keys: Seq[InfosetOptionKey] = Seq(
+    InfosetOptionKey(
+      name = "pretty",
+      applicableInfosetTypes = Set(InfosetType.XML, InfosetType.JSON, InfosetType.SAX),
+      valueDescription = "true|false",
+      description = "Indent the infoset and add newlines where the content is not affected.",
+      defaultValue = _.pretty,
+      update = (o, v) => booleanValue(v).map(b => o.copy(pretty = b))
+    ),
+    InfosetOptionKey(
+      name = "exiCompression",
+      applicableInfosetTypes = Set(InfosetType.EXI, InfosetType.EXISA),
+      valueDescription = "true|false",
+      description =
+        "Use EXI compression. The same setting must be used when unparsing an EXI infoset.",
+      defaultValue = _.exiCompression,
+      update = (o, v) => booleanValue(v).map(b => o.copy(exiCompression = b))
+    ),
+    InfosetOptionKey(
+      name = "xmlTextEscape",
+      applicableInfosetTypes = Set(InfosetType.XML),
+      valueDescription = XMLTextEscapeStyle.values.mkString("|"),
+      description = "Standard escapes special characters in xs:string values. CDATA instead " +
+        "wraps xs:string values that contain special characters or whitespace in CDATA sections.",
+      defaultValue = _.xmlTextEscapeStyle,
+      update = (o, v) =>
+        enumValue(XMLTextEscapeStyle.values, v).map(s => o.copy(xmlTextEscapeStyle = s))
+    )
+  )
+
+  /**
+   * The names of the supported keys.
+   */
+  val keyNames: Seq[String] = keys.map(_.name)
+
+  /**
+   * Description of the supported keys, one per paragraph, for help text.
+   */
+  val keysDescription: String =
+    keys
+      .map { k =>
+        "%s=%s\n%s Applies to: %s infosets. Default: %s.".format(
+          k.name,
+          k.valueDescription,
+          k.description,
+          k.applicableInfosetTypes.toSeq.sorted.mkString(", "),
+          k.defaultValue(Default)
+        )
+      }
+      .mkString("\n")
+
+  /**
+   * Parses a comma separated list of key=value pairs for the given infoset type.
+   * Later occurrences of a key replace earlier ones.
+   */
+  def parse(text: String, infosetType: InfosetType.Type): Either[String, InfosetOptions] =
+    Misc.parseKeyValuePairs(text, ",") match {

Review Comment:
   I would recommend we use Scallops option parsing capabilities instead of implementing our own. It already supports lists of key/value pairs using the `props[String]` option type. It will return a Map[String,String] that we can then validate and parse.
   
   And maybe the right thing to do is have a custom scallop converter that converts each key/value pair to an `(InfosetOptionKey, Any)` pair. Then the scallops option is something like
   
   ```scala
   val infosetOptions = props((InfosetOptionKey, Any)
   ```
   
   And it returns a Map[String, (InfosetOptionKey, Any)]. The `validateOption` part can validate that the options work with the infoset type and then main can do the flatmap to create the InfosetOptions. Would be nice to use sallops native capabilities where possible to we don't have to reinvent parsing.
   



##########
daffodil-cli/src/main/scala/org/apache/daffodil/cli/InfosetTypes.scala:
##########
@@ -99,19 +100,20 @@ object InfosetType extends Enumeration {
     infosetType: InfosetType.Type,
     dataProcessor: api.DataProcessor,
     schemaUri: Option[URI],
-    forPerformance: Boolean
+    forPerformance: Boolean,
+    options: InfosetOptions = InfosetOptions.Default

Review Comment:
   Should we make this mandatory to ensure every place that deals with infosets gets the options that could affect it?



##########
daffodil-cli/src/main/scala/org/apache/daffodil/cli/Main.scala:
##########
@@ -191,6 +191,11 @@ class CLIConf(arguments: Array[String], stdout: PrintStream, stderr: PrintStream
       }
     })
 
+  private val infosetOptionDescr =
+    "Comma separated list of key=value options for the infoset inputter or outputter, " +

Review Comment:
   Suggest we remove the "comma-separate" and just list "list of key=value options" and let scallop do the list parsing.



##########
daffodil-cli/src/main/scala/org/apache/daffodil/cli/Main.scala:
##########
@@ -488,6 +505,13 @@ class CLIConf(arguments: Array[String], stdout: PrintStream, stderr: PrintStream
       ) + ". Defaults to 'xml'.",
       default = Some(InfosetType.XML)
     )
+    val infosetOptions = opt[String](

Review Comment:
   We should also support this with the `performance` command. That also allows the -I/--infoset-type option. It might be useful to test performance with different infoset options.



##########
daffodil-cli/src/test/scala/org/apache/daffodil/cli/cliTest/TestCLIParsing.scala:
##########
@@ -878,6 +887,103 @@ class TestCLIParsing {
     }(ExitCode.Success)
   }
 
+  @Test def test_CLI_Parsing_InfosetOption_unknownKey(): Unit = {
+    val schema = path(
+      "daffodil-test/src/test/resources/org/apache/daffodil/section00/general/generalSchema.dfdl.xsd"
+    )
+
+    runCLI(args"parse --infoset-opts=bogus=true -s $schema -r e1") { cli =>
+      cli.expectErr("Unrecognized infoset option 'bogus'")
+    }(ExitCode.Usage)
+  }
+
+  @Test def test_CLI_Parsing_InfosetOption_notApplicable(): Unit = {
+    val schema = path(
+      "daffodil-test/src/test/resources/org/apache/daffodil/section00/general/generalSchema.dfdl.xsd"
+    )
+
+    runCLI(args"parse -I json --infoset-opts=xmlTextEscape=CDATA -s $schema -r e1") { cli =>
+      cli.expectErr("Infoset option 'xmlTextEscape' does not apply to the json infoset type")
+    }(ExitCode.Usage)
+  }
+
+  @Test def test_CLI_Parsing_InfosetOption_invalidValue(): Unit = {
+    val schema = path(
+      "daffodil-test/src/test/resources/org/apache/daffodil/section00/general/generalSchema.dfdl.xsd"
+    )
+
+    runCLI(args"parse --infoset-opts=pretty=bogus -s $schema -r e1") { cli =>
+      cli.expectErr("Invalid value 'bogus' for infoset option 'pretty'")
+    }(ExitCode.Usage)
+  }
+
+  @Test def test_CLI_Parsing_InfosetOption_missingEquals(): Unit = {
+    val schema = path(
+      "daffodil-test/src/test/resources/org/apache/daffodil/section00/general/generalSchema.dfdl.xsd"
+    )
+
+    runCLI(args"parse --infoset-opts=pretty -s $schema -r e1") { cli =>
+      cli.expectErr("Invalid infoset option 'pretty'. Expected key=value")
+    }(ExitCode.Usage)
+  }

Review Comment:
   If we switch to `props` I think we can drop this test since this is just testing scallops parsing of props. 



##########
daffodil-cli/src/main/scala/org/apache/daffodil/cli/Main.scala:
##########
@@ -191,6 +191,11 @@ class CLIConf(arguments: Array[String], stdout: PrintStream, stderr: PrintStream
       }
     })
 
+  private val infosetOptionDescr =
+    "Comma separated list of key=value options for the infoset inputter or outputter, " +
+      "for example --infoset-opts=pretty=false,xmlTextEscape=CDATA. " +

Review Comment:
   We should drop the examples. Examples belong in a man page or website documentation, --help option wants to be as terse as possible.



##########
daffodil-core/src/main/scala/org/apache/daffodil/lib/util/Misc.scala:
##########
@@ -47,6 +47,33 @@ import passera.unsigned.UByte
  */
 object Misc {
 
+  /**
+   * Splits text into key=value pairs. The text is split into items at each match
+   * of the separator regular expression, and each item is split at its first '='.
+   * Values may be empty or contain '='.
+   *
+   * @return Right with the pairs in order, empty if text is empty, or Left with
+   *   the first item that has no '=' or has an empty key.
+   */
+  def parseKeyValuePairs(

Review Comment:
   Suspect this an associated tests can go away in favor of scallops CLI props parsing.



##########
daffodil-cli/src/main/scala/org/apache/daffodil/cli/Main.scala:
##########
@@ -1263,17 +1292,22 @@ class Main(
                 }
               }
             }
-            Using.resource(input) { inStream =>
+            Using.Manager { use =>
+              val inStream = use(input)
               val output = parseOpts.output.toOption match {
                 case Some("-") | None => STDOUT
-                case Some(file) => new FileOutputStream(file)
+                case Some(file) => use(new FileOutputStream(file))
               }
 
               val infosetHandler = InfosetType.getInfosetHandler(
                 parseOpts.infosetType(),
                 processor,
                 parseOpts.schema.map(_.uri).toOption,
-                forPerformance = false
+                forPerformance = false,
+                options = InfosetOptions.parseValidated(

Review Comment:
   Note that if you had infosetOptions store a Map containin ghte parsed InfosetOptionKey's and values we wouldn't need to parse it again here, we just do the flatmap and everything should work



##########
daffodil-cli/src/main/scala/org/apache/daffodil/cli/InfosetTypes.scala:
##########
@@ -99,19 +100,20 @@ object InfosetType extends Enumeration {
     infosetType: InfosetType.Type,
     dataProcessor: api.DataProcessor,
     schemaUri: Option[URI],
-    forPerformance: Boolean
+    forPerformance: Boolean,
+    options: InfosetOptions = InfosetOptions.Default
   ): InfosetHandler = {
 
     infosetType match {
-      case InfosetType.EXI => EXIInfosetHandler(dataProcessor)
-      case InfosetType.EXISA => EXIInfosetHandler(dataProcessor, schemaUri.get)
+      case InfosetType.EXI => EXIInfosetHandler(dataProcessor, options)
+      case InfosetType.EXISA => EXIInfosetHandler(dataProcessor, schemaUri.get, options)
       case InfosetType.JDOM => JDOMInfosetHandler(dataProcessor)

Review Comment:
   Should we pass the options to every infoset handler even if they don't use any options? That way everything is the same and if they ever do support options in the future they'll already have it? 



##########
daffodil-cli/src/main/scala/org/apache/daffodil/cli/Main.scala:
##########
@@ -191,6 +191,11 @@ class CLIConf(arguments: Array[String], stdout: PrintStream, stderr: PrintStream
       }
     })
 
+  private val infosetOptionDescr =
+    "Comma separated list of key=value options for the infoset inputter or outputter, " +
+      "for example --infoset-opts=pretty=false,xmlTextEscape=CDATA. " +
+      "Keys:\n" + InfosetOptions.keysDescription

Review Comment:
   Can we inline this val for consistency with other descriptions? This reduces dupliation, but it's not what are other options do.I believe we have another bug about reducing duplication within our CLI arguments.



##########
daffodil-cli/src/test/scala/org/apache/daffodil/cli/cliTest/TestCLIParsing.scala:
##########
@@ -39,6 +40,14 @@ class TestCLIParsing {
     }(ExitCode.Success)
   }
 
+  @Test def test_CLI_help_documentsEveryInfosetOption(): Unit = {

Review Comment:
   I don't think we need a test that makes sure --help outputs the right thing.



##########
daffodil-cli/src/main/scala/org/apache/daffodil/cli/Main.scala:
##########
@@ -1263,17 +1292,22 @@ class Main(
                 }
               }
             }
-            Using.resource(input) { inStream =>
+            Using.Manager { use =>
+              val inStream = use(input)
               val output = parseOpts.output.toOption match {
                 case Some("-") | None => STDOUT
-                case Some(file) => new FileOutputStream(file)
+                case Some(file) => use(new FileOutputStream(file))

Review Comment:
   Why switch to Using.Manager with .use/.get instead of Using.resource? Seems using Using.resource is preferred in this case since we only have one input and any errors just bubble up.



##########
daffodil-cli/src/main/scala/org/apache/daffodil/cli/InfosetOptions.scala:
##########
@@ -0,0 +1,157 @@
+/*
+ * 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.cli
+
+import org.apache.daffodil.api.infoset.XMLTextEscapeStyle
+import org.apache.daffodil.lib.util.Misc
+
+/**
+ * Options for infoset inputters and outputters, given on the command line as a
+ * comma separated list of key=value pairs.
+ */
+final case class InfosetOptions(
+  pretty: Boolean = true,
+  xmlTextEscapeStyle: XMLTextEscapeStyle = XMLTextEscapeStyle.Standard,
+  exiCompression: Boolean = false
+)
+
+object InfosetOptions {
+
+  val Default: InfosetOptions = InfosetOptions()
+
+  /**
+   * One supported key: the infoset types it applies to, its allowed values and
+   * description for help text, how to get its default from the default options,
+   * and how it updates the options from the value text.
+   */
+  private case class InfosetOptionKey(
+    name: String,
+    applicableInfosetTypes: Set[InfosetType.Type],
+    valueDescription: String,
+    description: String,
+    defaultValue: InfosetOptions => Any,
+    update: (InfosetOptions, String) => Either[String, InfosetOptions]
+  )
+
+  private def enumValue[E <: java.lang.Enum[E]](
+    values: Array[E],
+    text: String
+  ): Either[String, E] =
+    values
+      .find(_.toString.equalsIgnoreCase(text))
+      .toRight("Must be one of " + values.mkString(", "))
+
+  private def booleanValue(text: String): Either[String, Boolean] =
+    text.toLowerCase match {
+      case "true" => Right(true)
+      case "false" => Right(false)
+      case _ => Left("Must be true or false")
+    }
+
+  private val keys: Seq[InfosetOptionKey] = Seq(
+    InfosetOptionKey(
+      name = "pretty",
+      applicableInfosetTypes = Set(InfosetType.XML, InfosetType.JSON, InfosetType.SAX),
+      valueDescription = "true|false",
+      description = "Indent the infoset and add newlines where the content is not affected.",
+      defaultValue = _.pretty,
+      update = (o, v) => booleanValue(v).map(b => o.copy(pretty = b))
+    ),
+    InfosetOptionKey(
+      name = "exiCompression",
+      applicableInfosetTypes = Set(InfosetType.EXI, InfosetType.EXISA),
+      valueDescription = "true|false",
+      description =
+        "Use EXI compression. The same setting must be used when unparsing an EXI infoset.",
+      defaultValue = _.exiCompression,
+      update = (o, v) => booleanValue(v).map(b => o.copy(exiCompression = b))
+    ),
+    InfosetOptionKey(
+      name = "xmlTextEscape",
+      applicableInfosetTypes = Set(InfosetType.XML),
+      valueDescription = XMLTextEscapeStyle.values.mkString("|"),
+      description = "Standard escapes special characters in xs:string values. CDATA instead " +
+        "wraps xs:string values that contain special characters or whitespace in CDATA sections.",
+      defaultValue = _.xmlTextEscapeStyle,
+      update = (o, v) =>
+        enumValue(XMLTextEscapeStyle.values, v).map(s => o.copy(xmlTextEscapeStyle = s))
+    )
+  )
+
+  /**
+   * The names of the supported keys.
+   */
+  val keyNames: Seq[String] = keys.map(_.name)
+
+  /**
+   * Description of the supported keys, one per paragraph, for help text.
+   */
+  val keysDescription: String =
+    keys
+      .map { k =>
+        "%s=%s\n%s Applies to: %s infosets. Default: %s.".format(
+          k.name,
+          k.valueDescription,
+          k.description,
+          k.applicableInfosetTypes.toSeq.sorted.mkString(", "),
+          k.defaultValue(Default)
+        )
+      }
+      .mkString("\n")

Review Comment:
   This makes for very verbose output for a flag that is going to be seldom used. Suggest we drop the human readable descriptions and what they apply to--the names/values are pretty self explanatory. We can add additional documentation on the website if needed. 



-- 
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: commits-unsubscribe@daffodil.apache.org

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


Re: [PR] Add CLI option to pass options to infoset inputters and outputters [daffodil]

Posted by "stevedlawrence (via GitHub)" <gi...@apache.org>.
stevedlawrence commented on code in PR #1743:
URL: https://github.com/apache/daffodil/pull/1743#discussion_r4261596062


##########
daffodil-cli/src/main/scala/org/apache/daffodil/cli/InfosetTypes.scala:
##########
@@ -282,10 +287,17 @@ sealed class InfosetParseResult(val parseResult: api.ParseResult) {
 /**
  * InfosetType.XML
  */
-case class XMLTextInfosetHandler(dataProcessor: api.DataProcessor) extends InfosetHandler {
+case class XMLTextInfosetHandler(
+  dataProcessor: api.DataProcessor,
+  infosetOptions: InfosetOptions = InfosetOptions.Default
+) extends InfosetHandler {
 
   def parse(input: InputSourceDataInputStream, os: OutputStream): InfosetParseResult = {
-    val output = new XMLTextInfosetOutputter(os, pretty = true)
+    val output = new XMLTextInfosetOutputter(
+      os,
+      infosetOptions(PrettyKey),
+      infosetOptions(XmlTextEscapeKey)

Review Comment:
   Is it possible to flatten the InfosetOptions into a class with a member for each option, something similar to what you had in the previous version of this?
   
   With this approach is it going to do a separate hash lookup for each key. It's not a big deal for normal parse/unparse, but for the performance command these parse/unparse functions are in the critical path so it would be best to avoid overhead. If we could flatten the map prior to passing infosetOptions to `getInfosetHandler` (or part of getInfosetHandler), which happens outside the critical path we could avoid that overhead.
   
   So we still have scallop parse and validation the options and create the Map, but the map is flattened before it's actually used.



##########
daffodil-cli/src/main/scala/org/apache/daffodil/cli/InfosetTypes.scala:
##########
@@ -99,19 +103,20 @@ object InfosetType extends Enumeration {
     infosetType: InfosetType.Type,
     dataProcessor: api.DataProcessor,
     schemaUri: Option[URI],
-    forPerformance: Boolean
+    forPerformance: Boolean,
+    infosetOptions: InfosetOptions = InfosetOptions.Default

Review Comment:
   Suggest we remove this default to make sure we don't miss any cases where we should be passing in infoset options if we ever add new things that call getInfosetHandler.



##########
daffodil-cli/src/main/scala/org/apache/daffodil/cli/InfosetTypes.scala:
##########
@@ -99,19 +100,20 @@ object InfosetType extends Enumeration {
     infosetType: InfosetType.Type,
     dataProcessor: api.DataProcessor,
     schemaUri: Option[URI],
-    forPerformance: Boolean
+    forPerformance: Boolean,
+    options: InfosetOptions = InfosetOptions.Default
   ): InfosetHandler = {
 
     infosetType match {
-      case InfosetType.EXI => EXIInfosetHandler(dataProcessor)
-      case InfosetType.EXISA => EXIInfosetHandler(dataProcessor, schemaUri.get)
+      case InfosetType.EXI => EXIInfosetHandler(dataProcessor, options)
+      case InfosetType.EXISA => EXIInfosetHandler(dataProcessor, schemaUri.get, options)
       case InfosetType.JDOM => JDOMInfosetHandler(dataProcessor)

Review Comment:
   I think you missed this comment.



-- 
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: commits-unsubscribe@daffodil.apache.org

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


Re: [PR] Add CLI option to pass options to infoset inputters and outputters [daffodil]

Posted by "stevedlawrence (via GitHub)" <gi...@apache.org>.
stevedlawrence commented on code in PR #1743:
URL: https://github.com/apache/daffodil/pull/1743#discussion_r4252851230


##########
daffodil-cli/src/main/scala/org/apache/daffodil/cli/Main.scala:
##########
@@ -1263,17 +1292,22 @@ class Main(
                 }
               }
             }
-            Using.resource(input) { inStream =>
+            Using.Manager { use =>
+              val inStream = use(input)
               val output = parseOpts.output.toOption match {
                 case Some("-") | None => STDOUT
-                case Some(file) => new FileOutputStream(file)
+                case Some(file) => use(new FileOutputStream(file))

Review Comment:
   Ah yes, I missed that this adds two `use`s, I only saw the one for the FileOutputStream one. Make sense.



-- 
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: commits-unsubscribe@daffodil.apache.org

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


Re: [PR] Add CLI option to pass options to infoset inputters and outputters [daffodil]

Posted by "olabusayoT (via GitHub)" <gi...@apache.org>.
olabusayoT merged PR #1743:
URL: https://github.com/apache/daffodil/pull/1743


-- 
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: commits-unsubscribe@daffodil.apache.org

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


Re: [PR] Add CLI option to pass options to infoset inputters and outputters [daffodil]

Posted by "olabusayoT (via GitHub)" <gi...@apache.org>.
olabusayoT commented on code in PR #1743:
URL: https://github.com/apache/daffodil/pull/1743#discussion_r4252700816


##########
daffodil-cli/src/main/scala/org/apache/daffodil/cli/Main.scala:
##########
@@ -1263,17 +1292,22 @@ class Main(
                 }
               }
             }
-            Using.resource(input) { inStream =>
+            Using.Manager { use =>
+              val inStream = use(input)
               val output = parseOpts.output.toOption match {
                 case Some("-") | None => STDOUT
-                case Some(file) => new FileOutputStream(file)
+                case Some(file) => use(new FileOutputStream(file))

Review Comment:
   Using.resource only allows automatic closing of the resource it is given. we have 2 resources here that need closing: the input and the file outputstream. Not closing the latter led to wIndows CI test failure (https://github.com/apache/daffodil/actions/runs/37497260941/job/112384882560#step:15:259). Manager allows  us to close both. 
   
   Since the failure is in the test I added, I can look into refactoring my test, but it is truly a leak that we don't close the FileOutputStream



-- 
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: commits-unsubscribe@daffodil.apache.org

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