예제 #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
파일: 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());
        }
예제 #3
0
파일: Schema.cs 프로젝트: fidothe/saxon-he
        /// <summary>
        /// Run the validation of the supplied source document, optionally
        /// writing the validated document to the supplied destination.
        /// </summary>

        public void Run()
        {
            AugmentedSource aug = AugmentedSource.makeAugmentedSource(source);

            aug.setSchemaValidationMode(lax ? Validation.LAX : Validation.STRICT);
            JReceiver receiver;

            if (destination == null)
            {
                receiver = new Sink();
            }
            else if (destination is Serializer)
            {
                receiver = ((Serializer)destination).GetReceiver(config);
            }
            else
            {
                Result result = destination.GetResult();
                if (result is JReceiver)
                {
                    receiver = (JReceiver)result;
                }
                else
                {
                    throw new ArgumentException("Unknown type of destination");
                }
            }
            PipelineConfiguration pipe = config.makePipelineConfiguration();

            if (errorList != null)
            {
                pipe.setErrorListener(new ErrorGatherer(errorList));
            }
            new Sender(pipe).send(aug, receiver, true);
        }
예제 #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.GetResult(), destination.GetOutputProperties());
            } catch (JXPathException err) {
                throw new DynamicError(err);
            }
            destination.Close();
        }
예제 #5
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)
        {
            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();
        }
예제 #6
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)
        {
            // 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);
            }
        }
예제 #7
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);
            }
        }
예제 #8
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);
            }
        }
예제 #9
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);
 }
예제 #10
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();
        }
        /// <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);
            }
        }