Package net.sf.saxon.trace

## Class ExpressionPresenter

- java.lang.Object
- - net.sf.saxon.trace.ExpressionPresenter

-     public class ExpressionPresenter
      extends java.lang.Object

  This class handles the display of an abstract expression tree in an XML format with some slight resemblance to XQueryX

- - ### Nested Class Summary

    Nested Classes
    Modifier and Type | Class | Description
    --- | --- | ---
    `static class` | `ExpressionPresenter.ExportOptions` |
    `static interface` | `ExpressionPresenter.Options` |

  - ### Constructor Summary

    Constructors
    Constructor | Description
    --- | ---
    `ExpressionPresenter()` | Make an uncommitted ExpressionPresenter.
    `ExpressionPresenter​(Configuration config)` | Make an ExpressionPresenter that writes indented output to the standard error output destination of the Configuration
    `ExpressionPresenter​(Configuration config, javax.xml.transform.stream.StreamResult out)` | Make an ExpressionPresenter that writes indented output to a specified output stream
    `ExpressionPresenter​(Configuration config, javax.xml.transform.stream.StreamResult out, boolean checksum)` | Make an ExpressionPresenter that writes indented output to a specified output stream, with checksumming
    `ExpressionPresenter​(Configuration config, Receiver receiver)` | Make an ExpressionPresenter for a given Configuration using a user-supplied Receiver to accept the output
    `ExpressionPresenter​(Configuration config, Logger out)` | Make an ExpressionPresenter that writes indented output to a specified output stream

  - ### Method Summary

    All Methods Static Methods Instance Methods Concrete Methods
    Modifier and Type | Method | Description
    --- | --- | ---
    `void` | `close()` | Close the output
    `static Receiver` | `defaultDestination​(Configuration config, Logger out)` | Make a receiver, using default output properties, with serialized output going to a specified OutputStream
    `void` | `emitAttribute​(java.lang.String name, java.lang.String value)` | Output an attribute node
    `void` | `emitAttribute​(java.lang.String name, StructuredQName value)` | Output a QName-valued attribute node
    `void` | `emitRetainedStaticContext​(RetainedStaticContext sc, RetainedStaticContext parentSC)` |
    `int` | `endElement()` | End an element in the expression tree
    `void` | `endSubsidiaryElement()` | End a child element in the output
    `Configuration` | `getConfiguration()` | Get the Saxon configuration
    `NamePool` | `getNamePool()` | Get the name pool
    `ExpressionPresenter.Options` | `getOptions()` | Get the options
    `TypeHierarchy` | `getTypeHierarchy()` | Get the type hierarchy cache
    `void` | `init​(Configuration config, javax.xml.transform.stream.StreamResult out, boolean checksum)` | Make an ExpressionPresenter that writes indented output to a specified output stream, with checksumming
    `void` | `init​(Configuration config, Receiver out, boolean checksum)` | Make an ExpressionPresenter that writes indented output to a specified output stream, with checksumming
    `boolean` | `isRelocatable()` | Ask whether the package can be deployed to a different location, with a different base URI
    `static java.lang.String` | `jsEscape​(java.lang.String in)` | Static method to escape a string using Javascript escaping conventions
    `static SerializationProperties` | `makeDefaultProperties​(Configuration config)` | Make a Properties object containing defaulted serialization attributes for the expression tree
    `void` | `namespace​(java.lang.String prefix, java.lang.String uri)` | Output a namespace declaration.
    `void` | `setChildRole​(java.lang.String role)` | Set the role of the next element to be output
    `void` | `setDefaultNamespace​(java.lang.String namespace)` | Set the default namespace, used for subsequent calls on startElement.
    `void` | `setOptions​(ExpressionPresenter.Options options)` | Set the options
    `void` | `setRelocatable​(boolean relocatable)` | Say whether the package can be deployed to a different location, with a different base URI
    `int` | `startElement​(java.lang.String name)` | Start an element
    `int` | `startElement​(java.lang.String name, Expression expr)` | Start an element representing an expression in the expression tree
    `void` | `startSubsidiaryElement​(java.lang.String name)` | Start a child element in the output

    - ### Methods inherited from class java.lang.Object

      `clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait`

- - ### Constructor Detail

    - #### ExpressionPresenter

          public ExpressionPresenter()

      Make an uncommitted ExpressionPresenter. This must be followed by a call on init()

    - #### ExpressionPresenter

          public ExpressionPresenter​(Configuration config)

      Make an ExpressionPresenter that writes indented output to the standard error output destination of the Configuration
      Parameters:
        `config` - the Saxon configuration

    - #### ExpressionPresenter

          public ExpressionPresenter​(Configuration config,
                                     javax.xml.transform.stream.StreamResult out)

      Make an ExpressionPresenter that writes indented output to a specified output stream
      Parameters:
        `config` - the Saxon configuration
        `out` - the output destination

    - #### ExpressionPresenter

          public ExpressionPresenter​(Configuration config,
                                     javax.xml.transform.stream.StreamResult out,
                                     boolean checksum)

      Make an ExpressionPresenter that writes indented output to a specified output stream, with checksumming
      Parameters:
        `config` - the Saxon configuration
        `out` - the output destination
        `checksum` - true if a checksum is to be written at the end of the file

    - #### ExpressionPresenter

          public ExpressionPresenter​(Configuration config,
                                     Logger out)

      Make an ExpressionPresenter that writes indented output to a specified output stream
      Parameters:
        `config` - the Saxon configuration
        `out` - the output stream

    - #### ExpressionPresenter

          public ExpressionPresenter​(Configuration config,
                                     Receiver receiver)

      Make an ExpressionPresenter for a given Configuration using a user-supplied Receiver to accept the output
      Parameters:
        `config` - the Configuration
        `receiver` - the user-supplied Receiver

  - ### Method Detail

    - #### init

          public void init​(Configuration config,
                           javax.xml.transform.stream.StreamResult out,
                           boolean checksum)

      Make an ExpressionPresenter that writes indented output to a specified output stream, with checksumming
      Parameters:
        `config` - the Saxon configuration
        `out` - the output destination
        `checksum` - true if a checksum is to be written at the end of the file

    - #### init

          public void init​(Configuration config,
                           Receiver out,
                           boolean checksum)

      Make an ExpressionPresenter that writes indented output to a specified output stream, with checksumming
      Parameters:
        `config` - the Saxon configuration
        `out` - the output destination
        `checksum` - true if a checksum is to be written at the end of the file

    - #### setDefaultNamespace

          public void setDefaultNamespace​(java.lang.String namespace)

      Set the default namespace, used for subsequent calls on startElement. Must be consistent throughout the whole document
      Parameters:
        `namespace` - the default namespace

    - #### setOptions

          public void setOptions​(ExpressionPresenter.Options options)

      Set the options

    - #### getOptions

          public ExpressionPresenter.Options getOptions()

      Get the options
      Returns:
        the options, or null if none have been set

    - #### isRelocatable

          public boolean isRelocatable()

      Ask whether the package can be deployed to a different location, with a different base URI
      Returns:
        if true then static-base-uri() represents the deployed location of the package, rather than its compile time location

    - #### setRelocatable

          public void setRelocatable​(boolean relocatable)

      Say whether the package can be deployed to a different location, with a different base URI
      Parameters:
        `relocatable` - if true then static-base-uri() represents the deployed location of the package, rather than its compile time location

    - #### defaultDestination

          public static Receiver defaultDestination​(Configuration config,
                                                    Logger out)
                                             throws XPathException

      Make a receiver, using default output properties, with serialized output going to a specified OutputStream
      Parameters:
        `config` - the Configuration
        `out` - the OutputStream
      Returns:
        a Receiver that directs serialized output to this output stream
      Throws:
        `XPathException`

    - #### makeDefaultProperties

          public static SerializationProperties makeDefaultProperties​(Configuration config)

      Make a Properties object containing defaulted serialization attributes for the expression tree
      Returns:
        a default set of properties

    - #### startElement

          public int startElement​(java.lang.String name,
                                  Expression expr)

      Start an element representing an expression in the expression tree
      Parameters:
        `name` - the name of the element
        `expr` - the expression represented
      Returns:
        the depth of the tree before this element: for diagnostics, this can be compared with the value returned by endElement

    - #### emitRetainedStaticContext

          public void emitRetainedStaticContext​(RetainedStaticContext sc,
                                                RetainedStaticContext parentSC)

    - #### startElement

          public int startElement​(java.lang.String name)

      Start an element
      Parameters:
        `name` - the name of the element
      Returns:
        the depth of the tree before this element: for diagnostics, this can be compared with the value returned by endElement

    - #### setChildRole

          public void setChildRole​(java.lang.String role)

      Set the role of the next element to be output
      Parameters:
        `role` - the value of the role output to be used

    - #### emitAttribute

          public void emitAttribute​(java.lang.String name,
                                    java.lang.String value)

      Output an attribute node
      Parameters:
        `name` - the name of the attribute
        `value` - the value of the attribute

    - #### emitAttribute

          public void emitAttribute​(java.lang.String name,
                                    StructuredQName value)

      Output a QName-valued attribute node
      Parameters:
        `name` - the name of the attribute
        `value` - the value of the attribute

    - #### namespace

          public void namespace​(java.lang.String prefix,
                                java.lang.String uri)

      Output a namespace declaration. All namespaces should be declared at the top level.
      Parameters:
        `prefix` - the namespace prefix
        `uri` - the namespace URI

    - #### endElement

          public int endElement()

      End an element in the expression tree
      Returns:
        the depth of the tree after ending this element. For diagnostics, this can be compared with the value returned by startElement()

    - #### startSubsidiaryElement

          public void startSubsidiaryElement​(java.lang.String name)

      Start a child element in the output
      Parameters:
        `name` - the name of the child element

    - #### endSubsidiaryElement

          public void endSubsidiaryElement()

      End a child element in the output

    - #### close

          public void close()

      Close the output

    - #### getConfiguration

          public Configuration getConfiguration()

      Get the Saxon configuration
      Returns:
        the Saxon configuration

    - #### getNamePool

          public NamePool getNamePool()

      Get the name pool
      Returns:
        the name pool

    - #### getTypeHierarchy

          public TypeHierarchy getTypeHierarchy()

      Get the type hierarchy cache
      Returns:
        the type hierarchy cache

    - #### jsEscape

          public static java.lang.String jsEscape​(java.lang.String in)

      Static method to escape a string using Javascript escaping conventions
      Parameters:
        `in` - the string to be escaped