Hi!

I'm new to XML and XSLT and need to transform some XML into other XML file in a .NET project. I use an XmlTextWriter to output the result. When I call Transform method of the XslTransform I can filter out some data but I don't get the Prolog (XML version="...).

I shouldn't have to do anything with the XmlWriter object between creation and use by the Transform method, should I? If I call WriteStartDocument() and WriteEndDocument() before and after Transformation I get an InvalidOperationException saying:

"Token Content in state Prolog would result in an invalid XML document."

Stack Trace:

at System.Xml.XmlTextWriter.AutoComplete(Token)
at System.Xml.XmlTextWriter.WriteString(String)
at System.Xml.Xsl.WriterOutput.RecordDone(RecordBuilder)
at System.Xml.Xsl.RecordBuilder.TheEnd()
at System.Xml.Xsl.Processor.Execute()
at System.Xml.Xsl.XslTransform.Transform(XPathNavigator, XsltArgumentList, XmlWriter, XmlResolver)
at System.Xml.Xsl.XslTransform.Transform(IXPathNavigable, XsltArgumentList, XmlWriter)

Any ideas what may cause this?

Very greatful for any hints!

Magnus