mbeckerle commented on a change in pull request #207: Added support for
enumerations and TypeValueCalc
URL: https://github.com/apache/incubator-daffodil/pull/207#discussion_r275127919
##########
File path:
daffodil-core/src/main/scala/org/apache/daffodil/dsom/ChoiceGroup.scala
##########
@@ -139,6 +167,49 @@ abstract class ChoiceTermBase(
ev
}
+ // If choiceDispatchKeyKind is byType, verify that all our children share a
repType,
+ // and use that. Otherwise, there is no need to associate a repType with
this choice
+ override final lazy val optRepTypeFactory: Option[SimpleTypeDefFactory with
NamedMixin] = defaultableChoiceDispatchKeyKind match {
+ case ChoiceKeyKindType.ByType => {
+ val branchReptypes: Seq[SimpleTypeDefFactory with NamedMixin] =
groupMembers.map(term => {
+ term match{
+ case e: ElementDeclMixin => e.typeDef match{
+ case t: SimpleTypeDefBase => t.optRepTypeDefFactory match{
+ case None => SDE("When <xs:choice> has
choiceBranchKey=\"byType\", all branches must have a type which defines a
repType")
+ case Some(x) => x
+ }
+ case _ : SimpleTypeBase => SDE("When <xs:choice> has
choiceBranchKey=\"byType\", no branch can have a primitive xsd type")
+ case _ => SDE("When <xs:choice> has choiceBranchKey=\"byType\",
all branches must be a simple type")
+ }
+ case _ => SDE("When <xs:choice> has choiceBranchKey=\"byType\",
all branches must be a simple element")
+ }
+ })
+ val ans = branchReptypes.reduce((a, b) => {
+ /*
+ * Since we inline all type definitions, the repTypes will not be
literally equal here, even when they are literally
+ * the same type in schema. Instead of checking for literal equality,
we compare their qNames.
+ */
+ if (a.namedQName != b.namedQName) {
+ SDE("All children of an <xs:choice> with
choiceDispatchKeyKind=byType must have the same reptype")
+ }
+ a
+ })
+ Some(ans)
+ }
+ case ChoiceKeyKindType.Speculative => None
+ case ChoiceKeyKindType.Explicit => None
+ case ChoiceKeyKindType.Implicit => None
+ }
+
+ /*
+ * Logically speaking, a choice group does have a repValueSet, which can be
found as either the union
+ * of that of its choices, or the union of its choiceBranchKey.
+ * In theory, these are both computable, but coersing the choiceBranchKeys
into the appropriate type
+ * is more work than justified for an attribute that we do not actually need.
Review comment:
I didn't understand the comment above.
----------------------------------------------------------------
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