當前位置: 首頁>>代碼示例>>C#>>正文


C# Api.Processor類代碼示例

本文整理匯總了C#中Saxon.Api.Processor的典型用法代碼示例。如果您正苦於以下問題:C# Processor類的具體用法?C# Processor怎麽用?C# Processor使用的例子?那麽, 這裏精選的類代碼示例或許可以為您提供幫助。


Processor類屬於Saxon.Api命名空間,在下文中一共展示了Processor類的15個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的C#代碼示例。

示例1: Transform

        public static void Transform(Uri StyleSheet, String Input,Encoding Encoding,out String Output)
        {
            Processor processor = new Processor();

            XdmNode input = processor.NewDocumentBuilder().Build(new XmlTextReader(new StringReader(Input)));

            processor.SetProperty("http://saxon.sf.net/feature/preferJaxpParser", "true");

            XsltCompiler compiler = processor.NewXsltCompiler();

            XsltExecutable executable = compiler.Compile(StyleSheet);

            XsltTransformer transformer = executable.Load();

            transformer.InitialContextNode = input;

            Serializer serializer = new Serializer();

            MemoryStream stream = new MemoryStream();

            System.IO.StreamWriter writer = new StreamWriter(stream);

            serializer.SetOutputWriter(writer);

            transformer.Run(serializer);

            Output = Encoding.GetString(stream.ToArray());

            writer.Close();

            stream.Close();
        }
開發者ID:MetalMynds,項目名稱:FlatGlass,代碼行數:32,代碼來源:XSLTHelper.cs

示例2: Xsl2Processor

 public Xsl2Processor()
 {
     // Create a Processor instance.
     _processor = new Processor();
     _compiler = _processor.NewXsltCompiler();
     
 }
開發者ID:GrgDmr,項目名稱:CDAManager,代碼行數:7,代碼來源:Xsl2Processor.cs

示例3: XQueryCompiler

        // internal constructor: the public interface is a factory method
        // on the Processor object

        internal XQueryCompiler(Processor processor)
        {
            this.processor = processor;
            this.config = processor.config;
            this.env = config.newStaticQueryContext();
            env.setModuleURIResolver(new DotNetStandardModuleURIResolver(processor.XmlResolver));
        }
開發者ID:nuxleus,項目名稱:saxonica,代碼行數:10,代碼來源:XQuery.cs

示例4: XsltCompiler

        // internal constructor: the public interface is a factory method
        // on the Processor object

        internal XsltCompiler(Processor processor)
        {
            this.processor = processor;
            this.config = processor.config;
            this.factory = new TransformerFactoryImpl(config);
            this.info = new JCompilerInfo();
            info.setURIResolver(config.getURIResolver());
            info.setErrorListener(config.getErrorListener());
        }
開發者ID:nuxleus,項目名稱:saxonica,代碼行數:12,代碼來源:Xslt.cs

示例5: ImportSchematron

        public static string ImportSchematron(string baseDir, string schemaPath, string xsltPath)
        {
            // Builds a new XSLT file from a schematron file.
            // This only needs to be done when the schematron file changes.
            var sxnProc = new Processor();

            var outPath = xsltPath;
            var baseXsltPath = Path.Combine(baseDir, @"Content\Saxon\");

            var schConverter = new string[]
                                   {
                                       baseXsltPath + "iso_dsdl_include.xsl",
                                       baseXsltPath + "iso_abstract_expand.xsl",
                                       baseXsltPath + "iso_svrl_for_xslt2.xsl"
                                   };
            var schemaUri = new Uri(schemaPath);
            var xslComp = sxnProc.NewXsltCompiler();

            //////transform-1/////
            var xslUri = new Uri(schConverter[0]);
            var xslExec = xslComp.Compile(xslUri);
            var xslTrans = xslExec.Load();
            var domOut1 = new DomDestination(new XmlDocument());
            using(var fs = File.Open(schemaPath, FileMode.Open, FileAccess.Read))
            {
                xslTrans.SetInputStream(fs, schemaUri); // set baseUri
                xslTrans.Run(domOut1);
            }

            //////transform-2/////
            xslUri = new Uri(schConverter[1]);
            xslExec = xslComp.Compile(xslUri);
            xslTrans = xslExec.Load();
            var domOut2 = new DomDestination(new XmlDocument());
            var docBuilder = sxnProc.NewDocumentBuilder();
            docBuilder.BaseUri = schemaUri;
            var inputDoc2 = docBuilder.Wrap(domOut1.XmlDocument);
            xslTrans.InitialContextNode = inputDoc2;
            xslTrans.Run(domOut2);

            //////transform-3/////
            xslUri = new Uri(schConverter[2]);
            xslExec = xslComp.Compile(xslUri);
            xslTrans = xslExec.Load();
            var inputDoc3 = docBuilder.Wrap(domOut2.XmlDocument);
            xslTrans.InitialContextNode = inputDoc3;
            var serializer = new Serializer();
            using (TextWriter tw = new StreamWriter(outPath, false))
            {
                serializer.SetOutputWriter(tw);
                serializer.SetOutputProperty(Serializer.INDENT, "no");
                xslTrans.Run(serializer);
            }

            return outPath;
        }
開發者ID:eddleston,項目名稱:DDEX-Validator,代碼行數:56,代碼來源:SchematronBuilder.cs

示例6: Main

        static void Main(string[] args)
        {
            String s1 = @"<xsl:stylesheet version='2.0' xmlns:xsl='http://www.w3.org/1999/XSL/Transform'><xsl:output method='xml' indent='yes'/><xsl:template match='/'>";
            String s2 = "This is running an XSLT engine by <xsl:value-of select=\"system-property('xsl:vendor')\" />  <a href=\"{system-property('xsl:vendor-url')}\"><xsl:value-of select=\"system-property('xsl:vendor-url')\" /></a> implementing XSLT v<xsl:value-of select=\"system-property('xsl:version')\" /> ";
            String s3 = @"\n<xsl:apply-templates/></xsl:template><xsl:template match='@*|node()'> ";
            String s4 = @"<xsl:copy><xsl:apply-templates select='@*|node()'/></xsl:copy></xsl:template></xsl:stylesheet>";

            String str = s1 + s2 + s3  + s4;

            //Run Saxon
            //new SaxonTransform().doTransform(args, "Transform");

            //Run Saxon s9 api
            // Create a Processor instance.
            Processor processor = new Processor();

            // Load the source document.
            XdmNode input = processor.NewDocumentBuilder().Build(XmlReader.Create(new StringReader(str)));

            XsltCompiler compiler = processor.NewXsltCompiler();
            //although it is not required in this example, we need to set otherwise exception will be thrown
            compiler.BaseUri = new Uri("http://dummyurl.com");
            // Create a transformer for the stylesheet.
            XsltTransformer transformer = compiler.Compile(XmlReader.Create(new StringReader(str))).Load();

            // BaseOutputUri is only necessary for xsl:result-document.
            //transformer.BaseOutputUri = new Uri("http://dummyurl.com");
            // Set the root node of the source document to be the initial context node.
            transformer.InitialContextNode = input;

            transformer.SetParameter(new QName("", "", "maxmin"), new XdmAtomicValue("parm1"));
            transformer.SetParameter(new QName("", "", "pricestock"), new XdmAtomicValue("parm2"));

            // Create a serializer.
            Serializer serializer = new Serializer();

            // Set the root node of the source document to be the initial context node
            //transformer.InitialTemplate = new QName("","","go");

            serializer.SetOutputWriter(Console.Out);
            serializer.SetOutputProperty(Serializer.INDENT, "yes");

            // serializer.SetOutputFile(Server.MapPath("test.html")); //for file

            // Transform the source XML to System.out.
            transformer.Run(serializer);

            //Call the SaxonMediator
            SaxonMediator mediator = new SaxonMediator();

            //mediator.Transform(null, Template template, Package package)

            //wait for user to exit
            Console.ReadLine();
        }
開發者ID:mycguo,項目名稱:XSLTMediatorSAXON,代碼行數:55,代碼來源:Program.cs

示例7: Process

 private static XmlDocument Process (XmlReader funcSeq, XmlReader extTransform, Uri baseUri) {
   Processor processor = new Processor();
   XdmNode input = processor.NewDocumentBuilder().Build(funcSeq);
   XsltCompiler compiler = processor.NewXsltCompiler();
   compiler.BaseUri = baseUri;
   XsltTransformer transformer = compiler.Compile(extTransform).Load();
   transformer.InitialContextNode = input;
   DomDestination result = new DomDestination();
   transformer.Run(result);
   return result.XmlDocument;
 }
開發者ID:nuxleus,項目名稱:Nuxleus.Extf,代碼行數:11,代碼來源:Process.cs

示例8: getLinkedDocument

 private XdmNode getLinkedDocument(XdmNode element, Processor processor, bool validate)
 {
     String href = element.GetAttributeValue(xlinkHref);
     DocumentBuilder builder = processor.NewDocumentBuilder();
     Uri target = new Uri(element.BaseUri, href);
     builder.IsLineNumbering = true;
     if (validate) {
         builder.SchemaValidationMode = SchemaValidationMode.Strict;
     }
     return builder.Build(target);
 }
開發者ID:zhuyue1314,項目名稱:xcat,代碼行數:11,代碼來源:SchemaTestSuiteDriver.cs

示例9: SaxonDotNetTransform

        public SaxonDotNetTransform(string sTransformName, string sTargetLanguageCode)
            : base(sTargetLanguageCode)
        {
            // Create a Processor instance.
            m_processor = new Processor();
            m_compiler = m_processor.NewXsltCompiler();

            // Load transform from file
            var uri = new Uri(sTransformName);
            var errorList = new List<StaticError>();
            m_compiler.ErrorList = errorList;
            var t = m_compiler.Compile(uri);
            m_transformer = t.Load();
        }
開發者ID:sillsdev,項目名稱:CarlaLegacy,代碼行數:14,代碼來源:SaxonDotNetTransform.cs

示例10: Init

        private void Init (HttpContext context) {
            AppSettings baseXslt = new AppSettings();
            String xsltUri = context.Server.MapPath(baseXslt.GetSetting("baseTemplate"));
            Uri xUri = new Uri(xsltUri);

            this._Resolver = new XmlUrlResolver();
            this._Resolver.Credentials = CredentialCache.DefaultCredentials;

            this._TemplateStream = (Stream)this._Resolver.GetEntity(xUri, null, typeof(Stream));
            this._Processor = new Processor();
            this._Compiler = _Processor.NewXsltCompiler();
            this._Compiler.BaseUri = xUri;
            this._Template = this._Compiler.Compile(_TemplateStream);
            this._IS_INITIALIZED = true;
        }
開發者ID:nuxleus,項目名稱:Nuxleus.Extf,代碼行數:15,代碼來源:Init.cs

示例11: ProcessRequest

    public void ProcessRequest(HttpContext context) {

      _requestMethod = context.Request.HttpMethod;
      _writer = context.Response.Output;
      _context = context;
      _processor = (Processor)context.Application["processor"];
      _compiler = (XsltCompiler)context.Application["compiler"];
      _serializer = (Serializer)context.Application["serializer"];
      _resolver = (XmlUrlResolver)context.Application["resolver"];
      _globalXsltParams = (Hashtable)context.Application["globalXsltParams"];
      _sessionXsltParams = (Hashtable)context.Application["sessionXsltParams"];
      _requestXsltParams = (Hashtable)context.Application["requestXsltParams"];
      Hashtable xsltParams = new Hashtable();
      foreach (DictionaryEntry param in _globalXsltParams) {
        xsltParams[param.Key] = param.Value;
      }
      foreach (DictionaryEntry param in _sessionXsltParams) {
        xsltParams[param.Key] = param.Value;
      }
      foreach (DictionaryEntry param in _requestXsltParams) {
        xsltParams[param.Key] = param.Value;
      }
      _transformContext = new Context(context, _processor, _compiler, _serializer, _resolver, xsltParams);

      switch (_requestMethod) {

        case "GET": {
            new Transform().Process(_transformContext);
            break;
          }
        case "PUT": {
            new Transform().Process(_transformContext);
            break;
          }
        case "POST": {
            new Transform().Process(_transformContext);
            break;
          }
        case "DELETE": {
            new Transform().Process(_transformContext);
            break;
          }
        default: {
            new Transform().Process(_transformContext);
            break;
          }
      }
    }
開發者ID:nuxleus,項目名稱:Nuxleus.Extf,代碼行數:48,代碼來源:S3HttpHandler.cs

示例12: xml2HtmlTree

        private string xml2HtmlTree()
        {
            XmlDocument xml = new XmlDocument();
            xml.LoadXml(this.Xsd);
            StreamReader xsl = new StreamReader(AppDomain.CurrentDomain.BaseDirectory + "/Areas/MSM/Resources/Stylesheets/xsd2htmlTree.xslt");

            Processor processor = new Processor();
            XdmNode input = processor.NewDocumentBuilder().Build(xml);
            XsltTransformer transformer = processor.NewXsltCompiler().Compile(xsl).Load();
            transformer.InitialContextNode = input;
            StringWriter writer = new StringWriter();
            Serializer serializer = new Serializer();
            serializer.SetOutputWriter(writer);
            transformer.Run(serializer);
            return writer.ToString();
        }
開發者ID:BEXIS2,項目名稱:Core,代碼行數:16,代碼來源:TreePartialModel.cs

示例13: Main

        static void Main(string[] args)
        {
            string infile = @"c:\daisybooks\verysimplebook\verysimplebook.xml";
            string infile_dir = @"c:\daisybooks\verysimplebook\";
            string xsltfile = @"c:\devel\amis\trunk\amis\bin\xslt\dtbook\dtbook2xhtml.xsl";
            string outfile = @"c:\devel\amis\sandbox\dtbooktransformer_out.xml";

            // Create a Processor instance.
            Processor processor = new Processor();

            // Load the source document
            XdmNode input = processor.NewDocumentBuilder().Build(new Uri(infile));

            // Create a transformer for the stylesheet.
            XsltTransformer transformer =
                processor.NewXsltCompiler().Compile(new Uri(xsltfile)).Load();

            QName basedir = new QName("", "baseDir");

            List<XdmAtomicValue> elementNames = new List<XdmAtomicValue>();
            elementNames.Add(new XdmAtomicValue(infile_dir));
            XdmValue basedir_value = new XdmValue(elementNames);

            transformer.SetParameter(basedir, basedir_value);

            // Set the user-written XmlResolver
            UserXmlResolver runTimeResolver = new UserXmlResolver();
            runTimeResolver.Message = "** Calling transformation-time XmlResolver: ";
            transformer.InputXmlResolver = runTimeResolver;

            // Set the root node of the source document to be the initial context node
            transformer.InitialContextNode = input;

            /*
             *  String outfile = "OutputFromXsltSimple2.xml";
            Serializer serializer = new Serializer();
            serializer.SetOutputStream(new FileStream(outfile, FileMode.Create, FileAccess.Write));
            */
              // Create a serializer, with output to the standard output stream
            Serializer serializer = new Serializer();
            serializer.SetOutputWriter(Console.Out);

            // Transform the source XML and serialize the result document
            transformer.Run(serializer);

            Console.ReadLine();
        }
開發者ID:daisy,項目名稱:amis,代碼行數:47,代碼來源:Program.cs

示例14: Main

        static void Main(string[] args)
        {
            if ( args.Length < 2)
            {
                Console.Error.WriteLine("Syntax: demo <path-to-xml-file> <xpath-expression> [<num-iterations(default={0})>]", numIters);
                return;
            }

            var file = args[0];
            var xpath = args[1];

            if ( args.Length > 2)
            {
                numIters = int.Parse(args[2]);
            }

            Console.WriteLine("Loading {0}", file);

            var proc = new Processor();

            var ms_xp = System.Xml.XPath.XPathExpression.Compile(xpath);

            var xpc = proc.NewXPathCompiler();
            var xpe = xpc.Compile(xpath);
            var sel = xpe.Load();

            var doc = XDocument.Load(file);
            var ctx = proc.Wrap(doc);
            sel.ContextItem = ctx;

            var nt = new NameTable();
            XmlDocument xd = new XmlDocument(nt);
            xd.Load(file);

            var ctxXmlDoc = proc.NewDocumentBuilder().Wrap(xd);

            Console.WriteLine("Evaluating {0}", xpath);

            Time(() => Saxon(sel), "XDoc (Saxon)");
            Time(() => Native(ms_xp, doc), "XDoc (Native)");

            sel.ContextItem = ctxXmlDoc;

            Time(() => Saxon(sel), "XmlDoc (Saxon)");
            Time(() => Native(ms_xp, xd), "XmlDoc (Native)");
        }
開發者ID:zanyants,項目名稱:saxon-xdoc,代碼行數:46,代碼來源:Program.cs

示例15: RegisterExtensionFunctions

      void RegisterExtensionFunctions(Processor processor, SaxonItemFactory itemFactory) {

         IEnumerable<IEnumerable<Type>> builtInFunctions = 
            new IEnumerable<Type>[] { 
               new modules.exslt.common.Index(),
               new modules.request.Index(),
               new modules.response.Index(),
               new modules.session.Index(),
               new modules.util.Index(),
               new modules.validation.Index(),
               new modules.smtpclient.Index(),
               new modules.expath.httpclient.Index(),
            };

         IEnumerable<IEnumerable<Type>> importedFunctions =
            (from m in XPathModules.GetModuleAdaptersForProcessor(this.GetType())
             let t = m.AdapterType
             let isCollection = typeof(IEnumerable<Type>).IsAssignableFrom(t)
             select (isCollection) ? 
               (IEnumerable<Type>)Activator.CreateInstance(t)
               : new Type[] { t });

         Type itemFactoryType = itemFactory.GetType();

         foreach (var types in Enumerable.Concat(builtInFunctions, importedFunctions)) {

            var functions =
               from t in types
               let ctor = t.GetConstructors().First()
               let param = ctor.GetParameters()
               let args = param.Select(p => p.ParameterType.IsAssignableFrom(itemFactoryType) ? (object)itemFactory : null).ToArray()
               select (ExtensionFunctionDefinition)ctor.Invoke(args);

            if (functions.Select(f => f.FunctionName.Uri).Distinct().Count() > 1) 
               throw new InvalidOperationException("Functions in module must belog to the same namespace.");

            foreach (var fn in functions)
               processor.RegisterExtensionFunction(fn);
         }
      }
開發者ID:nuxleus,項目名稱:Nuxleus,代碼行數:40,代碼來源:SaxonProcessor.cs


注:本文中的Saxon.Api.Processor類示例由純淨天空整理自Github/MSDocs等開源代碼及文檔管理平台,相關代碼片段篩選自各路編程大神貢獻的開源項目,源碼版權歸原作者所有,傳播和使用請參考對應項目的License;未經允許,請勿轉載。