XSLT problem with 'disable-output-espacing' parameter

G

Guest

Hey,

I'm doing a series of XSL Transformations from a C#.NET Console app.

I've designed a .xsl file (to output to "text" not "xml") to generate a text
file with entries that look like:

"<OD:FO:"yes.gif",Picture,"C:\images\yes.gif">"

I designed the .xsl file in Marrowsofts Xselerator application and when I
run the stylesheet over the .xml file in this application I do infact get the
output entries I want (as shown above). However when I run the XSL
Transformations from my Console application my output becomes, the escaped
version:

"<OD:FO:"yes.gif",Picture,"C:\images\yes.gif">"

I'm doing the transformation in the Console application using the following
code:

--Start Fragment--

XslTransform transformer = new XslTransform();

XmlUrlResolver resolver = new XmlUrlResolver();
resolver.Credentials = System.Net.CredentialCache.DefaultCredentials;

// Load the .xsl file
transformer.Load(transformationFilePath, resolver);

// Load the target of the transformation
XPathDocument document = new XPathDocument(inFilePath);

// Create a stream to the output file
StreamWriter writer = new StreamWriter(outFilePath);

XmlTextWriter xmlWriter = new XmlTextWriter(writer);

// Perform the transformation and write out the results
transformer.Transform(document, parameters, xmlWriter, resolver);

--End Fragment--

Does anyone have any suggestions as to why my output is coming out as
escaped sequences when I'm specifying that I don't want them to be escaped!

Thank you,

Sam.
 
G

Guest

Shortly after posting this I discovered the reason why this was occuring,
although I am unsure as to whether this is documented anywhere.

The reason why this was occuring is because I was passing an XmlWriter
object to the XslTransform.Transform() function as the object to use to write
out the result of the transformation.

I have edited the code fragment below to illustrate the simple change that I
made.
--Start Fragment--

XslTransform transformer = new XslTransform();

XmlUrlResolver resolver = new XmlUrlResolver();
resolver.Credentials = System.Net.CredentialCache.DefaultCredentials;

// Load the .xsl file
transformer.Load(transformationFilePath, resolver);

// Load the target of the transformation
XPathDocument document = new XPathDocument(inFilePath);

// Create a stream to the output file
StreamWriter writer = new StreamWriter(outFilePath);

// I removed this line
// XmlTextWriter xmlWriter = new XmlTextWriter(writer);

// Then I edited this line to use the straight StreamWriter object instead
transformer.Transform(document, parameters, writer, resolver);
// Perform the transformation and write out the results
// transformer.Transform(document, parameters, xmlWriter, resolver);
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Similar Threads


Top