Exemplo n.º 1
0
 public ResultDocumentHandlerWrapper(IResultDocumentHandler handler)
 {
     this.handler = handler;
 }
Exemplo n.º 2
0
 public ResultDocumentHandlerWrapper(IResultDocumentHandler handler, JPipelineConfiguration pipe)
 {
     this.handler = handler;
     this.pipe = pipe;
 }
 /// <summary>
 /// Execute the transformation
 /// </summary>
 public string Run(XDocument doc, IResultDocumentHandler handler = null)
 {
     DocumentBuilder docbuilder = processor.NewDocumentBuilder();
     docbuilder.WhitespacePolicy = WhitespacePolicy.StripIgnorable;
     XdmNode input = docbuilder.Build(doc.CreateReader());
     return Execute(input, handler);
 }
        /// <summary>
        /// Actually execute the transformation using the Saxon API
        /// </summary>
        private string Execute(XdmNode input, IResultDocumentHandler handler)
        {
            transform.InitialContextNode = input;
            if(handler != null)
                transform.ResultDocumentHandler = handler;

            var output = new StringBuilder();
            var settings = new XmlWriterSettings();
            settings.OmitXmlDeclaration = true;
            transform.Run(new TextWriterDestination(XmlWriter.Create(output, settings)));
            return output.ToString();
        }
        /// <summary>
        /// Load the input file and execute the transformation
        /// </summary>
        public string Run(string inputfile, IResultDocumentHandler handler = null)
        {
            DocumentBuilder docbuilder = processor.NewDocumentBuilder();
            docbuilder.WhitespacePolicy = WhitespacePolicy.StripIgnorable;
            XdmNode input = docbuilder.Build(new Uri(inputfile));

            return Execute(input, handler);
        }