[ValidateInput(false)]//Security Warning: Unsafe, can lead to XSS
        public ActionResult Process(string xslt, string xml, int processor)
        {
            var model = new XsltViewModel
            {
                Xslt   = xslt,
                Xml    = xml,
                Parser = (XsltProcessorClassTypeEnum)processor
            };

            var factory       = new XsltProcessorFactory();
            var xsltProcessor = factory.GetXsltProcessor((XsltEnums.XsltProcessorTypeEnum)processor);

            model.Output = xsltProcessor.ProcessXslt(xslt, xml);

            return(View("Index", model));
        }
        // GET: Xslt
        public ActionResult Index()
        {
            var model = new XsltViewModel();

            model.Xml  = @"<?xml version=""1.0"" encoding=""ISO-8859-1""?>
<foo>bar</foo>";
            model.Xslt = @"<?xml version=""1.0""?>
<xsl:stylesheet version=""1.0"" xmlns:xsl=""http://www.w3.org/1999/XSL/Transform"">
    <xsl:template match=""@*|node()"">
        <xsl:copy>
            <xsl:apply-templates select=""@*|node()""/>
        </xsl:copy>
    </xsl:template>
</xsl:stylesheet>";
            return(View(model));
        }
Ejemplo n.º 3
0
        public ActionResult XmlShow()
        {
            XsltViewModel model = new XsltViewModel()
            {
                XmlPath = Server.MapPath("~/App_Data/data.xml"),
                XsltPath = Server.MapPath("~/App_Data/view.xsl")
            };

            return View(model);
        }
Ejemplo n.º 4
0
 public ActionResult XmlEditResult()
 {
     // here the user has access to the Request.Form object, which contains all the attributes defined in the xsl FileStream and the associated values
     // I'd prefer to have an xml doc like the original one with new values. It is possible to find relevant fields in the xml based on the Form.Key and update its value
     // something like XmlDocument doc = createUpdatedDoc(originalfile, Request.Form);
     string url = Url.Action("Index", "Home", new { Area = string.Empty });
     XsltViewModel model = new XsltViewModel()
     {
         XmlPath = Server.MapPath("~/App_Data/data2.xml"),
         XsltPath = Server.MapPath("~/App_Data/edit.xsl"),
         Params = new Dictionary<string, object>()
         {
             {"postBackUrl", url},
         }
     };
     //send the Request.Form object to the view too, so that it can overrides them to show the updated version
     return View("XmlEdit", model);
 }
Ejemplo n.º 5
0
        public ActionResult XmlEdit()
        {
            string url = Url.Action("XmlEditResult", "Test", new { Area = string.Empty });
            XsltViewModel model = new XsltViewModel()
            {
                XmlPath = Server.MapPath("~/App_Data/data2.xml"),
                XsltPath = Server.MapPath("~/App_Data/edit.xsl"),
                Params = new Dictionary<string, object>()
                {
                    {"postBackUrl", url},
                }
            };

            return View(model);
        }