first_page the funky knowledge base
personal notes from way, _way_ back and maybe today

System.Xml.Xsl.XslTransform PROBLEM: Document Type Declarations Are Ignored; xsl:output Element; DOCTYPE; .NET Framework 1.1

The xsl:output element is supported by the .NET Framework. The xsl:output element is ignored when the output of the XslTransform.Transform method is an XmlReader or XmlWriter. These types are not byte-stream-based, using .NET-native UTF-16 encoded strings to store data.

The following sketch uses the MemoryStream type to represent data as bytes instead of UTF-16 strings:

XslTransform xslt = new XslTransform();
XPathDocument xml = new XPathDocument("data.xml");
MemoryStream ms = new MemoryStream();

xslt.Load("template.xslt");
xslt.Transform(xml,null,ms,null);

xhtml = Encoding.UTF8.GetString(ms.GetBuffer());

For details see "Outputs from an XslTransform" at:

http://msdn.microsoft.com/library/
    en-us/cpguide/html/cpconInputsOutputsToXslTransform.asp
mod date: 2005-10-28T22:43:41.000Z