tuxji commented on code in PR #821:
URL: https://github.com/apache/daffodil/pull/821#discussion_r1042450177
##########
daffodil-japi/src/test/java/org/apache/daffodil/example/TestJavaAPI.java:
##########
@@ -931,6 +931,15 @@ public void testJavaAPI20() throws IOException,
ClassNotFoundException {
assertEquals("42", unparseBos.toString());
}
+ @Test
+ public void testJavaAPINullXmlOutputStyle() {
+ ByteArrayOutputStream xmlBos = new ByteArrayOutputStream();
+ try {
+ XMLTextInfosetOutputter outputter = new
XMLTextInfosetOutputter(xmlBos, true, null);
+ } catch (Exception e) {
+ assertTrue(e.getMessage().contains("Null is not a valid value
for parameter xmlOutputStyle"));
+ }
+ }
Review Comment:
Daffodil contributors are expected to maintain the Daffodil codebase's
standard Scala formatting (2 spaces per indentation, etc.). Your new test
(thank you for the test!) is formatted with 4 spaces per indentation and also
contains 2 tabs on line 940. I suggest you configure your IDE with standard
Scala formatting settings (including no tabs in indentation) and then use your
IDE to indent your new test. DEVELOP.md has a section on code style and an
IDEA setup link. We don't have sbt set up to run a formatter over the Daffodil
codebase, so we have to rely on PR review to keep the codebase's formatting
consistent.
Also, consider testing only that the message contains the word
"xmlOutputStyle". Otherwise, the test will be fragile and break as soon as
someone changes that exception's message even slightly (rearrange the order of
words, lowercase Null, etc.).
##########
daffodil-sapi/src/main/scala/org/apache/daffodil/sapi/infoset/Infoset.scala:
##########
@@ -248,8 +250,14 @@ class XMLTextInfosetOutputter private (outputter:
SXMLTextInfosetOutputter)
* @param pretty enable or disable pretty printing. Pretty printing will only
* insert indentation and newlines where it will not affect the
* content of the XML.
+ * @param xmlOutputStyle determine whether to wrap values of elements of type
+ * xs:string in CDATA chunks in order to preserve
+ * whitespace.
*/
- def this(os: java.io.OutputStream, pretty: Boolean) = this(new
SXMLTextInfosetOutputter(os, pretty))
+ def this(os: java.io.OutputStream, pretty: Boolean,
+ xmlOutputStyle: XMLOutputStyle.Type = XMLOutputStyle.Standard) = {
+ this(new SXMLTextInfosetOutputter(os, pretty, xmlOutputStyle))
+ }
Review Comment:
Too much indentation on lines 259-260.
##########
daffodil-lib/src/main/scala/org/apache/daffodil/api/XMLOutputStyle.scala:
##########
@@ -0,0 +1,26 @@
+/*
+ * 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.api
+
+import org.apache.daffodil.util.Enum
+
+object XMLOutputStyle extends Enum {
+ sealed abstract trait Type extends EnumValueType
+ case object Standard extends Type
+ case object PrettyPrintSafe extends Type
+}
Review Comment:
Enum XMLOutputStyle is in the api package, so it should have a scaladoc.
--
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]