Hi all - I am attempting to modify an XSL before applying a transformation to it. I would like to change the file being imported based upon certain conditions.
My approach was the following: docXML = new XmlDocument(); docXML.LoadXml(Request.ToString()); XmlNamespaceManager ns = new XmlNamespaceManager(docXML.NameTable); ns.AddNamespace(String.Empty,"http://www.w3.org/1999/XSL/Transform"); ns.AddNamespace("xsl","http://www.w3.org/1999/XSL/Transform"); XmlDocumentFragment docFrag = docXML.CreateDocumentFragment(); try { // Does not work - it gives the error "'xsl' is an undeclared namespace. " docFrag.InnerXml = "<xsl:import href='head2.xslt'/>"; if((node = docXML.DocumentElement.SelectSingleNode ("//xsl:stylesheet",ns)) != null) { node.InsertAfter(docFrag,node.FirstChild); } } Because I am not adding the xsl namespace declaration, the docFrag line fails. However I don't want to add it, since it already exists in the loaded XSL. Is there a way to add the document fragment without having to resolve the namespace problem? If not, what other approach could I take? Thanks a lot.