Interpretation of the Recommendation

At one point while developing MorganaXProc we came to the need of interpreting the rules set out in the Recommendation. When it comes to implementing <p:unwrap> we are facing the problem about what to do, when the document element is unwrapped and the resulting document then is not well-formed XML. The Recommendation mentions this case, but it is unclear, whether this is just a warning for pipeline designers about what might happen or if it is a hint to implementors to allow non well-formed XML on the output of this step.

On the other hand, there is XProc's dynamic error XD0001, which reads: "It is a dynamic error if a non-XML resource is produced on a step output or arrives on a step input." An there is the whole logic of XProc making it a pipeline language where xml document flow through the port. Taken this two things together, one could come to the conclusion, that event in the special case with <p:unwrap> the rationale holds.

So: MorgganaXProc is probably more strict on <p:unwrap> than the Recommendation, for it will require even the output of <p:unwrap> to be a valid xml document. This means you can unwrap document element, but if you do so, the resulting document must be valid xml. If it is not, an XD0001 error will occur.