当前位置: 首页>>代码示例>>C#>>正文


C# Processor.NewDocumentBuilder方法代码示例

本文整理汇总了C#中Saxon.Api.Processor.NewDocumentBuilder方法的典型用法代码示例。如果您正苦于以下问题:C# Processor.NewDocumentBuilder方法的具体用法?C# Processor.NewDocumentBuilder怎么用?C# Processor.NewDocumentBuilder使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在Saxon.Api.Processor的用法示例。


在下文中一共展示了Processor.NewDocumentBuilder方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。

示例1: Transform

        public static void Transform(String StylesheetFilename, String SourceFilename, String OutputFilename)
        {
            if (StylesheetFilename.StartsWith(".\\"))
            {
                StylesheetFilename = System.IO.Path.GetDirectoryName(Assembly.GetExecutingAssembly().Location) + "\\" + StylesheetFilename;
            }

            Processor processor = new Processor();

            XdmNode input = processor.NewDocumentBuilder().Build(new Uri(SourceFilename));

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

            XsltCompiler compiler = processor.NewXsltCompiler();

            XsltExecutable executable = compiler.Compile(new Uri(StylesheetFilename));

            XsltTransformer transformer = executable.Load();

            transformer.InitialContextNode = input;

            Serializer serializer = new Serializer();

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

            serializer.SetOutputWriter(stream);

            transformer.Run(serializer);

            stream.Close();
        }
开发者ID:MetalMynds,项目名称:FlatGlass,代码行数:31,代码来源:XSLTHelper.cs

示例2: GenXML

    public void GenXML()
    {
        String sourceUri = Server.MapPath("5648.xml");
        String xqUri = Server.MapPath("graph.xq");

        using (FileStream sXml = File.OpenRead(sourceUri))
        {
            using (FileStream sXq = File.OpenRead(xqUri))
            {
                Processor processor = new Processor();
                XQueryCompiler compiler = processor.NewXQueryCompiler();
                compiler.BaseUri = sourceUri;
                XQueryExecutable exp = compiler.Compile(sXq);
                XQueryEvaluator eval = exp.Load();

                DocumentBuilder loader = processor.NewDocumentBuilder();
                loader.BaseUri = new Uri(sourceUri);
                XdmNode indoc = loader.Build(new FileStream(sourceUri, FileMode.Open, FileAccess.Read));

                eval.ContextItem = indoc;
                Serializer qout = new Serializer();
                qout.SetOutputProperty(Serializer.METHOD, "xml");
                qout.SetOutputProperty(Serializer.INDENT, "yes");
                qout.SetOutputProperty(Serializer.SAXON_INDENT_SPACES, "1");
                qout.SetOutputWriter(Response.Output);
                eval.Run(qout);
            }
        }
    }
开发者ID:plasma-umass,项目名称:Hound,代码行数:29,代码来源:Default.aspx.cs

示例3: Transform

        public string Transform(string baseDir, string sourceXml, string releaseType, string version)
        {
            var sourceXsl = SchematronBuilder.CheckForNewerSchematron(baseDir, releaseType, version);

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

            var result = new StringBuilder();

            var xmlDocumentBuilder = processor.NewDocumentBuilder();
            xmlDocumentBuilder.BaseUri = new Uri(baseDir);

            var xsltCompiler = processor.NewXsltCompiler();
            xsltCompiler.ErrorList = new ArrayList();
            var xmlToValidate = xmlDocumentBuilder.Build(new StringReader(sourceXml));
            var compiledXsl = xsltCompiler.Compile(new XmlTextReader(sourceXsl));
            var xmlValidator = compiledXsl.Load();

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

            // BaseOutputUri is only necessary for xsl:result-document.
            xmlValidator.BaseOutputUri = new Uri(Path.Combine(baseDir, "output.xml"));

            var validationSerializer = new Serializer();

            using (var resultsWriter = new StringWriter(result))
            {
                validationSerializer.SetOutputWriter(resultsWriter);
                xmlValidator.Run(validationSerializer);
            }

            return result.ToString();
        }
开发者ID:eddleston,项目名称:DDEX-Validator,代码行数:34,代码来源:DdexValidator.cs

示例4: 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

示例5: 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

示例6: 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

示例7: DoTransform

        internal XmlDocument DoTransform()
        {
            Processor processor = new Processor();

            XdmNode input = processor.NewDocumentBuilder().Wrap(_docToTransform);

            // Create a compiler
            XsltCompiler compiler = processor.NewXsltCompiler();

            DocumentBuilder builder = processor.NewDocumentBuilder();
            XdmNode xsltSheetNode = builder.Build(_xsltDocReader);

            // Compile the stylesheet
            XsltTransformer transformer = compiler.Compile(xsltSheetNode).Load();

            // Run the transformation
            transformer.InitialContextNode = input;
            DomDestination result = new DomDestination();
            transformer.Run(result);

            return result.XmlDocument;
        }
开发者ID:petegee,项目名称:AHPilotStats,代码行数:22,代码来源:XSLT2Transformer.cs

示例8: 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

示例9: 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

示例10: Main

        public static void Main()
        {
            using (FileStream streamXml = File.OpenRead(XmlPath))
            {
                using (FileStream streamXsl = File.OpenRead(XsltPath))
                {
                    Processor processor = new Processor();

                    DocumentBuilder builder = processor.NewDocumentBuilder();
                    Uri uri = new Uri("urn:catalogue");
                    builder.BaseUri = uri;
                    XdmNode input = builder.Build(streamXml);
                    XsltTransformer transformer = processor.NewXsltCompiler().Compile(streamXsl).Load();
                    transformer.InitialContextNode = input;
                    Serializer serializer = new Serializer();
                    serializer.SetOutputFile(HtmlPath);
                    transformer.Run(serializer);
                }
            }

            Console.WriteLine("catalogue.html created successfully");
        }
开发者ID:AYankova,项目名称:Databases,代码行数:22,代码来源:Program.cs

示例11: getXdmNode

        private static XdmNode getXdmNode(String uri, String path) {
            try {

                SgmlReader sr = new SgmlReader();
                sr.Href = uri;

                XmlDocument htmlDoc = new XmlDocument();

                try {
                    htmlDoc.Load(sr);
                } catch (Exception e) {
                    throw;
                }

                XmlNode html = htmlDoc.SelectSingleNode(path);
                Processor processor = new Processor();
                return processor.NewDocumentBuilder().Build(html);

            } catch (Exception e) {
                throw;
            }
        }
开发者ID:nuxleus,项目名称:Nuxleus.Extf,代码行数:22,代码来源:HttpSgmlToXml.cs

示例12: SaxonXsltTransform

        /// <summary>
        /// Initializes a new instance of the <see cref="SaxonXsltTransform"/> class.
        /// </summary>
        /// <param name="context">The context.</param>
        /// <param name="stylesheetMarkup">The stylesheet markup.</param>
        /// <exception cref="SageHelpException"></exception>
        public SaxonXsltTransform(SageContext context, XmlDocument stylesheetMarkup)
        {
            Contract.Requires<ArgumentNullException>(context != null);
            Contract.Requires<ArgumentNullException>(stylesheetMarkup != null);

            UrlResolver resolver = new UrlResolver(context);

            processor = new Processor();

            XdmNode input = processor.NewDocumentBuilder().Build(stylesheetMarkup);
            XsltTransformer transformer = processor.NewXsltCompiler().Compile(XmlReader.Create(stylesheetMarkup.OuterXml)).Load();

            try
            {
                //this.processor.Load(stylesheetMarkup, XsltSettings.TrustedXslt, resolver);
                dependencies.AddRange(resolver.Dependencies);
            }
            catch //(Exception ex)
            {
                //ProblemInfo problem = this.DetectProblemType(ex);
                //throw new SageHelpException(problem, ex);
            }
        }
开发者ID:igorfrance,项目名称:sage,代码行数:29,代码来源:SaxonXsltTransform.cs

示例13: _convert

        private static SVGImage.SVG.SVGImage _convert(XmlReader xml)
        {
            var processor = new Processor();

            // Load the source document
            XdmNode input = processor.NewDocumentBuilder().Build(xml);

            // Create a transformer for the stylesheet
            if (transformer == null)
            {
                var file = Path.Combine(System.IO.Path.GetDirectoryName(System.Reflection.Assembly.GetExecutingAssembly().GetName().CodeBase), "libs\\pMML2SVG\\pmml2svg.xsl");
                var xslt = XmlReader.Create(file);
                transformer = processor.NewXsltCompiler().Compile(xslt).Load();
            }

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

            var ms = new MemoryStream();

            // Create a serializer
            var serializer = new Serializer();
            serializer.SetOutputStream(ms);

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

            serializer.Close();

            ms.Position = 0;

            var img = new SVGImage.SVG.SVGImage();
            img.SetImage(ms);
            
            return img;
        }
开发者ID:ChrisCross67,项目名称:CodeReason.Reports,代码行数:36,代码来源:MathMLToSVGviaXSLT.cs

示例14:

 public XsltTransformationManager
   (
     Processor processor,
     Transform transform,
     XmlUrlResolver resolver,
     Serializer serializer,
     Dictionary<string, XsltTransformer> xsltHashtable,
     Hashtable xmlSourceHashtable,
     Hashtable xdmNodeHashtable,
     Hashtable namedXsltHashtable,
     Hashtable namedXsltETagIndex,
     Hashtable xdmNodeETagIndex,
     Uri baseXsltUri,
     String baseXsltUriHash,
     String baseXsltName
   ) {
     m_baseXsltUri = baseXsltUri;
     m_baseXsltUriHash = baseXsltUriHash;
     m_baseXsltName = baseXsltName;
     m_transform = transform;
     m_xsltHashtable = xsltHashtable;
     m_processor = processor;
     m_compiler = m_processor.NewXsltCompiler();
     m_sourceHashtable = xmlSourceHashtable;
     m_resolver = resolver;
     m_compiler.XmlResolver = m_resolver;
     m_builder = m_processor.NewDocumentBuilder();
     m_serializer = serializer;
     m_xdmNodeHashtable = xdmNodeHashtable;
     m_xdmNodeETagIndex = xdmNodeETagIndex;
     m_namedXsltHashtable = namedXsltHashtable;
     m_namedXsltETagIndex = namedXsltETagIndex;
     _hashAlgorithm = HashAlgorithm.MD5;
     //NOTE: TransformEngine enum PLACEHOLDER FOR FUTURE USE
     m_transformEngine = TransformEngine.SAXON;
 }
开发者ID:xxjeng,项目名称:nuxleus,代码行数:36,代码来源:XsltTransformationManager.cs

示例15: run

        /// <summary>
        /// Run a transformation: simplest possible script
        /// </summary>
        public override void run(Uri samplesDir)
        {
            // Create a Processor instance.
            Processor processor = new Processor();

            // Load the source document
            XdmNode input = processor.NewDocumentBuilder().Build(new Uri(samplesDir, "data/books.xml"));

            // Create an XPath compiler
            XPathCompiler xpath = processor.NewXPathCompiler();

            // Enable caching, so each expression is only compiled once
            xpath.Caching = true;

            // Compile and evaluate some XPath expressions
            foreach (XdmItem item in xpath.Evaluate("//ITEM", input))
            {
                Console.WriteLine("TITLE: " + xpath.EvaluateSingle("string(TITLE)", item));
                Console.WriteLine("PRICE: " + xpath.EvaluateSingle("string(PRICE)", item));
            }
        }
开发者ID:nuxleus,项目名称:saxonica,代码行数:24,代码来源:ExamplesPE.cs


注:本文中的Saxon.Api.Processor.NewDocumentBuilder方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。