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 2023/01/09 16:00:53 UTC

[GitHub] [daffodil] jadams-tresys opened a new pull request, #907: Properly handle dfdlx:repValues=''

jadams-tresys opened a new pull request, #907:
URL: https://github.com/apache/daffodil/pull/907

   This should have been failing schema validation, but instead would result in an error when we attempted to pasre a number from an empty string.
   
   DAFFODIL-2632


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


[GitHub] [daffodil] jadams-tresys commented on pull request #907: Properly handle dfdlx:repValues=''

Posted by GitBox <gi...@apache.org>.
jadams-tresys commented on PR #907:
URL: https://github.com/apache/daffodil/pull/907#issuecomment-1375988232

   Forgot to add the new tdml file I created when I did a git commit.  Should all pass now.


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


[GitHub] [daffodil] stevedlawrence commented on a diff in pull request #907: Properly handle dfdlx:repValues=''

Posted by GitBox <gi...@apache.org>.
stevedlawrence commented on code in PR #907:
URL: https://github.com/apache/daffodil/pull/907#discussion_r1065012330


##########
daffodil-test/src/test/resources/org/apache/daffodil/extensions/enum/enumInvalid.tdml:
##########
@@ -0,0 +1,69 @@
+<?xml version="1.0" encoding="UTF-8"?>
+<!--
+  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.
+-->
+
+<testSuite
+  xmlns:ex="http://example.com"
+  xmlns:tdml="http://www.ibm.com/xmlns/dfdl/testData"
+  xmlns="http://www.ibm.com/xmlns/dfdl/testData"
+  xmlns:xs="http://www.w3.org/2001/XMLSchema"
+  xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
+  xmlns:dfdl="http://www.ogf.org/dfdl/dfdl-1.0/"
+  xmlns:dfdlx="http://www.ogf.org/dfdl/dfdl-1.0/extensions"
+  xmlns:fn="http://www.w3.org/2005/xpath-functions"
+  xmlns:tns="http://example.com"
+  defaultRoundTrip="onePass"
+  defaultValidation="off">
+
+  <tdml:defineSchema
+    name="s3"
+    useDefaultNamespace="false"
+    elementFormDefault="unqualified"
+    xmlns="http://www.w3.org/2001/XMLSchema">
+
+    <include schemaLocation="org/apache/daffodil/xsd/DFDLGeneralFormat.dfdl.xsd"/>
+    <dfdl:format ref="ex:GeneralFormat" representation="binary"/>
+
+    <element name="r2">
+      <complexType>
+        <sequence>
+          <element name="e2" type="ex:enum2"/>
+        </sequence>
+      </complexType>
+    </element>
+
+    <simpleType name="enum2" dfdlx:repType="ex:myByte">
+      <restriction base="xs:string">
+        <enumeration value="valid" dfdlx:repValues="0"/>
+        <enumeration value="empty" dfdlx:repValues=""/>
+      </restriction>
+    </simpleType>
+
+  </tdml:defineSchema>
+
+  <parserTestCase name="emptyRepValues" model="s3" root="r2" validation="off">
+    <document>
+      <documentPart type="bits">01010101</documentPart>
+    </document>
+    <errors>
+      <error>Schema Definition Error</error>
+      <error>'' is not a valid value</error>
+      <error>NonEmptyListofDFDLStringLiteralOrNonEmptyListOfInteger</error>

Review Comment:
   Should we check that `%ES;` is in the error message? The whole point of this special type is so we can give a better message, so we should verify that the unique part is included and it actually is more helpful.



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


[GitHub] [daffodil] jadams-tresys merged pull request #907: Properly handle dfdlx:repValues=''

Posted by GitBox <gi...@apache.org>.
jadams-tresys merged PR #907:
URL: https://github.com/apache/daffodil/pull/907


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


[GitHub] [daffodil] jadams-tresys commented on a diff in pull request #907: Properly handle dfdlx:repValues=''

Posted by GitBox <gi...@apache.org>.
jadams-tresys commented on code in PR #907:
URL: https://github.com/apache/daffodil/pull/907#discussion_r1065027417


##########
daffodil-test/src/test/resources/org/apache/daffodil/extensions/enum/enumInvalid.tdml:
##########
@@ -0,0 +1,69 @@
+<?xml version="1.0" encoding="UTF-8"?>
+<!--
+  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.
+-->
+
+<testSuite
+  xmlns:ex="http://example.com"
+  xmlns:tdml="http://www.ibm.com/xmlns/dfdl/testData"
+  xmlns="http://www.ibm.com/xmlns/dfdl/testData"
+  xmlns:xs="http://www.w3.org/2001/XMLSchema"
+  xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
+  xmlns:dfdl="http://www.ogf.org/dfdl/dfdl-1.0/"
+  xmlns:dfdlx="http://www.ogf.org/dfdl/dfdl-1.0/extensions"
+  xmlns:fn="http://www.w3.org/2005/xpath-functions"
+  xmlns:tns="http://example.com"
+  defaultRoundTrip="onePass"
+  defaultValidation="off">
+
+  <tdml:defineSchema
+    name="s3"
+    useDefaultNamespace="false"
+    elementFormDefault="unqualified"
+    xmlns="http://www.w3.org/2001/XMLSchema">
+
+    <include schemaLocation="org/apache/daffodil/xsd/DFDLGeneralFormat.dfdl.xsd"/>
+    <dfdl:format ref="ex:GeneralFormat" representation="binary"/>
+
+    <element name="r2">
+      <complexType>
+        <sequence>
+          <element name="e2" type="ex:enum2"/>
+        </sequence>
+      </complexType>
+    </element>
+
+    <simpleType name="enum2" dfdlx:repType="ex:myByte">
+      <restriction base="xs:string">
+        <enumeration value="valid" dfdlx:repValues="0"/>
+        <enumeration value="empty" dfdlx:repValues=""/>
+      </restriction>
+    </simpleType>
+
+  </tdml:defineSchema>
+
+  <parserTestCase name="emptyRepValues" model="s3" root="r2" validation="off">
+    <document>
+      <documentPart type="bits">01010101</documentPart>
+    </document>
+    <errors>
+      <error>Schema Definition Error</error>
+      <error>'' is not a valid value</error>
+      <error>NonEmptyListofDFDLStringLiteralOrNonEmptyListOfInteger</error>

Review Comment:
   The %ES; check had only been for nilValue.  Does it make sense to have a dfdlx:repValues="%ES;"?  If it does and we want to suggest that, this will need more changes and we would have to go back to ignoring the minLength restriction and add a check for empty string before attempting to parse as an number.



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


[GitHub] [daffodil] stevedlawrence commented on a diff in pull request #907: Properly handle dfdlx:repValues=''

Posted by GitBox <gi...@apache.org>.
stevedlawrence commented on code in PR #907:
URL: https://github.com/apache/daffodil/pull/907#discussion_r1065030175


##########
daffodil-test/src/test/resources/org/apache/daffodil/extensions/enum/enumInvalid.tdml:
##########
@@ -0,0 +1,69 @@
+<?xml version="1.0" encoding="UTF-8"?>
+<!--
+  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.
+-->
+
+<testSuite
+  xmlns:ex="http://example.com"
+  xmlns:tdml="http://www.ibm.com/xmlns/dfdl/testData"
+  xmlns="http://www.ibm.com/xmlns/dfdl/testData"
+  xmlns:xs="http://www.w3.org/2001/XMLSchema"
+  xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
+  xmlns:dfdl="http://www.ogf.org/dfdl/dfdl-1.0/"
+  xmlns:dfdlx="http://www.ogf.org/dfdl/dfdl-1.0/extensions"
+  xmlns:fn="http://www.w3.org/2005/xpath-functions"
+  xmlns:tns="http://example.com"
+  defaultRoundTrip="onePass"
+  defaultValidation="off">
+
+  <tdml:defineSchema
+    name="s3"
+    useDefaultNamespace="false"
+    elementFormDefault="unqualified"
+    xmlns="http://www.w3.org/2001/XMLSchema">
+
+    <include schemaLocation="org/apache/daffodil/xsd/DFDLGeneralFormat.dfdl.xsd"/>
+    <dfdl:format ref="ex:GeneralFormat" representation="binary"/>
+
+    <element name="r2">
+      <complexType>
+        <sequence>
+          <element name="e2" type="ex:enum2"/>
+        </sequence>
+      </complexType>
+    </element>
+
+    <simpleType name="enum2" dfdlx:repType="ex:myByte">
+      <restriction base="xs:string">
+        <enumeration value="valid" dfdlx:repValues="0"/>
+        <enumeration value="empty" dfdlx:repValues=""/>
+      </restriction>
+    </simpleType>
+
+  </tdml:defineSchema>
+
+  <parserTestCase name="emptyRepValues" model="s3" root="r2" validation="off">
+    <document>
+      <documentPart type="bits">01010101</documentPart>
+    </document>
+    <errors>
+      <error>Schema Definition Error</error>
+      <error>'' is not a valid value</error>
+      <error>NonEmptyListofDFDLStringLiteralOrNonEmptyListOfInteger</error>

Review Comment:
   Ah, you're right, this is a test for repValues. I don't think %ES; is valid for repValues so what you have is probably fine. Presumably we already have a test that checks for the ES error message when nilValue="".



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