Transformation problems...
Question posted by: Andrew Connell
(Guest)
on
November 12th, 2005 02:08 AM
I have an XML document and an XSLT transformation sheet. My first issue is that my XML file won't load into the XPathDocument object. However, when I use an obsolete transformation method where I specify the XML input file and output file, I get the same error. The error is:
An unhandled exception of type 'System.Xml.XmlException' occurred in system.xml.dll
Additional information: System error.
Here's my code... commented to show where the errors are...
//XmlDocument xmlDoc = new XmlDocument();
XslTransform xslDoc = new XslTransform();
// ++++++ IF I UNCOMMENT THIS, THE FILE LOADS JUST FINE
//xmlDoc.Load(this.xmlFilePath.Text);
//xmlDoc.Save(@"c:\temp\xml.xml");
xslDoc.Load(this.xslFilePath.Text, null);
// +++++ ERROR HAPPENS HERE...
XPathDocument xpathdocument = new XPathDocument(@"C:\Temp\xml.xml");
XmlTextWriter writer = new XmlTextWriter(@"C:\temp\output.html", System.Text.Encoding.UTF8);
writer.Formatting = Formatting.Indented;// never reaches this part
xslDoc.Transform(xpathdocument, null, writer, null);
// +++++ IF I CHANGE THIS TO THE FOLLWOING, I GET THE SAME ERROR:
xslDoc.Transform(@"c:\temp\xml.xml", @"c:\temp\output.html");
1
Answer Posted
Why don't you catch the exception and print it out to see what the error is? It looks like there is an error in your file.
--
This posting is provided "AS IS" with no warranties, and confers no rights.
"Andrew Connell" <spam@aNOSPAMMEconnell.com> wrote in message news:OvWyXrEtDHA.2340@TK2MSFTNGP12.phx.gbl...
I have an XML document and an XSLT transformation sheet. My first issue is that my XML file won't load into the XPathDocument object. However, when I use an obsolete transformation method where I specify the XML input file and output file, I get the same error. The error is:
An unhandled exception of type 'System.Xml.XmlException' occurred in system.xml.dll
Additional information: System error.
Here's my code... commented to show where the errors are...
//XmlDocument xmlDoc = new XmlDocument();
XslTransform xslDoc = new XslTransform();
// ++++++ IF I UNCOMMENT THIS, THE FILE LOADS JUST FINE
//xmlDoc.Load(this.xmlFilePath.Text);
//xmlDoc.Save(@"c:\temp\xml.xml");
xslDoc.Load(this.xslFilePath.Text, null);
// +++++ ERROR HAPPENS HERE...
XPathDocument xpathdocument = new XPathDocument(@"C:\Temp\xml.xml");
XmlTextWriter writer = new XmlTextWriter(@"C:\temp\output.html", System.Text.Encoding.UTF8);
writer.Formatting = Formatting.Indented;// never reaches this part
xslDoc.Transform(xpathdocument, null, writer, null);
// +++++ IF I CHANGE THIS TO THE FOLLWOING, I GET THE SAME ERROR:
xslDoc.Transform(@"c:\temp\xml.xml", @"c:\temp\output.html");
|
|
|
What is Bytes?
We are a network of experts and professionals in IT and software development that help one another with answers to tough questions and share insights.
Get the best answers to your questions from over 196,847 network members.
Top Community Contributors
|