stevedlawrence commented on a change in pull request #262: Unordered sequences
URL: https://github.com/apache/incubator-daffodil/pull/262#discussion_r324002092
 
 

 ##########
 File path: 
daffodil-runtime1/src/main/scala/org/apache/daffodil/processors/parsers/SequenceParserBases.scala
 ##########
 @@ -224,12 +264,35 @@ abstract class OrderedSequenceParserBase(
               pstate.setSuccess()
               isDone = true
             }
+            case (MissingItem | MissingSeparator | FailureUnspecified) if 
(!isOrdered) => {
+              pstate.setSuccess()
+              isDone = true
+            }
             case _ => // ok.
           }
           pstate.mpstate.moveOverOneGroupIndexOnly()
         } // end case scalarParser
       } // end match case parser
-      scpIndex += 1
+      if (isOrdered)
+        scpIndex += 1
+      else if (isDone) {
+        val erds = 
pstate.infoset.asInstanceOf[DIComplex].flattenAndValidateChildNodes()
+        pstate.infoset.asInstanceOf[DIComplex].sortChildNodesByPosition()
+
+        // Check for a min/maxOccurs validation error
+        if (erds.isDefined) {
+          erds.get.foreach(e => {
+            val min = e.minOccurs
+            val max = e.maxOccurs
+            val isUnbounded = max == -1
+
+            if (isUnbounded)
+              pstate.validationError("Element %s failed check of 
minOccurs='%s' and maxOccurs='UNBOUNDED", e.diagnosticDebugName, min)
+            else
+              pstate.validationError("Element %s failed check of 
minOccurs='%s' and maxOccurs='%s'", e.diagnosticDebugName, min, max)
+          })
+        }
 
 Review comment:
   Duplicated logic, can it be move to function?

----------------------------------------------------------------
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.
 
For queries about this service, please contact Infrastructure at:
[email protected]


With regards,
Apache Git Services

Reply via email to