SpeculativeParsing (data, dfdlSchema, globalElementName) lookforType( globalElement) if (notfound) { return (error) } return bool lookforType (t type) { if (INITIATOR expected and notfound) { return(notfound) } if (prefixSeparator-expected and notfound) {return(notfound) } if (xpath(assert-timing-before) = false) { return(notfound) } if (initiator and terminator) { outofscope(endingsyntax) } add terminator to endingsyntax if (complexType) lookforComplexType() else if (maxoccurs>1) { lookforArray } else lookforSimpleType() if (initiator and terminator) { backInscope(endingsyntax) } if (terminator(e) defined and notfound) { return(notfound) } return(found) } element lookforComplexType (g group) { Switch (GroupType) When(Sequence) { if (prefixSeparator(g) or inFixSeparator(g) or postfixSeparator(g) are defined){ addto endingSyntax } for (each type t in group g ) { lookforType(type(t)) if (notfound and not(optional)) {return(notfound)} } return(found) } When(Choice) { for (each type t in group g ) { lookforType(type(t)) if found return(found) } return(notfound) } When(Any) { ??? } } lookforArray (t) { do {lookforSimpleType()} while (found) } lookforSimpleType (t) { findlengthInData(t) if (knownLength(t) noteq findlengthInData(t)) { return(notfound) } if (xpath(assert-timing-after) or (discriminator) = false) { return(notfound) } /* would need to add validation of facets here if needed */ return(found); } findlengthInData (t type) { if (rep=binary and knownlength(t)) { return (min(knownlength(t), lenghtOfRemainigData )) } else if (rep=text and endingSyntax){ scan for endingSynatx return (length) } else if (rep=text and knownlength(t)) return(length) else return (lengthOfRemianingData) } int knownlength(t type) { if (lengthGivenInModel) { return (lengthFromModel) } else if (lengthReference) { return ( valueOfReferencedField) } else return(notdefined) }