AddParam() public method

public AddParam ( string name, string namespaceUri, object parameter ) : void
name string
namespaceUri string
parameter object
return void
        private void DrawProfilesModule()
        {
            XsltArgumentList args = new XsltArgumentList();
            XslCompiledTransform xslt = new XslCompiledTransform();
            SessionManagement sm = new SessionManagement();

            Utilities.DataIO data = new Profiles.Profile.Utilities.DataIO();
            string email = string.Empty;
            string imageemailurl = string.Empty;
            if (this.BaseData.SelectSingleNode("rdf:RDF[1]/rdf:Description[1]/prns:emailEncrypted", this.Namespaces) != null &&
                this.BaseData.SelectSingleNode("rdf:RDF[1]/rdf:Description[1]/vivo:email", this.Namespaces) == null)
            {
                email = this.BaseData.SelectSingleNode("rdf:RDF[1]/rdf:Description[1]/prns:emailEncrypted", this.Namespaces).InnerText;
                imageemailurl = string.Format(Root.Domain + "/profile/modules/CustomViewPersonGeneralInfo/" + "EmailHandler.ashx?msg={0}", HttpUtility.UrlEncode(email));
            }

            args.AddParam("root", "", Root.Domain);
            if (email != string.Empty)
            {
                args.AddParam("email", "", imageemailurl);
            }
            args.AddParam("imgguid", "", Guid.NewGuid().ToString());

            litPersonalInfo.Text = XslHelper.TransformInMemory(Server.MapPath("~/Profile/Modules/CustomViewPersonGeneralInfo/CustomViewPersonGeneralInfo.xslt"), args, base.BaseData.OuterXml);

            if (base.BaseData.SelectSingleNode("rdf:RDF/rdf:Description[1]/prns:mainImage/@rdf:resource", base.Namespaces) != null)
            {
                string imageurl = base.BaseData.SelectSingleNode("//rdf:RDF/rdf:Description[1]/prns:mainImage/@rdf:resource", base.Namespaces).Value;
                imgPhoto.ImageUrl = imageurl + "&cachekey=" + Guid.NewGuid().ToString();
            }
            else
            {
                imgPhoto.Visible = false;
            }
        }
Exemplo n.º 2
0
        public static void TransformHtml(XmlSerializer serializer, object report, Type reportType, string outputFilePath, GeneratorConfiguration generatorConfiguration, string xsltFile)
        {
            var xmlOutputWriter = new StringWriter();
            serializer.Serialize(xmlOutputWriter, report);

            XslCompiledTransform xslt = new XslCompiledTransform();
            var xsltSettings = new XsltSettings(true, false);
            XmlResolver resourceResolver;

            var reportName = reportType.Name.Replace("Generator", "");
            using (var xsltReader = GetTemplateReader(reportType, reportName, xsltFile))
            {
                resourceResolver = new XmlResourceResolver();
                xslt.Load(xsltReader, xsltSettings, resourceResolver);
            }

            var xmlOutputReader = new XmlTextReader(new StringReader(xmlOutputWriter.ToString()));

            XsltArgumentList argumentList = new XsltArgumentList();
            argumentList.AddParam("feature-language", "", generatorConfiguration.FeatureLanguage.Name);
            argumentList.AddParam("tool-language", "", generatorConfiguration.ToolLanguage.Name);
            
            using (var xmlTextWriter = new XmlTextWriter(outputFilePath, Encoding.UTF8))
            {
				xslt.Transform(xmlOutputReader, argumentList, xmlTextWriter, resourceResolver);
            }            
        }
Exemplo n.º 3
0
        private void GenerateSinglePage(string kind, string kindName, string name, string slug, string title)
        {
            string filename = Path.Combine(this.OutputDirectory, slug + "." + this.FileSuffix);

            Dictionary<string, XElement> inputXml = new Dictionary<string, XElement>();

            var type = inputDocument.Elements("type").Where(c => c.Attribute("kind").Value == kind && c.Attribute("name").Value == name).Single();

            InsertExamples(type);

            using (var reader = inputDocument.CreateReader())
            {
                using (XmlWriter writer = XmlWriter.Create(filename + ".tmp", new XmlWriterSettings { OmitXmlDeclaration = true }))
                {
                    XsltArgumentList arguments = new XsltArgumentList();
                    arguments.AddParam("kind", "", kind);
                    arguments.AddParam("kindName", "", kindName);
                    arguments.AddParam("name", "", name);
                    arguments.AddParam("slug", "", slug);
                    arguments.AddParam("mode", "", this.Mode);
                    transform.Transform(reader, arguments, writer);
                }
            }

            PostProcessFile(filename + ".tmp");
            RewriteIfChanged(filename);
        }
Exemplo n.º 4
0
        public new void Init(object objParam)
        {
            // Get parameter info
            _strPath = Path.Combine(@"TestFiles\", FilePathUtil.GetTestDataPath(), @"XsltApi\");

            xsltArg1 = new XsltArgumentList();

            MyObject obj1 = new MyObject(1, _output);
            MyObject obj2 = new MyObject(2, _output);
            MyObject obj3 = new MyObject(3, _output);
            MyObject obj4 = new MyObject(4, _output);
            MyObject obj5 = new MyObject(5, _output);

            xsltArg1.AddExtensionObject("urn:my-obj1", obj1);
            xsltArg1.AddExtensionObject("urn:my-obj2", obj2);
            xsltArg1.AddExtensionObject("urn:my-obj3", obj3);
            xsltArg1.AddExtensionObject("urn:my-obj4", obj4);
            xsltArg1.AddExtensionObject("urn:my-obj5", obj5);

            xsltArg1.AddParam("myArg1", szEmpty, "Test1");
            xsltArg1.AddParam("myArg2", szEmpty, "Test2");
            xsltArg1.AddParam("myArg3", szEmpty, "Test3");
            xsltArg1.AddParam("myArg4", szEmpty, "Test4");
            xsltArg1.AddParam("myArg5", szEmpty, "Test5");

            return;
        }
Exemplo n.º 5
0
        public static string Transform(string xml,string xslFile)
        {
            XslTransform transform = new XslTransform();
            XsltArgumentList args = new XsltArgumentList();
            //define the xslt rendering file
            //get the iterators for the root and context item
            XPathDocument xmlDoc = new XPathDocument(new StringReader(xml));
            XPathNavigator iter = xmlDoc.CreateNavigator();

            //define and add the xslt extension classes
            //Sitecore.Xml.Xsl.XslHelper sc = new Sitecore.Xml.Xsl.XslHelper();
            XsltHelper xslt = new XsltHelper();
            args.AddExtensionObject("http://www.rlmcore.vn/helper", xslt);

            //add parameters
            args.AddParam("item", "", iter);
            args.AddParam("currentitem", "", iter.Select("."));
            //define the stream which will contain the result of xslt transformation
            //StringBuilder sb = new StringBuilder();
            //TextWriter stream = new FileStream(new MemoryStream(Encoding.ASCII.GetBytes(sb.ToString())));
            System.IO.StringWriter stream = new System.IO.StringWriter();

            //load xslt rendering to XslTransform class
            transform.Load(xslFile);
            //perform a transformation with the rendering
            transform.Transform(iter, args, stream);

            return stream.ToString();
        }
Exemplo n.º 6
0
		public string CreateResultPage(XDocument result, bool isTrace)
		{
			var args = new XsltArgumentList();
			args.AddParam("prmHCTraceLoadErrorFile", "", Path.Combine(Path.GetTempPath(), m_cache.ProjectId.Name + "HCLoadErrors.xml"));
			args.AddParam("prmShowTrace", "", isTrace.ToString().ToLowerInvariant());
			return TraceTransform.Transform(m_mediator, result, isTrace ? "HCTrace" : "HCParse", args);
		}
Exemplo n.º 7
0
        public void BuildNavigator(string modelFilePath)
        {
            XmlResolver resolver = new XmlUrlResolver();
            resolver.Credentials = CredentialCache.DefaultCredentials;
            XmlTextReader tr = new XmlTextReader(modelFilePath);
            XslCompiledTransform transform = new XslCompiledTransform();
            transform.Load(this.stylesheetFilesPath + Path.DirectorySeparatorChar + "ModelTree.xsl",null,resolver);
            XmlTextWriter tw = new XmlTextWriter(this.htmlFilesPath + Path.DirectorySeparatorChar + "ModelTree.htm", Encoding.UTF8);
            XsltArgumentList al = new XsltArgumentList();
            al.AddParam("modelBrowser","",this.localizer.GetValue("Globals","ModelBrowser"));
            al.AddParam("glossary","",this.localizer.GetValue("Globals","Glossary"));
            al.AddParam("stakeholders", "", this.localizer.GetValue("Globals", "Stakeholders"));
            transform.Transform(tr,al,tw,null);
            tw.Close();
            tr.Close();

            tr = new XmlTextReader(modelFilePath);
            transform.Load(this.stylesheetFilesPath + Path.DirectorySeparatorChar + "HomePage.xsl",null,resolver);
            tw = new XmlTextWriter(this.htmlFilesPath + Path.DirectorySeparatorChar + "main.htm",Encoding.UTF8);
            al = new XsltArgumentList();
            AssemblyName an = this.GetType().Assembly.GetName();
            al.AddParam("version","",an.Version.ToString(3));
            al.AddParam("model", "", this.localizer.GetValue("Globals", "Model"));
            al.AddParam("author", "", this.localizer.GetValue("Globals", "Author"));
            al.AddParam("company", "", this.localizer.GetValue("Globals", "Company"));
            al.AddParam("creationDate", "", this.localizer.GetValue("Globals", "CreationDate"));
            al.AddParam("exportPrintDate", "", this.localizer.GetValue("Globals", "ExportPrintDate"));
            al.AddParam("now", "", Convert.ToString(DateTime.Now, DateTimeFormatInfo.InvariantInfo));
            al.AddParam("release", "", this.localizer.GetValue("Globals", "Release"));
            transform.Transform(tr,al,tw,null);
            tw.Close();
            tr.Close();
        }
Exemplo n.º 8
0
        public static IGraph CreateNuspecGraph(XDocument nuspec, string baseAddress)
        {
            nuspec = NormalizeNuspecNamespace(nuspec);

            XslCompiledTransform transform = CreateTransform("xslt.nuspec.xslt");

            XsltArgumentList arguments = new XsltArgumentList();
            arguments.AddParam("base", "", baseAddress + "packages/");
            arguments.AddParam("extension", "", ".json");

            arguments.AddExtensionObject("urn:helper", new XsltHelper());

            XDocument rdfxml = new XDocument();
            using (XmlWriter writer = rdfxml.CreateWriter())
            {
                transform.Transform(nuspec.CreateReader(), arguments, writer);
            }

            RdfXmlParser rdfXmlParser = new RdfXmlParser();
            XmlDocument doc = new XmlDocument();
            doc.Load(rdfxml.CreateReader());
            IGraph graph = new Graph();
            rdfXmlParser.Load(graph, doc);

            return graph;
        }
        protected override void TransformXml(XPathDocument document, XmlTextWriter writer)
        {
			XsltArgumentList args = new XsltArgumentList();
			args.AddParam("separate-fixtures", "", (this.GenerateFixtureInSeparateFile) ? 1 : 0);
            args.AddParam("show-fixtures-summary", "", (this.ShowFixturesSummary) ? 1 : 0);
            args.AddParam("creation-time", "", this.CreationTime.ToString("u"));

			if (this.GenerateFixtureInSeparateFile)
				this.GenerateFixtureReports(document, args);

            UnitResourceManager.HtmlReport.Transform(document, args, writer);
            writer.Close();

        }
        protected override XElement BuildUploadXML()
        {
            // Get and transform this effectively does basic format validation
            XElement results = this.GetWorksheetXML(0, HttpContext.Current.Server.MapPath(@"~\Xslt\Senior\SeniorResults.xslt"));

            // Unify and return
            XsltArgumentList xal = new XsltArgumentList();

            // Set some other parameters
            xal.AddParam("fileName", "", this.Filename);
            xal.AddParam("tournamentId", "", this.TournamentId);

            XElement transformed = XElement.Parse(Utility.Transform(results.ToString(), HttpContext.Current.Server.MapPath(@"~\Xslt\Senior\Senior.xslt"), xal));
            return transformed;
        }
        private void DrawProfilesModule()
        {
            XsltArgumentList args = new XsltArgumentList();
            args.AddParam("root", "", Root.Domain);

            litPublication.Text = XslHelper.TransformInMemory(Server.MapPath("~/Profile/Modules/CustomViewInformationResource/CustomViewInformationResource.xslt"), args, base.BaseData.OuterXml);
        }
Exemplo n.º 12
0
        public void CreateCodeBaseXML()
        {
            try
            {
                package = Package.Open(fileCodeBase);

                XmlDocument sharedString = GetPartFile(OfficeFilePart.ShareString, 0);
                sharedString.Save(Common.SHARED_STRING);
                XmlDocument sheet = GetPartFile(OfficeFilePart.Sheet, 1);

                XsltArgumentList xsltArgListSheet = new XsltArgumentList();
                XsltSettings settings = new XsltSettings(true, true);
                XslCompiledTransform xslTransSheet = new XslCompiledTransform();
                xslTransSheet.Load(Common.XSLT_CODE_BASE, settings, new XmlUrlResolver());
                xsltArgListSheet.AddParam("prmDocSharedStrings", "", sharedString.CreateNavigator());
                string sOutXmlSheet = System.String.Empty;
                using (FileStream fs = new FileStream(Common.XML_CODE_BASE, FileMode.Create))
                {
                    xslTransSheet.Transform(sheet.CreateNavigator(), xsltArgListSheet, fs);
                }

                XslCompiledTransform xslRowSheet = new XslCompiledTransform();
                xslRowSheet.Load(Common.XSLT_TO_ROW);
                xslRowSheet.Transform(Common.XML_CODE_BASE, Common.XML_ROW);

            }
            finally
            {
                package.Close();
            }
        }
        /// <summary>
        /// выполнить конвертацию структуры
        /// </summary>
        public void Do()
        {
            try
            {
                SendMessage("\n- Конвертация структуры курса");
                XDocument doc = new XDocument(course);
                doc.Document.Declaration = new XDeclaration("1.0", "utf-8", "true");
                XPathNavigator nv = doc.CreateNavigator();

                XslCompiledTransform xslt = new XslCompiledTransform();

                xslt.Load(convParams.ContentShemePath);

                XsltArgumentList xslArg = new XsltArgumentList();
                xslArg.AddParam("itemsPath", "", convParams.RootFolderName);

                string outFile = Path.Combine(convParams.OutputAbsPath, convParams.StartFileName);

                using (FileStream fs = new FileStream(outFile, FileMode.Create))
                {
                    xslt.Transform(nv, xslArg, fs);
                }
            }
            catch(Exception ex)
            {
                LastError = ex.Message;
                throw new Exception("Исключение при конвертации структуры курса: "+ex.Message);
            }
        }
 public ActionResult Index()
 {
     HttpServerUtilityBase server = base.HttpContext.Server;
     HttpResponseBase response = base.HttpContext.Response;
     HttpRequestBase request = base.HttpContext.Request;
     IContainerAccessor applicationInstance = base.HttpContext.ApplicationInstance as IContainerAccessor;
     this.Logger.Debug("GoogleSitemap handler >>>>>>>>>>>>>>>>>>");
     string url = string.Format("http://{0}", request.Url.Host.ToLower()) + ((request.Url.Port != 80) ? (":" + request.Url.Port) : "");
     url = this.AdjustUrlToContext(url);
     XsltArgumentList arguments = new XsltArgumentList();
     arguments.AddParam("domain", "", url);
     try
     {
         string siteMapFile = WebConfiguration.Current.SiteMapFile;
         this.Logger.DebugFormat("GoogleSitemap config sitemap file {0}", new object[] { siteMapFile });
         string uri = server.MapPath(siteMapFile);
         this.Logger.DebugFormat("GoogleSitemap mapped sitemap file {0}", new object[] { uri });
         XPathDocument document = new XPathDocument(uri);
         XslCompiledTransform transform = new XslCompiledTransform();
         EmbeddedResourceResolver stylesheetResolver = new EmbeddedResourceResolver();
         transform.Load("Coats.Crafts.google-sitemap.xsl", XsltSettings.TrustedXslt, stylesheetResolver);
         StringWriter w = new StringWriter();
         XmlTextWriter writer2 = new XmlTextWriter(w);
         transform.Transform((IXPathNavigable) document, arguments, (XmlWriter) writer2);
         return this.Content(w.ToString(), "text/xml", Encoding.UTF8);
     }
     catch (Exception exception)
     {
         this.Logger.Error("Error rendering Google Sitemap XSLT", exception);
     }
     return base.Content("Error creating Google Sitemap");
 }
Exemplo n.º 15
0
 public static void CopyAdditionalParams(Dictionary<string, string> additionalParams, XsltArgumentList arguments)
 {
     foreach (KeyValuePair<string, string> pair in additionalParams)
     {
         arguments.AddParam(pair.Key, "", pair.Value);
     }
 }
Exemplo n.º 16
0
		/// <summary>
		/// This function retuns list of states for a given country as XML Document in a string 
		/// and this value is used in client side java script to populate state combo box.
		/// Functionality: Transform the CountriesAndStates xml string into another XML string having the single country 
		/// and states under that country. 
		/// </summary>
		public string GetStatesXMLString(string countryName)
		{
			//Creates a XslTransform object and load the CountriesAndStates.xsl file
			XslTransform transformToCountryNode = new XslTransform();
			transformToCountryNode.Load(new XPathDocument(HttpContext.Current.Server.MapPath("~/xmlxsl/CountriesAndStates.xsl")).CreateNavigator(), new XmlUrlResolver());
			//TransformToCountryNode.Load(new XPathDocument(HttpContext.Current.Server.MapPath("~/xmlxsl/CountriesAndStates.xsl")).CreateNavigator(), new XmlUrlResolver(), this.GetType().Assembly.Evidence);

			//Creating the XSLT parameter country-name and setting the value
			XsltArgumentList xslArgs = new XsltArgumentList();
			xslArgs.AddParam("country-name", "", countryName);
				
			// Memory stream to store the result of XSL transform 
			MemoryStream countryNodeMemoryStream = new MemoryStream(); 
			XmlTextWriter countryNodeXmlTextWriter = new XmlTextWriter(countryNodeMemoryStream, Encoding.UTF8); 
			countryNodeXmlTextWriter.WriteProcessingInstruction("xml", "version='1.0' encoding='UTF-8'");

			//transforming the current XML string to get the state XML string
			transformToCountryNode.Transform(xPathDoc, xslArgs,  countryNodeXmlTextWriter);
			//TransformToCountryNode.Transform(XPathDoc, XslArgs,  CountryNodeXmlTextWriter, null);

			//reading the XML string using StreamReader and return the same
			countryNodeXmlTextWriter.Flush(); 
			countryNodeMemoryStream.Position = 0; 
			StreamReader countryNodeStreamReader = new StreamReader(countryNodeMemoryStream); 
			return  countryNodeStreamReader.ReadToEnd(); 
		}
Exemplo n.º 17
0
        public void split()
        {
            System.Xml.Xsl.XslCompiledTransform trans = new System.Xml.Xsl.XslCompiledTransform();
            //XsltSettings settings = new XsltSettings(false, true);

            string xsltFile = @"C:\Users\yxzhk\WorkSpace\CodeDemo\CsPoc\CsPoc\XML\split.xsl";

            using (StreamReader rdr = new StreamReader(xsltFile))
            {
                using (XmlReader xmlRdr = XmlReader.Create(rdr))
                {
                    trans.Load(xmlRdr);
                }
            }

            string inputFile = @"C:\Users\yxzhk\WorkSpace\CodeDemo\CsPoc\CsPoc\XML\split.xml";
            string outputFile = @"C:\Users\yxzhk\WorkSpace\CodeDemo\CsPoc\CsPoc\XML\split-out.xml";

            XsltArgumentList xslArg = new XsltArgumentList();
            xslArg.AddParam("tag", "", "ItemA,ItemB,ItemC");

            //trans.Transform(inputFile,outputFile);

            using (XmlWriter w = XmlWriter.Create(outputFile))
            {
                trans.Transform(inputFile, xslArg, w);
            }
        }
        /// <summary>
        /// Repairs an html fragment (makes it Xhtml) and executes a transformation on it.
        /// </summary>
        /// <param name="html">The html to repair</param>
        /// <param name="xsltPath">The path to the XSLT to use for transformation</param>
        /// <param name="xsltParameters"></param> 
        /// <param name="errorSummary">out value - warnings generated while repairing the html</param>
        /// <returns></returns>
        public static XDocument RepairXhtmlAndTransform(string html, string xsltPath, Dictionary<string, string> xsltParameters, out string errorSummary)
        {
            TidyHtmlResult tidyHtmlResult = MarkupTransformationServices.TidyHtml(html);

            errorSummary = tidyHtmlResult.ErrorSummary;
            XNode tidiedXhtml = tidyHtmlResult.Output;
            XDocument outputDocument = new XDocument();

            XslCompiledTransform xslt = XsltServices.GetCompiledXsltTransform(xsltPath);

            using (XmlWriter writer = outputDocument.CreateXhtmlWriter())
            {
                using (XmlReader reader = tidiedXhtml.CreateReader())
                {
                    if (xsltParameters != null && xsltParameters.Count > 0)
                    {
                        XsltArgumentList xsltArgumentList = new XsltArgumentList();
                        foreach (var xsltParameter in xsltParameters)
                        {
                            xsltArgumentList.AddParam(xsltParameter.Key, "", xsltParameter.Value );
                        }
                        xslt.Transform(reader, xsltArgumentList, writer);
                    }
                    else
                    {
                        xslt.Transform(reader, writer);
                    }
                }
            }

            return outputDocument;
        }
Exemplo n.º 19
0
		public static void Parse(
			XmlDocument		xmlMetadata_in, 
			string			xsltTemplateURL_in, 
			Hashtable		xsltParameters_in, 

			StringWriter	parsedOutput_in
		) {
			#region XsltArgumentList _xsltparameters = new XsltArgumentList().AddParam(...);
			XsltArgumentList _xsltparameters = new XsltArgumentList();
			IDictionaryEnumerator _denum = xsltParameters_in.GetEnumerator();
			_denum.Reset();
			while (_denum.MoveNext()) {
				_xsltparameters.AddParam(
					_denum.Key.ToString(), 
					"", 
					System.Web.HttpUtility.UrlEncode(
						_denum.Value.ToString()
					)
				);
			}
			#endregion

			XPathNavigator _xpathnav = xmlMetadata_in.CreateNavigator();
			XslTransform _xslttransform = new XslTransform();
			_xslttransform.Load(
				xsltTemplateURL_in
			);
			_xslttransform.Transform(
				_xpathnav, 
				_xsltparameters, 
				parsedOutput_in, 
				null
			);
		}
        public string RenderComponentFieldAsBBCode(string fieldExpression, int fieldIndex, bool outputImages)
        {
            BuiltInFunctions functions = new BuiltInFunctions(_engine, _package);
            string output = functions.RenderComponentField(fieldExpression, fieldIndex);

            StringReader sr = new StringReader(output);
            NameTable nt = new NameTable();
            XmlNamespaceManager nsmgr = new XmlNamespaceManager(nt);
            nsmgr.AddNamespace("tcdl", Tridion.ContentManager.Templating.TcdlTags.TcdlNamespace);
            XmlParserContext parserContext = new XmlParserContext(null, nsmgr, null, XmlSpace.None);

            XmlReader xmlReader = XmlReader.Create(sr, new XmlReaderSettings(), parserContext);

            XslCompiledTransform transform = new XslCompiledTransform(true);

            using (Stream xsltStream = System.Reflection.Assembly.GetExecutingAssembly().GetManifestResourceStream("Tridion.ContentManager.Templating.Expression.NetbiscuitsFunctions.XhtmlToBBCode.xslt"))
            {
                using (XmlReader xsltReader = XmlReader.Create(xsltStream))
                {
                    transform.Load(xsltReader);
                }
            }

            StringWriter resultWriter = new StringWriter();
            XsltArgumentList argumentList = new XsltArgumentList();
            argumentList.AddParam("IncludeImages", String.Empty, outputImages);

            transform.Transform(xmlReader, argumentList, resultWriter);

            return resultWriter.ToString();   
        }
 protected void Button1_Click(object sender, EventArgs e)
 {
     XsltArgumentList argsList = new XsltArgumentList();
     argsList.AddParam("calories", "", TextBox1.Text);
     Xml1.TransformArgumentList = argsList;
     Xml1.Visible = true;
 }
        public static IHtmlString Transform(string sXmlPath, string sXslPath)
        {
            try
            {
                //load the Xml doc
                XPathDocument myXPathDoc = new XPathDocument(sXmlPath);

                XsltArgumentList args = new XsltArgumentList();

                IDictionary<string, string> parameters = null;
                if (parameters != null)
                {
                    foreach (string key in parameters.Keys)
                    {
                        args.AddParam(key, "", parameters[key]);
                    }
                }
                XslCompiledTransform tt = new XslCompiledTransform();

                //load the Xsl
                tt.Load(sXslPath);

                XmlReaderSettings settings = new XmlReaderSettings();
                settings.DtdProcessing = DtdProcessing.Parse;
                settings.ValidationType = ValidationType.DTD;

                //create the output stream
                //XmlTextWriter myWriter = new XmlTextWriter("result.html", null);
                //StringWriter writer = new StringWriter();

                //do the actual transform of Xml
                //myXslTrans.Transform(myXPathDoc, null, myWriter);

                //System.Text.StringBuilder sb = new System.Text.StringBuilder();
                //StringWriter sw = new StringWriter(sb);

                using (XmlReader reader = XmlReader.Create(sXmlPath, settings))
                {
                    StringWriter writer = new StringWriter();
                    tt.Transform(reader, args, writer);
                    return new HtmlString(writer.ToString());
                }

                //myXslTrans.Transform(myXPathDoc, null, sw);
                //sw.Close();
                //string results = sb.ToString();

                //Console.WriteLine(results);

                //myWriter.Close();
                //return new HtmlString(results);

            }
            catch (Exception e)
            {

                Console.WriteLine("Exception: {0}", e.ToString());
                return new HtmlString(e.ToString());
            }
        }
Exemplo n.º 23
0
        public static string Transform (string xml, XslCompiledTransform xslTrans, IDictionary<string, string> xslParams)
        {
            if (xml.Trim ().Length == 0)
                return String.Empty;

            XmlDocument xmlDoc = new XmlDocument ();
            xmlDoc.LoadXml (xml);

            XsltArgumentList xslArgs = null;

            if (xslParams != null)
            {
                xslArgs = new XsltArgumentList ();

                foreach (string paramName in xslParams.Keys)
                {
                    xslArgs.AddParam (paramName, "", xslParams [paramName]);
                }
            }

            using (StringWriter sw = new StringWriter())
            {
                xslTrans.Transform(xmlDoc, xslArgs, sw);
                return sw.ToString();
            }
        }
Exemplo n.º 24
0
        //
        // PROTECTED METHODS
        // 
        protected virtual XsltArgumentList GetArgumentList() {
            XsltArgumentList argsList = new XsltArgumentList();

            argsList.AddParam("title", string.Empty, Resources.TEXT_REPORT_TITLE);
            argsList.AddParam("credit", string.Empty, Resources.TEXT_REPORT_CREDIT);
            argsList.AddParam("disclaimer", string.Empty, Resources.TEXT_REPORT_DISCLAIMER);
            argsList.AddParam("creationdate", string.Empty, DateTime.Now.ToLongDateString());
            argsList.AddParam("username", string.Empty, Environment.UserName);
            argsList.AddParam("userdomainname", string.Empty, Environment.UserDomainName);
            argsList.AddParam("machinename", string.Empty, Environment.MachineName);
            argsList.AddParam("osversion", string.Empty, Environment.OSVersion.ToString());
            argsList.AddParam("dotnetversion", string.Empty, Environment.Version.ToString());
            argsList.AddParam("assemblyversion", string.Empty, Assembly.GetExecutingAssembly().GetName().Version.ToString());

            return argsList;
        }
		public void Render(object source, HtmlTextWriter htmlWriter, TemplateDefinition liveDefinition)
		{
			var resolver = new PathResolver(liveDefinition.Folder);
			var hostPage = DNNContext.Current.Page;

			var args = new XsltArgumentList();
			args.AddExtensionObject("urn:ddrmenu", new XsltFunctions());
			args.AddExtensionObject("urn:dnngarden", new XsltFunctions());
			args.AddParam("ControlID", "", DNNContext.Current.HostControl.ClientID);
			args.AddParam("Options", "", ConvertToJson(liveDefinition.ClientOptions));
			args.AddParam("DNNPath", "", hostPage.ResolveUrl(resolver.Resolve("/", PathResolver.RelativeTo.Dnn)));
			args.AddParam("ManifestPath", "", hostPage.ResolveUrl(resolver.Resolve("/", PathResolver.RelativeTo.Manifest)));
			args.AddParam("PortalPath", "", hostPage.ResolveUrl(resolver.Resolve("/", PathResolver.RelativeTo.Portal)));
			args.AddParam("SkinPath", "", hostPage.ResolveUrl(resolver.Resolve("/", PathResolver.RelativeTo.Skin)));
			liveDefinition.TemplateArguments.ForEach(a => args.AddParam(a.Name, "", a.Value));

			HttpContext.Current.Items["Resolver"] = resolver;

			using (var xmlStream = new MemoryStream())
			{
				Utilities.SerialiserFor(source.GetType()).Serialize(xmlStream, source);
				xmlStream.Seek(0, SeekOrigin.Begin);
				xsl.Transform(XmlReader.Create(xmlStream), args, htmlWriter);
			}
		}
Exemplo n.º 26
0
        public void Render(ViewContext viewContext, TextWriter writer)
        {
            this.viewContext = viewContext;

            string url = viewContext.HttpContext.Request.Url.ToString();
            construct.AppendPage("", url, viewData.PageVars);

            var args = new XsltArgumentList();
            args.AddExtensionObject("urn:HtmlHelper", new HtmlHelper(viewContext, this));
            args.AddParam("AjaxProScriptReferences", "", ajaxDeclaration);

            foreach (var pair in viewData.PageVars)
            {
                args.AddParam(pair.Key, construct.Message.NamespaceURI, pair.Value);
            }

            xslTransformer.Transform(new XmlInput(construct.Message.CreateNavigator()), args, new XmlOutput(writer));
        }
Exemplo n.º 27
0
		public string Htmlize (XmlReader ecma_xml, Dictionary<string, string> extraArgs)
		{
			var args = new XsltArgumentList ();
			args.AddExtensionObject("monodoc:///extensions", ExtObject);
			foreach (var kvp in extraArgs)
				args.AddParam (kvp.Key, string.Empty, kvp.Value);

			return Htmlize(ecma_xml, args);
		}
Exemplo n.º 28
0
        private XsltArgumentList CreateArgs() {
            XsltArgumentList args = new XsltArgumentList();

        	InputParameterCollection parms = Context.Parameters;
            foreach (InputParameter parameter in parms) {
                args.AddParam(parameter.Name, "", parameter.Value);
            }

            return args;
        }
Exemplo n.º 29
0
 protected virtual System.Xml.Xsl.XsltArgumentList DoGetArguments(PDFDataContext context)
 {
     System.Xml.Xsl.XsltArgumentList args = new System.Xml.Xsl.XsltArgumentList();
     if (this.HasArguments)
     {
         foreach (XsltArgumentBase arg in this.Arguments)
         {
             string name  = arg.Name;
             string ns    = null == arg.Namespace ? string.Empty : arg.Namespace;
             object value = arg.GetValue(context);
             args.AddParam(name, ns, value);
         }
     }
     return(args);
 }
Exemplo n.º 30
0
    private static void GenerateViaXSLT(string xsltFileName,
                                        System.Xml.XmlDocument xmlMetaData,
                                        string outputFile,
                                        params XSLTParam[] @params)
    {
        System.Xml.Xsl.XslTransform     xslt = new System.Xml.Xsl.XslTransform();
        System.Xml.XPath.XPathNavigator xNav;
        System.IO.StreamWriter          streamWriter = null;
        System.Xml.Xsl.XsltArgumentList args         = new System.Xml.Xsl.XsltArgumentList();

        try
        {
            if (xmlMetaData == null)
            {
                xmlMetaData = new System.Xml.XmlDocument();
            }
            foreach (XSLTParam param in @params)
            {
                args.AddParam(param.Name, "", param.Value);
            }

            xNav         = xmlMetaData.CreateNavigator();
            streamWriter = new System.IO.StreamWriter(outputFile);

            xslt.Load(xsltFileName);
            xslt.Transform(xNav, args, streamWriter, null);
        }
        finally
        {
            if (streamWriter != null)
            {
                streamWriter.Flush();
                streamWriter.Close();
            }
        }
    }
Exemplo n.º 31
0
        public void WriteZed(XmlReader input)
        {
            System.IO.StringWriter dataHolder = new System.IO.StringWriter();
            XmlWriter results = XmlWriter.Create((System.IO.TextWriter)dataHolder);

            string strDcDate = (string)TransformationArguments.GetParam("dcDate", "");

            if (strDcDate == null)
            {
                strDcDate = DateTime.Now.ToString("yyyy-MM-dd");
                TransformationArguments.AddParam("dcDate", "", strDcDate);
            }

            try
            {
                theTransformer.Transform(input, TransformationArguments, results);
            }
            catch (Exception eAnything)
            {
                results = null;
            }
            input.Close(); //Since the stream has been read to the end, we might as well close it.

            #region this region only needed for debugging, will be removed
            //TODO: the actual removal!
            string[] strSmilFiles = System.IO.Directory.GetFiles(strOutputDir, "*.smil");
            foreach (string aSmilFile in strSmilFiles)
            {
                System.IO.File.Delete(aSmilFile);
            }
            #endregion

            XmlDocument resDoc = new XmlDocument();
            resDoc.LoadXml(dataHolder.ToString());

            XmlWriterSettings fileSettings = new XmlWriterSettings();
            fileSettings.Indent = true;

            //TODO:Remove following line
            resDoc.Save(strOutputDir + "/raw.xml");


            XmlNamespaceManager xPathNSManager = new XmlNamespaceManager((XmlNameTable) new NameTable());
            xPathNSManager.AddNamespace("smil", "http://www.w3.org/2001/SMIL20/Language");
            xPathNSManager.AddNamespace("opf", "http://openebook.org/namespaces/oeb-package/1.0/");
            xPathNSManager.AddNamespace("ncx", "http://www.daisy.org/z3986/2005/ncx/");


            XmlNode ncxTree     = resDoc.DocumentElement.SelectSingleNode("//ncx:ncx", xPathNSManager);
            string  ncxFilename = (string)TransformationArguments.GetParam("ncxFilename", "");
            if (ncxFilename == "")
            {
                ncxFilename = "navigation.ncx";
            }
            XmlWriter ncxFile = XmlWriter.Create(strOutputDir + "/" + ncxFilename, fileSettings);
            ncxFile.WriteNode(ncxTree.CreateNavigator(), false);
            ncxFile.Close();
            ncxTree.ParentNode.RemoveChild(ncxTree); //remove the written bit


            #region Calculating running time, setting on smil file nodes as required

            TimeSpan prevDuration = new TimeSpan();
            try
            {
                string      tmpXpathStatement = "//*[self::smil:smil or self::smil:audio]";
                XmlNodeList lstAudAndSmil     = resDoc.DocumentElement.SelectNodes(tmpXpathStatement, xPathNSManager);

                for (int i = 0; i < lstAudAndSmil.Count; i++)
                {
                    XmlElement curElement = (XmlElement)lstAudAndSmil[i];
                    switch (curElement.LocalName)
                    {
                    case "smil":
                        XmlElement ndElapsed = (XmlElement)curElement.SelectSingleNode(".//smil:meta[@name='dtb:totalElapsedTime']", xPathNSManager);
                        ndElapsed.SetAttribute("content", prevDuration.ToString().TrimEnd(".0".ToCharArray()));
                        break;

                    case "audio":
                        try
                        {
                            prevDuration = prevDuration.Subtract(TimeSpan.Parse(curElement.GetAttribute("clipBegin")));
                        }
                        catch { }
                        try
                        {
                            prevDuration = prevDuration.Add(TimeSpan.Parse((curElement.GetAttribute("clipEnd"))));
                        }
                        catch { }
                        break;

                    default:

                        break;
                    }
                }
            }
            catch (Exception eAnything)
            {
                //TODO: Error forwarding
                System.Diagnostics.Debug.WriteLine(eAnything.ToString());
            }

            //TODO:Remove following line
            //resDoc.Save(strOutputDir + "/raw.xml");
            #endregion

            XmlElement metaDtbTotalDuration = (XmlElement)resDoc.SelectSingleNode("//opf:meta[@name='dtb:totalTime']", xPathNSManager);
            metaDtbTotalDuration.SetAttribute("content", prevDuration.ToString().TrimEnd(".0".ToCharArray()));

            XmlNode opfTree     = resDoc.DocumentElement.SelectSingleNode("//opf:package", xPathNSManager);
            string  opfFilename = (string)TransformationArguments.GetParam("packageFilename", "");
            if (opfFilename == "")
            {
                opfFilename = "package.opf";
            }
            XmlWriter opfFile = XmlWriter.Create(strOutputDir + "/" + opfFilename, fileSettings);
            opfFile.WriteNode(opfTree.CreateNavigator(), false);
            opfFile.Close();
            opfTree.ParentNode.RemoveChild(opfTree); //remove the written bit

            XmlNodeList smilTrees = resDoc.DocumentElement.SelectNodes("//smil:smil", xPathNSManager);
            for (int i = smilTrees.Count - 1; i > -1; i--)
            {
                XmlElement newRoot  = (XmlElement)smilTrees[i];
                XmlWriter  smilFile = XmlWriter.Create(strOutputDir + "/" + newRoot.GetAttribute("filename") + ".smil", fileSettings);
                newRoot.RemoveAttribute("filename");
                smilFile.WriteNode(newRoot.CreateNavigator(), false);
                smilFile.Close();
                newRoot.ParentNode.RemoveChild(newRoot);
            }

            //TODO:Remove following line
            //resDoc.Save(strOutputDir + "/raw.xml");

            XmlNodeList filesToCopy = resDoc.DocumentElement.SelectNodes("filenames/file", xPathNSManager);
            foreach (XmlNode fileNode in filesToCopy)
            {
                string strSourceFileName = strContextFolder + "\\" + fileNode.InnerText;
                strSourceFileName = strSourceFileName.Replace("/", "\\");

                string strDestFileName = fileNode.InnerText.Substring((fileNode.InnerText.LastIndexOf("/") > 0) ? fileNode.InnerText.LastIndexOf("/") + 1 : 0);
                strDestFileName = OuputDir + "\\" + strDestFileName;
                strDestFileName = strDestFileName.Replace("/", "\\");
                try
                {
                    System.IO.File.Copy(strSourceFileName, strDestFileName, true);
                }
                catch (Exception eAnything)
                {
                    System.Diagnostics.Debug.WriteLine(eAnything.ToString());
                }
            }
        }
Exemplo n.º 32
-1
        private static XsltArgumentList MakeArgs( string[] args )
        {
            if ( args.Length > 3 ){
                var xsltArgs = new XsltArgumentList();
                var pos = 0;
                while ( args.Length > ( 3 + (3*pos) ) ){

                    if ( string.IsNullOrEmpty( args[ 3 + (3*pos) +1 ] ) ){
                        break;
                    } else if (   args[ 3 + (3*pos) +1 ] != "=" ){
                        break;
                    }
                    var parmName = args[3 + (3 * pos)];
                    var parmVal = args[3 + (3 * pos) + 2];

                    Console.WriteLine("Parm( " + pos.ToString() + ")  {" + parmName + ", " + parmVal + "}");

                    xsltArgs.AddParam(parmName,string.Empty,parmVal );

                    ++pos;
                }
                return xsltArgs;
            }

            return null;
        }
        private void DrawProfilesModule()
        {
            XsltArgumentList args = new XsltArgumentList();

            args.AddParam("root", "", Root.Domain);

            Search.Utilities.APISearchRequest apisearch = new APISearchRequest();
            Search.Utilities.DataIO data = new Profiles.Search.Utilities.DataIO();

            string queryid = string.Empty;
            string keyword = string.Empty;
            string personid = string.Empty;
            string nodeid = string.Empty;

            //I dont know what the root of /people should return so for now I require the queryid
            if (Request.QueryString["queryid"] != null)
            {
                queryid = Request.QueryString["queryid"].ToString().Trim();

            }

            if (Request.QueryString["nodeid"] != null)
            {
                nodeid = Request.QueryString["nodeid"].ToString().Trim();

            }

            keyword = data.KeyKeyword(queryid);
            personid = data.PersonID(queryid, nodeid);

            this.SearchData = apisearch.Execute(queryid, keyword, personid);

            litKeywordConnection.Text = XslHelper.TransformInMemory(Server.MapPath("~/Search/Modules/KeywordConnection/KeywordConnection.xslt"), args, this.SearchData.OuterXml);
        }