Hi I've got several XSLT 2.0 files. I need to transform these with C#.. I use the following code I got from this site: http://www.csharpfriends.开发者_高级运维com/Articles/getArticle.aspx?articleID=63
public bool Transform(string XMLPath, string XSLPath, string newXMLname){
try{
XPathDocument myXMLPath = new XPathDocument(XMLPath); //load the Xml doc
XslCompiledTransform myXSLTrans = new XslCompiledTransform();
myXSLTrans.Load(XSLPath); //load the Xsl
XmlTextWriter myWriter = new XmlTextWriter(newXMLname, null); //create the output stream
myXSLTrans.Transform(myXMLPath, null, myWriter); //do the actual transform of Xml ---> fout!!??
myWriter.Close() ;
return true;
}catch(Exception e){
return false;
}
}
But it doesn't work.. I think it's because I use XSLT version 2.0. Is there a code/way to do this? Because there is no way to change my XSLT files to version 1.0...
Thanks in advance!
The two XSLT 2.0 processors that are designed to work in the .NET environment are Saxon.NET and XQSharp.
The XslCompiledTransform and XslTransform processors that come as part of .NET only implement XSLT 1.0.
Natively .Net Framework doesn't support XSLT 2.0. I would suggest to use XSLT 1.0, but if you can't, then use third party component, for example Saxon.
精彩评论