c# .net xslTransform using XsltArgumentList

Collapse
X
 
  • Time
  • Show
Clear All
new posts
  • MedIt
    New Member
    • Feb 2008
    • 15

    c# .net xslTransform using XsltArgumentList

    Hi all,
    Help needed in the xsl transformation in c# while passing with arguments.
    I am trying to transform an xml programtically (c#), while passing with two parameters using the
    XsltArgumentLis t class.
    My problem is in the transformed xml.
    Even when I set in my XmlWriter the Encoding to UTF-8, or even when I set it null,
    my output transformed xml is without the xml header encoding attribute:<?xml version="1.0" encoding="utf-8"?>
    Wether I set the encoding to utf-8 or null, it does not have any effect on my output file.

    My bits of code doing the transformation is:

    XslTransform myTran = new XslTransform();
    myTran.Load(xsl );

    XsltArgumentLis t args = new XsltArgumentLis t();
    args.AddParam(" param1", "", param1);
    args.AddParam(" param2", "", param2);

    XPathDocument xpathdocument = new XPathDocument(i File);
    XmlTextWriter xmlWriter = new XmlTextWriter(o File, Encoding.UTF8);
    // XmlTextWriter xmlWriter = new XmlTextWriter(o File, null);
    myTran.Transfor m(xpathdocument , args, xmlWriter);
    xmlWriter.Close ();

    Please help me clear my mind on this!
    Thanks in advance.
Working...