I have a generic routing for passing parameters to an XSLT see code fragment 1
The test harness for is in code fragment 2
for some reason the parameter is not been passed to the XSLT
Can anyone help
FRAGMENT 1
public string Transform(string xslt, string xmlBuffer, string xsltParamsAsXml, string namespaceXML) { string functionReturnValue = null; try { XmlDocument xmlParamsDoc = new XmlDocument(); xmlParamsDoc.LoadXml(xsltParamsAsXml); XsltArgumentList argsList = new XsltArgumentList(); foreach (XmlNode xmlParam in xmlParamsDoc.SelectNodes("/Params/Param")) { string name = xmlParam.Attributes.GetNamedItem("name").InnerText; string value = xmlParam.Attributes.GetNamedItem("value").InnerText; argsList.AddParam(name, namespaceXML, value); } XmlDocument XMLDOM = new XmlDocument(); XMLDOM.LoadXml(xmlBuffer); //' We create a new XslCompiledTransform object which supercedes the XslTransform class XslCompiledTransform Transformer = new XslCompiledTransform(); //XmlReader xmlReader = new XmlTextReader(); //Convert to Bytes System.Text.ASCIIEncoding encoding = new System.Text.ASCIIEncoding(); Byte[] bytes = encoding.GetBytes(xslt); MemoryStream ms = new MemoryStream(bytes); Stream xlstStream = (Stream)ms; XmlReader xmlReader = XmlReader.Create(xlstStream); //' We have to load the XSL style sheet before we perform any transformation Transformer.Load(xmlReader); //' We are setting the XmlWriterSettings so that we match the conformance level of the XmlReaderSettings XmlWriterSettings myWriterSettings = new XmlWriterSettings(); myWriterSettings.ConformanceLevel = ConformanceLevel.Fragment; //' Create a string builder which will eventually contain our transformed results StringBuilder myString = new StringBuilder(); //' Perform the transformation using the XmlDocument, the Parameters created from the Iterator and //' write it to the StringBuilder Transformer.Transform(XMLDOM, argsList, XmlWriter.Create(myString, myWriterSettings)); functionReturnValue = myString.ToString(); } /* throw */ catch (Exception ex) { GenericLogger.ErrorLog(_userName, _machineName, ex.Message); throw new Exception("xmlFunctions:: Transform " + ex.Message); } /* catch */ return functionReturnValue; }
MANY THANKS