I am trying to just make a basic class to read an xml file and apple the xslt but I keep getting an System.Xml.Xsl.XsltCompileException on the transform load event.
I have looked up what causes this error and it says that there is a problem in the xslt file, but there doesn't seem to be a problem with the xslt file that I can find.
Can someone help me identify the problem? Thanks
XSLTCode:XPathDocument xpd = new XPathDocument(@"E:\Visual Studio Projects\XmlWithXslt\XmlWithXslt\xml.xml"); XslTransform xlst = new XslTransform(); XPathNavigator xpn = xpd.CreateNavigator(); XmlTextWriter writer = new XmlTextWriter(@"E:\Visual Studio Projects\XmlWithXslt\XmlWithXslt\result.xml", null); xlst.Load(xpn); xlst.Transform(xpd, null, writer); writer.Close(); StreamReader stream = new StreamReader (@"E:\Visual Studio Projects\XmlWithXslt\XmlWithXslt\result.xml"); Console.Write("**This is result document**\n\n"); Console.Write(stream.ReadToEnd());;
XMLCode:<?xml version="1.0"?> <xsl:sytlesheet version="1.0" xmlns:xsl="http://www.w3.org/1999/XSL/Transform"> <xsl:template match="PERIODIC_TABLE"> <HTML> <xsl:apply-templates/> </HTML> </xsl:template> <xsl:template match="ATOM"> <P> <xsl:apply-templates/> </P> </xsl:template> </xsl:sytlesheet>
Code:<?xml version="1.0"?> <?xml-stylesheet type="application/xml" href="style.xsl"?> <PERIODIC_TABLE> <ATOM STATE="GAS"> <NAME>Hydrogen</NAME> <SYMBOL>H</SYMBOL> <NUMBER>1</NUMBER> <WEIGHT>1.00794</WEIGHT> </ATOM> </PERIODIC_TABLE>




Reply With Quote