stevedlawrence commented on a change in pull request #207: Added support for
enumerations and TypeValueCalc
URL: https://github.com/apache/incubator-daffodil/pull/207#discussion_r278231261
##########
File path:
daffodil-core/src/main/scala/org/apache/daffodil/dsom/ChoiceGroup.scala
##########
@@ -139,6 +167,52 @@ 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) => {
+ /*
+ * We tolerate type objects being copies or the same object because we
compare the QNames.
+ */
+ if (a.namedQName != b.namedQName) {
+ SDE("All children of an <xs:choice> with
choiceDispatchKeyKind=byType must have the same reptype")
Review comment:
Might be worth including information about a and b to show which elements to
not have the same reptype, since this SDE will just show the location of the
containing choice.
----------------------------------------------------------------
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