コード例 #1
0
        /// <summary>
        /// Run the transformation, sending the result to a specified destination.
        /// </summary>
        /// <param name="destination">
        /// The destination for the results of the stylesheet. The class <c>XmlDestination</c>
        /// is an abstraction that allows a number of different kinds of destination
        /// to be specified.
        /// </param>
        /// <exception cref="DynamicError">Throws a DynamicError if the transformation
        /// fails.</exception>

        public void Run(XmlDestination destination)
        {
            try
            {
                controller.setOutputProperties(destination.GetOutputProperties());
                if (streamSource != null)
                {
                    controller.transform(streamSource, destination.GetResult());
                }
                else if (initialContextNode != null)
                {
                    JDocumentInfo doc = initialContextNode.getDocumentRoot();
                    controller.registerDocument(doc, doc.getBaseURI());
                    controller.transform(initialContextNode, destination.GetResult());
                }
                else
                {
                    controller.transform(null, destination.GetResult());
                }
                destination.Close();
            }
            catch (javax.xml.transform.TransformerException err)
            {
                throw new DynamicError(err);
            }
        }
コード例 #2
0
        /// <summary>Setup Validation Reporting feature which saves the validation errors in an XML file</summary>
        /// <param name="destination"> destination where XML will be sent</param>

        public void SetValidityReporting(XmlDestination destination)
        {
            JInvalidityReportGenerator reporter = processor.Implementation.createValidityReporter();

            reporter.setReceiver(destination.GetReceiver(processor.Implementation.makePipelineConfiguration()));

            this.invalidityHandler = reporter;
        }
コード例 #3
0
ファイル: XQuery.cs プロジェクト: orbeon/saxon-he
        /// <summary>
        /// Evaluate the query, sending the result to a specified destination.
        /// </summary>
        /// <param name="destination">
        /// The destination for the results of the query. The class <c>XmlDestination</c>
        /// is an abstraction that allows a number of different kinds of destination
        /// to be specified.
        /// </param>
        /// <exception cref="DynamicError">Throws a DynamicError if any run-time failure
        /// occurs while evaluating the expression.</exception>

        public void Run(XmlDestination destination)
        {
            try {
                exp.run(context, destination.GetResult(), destination.GetOutputProperties());
            } catch (JXPathException err) {
                throw new DynamicError(err);
            }
            destination.Close();
        }
コード例 #4
0
ファイル: XQuery.cs プロジェクト: orbeon/saxon-he
        /// <summary>
        /// Evaluate the query, sending the result to a specified destination.
        /// </summary>
        /// <param name="destination">
        /// The destination for the results of the query. The class <c>XmlDestination</c>
        /// is an abstraction that allows a number of different kinds of destination
        /// to be specified.
        /// </param>
        /// <exception cref="DynamicError">Throws a DynamicError if any run-time failure
        /// occurs while evaluating the expression.</exception>

        public void Run(XmlDestination destination)
        {
            try
            {
                exp.run(context, destination.GetReceiver(context.getConfiguration().makePipelineConfiguration()), destination.GetOutputProperties());
            }
            catch (JXPathException err)
            {
                throw new DynamicError(err);
            }
            destination.Close();
        }
コード例 #5
0
ファイル: XQuery.cs プロジェクト: orbeon/saxon-he
        /// <summary>
        /// Evaluate the query, sending the result to a specified destination.
        /// </summary>
        /// <param name="destination">
        /// The destination for the results of the query. The class <c>XmlDestination</c>
        /// is an abstraction that allows a number of different kinds of destination
        /// to be specified.
        /// </param>
        /// <exception cref="DynamicError">Throws a <c>DynamicError</c> if any run-time failure
        /// occurs while evaluating the expression.</exception>

        public void Run(XmlDestination destination)
        {
            try
            {
                evaluator.setDestination(destination.GetUnderlyingDestination());
                evaluator.run();
            }
            catch (JSaxonApiException err)
            {
                throw new DynamicError(err);
            }
        }
コード例 #6
0
      void Run(XmlDestination destination, XsltRuntimeOptions options) {

         if (options == null) throw new ArgumentNullException("options");

         XsltTransformer transformer = executable.Load();
         transformer.RecoveryPolicy = RecoveryPolicy.DoNotRecover;

         if (options.InputXmlResolver != null)
            transformer.InputXmlResolver = options.InputXmlResolver;

         // XsltTransformer.BaseOutputUri doesn't accept null
         if (options.BaseOutputUri != null)
            transformer.BaseOutputUri = options.BaseOutputUri;

         // TODO: Bug in Saxon 9.3
         //else if (this.StaticBaseUri != null && this.StaticBaseUri.IsFile)
         //   transformer.BaseOutputUri = new Uri(Path.GetDirectoryName(this.StaticBaseUri.LocalPath), UriKind.Absolute);

         try {
            if (options.InitialTemplate != null)
               transformer.InitialTemplate = new QName(options.InitialTemplate);

         } catch (DynamicError err) {
            throw new SaxonException(err);
         }

         if (options.InitialMode != null)
            transformer.InitialMode = new QName(options.InitialMode);

         if (options.InitialContextNode != null) 
            transformer.InitialContextNode = options.InitialContextNode.ToXdmNode(this.Processor.ItemFactory);

         transformer.MessageListener = new SaxonMessageListener();

         foreach (var pair in options.Parameters) {
            
            QName qname = new QName(pair.Key);
            XdmValue xdmValue = pair.Value.ToXdmValue(this.Processor.ItemFactory);
         
            transformer.SetParameter(qname, xdmValue);
         }

         try {
            transformer.Run(destination);

         } catch (DynamicError ex) {
            throw new SaxonException(ex);

         } catch (Exception ex) {
            throw new SaxonException(ex.Message, ex);
         }
      }
コード例 #7
0
ファイル: XSLT.cs プロジェクト: orbeon/saxon-he
        public JResult resolve(String href, String baseString)
        {
            Uri baseUri;

            try {
                baseUri = new Uri(baseString);
            } catch (System.UriFormatException err) {
                throw new JTransformerException("Invalid base output URI " + baseString, err);
            }
            XmlDestination destination = handler.HandleResultDocument(href, baseUri);
            JResult        result      = destination.GetResult();

            resultMap.Add(result, destination);
            return(destination.GetResult());
        }
コード例 #8
0
ファイル: Configuration.cs プロジェクト: orbeon/saxon-he
        /// <summary>
        /// Copy an XdmValue to an XmlDestination
        /// </summary>
        /// <remarks>
        /// This method can be used to copy any kind of <c>XdmValue</c> to any kind
        /// of <c>XdmDestination</c>. The supplied <c>XdmValue</c> is first converted
        /// to an XML document according to the rules of the XSLT/XQuery serialization
        /// specification (for example, if the <c>XdmValue</c> is a sequence of atomic
        /// values, they will be turned in a text node in which the values are converted
        /// to strings and separated by single spaces). The resulting document is then
        /// written to the supplied <c>XmlDestination</c>.</remarks>
        /// <param name="sequence">The value to be written</param>
        /// <param name="destination">The destination to which the value should be written</param>
        ///

        public void WriteXdmValue(XdmValue sequence, XmlDestination destination)
        {
            JResult   result = destination.GetResult();
            JReceiver r      = config.getSerializerFactory().getReceiver(result,
                                                                         config.makePipelineConfiguration(), new JProperties());

            r = new JNamespaceReducer(r);
            JTreeReceiver tree = new JTreeReceiver(r);

            tree.open();
            tree.startDocument(0);
            foreach (XdmItem it in sequence)
            {
                tree.append((Item)it.Unwrap(), 0, JNodeInfo.__Fields.ALL_NAMESPACES);
            }
            tree.endDocument();
            tree.close();
        }
コード例 #9
0
ファイル: Xslt.cs プロジェクト: geonetwork/patched-jars
        /// <summary>
        /// Run the transformation, sending the result to a specified destination.
        /// </summary>
        /// <param name="destination">
        /// The destination for the results of the stylesheet. The class <c>XmlDestination</c>
        /// is an abstraction that allows a number of different kinds of destination
        /// to be specified.
        /// </param>
        /// <exception cref="DynamicError">Throws a DynamicError if the transformation
        /// fails.</exception>

        public void Run(XmlDestination destination)
        {
            // TODO: This isn't an ideal way of running the stylesheet if it invokes xsl:strip-space: it's better to do the
            // whitespace stripping while building the tree.
            try
            {
                controller.setOutputProperties(destination.GetOutputProperties());
                if (initialContextNode != null)
                {
                    JDocumentInfo doc = initialContextNode.getDocumentRoot();
                    controller.registerDocument(doc, doc.getBaseURI());
                }
                controller.transform(initialContextNode, destination.GetResult());
                destination.Close();
            }
            catch (javax.xml.transform.TransformerException err)
            {
                throw new DynamicError(err);
            }
        }
コード例 #10
0
        /// <summary>
        /// Copy an XdmValue to an XmlDestination
        /// </summary>
        /// <remarks>
        /// This method can be used to copy any kind of <c>XdmValue</c> to any kind
        /// of <c>XdmDestination</c>. The supplied <c>XdmValue</c> is first converted
        /// to an XML document according to the rules of the XSLT/XQuery serialization
        /// specification (for example, if the <c>XdmValue</c> is a sequence of atomic
        /// values, they will be turned in a text node in which the values are converted
        /// to strings and separated by single spaces). The resulting document is then
        /// written to the supplied <c>XmlDestination</c>.</remarks>
        /// <param name="sequence">The value to be written</param>
        /// <param name="destination">The destination to which the value should be written</param>
        ///

        public void WriteXdmValue(XdmValue sequence, XmlDestination destination)
        {
            try
            {
                JPipelineConfiguration pipe = config.makePipelineConfiguration();
                JResult   result            = destination.GetResult(pipe);
                JReceiver r = config.getSerializerFactory().getReceiver(result,
                                                                        pipe, destination.GetOutputProperties());
                r = new JNamespaceReducer(r);
                JTreeReceiver tree = new JTreeReceiver(r);
                tree.open();
                tree.startDocument(0);
                foreach (XdmItem it in sequence)
                {
                    tree.append((Item)it.Unwrap(), 0, JNodeInfo.__Fields.ALL_NAMESPACES);
                }
                tree.endDocument();
                tree.close();
            } catch (JXPathException err) {
                throw new DynamicError(err);
            }
        }
コード例 #11
0
ファイル: XSLT.cs プロジェクト: orbeon/saxon-he
        public void close(JResult result)
        {
            XmlDestination destination = (XmlDestination)resultMap[result];

            destination.Close();
        }
コード例 #12
0
ファイル: Xslt.cs プロジェクト: nuxleus/saxonica
        /// <summary>
        /// Run the transformation, sending the result to a specified destination.
        /// </summary>
        /// <param name="destination">
        /// The destination for the results of the stylesheet. The class <c>XmlDestination</c>
        /// is an abstraction that allows a number of different kinds of destination
        /// to be specified.
        /// </param>
        /// <exception cref="DynamicError">Throws a DynamicError if the transformation
        /// fails.</exception>

        public void Run(XmlDestination destination)
        {
            try
            {
                controller.setOutputProperties(destination.GetOutputProperties());
                if (streamSource != null)
                {
                    controller.transform(streamSource, destination.GetResult(controller.makePipelineConfiguration()));
                }
                else if (initialContextNode != null)
                {
                    JDocumentInfo doc = initialContextNode.getDocumentRoot();
                    controller.registerDocument(doc, (doc.getBaseURI()==null ? null : new JDocumentURI(doc.getBaseURI())));
                    controller.transform(initialContextNode, destination.GetResult(controller.makePipelineConfiguration()));
                }
                else
                {
                    controller.transform(null, destination.GetResult(controller.makePipelineConfiguration()));
                }
                destination.Close();
            }
            catch (javax.xml.transform.TransformerException err)
            {
                throw new DynamicError(err);
            }
        }
コード例 #13
0
ファイル: XQuery.cs プロジェクト: nuxleus/saxonica
        /// <summary>
        /// Evaluate the query, sending the result to a specified destination.
        /// </summary>
        /// <param name="destination">
        /// The destination for the results of the query. The class <c>XmlDestination</c>
        /// is an abstraction that allows a number of different kinds of destination
        /// to be specified.
        /// </param>
        /// <exception cref="DynamicError">Throws a DynamicError if any run-time failure
        /// occurs while evaluating the expression.</exception>

        public void Run(XmlDestination destination)
        {
            try
            {
                exp.run(context, destination.GetResult(context.getConfiguration().makePipelineConfiguration()), destination.GetOutputProperties());
            }
            catch (JXPathException err)
            {
                throw new DynamicError(err);
            }
            destination.Close();
        }
コード例 #14
0
ファイル: Schema.cs プロジェクト: fidothe/saxon-he
        /// <summary>
        /// Supply the destination to hold the validated document. If no destination
        /// is supplied, the validated document is discarded.
        /// </summary>
        /// <remarks>
        /// The destination differs from the source in that (a) default values of missing
        /// elements and attributes are supplied, and (b) the typed values of elements and
        /// attributes are available. However, typed values can only be accessed if the result
        /// is represented using the XDM data model, that is, if the destination is supplied
        /// as an XdmDestination.
        /// </remarks>

        public void SetDestination(XmlDestination destination)
        {
            this.destination = destination;
        }
コード例 #15
0
      void Run(XmlDestination destination, XQueryRuntimeOptions options) {

         XQueryEvaluator eval = GetEvaluator(options);

         try {
            eval.Run(destination);

         } catch (DynamicError ex) {
            throw new SaxonException(ex);

         } catch (Exception ex) {
            throw new SaxonException(ex.Message, ex);
         }
      }
コード例 #16
0
ファイル: Schema.cs プロジェクト: orbeon/saxon-he
        /// <summary>
        /// Supply the destination to hold the validated document. If no destination
        /// is supplied, the validated document is discarded.
        /// </summary>
        /// <remarks>
        /// The destination differs from the source in that (a) default values of missing
        /// elements and attributes are supplied, and (b) the typed values of elements and
        /// attributes are available. However, typed values can only be accessed if the result
        /// is represented using the XDM data model, that is, if the destination is supplied
        /// as an <c>XdmDestination</c>.
        /// </remarks>
        /// <param name="destination">
        /// The destination to hold the validated document.
        /// </param>

        public void SetDestination(XmlDestination destination)
        {
            schemaValidator.setDestination(destination.GetUnderlyingDestination());
        }
コード例 #17
0
ファイル: Schema.cs プロジェクト: orbeon/saxon-he
        /// <summary>Set the validation reporting feature, which saves the validation errors in an XML file</summary>
        /// <param name="destination"> destination where XML will be sent</param>

        public void SetValidityReporting(XmlDestination destination)
        {
            schemaValidator.setValidityReporting(destination.GetUnderlyingDestination());
        }
コード例 #18
0
 internal AbstractDestination(Xslt30Transformer xslt30Transformer, XmlDestination destination)
 {
     this.xslt30Transformer = xslt30Transformer;
     this.destination       = destination;
 }
コード例 #19
0
ファイル: Schema.cs プロジェクト: nuxleus/saxonica
        /// <summary>
        /// Supply the destination to hold the validated document. If no destination
        /// is supplied, the validated document is discarded.
        /// </summary>
        /// <remarks>
        /// The destination differs from the source in that (a) default values of missing
        /// elements and attributes are supplied, and (b) the typed values of elements and
        /// attributes are available. However, typed values can only be accessed if the result
        /// is represented using the XDM data model, that is, if the destination is supplied
        /// as an XdmDestination.
        /// </remarks>
        /// <param name="destination">
        /// The destination to hold the validated document.
        /// </param>

        public void SetDestination(XmlDestination destination)
        {
            this.destination = destination;
        }
コード例 #20
0
ファイル: Xslt.cs プロジェクト: nuxleus/saxonica
 /// <summary>
 /// Output an XML representation of the compiled code of the stylesheet, for purposes of 
 /// diagnostics and instrumentation
 /// </summary>
 /// <param name="destination">The destination for the diagnostic output</param>
 
 public void Explain(XmlDestination destination) {
     JConfiguration config = pss.getConfiguration();
     JResult result = destination.GetResult(config.makePipelineConfiguration());          
     JProperties properties = new JProperties();
     properties.setProperty("indent", "yes");
     properties.setProperty("{http://saxon.sf.net/}indent-spaces", "2");
     JReceiver receiver = config.getSerializerFactory().getReceiver(
         result, config.makePipelineConfiguration(), properties);
     JExpressionPresenter presenter = new JExpressionPresenter(config, receiver);
     pss.explain(presenter);
 }
        /// <summary>
        /// Run the transformation, sending the result to a specified destination.
        /// </summary>
        /// <param name="destination">
        /// The destination for the results of the stylesheet. The class <c>XmlDestination</c>
        /// is an abstraction that allows a number of different kinds of destination
        /// to be specified.
        /// </param>
        /// <exception cref="DynamicError">Throws a DynamicError if the transformation
        /// fails.</exception>

        public void Run(XmlDestination destination) {
            try {
                controller.setOutputProperties(destination.GetOutputProperties());
                if (initialContextNode != null) {
                    JDocumentInfo doc = initialContextNode.getDocumentRoot();
                    controller.registerDocument(doc, doc.getBaseURI());
                }
                controller.transformDocument(initialContextNode, destination.GetResult());
                destination.Close();
            } catch (javax.xml.transform.TransformerException err) {
                throw new DynamicError(err);
            }
        }