Esempio n. 1
0
        protected internal IContent WritePage(IPageData pageData, OutputData outputData)
        {
            PageMakerUtil.AssertType(this, outputData, SourceOutputType.XmlReader, SourceOutputType.String,
                                     SourceOutputType.DataSet, SourceOutputType.ToolkitObject);

            string xsltFile = GetRealXsltFile(pageData); // Path.Combine(AppSetting.Current.XmlPath, XsltFile);

            TkDebug.AssertNotNullOrEmpty(xsltFile, "没有设置XsltFile属性,该值为空", this);
            TkDebug.Assert(File.Exists(xsltFile), string.Format(ObjectUtil.SysCulture,
                                                                "系统中并不存在文件名为{0}的文件,请检查路径!", xsltFile), this);

            XsltArgumentList args = null;

            if (UseXsltArgs)
            {
                args = new XsltArgumentList();
                AddXsltParam(args, pageData);
            }
            string    content = string.Empty;
            XmlReader reader  = null;

            switch (outputData.OutputType)
            {
            case SourceOutputType.XmlReader:
                reader = outputData.Data.Convert <XmlReader>();
                break;

            case SourceOutputType.String:
                reader = XmlTransformUtil.GetXmlReader(outputData.Data.Convert <string>());
                break;

            case SourceOutputType.ToolkitObject:
                XDocument doc = outputData.Data.CreateXDocument(null, ObjectUtil.WriteSettings, QName.ToolkitNoNS);
                reader = doc.CreateReader();
                break;

            case SourceOutputType.DataSet:
                reader = new XmlDataSetReader(outputData.Data.Convert <DataSet>());
                break;

            default:
                TkDebug.ThrowImpossibleCode(this);
                break;
            }
            content = XmlTransformUtil.Transform(reader, xsltFile, args, TransformSetting.All);
            Encoding encoding = Encoding ?? (pageData.IsPost ? Encoding.UTF8 : null);

            return(CreateContent(pageData, content, encoding));
        }
Esempio n. 2
0
        public IContent WritePage(ISource source, IPageData pageData, OutputData outputData)
        {
            TkDebug.AssertArgumentNull(outputData, "outputData", this);

            PageMakerUtil.AssertType(source, outputData, SourceOutputType.ToolkitObject);
            ExceptionData data = outputData.Data.Convert <ExceptionData>();
            XDocument     doc  = data.CreateXDocument(null, ObjectUtil.WriteSettings, QName.ToolkitNoNS);

            string xsltFile = FileUtil.GetRealFileName(@"xslttemplate/bin/Exception.xslt",
                                                       FilePathPosition.Xml);
            string content = XmlTransformUtil.Transform(doc.CreateReader(), xsltFile,
                                                        null, TransformSetting.All);

            return(new SimpleContent(ContentTypeConst.HTML, content));
        }