Class QueryResult


  • public class QueryResult
    extends java.lang.Object
    This utility class takes the result sequence produced by a query, and wraps it as an XML document. The class is never instantiated.
    • Field Summary

      Fields 
      Modifier and Type Field Description
      static java.lang.String RESULT_NS  
    • Method Summary

      All Methods Static Methods Concrete Methods 
      Modifier and Type Method Description
      static void rewriteToDisk​(NodeInfo doc, java.util.Properties outputProperties, boolean backup, java.io.PrintStream log)
      Write an updated document back to disk, using the original URI from which it was read
      static void sendWrappedSequence​(SequenceIterator iterator, Receiver destination)
      Take a sequence supplied in the form of an iterator and generate a wrapped represention of the items in the sequence, the wrapped representation being a sequence of events sent to a supplied Receiver, in which each item is wrapped in a containing element that identifies its type
      static java.lang.String serialize​(NodeInfo nodeInfo)
      Convenience method to serialize a node using default serialization options, placing the result in a string.
      static void serialize​(NodeInfo node, javax.xml.transform.Result destination, java.util.Properties outputProperties)
      Serialize a document containing wrapped query results (or any other document, in fact) as XML.
      static void serialize​(NodeInfo node, javax.xml.transform.Result destination, SerializationProperties properties)
      Serialize a document or element node.
      static void serializeSequence​(SequenceIterator iterator, Configuration config, java.io.OutputStream destination, java.util.Properties outputProps)
      Serialize an arbitrary sequence, without any special wrapping.
      static void serializeSequence​(SequenceIterator iterator, Configuration config, java.io.Writer writer, java.util.Properties outputProps)
      Serialize an arbitrary sequence, without any special wrapping.
      static void serializeSequence​(SequenceIterator iterator, Configuration config, javax.xml.transform.Result result, java.util.Properties outputProperties)
      Serialize a sequence to a given result
      static void serializeSequence​(SequenceIterator iterator, Configuration config, javax.xml.transform.Result result, SerializationProperties properties)
      Serialize a sequence to a given result.
      static NodeInfo wrap​(SequenceIterator iterator, Configuration config)
      Take the results of a query (or any other SequenceIterator) and create an XML document containing copies of all items in the sequence, each item wrapped in a containing element that identifies its type
      • Methods inherited from class java.lang.Object

        clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
    • Field Detail

      • RESULT_NS

        public static java.lang.String RESULT_NS
    • Method Detail

      • serialize

        public static java.lang.String serialize​(NodeInfo nodeInfo)
                                          throws XPathException
        Convenience method to serialize a node using default serialization options, placing the result in a string.
        Parameters:
        nodeInfo - the node to be serialized. This must not be an attribute or namespace node.
        Returns:
        the serialization of the node
        Throws:
        XPathException - if a serialization error occurs
        Since:
        9.0
      • wrap

        public static NodeInfo wrap​(SequenceIterator iterator,
                                    Configuration config)
                             throws XPathException
        Take the results of a query (or any other SequenceIterator) and create an XML document containing copies of all items in the sequence, each item wrapped in a containing element that identifies its type
        Parameters:
        iterator - The values to be wrapped
        config - The Saxon configuration used to evaluate the query
        Returns:
        the document containing the wrapped results
        Throws:
        XPathException - if any failure occurs
        Since:
        8.8
      • sendWrappedSequence

        public static void sendWrappedSequence​(SequenceIterator iterator,
                                               Receiver destination)
                                        throws XPathException
        Take a sequence supplied in the form of an iterator and generate a wrapped represention of the items in the sequence, the wrapped representation being a sequence of events sent to a supplied Receiver, in which each item is wrapped in a containing element that identifies its type
        Parameters:
        iterator - the input sequence
        destination - the Receiver to accept the wrapped output
        Throws:
        XPathException - if a failure occurs processing the input iterator
        Since:
        8.8
      • serialize

        public static void serialize​(NodeInfo node,
                                     javax.xml.transform.Result destination,
                                     java.util.Properties outputProperties)
                              throws XPathException
        Serialize a document containing wrapped query results (or any other document, in fact) as XML.
        Parameters:
        node - The document or element to be serialized
        destination - The Result object to contain the serialized form
        outputProperties - Serialization options as defined in JAXP. The requested properties are not validated.
        Throws:
        XPathException - If serialization fails
        Since:
        8.9
      • serialize

        public static void serialize​(NodeInfo node,
                                     javax.xml.transform.Result destination,
                                     SerializationProperties properties)
                              throws XPathException
        Serialize a document or element node.
        Parameters:
        node - The document or element to be serialized
        destination - The Result object to contain the serialized form
        properties - Serialization options as defined in JAXP. The requested properties are not validated.
        Throws:
        XPathException - If serialization fails
        Since:
        9.9.1.3
      • serializeSequence

        public static void serializeSequence​(SequenceIterator iterator,
                                             Configuration config,
                                             java.io.OutputStream destination,
                                             java.util.Properties outputProps)
                                      throws XPathException
        Serialize an arbitrary sequence, without any special wrapping.
        Parameters:
        iterator - the sequence to be serialized
        config - the configuration (gives access to information such as the NamePool)
        destination - the output stream to which the output is to be written
        outputProps - a set of serialization properties as defined in JAXP. The requested properties are not validated.
        Throws:
        XPathException - if any failure occurs
        Since:
        8.9
      • serializeSequence

        public static void serializeSequence​(SequenceIterator iterator,
                                             Configuration config,
                                             java.io.Writer writer,
                                             java.util.Properties outputProps)
                                      throws XPathException
        Serialize an arbitrary sequence, without any special wrapping.
        Parameters:
        iterator - the sequence to be serialized
        config - the configuration (gives access to information such as the NamePool)
        writer - the writer to which the output is to be written
        outputProps - a set of serialization properties as defined in JAXP. The requested properties are not validated.
        Throws:
        XPathException - if any failure occurs
        Since:
        8.9
      • serializeSequence

        public static void serializeSequence​(SequenceIterator iterator,
                                             Configuration config,
                                             javax.xml.transform.Result result,
                                             java.util.Properties outputProperties)
                                      throws XPathException
        Serialize a sequence to a given result
        Parameters:
        iterator - the sequence to be serialized
        config - the Saxon Configuration
        result - the destination to receive the output
        outputProperties - the serialization properties to be used. The requested properties are not validated.
        Throws:
        XPathException - if any failure occurs
        Since:
        9.0
      • serializeSequence

        public static void serializeSequence​(SequenceIterator iterator,
                                             Configuration config,
                                             javax.xml.transform.Result result,
                                             SerializationProperties properties)
                                      throws XPathException
        Serialize a sequence to a given result. This version of the method allows character maps to be supplied
        Parameters:
        iterator - the sequence to be serialized
        config - the Saxon Configuration
        result - the destination to receive the output
        properties - the serialization properties to be used. The requested properties are not validated.
        Throws:
        XPathException - if any failure occurs
        Since:
        9.9.1.3
      • rewriteToDisk

        public static void rewriteToDisk​(NodeInfo doc,
                                         java.util.Properties outputProperties,
                                         boolean backup,
                                         java.io.PrintStream log)
                                  throws XPathException
        Write an updated document back to disk, using the original URI from which it was read
        Parameters:
        doc - an updated document. Must be a document node, or a parentless element, or an element that has a document node as its parent. The document will be written to the URI found in the systemId property of this node.
        outputProperties - serialization properties
        backup - true if the old document at that location is to be copied to a backup file
        log - destination for progress messages; if null, no progress messages are written
        Throws:
        XPathException - if the document has no known URI, if the URI is not a writable location, or if a serialization error occurs.