Github user stevedlawrence commented on a diff in the pull request:
https://github.com/apache/incubator-daffodil/pull/5#discussion_r151129750
--- Diff:
daffodil-core/src/main/scala/edu/illinois/ncsa/daffodil/dsom/Root.scala ---
@@ -2,19 +2,31 @@ package edu.illinois.ncsa.daffodil.dsom
import edu.illinois.ncsa.daffodil.grammar.RootGrammarMixin
import edu.illinois.ncsa.daffodil.xml.NamedQName
+import edu.illinois.ncsa.daffodil.xml.XMLUtils
+import scala.xml.Node
-final class Root(parentArg: SchemaDocument,
+/**
+ * Root is a special kind of ElementRef that has no enclosing group.
+ *
+ * This is the entity that is compiled by the schema compiler.
+ */
+final class Root(defXML: Node, parentArg: SchemaDocument,
namedQNameArg: NamedQName,
globalElementDecl: => GlobalElementDecl)
- extends AbstractElementRef(
- <root/>, // % Attribute(None, "ref", Text(refQName.toQNameString),
Null), // have to have ref attribute.
- parentArg, 1)
+ extends AbstractElementRef(null, parentArg, 1)
with RootGrammarMixin {
+ final override lazy val xml = {
+ val elem = XMLUtils.getXSDElement(defXML.scope)
+ val attrs =
+ <dummy ref={ refQName.toQNameString }/>.attributes
+ val res = elem % attrs
--- End diff --
Seems an odd way to add an attribute. Can you do something like
```
val res = elem % Attribute("", "ref", refQName.toQNameString,
scala.xml.Null)
```
Not sure if Null is correct for the ``next`` parameter, but something like
that is a little more clear to me.
---