Studio Reports Illegal to Have Multiple Roots Because the XSLT Emits the Root Inside a for-each
The error Data is described as XML, but may not be: Illegal to have multiple roots (start tag in epilog?).
at [row,col {unknown-source}]: [92,2]
What does "Data is described as XML, but may not be: Illegal" mean in Workday Studio?
The step after a transform received a document with more than one top-level element, which is not well formed XML. This almost always means the stylesheet writes its outermost element once per input record instead of once per document.
Quick fix
Move the outermost result element above the xsl:for-each so it is written once, and keep only the repeating child inside the loop.
Permanent fix
Treat any bulk request wrapper as document scope, not record scope. Write the wrapper in the template that matches the document root and let a for-each or apply-templates fill in the repeating children, so the stylesheet cannot produce more than one root regardless of how many records arrive.
Troubleshooting
- Note the row and column in the message. It points at the start of the second root, so the content above that line is your first complete record and tells you what is being repeated.
- Open the stylesheet and find the outermost literal result element. Check whether it sits inside an xsl:for-each or an xsl:template that matches a repeating node.
- Store the transform output to a file before the failing step and open it. Multiple sibling top-level elements confirm the diagnosis in seconds.
- If the transform looks correct, check whether an earlier step concatenated two messages into one, since an aggregate or a loop that appends without a wrapper produces the same shape.
- Rule out a stray prolog. A second XML declaration part way through the payload produces a similar complaint and comes from concatenating two serialized documents.
Was this helpful?