Note that there are some explanatory texts on larger screens.

plurals
  1. POUsing C# to do xslt transform ignoring xsl:output
    primarykey
    data
    text
    <p>I am doing an xslt transform inside my c# program. When I run the xslt on its own it outputs just fine, but when I run it from within my c# program it always leaves off the:</p> <pre><code>&lt;?xml version="1.0" encoding="UTF-8"?&gt; </code></pre> <p>At the top of the resulting xml document. My XSLT file looks like:</p> <pre><code>&lt;?xml version="1.0" encoding="utf-8"?&gt; &lt;xsl:stylesheet version="1.0" xmlns:xsl="http://www.w3.org/1999/XSL/Transform" xmlns:hd="http://www.hotdocs.com/schemas/component_library/2009" xmlns:xsd="http://www.w3.org/2001/XMLSchema" xmlns:xml="http://www.w3.org/XML/1998/namespace"&gt; &lt;xsl:output method="xml" omit-xml-declaration="no" version="1.0" encoding="UTF-8"/&gt; &lt;xsl:template match="/xsd:schema"&gt; &lt;hd:componentLibrary xmlns:hd="something" version="10"&gt; &lt;/hd:componentLibrary&gt; &lt;/xsl:template&gt; &lt;xsl:template match="text()" /&gt; &lt;/xsl:stylesheet&gt; </code></pre> <p>I am running the xslt in my c# program like this:</p> <pre><code>XPathDocument myXPathDoc = new XPathDocument(PathToXMLDocument); XslCompiledTransform myXslTrans = new XslCompiledTransform(); myXslTrans.Load(PathToXSLTDocument); XmlTextWriter myWriter = new XmlTextWriter(PathToOutputLocation, null); myXslTrans.Transform(myXPathDoc,null,myWriter); myWriter.Close(); </code></pre> <p>I have tried the xslt document without the xsl:output line, but that does not seem to help.</p> <p>How can i get the ?xml tag at the top of my outputted xml file?</p> <p>Thanks</p>
    singulars
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    plurals
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
 

Querying!

 
Guidance

SQuiL has stopped working due to an internal error.

If you are curious you may find further information in the browser console, which is accessible through the devtools (F12).

Reload