Github user mbeckerle commented on a diff in the pull request:
https://github.com/apache/incubator-daffodil/pull/5#discussion_r149840571
--- Diff:
daffodil-core/src/main/scala/edu/illinois/ncsa/daffodil/dsom/ModelGroup.scala
---
@@ -80,17 +96,56 @@ sealed abstract class ModelGroupFactory private () {
object ModelGroupFactory extends ModelGroupFactory()
+sealed abstract class TermFactory private () {
+ /**
+ * Factory for Terms
+ *
+ * Because of the context where this is used, this returns a list. Nil
for non-terms, non-Nil for
+ * an actual term. There should be only one non-Nil.
+ *
+ * This could be static code in an object. It doesn't reference any of
the state of the ModelGroup,
+ * it's here so that type-specific overrides are possible in Sequence or
Choice
+ */
+ def apply(child: Node, parent: GroupDefLike, position: Int) = {
+ val childList: List[Term] = child match {
+ case <element>{ _* }</element> => {
+ val refProp = child.attribute("ref").map { _.text }
+ // must get an unprefixed attribute name, i.e. ref='foo:bar', and
not
+ // be tripped up by dfdl:ref="fmt:fooey" which is a format
reference.
+ refProp match {
+ case None => {
+ val factory = parent.schemaSet.LocalElementDeclFactory(
+ child,
+ parent.schemaDocument)
+ val eDecl = factory.forModelGroup(parent, position)
+ List(eDecl)
+ }
+ case Some(_) => List(new ElementRef(child, parent, position))
+ }
+ }
+ case <annotation>{ _* }</annotation> => Nil
+ case textNode: Text => Nil
+ case _ => ModelGroupFactory(child, parent, position, false)
+ }
+ childList
+ }
+}
+
+object TermFactory extends TermFactory()
--- End diff --
collapse to just the object. class is unnecessary.
---