tuxji commented on code in PR #821:
URL: https://github.com/apache/daffodil/pull/821#discussion_r1061731550
##########
daffodil-japi/src/test/java/org/apache/daffodil/example/TestJavaAPI.java:
##########
@@ -1213,4 +1215,81 @@ public void testJavaAPI26() throws IOException,
ClassNotFoundException, External
assertTrue(DaffodilXMLEntityResolver.getXMLEntityResolver() != null);
assertTrue(DaffodilXMLEntityResolver.getLSResourceResolver() != null);
}
+
+ @Test
+ public void testJavaAPINullXMLTextEscapeStyle() throws IOException,
ClassNotFoundException {
+ ByteArrayOutputStream xmlBos = new ByteArrayOutputStream();
+ try {
+ XMLTextInfosetOutputter outputter = new
XMLTextInfosetOutputter(xmlBos, true, null);
+ } catch (Exception e) {
+ String msg = e.getMessage().toLowerCase();
+ assertTrue(msg.contains("unrecognized"));
+ assertTrue(msg.contains("null"));
+ assertTrue(msg.contains("xmltextescapestyle"));
+ }
+ }
+
+ @Test
+ public void testJavaAPICDATA1() throws IOException, ClassNotFoundException
{
+ String expected = "<![CDATA[NO_WHITESPACE_AT_ALL]]>";
+ String data = "NO_WHITESPACE_AT_ALL$";
+ String schemaType = "string";
+ doXMLTextEscapeStyleTest(expected, data, schemaType);
Review Comment:
Currently the CDATA escape style always wraps all XML text content in CDATA
brackets regardless of whether the text actually contains any whitespace or
special characters. I wonder if users would prefer the CDATA escape style to
escape only XML text content which really needs to be wrapped in CDATA to
preserve its original contents? If such "smart" escaping would be more
difficult to implement than it's worth, we can wait for users to request it and
create an issue at that time.
##########
daffodil-runtime1/src/main/scala/org/apache/daffodil/infoset/XMLTextEscapeStyle.scala:
##########
@@ -0,0 +1,31 @@
+/*
+ * 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.infoset
+/**
+ * XMLTextEscapeStyle determines how to wrap values of elements of type
xs:string
+ *
+ * Standard - Special characters ('backslash','quotation
mark','ampersand','less-than','greater-than')
+ * in the values of elements of type xs:string are escaped, while,
+ * non-special character are written as is.
Review Comment:
Please fix singular/plural agreement and punctuation:
```
* Standard - Special characters (backslash, quotation mark, ampersand,
less-than, greater-than) in
* the text of xs:string elements are escaped, while non-special characters
are written as is.
*
* CDATA - The text of xs:string elements are wrapped in CDATA tags.
```
The same fixes should also be applied to
-
daffodil-japi/src/main/java/org/apache/daffodil/japi/infoset/XMLTextEscapeStyle.java
-
daffodil-sapi/src/main/scala/org/apache/daffodil/sapi/infoset/XMLTextEscapeStyle.scala
--
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]