private static void Copy(System.Xml.Xsl.XsltArgumentList source, System.Xml.Xsl.XsltArgumentList target)
        {
            if (source == null)
            {
                throw new ArgumentNullException("source");
            }
            if (target == null)
            {
                throw new ArgumentNullException("target");
            }

            var parameters = (Hashtable)Reflector.GetField(source, "parameters");

            foreach (DictionaryEntry entry in parameters)
            {
                var qn = (XmlQualifiedName)entry.Key;
                target.AddParam(qn.Name, qn.Namespace, entry.Value);
            }
            var extensions = (Hashtable)Reflector.GetField(source, "extensions");

            foreach (DictionaryEntry entry in extensions)
            {
                target.AddExtensionObject((string)entry.Key, entry.Value);
            }
        }
Пример #2
0
        public void GetCraigslistJobDetailsTest()
        {
            XsltExtensions target = new XsltExtensions();
              var source = XDocument.Load( AppDomain.CurrentDomain.BaseDirectory + "\\craigslistResponse.xml" );
              var args = new System.Xml.Xsl.XsltArgumentList();

              args.AddExtensionObject( "urn:extensions", target );
              var actual = source.Transform( args, XDocument.Load( @"C:\Projects\Urbana\Marketing\LeadScraper\LeadScraper.Utils\Resources\CraigslistResponse.xslt" ), true );
              Console.Out.Write( actual.ToString() );
        }
Пример #3
0
 public static string ProcessString(string localhost, string xmlstring, string xslt, Hashtable htParams, Hashtable htExtObjs)
 {
     System.Xml.Xsl.XslCompiledTransform xsl = new System.Xml.Xsl.XslCompiledTransform();
     xsl.Load(localhost + xslt);
     XmlDocument xmldoc = new XmlDocument();
     xmldoc.LoadXml(xmlstring);
     StringWriter sw = new StringWriter();
     System.Xml.Xsl.XsltArgumentList arg = new System.Xml.Xsl.XsltArgumentList();
     if (htParams != null)
     {
         foreach (string k in htParams.Keys) arg.AddParam(k, "", htParams[k]);
     }
     if (htExtObjs != null)
     {
         foreach (string k in htExtObjs.Keys) arg.AddExtensionObject(k, htExtObjs[k]);
     }
     xsl.Transform(xmldoc, arg, sw);
     return System.Web.HttpUtility.HtmlDecode(sw.ToString());
 }