The errors are showing up because you are attempting to output something that is not well-formed.
Is it really a requirement that the "form" start tag and end tag appear within prompt elements separately?
I will slightly modify a reply from Mr. Kay (by only changing "tr" to "form") from the October 2001 archives "HTML Forced Output" dealing with a similar situation:
"A stylesheet transforms an input tree to an output tree, and then serializes the result as XML or HTML. Clearly the tree can't contain half a node.
You can cheat by using
but you need to be aware that you are not using the language the way it was intended to be used, and that this will limit the options on deploying the stylesheet. I'd prefer to look back at your design, and correct it at source. There must be a better way of doing this."