stevedlawrence commented on code in PR #1057:
URL: https://github.com/apache/daffodil/pull/1057#discussion_r1532973954


##########
daffodil-tdml-lib/src/test/scala/org/apache/daffodil/tdml/scalaxb/ScalaxbTests.scala:
##########
@@ -0,0 +1,142 @@
+/*
+ * 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.tdml.scalaxb
+
+import org.junit.Assert._
+import org.junit.Test
+
+class ScalaxbTests {
+
+  @Test def testReadingNoTests(): Unit = {
+    val testSuite =
+      scalaxb.fromXML[TestSuite](
+        scala.xml.XML.load(
+          getClass
+            .getClassLoader()
+            .getResourceAsStream("test-suite/ibm-contributed/dpaext1-2.tdml"),
+        ),
+      )
+
+    assertNotNull(testSuite)
+    assertEquals(Some("dpaext"), testSuite.suiteName)
+  }
+
+  // currently failing, not sure why scalaxb isn't handling comments. is the 
xsd too strict and somehow excludes allowing comments?

Review Comment:
   I'mt not sure XSD can allow or disallow comments, I think they're just baked 
into XML. So it probably means scalaxb just can't handle comments.
   
   Ideally, we could open a ticket with scalaxb to see if they could add the 
ability to ignored comments.
   
   Alternatively, and maybe an interim solution until scalaxb ignores comments, 
users of `scalaxb.fromXML[TestSuite](...)`  could filter the NodeSeq to remove 
comments before passing it to scalaxb. Scala-xml has a [Transformer 
API](https://github.com/scala/scala-xml/tree/main/shared/src/main/scala/scala/xml/transform)
 that should make it not too painful. It's definitely annoying to have to worry 
about that, but I'm not sure it's necessarily a blocker as long as we document 
it. E.g.
   ```scala
   val node = scala.xml.XML.load(...)
   val noComments = CustomRemoveCommentsTransformer.transform(node)
   val testSuite = scalaxb.fromXML[TestSuite](noComments)
   ```



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

Reply via email to