PDA

Click to See Complete Forum and Search --> : [RESOLVED] [1.0/1.1] Xml And Xslt


Jumpercables
Jan 9th, 2007, 11:36 AM
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


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());;


XSLT

<?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>


XML

<?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>

mendhak
Jan 9th, 2007, 11:50 AM
When it matches ATOM, what template does it apply?

axion_sa
Jan 9th, 2007, 11:56 AM
xsl:sytlesheet

:)

mendhak
Jan 9th, 2007, 11:57 AM
Lol :d

penagate
Jan 9th, 2007, 12:22 PM
apple the xslt

Spelling isn't exactly your forté, is it? :)

Jumpercables
Jan 9th, 2007, 01:38 PM
Spelling isn't exactly your forté, is it? :)
Spelling is fun!

I needed to apple :) the correct template.

Thanks...