Praveen wrote:
Quote:
var xslDoc = xslobj.documentElement;
var newNode =
xslobj.createNode(1,"xsl:import","http://www.w3.org/1999/XSL/Transform") ;
newNode.setAttribute ("href",server.mappath("common.xsl") ;
FirstChild=xslobj.documentElement.childNodes(0);
xslDoc.insertBefore(newNode, FirstChild);
>
This works fine in Javascript.
>
Now I'm trying to use the same logic in C Sharp.
Using System.Xml.Xsl.XslTransform for xsl.
Is it possible to do similar thing in C Sharp using
'System.Xml.Xsl.XslTransform' class.
XslTransform is an XSLT processor, not a DOM document. If you want to
manipulate a stylesheet as a DOM document with .NET then you can use
System.Xml.XmlDocument e.g.
XmlDocument stylesheet = new XmlDocument();
stylesheet.Load(xslpath);
XmlElement xslImport = stylesheet.CreateElement("xsl:import",
stylesheet.DocumentElement.NamespaceURI);
xslImport.SetAttribute("href", Server.MapPath("common.xsl");
stylesheet.DocumentElement.InsertBefore(xslImport,
stylesheet.DocumentElement.FirstChild);
Then pass that stylesheet object to the Load method of an XslTransform
instance that takes an IXPathNavigable
<http://msdn2.microsoft.com/en-us/library/ms163479.aspx>
Also note that with .NET 2.0 the preferred XSLT implementation is
XslCompiledTransform, not XslTransform, which should only be used with
..NET 1.x.
--
Martin Honnen --- MVP XML
http://JavaScript.FAQTs.com/