Class FragmentValue

All Implemented Interfaces:
NodeList

public final class FragmentValue extends SingletonNodeSet
This class represents a Value of type result tree fragment.
A Result Tree Fragment can be created by defining a variable in XSL whose value is defined by the contents of the xsl:variable element, possibly including start and end element tags.
  • Constructor Details

    • FragmentValue

      public FragmentValue(Controller c)
  • Method Details

    • setBaseURI

      public void setBaseURI(String uri)
      Set the Base URI for the nodes in the result tree fragment. This is defined to be the Base URI of the relevant xsl:variable element in the stylesheet.
    • getEmitter

      public Emitter getEmitter()
      Get an Emitter that can be used to feed data to this result tree fragment
    • asString

      public String asString()
      Convert the result tree fragment to a string.
      Overrides:
      asString in class SingletonNodeSet
      Returns:
      the value of the first node in the node-set if there is one, otherwise an empty string
    • outputStringValue

      public void outputStringValue(Outputter out, Context context) throws TransformerException
      Evaluate an expression as a String and write the result to the specified outputter.
      Overrides:
      outputStringValue in class Expression
      Parameters:
      out - The required outputter
      context - The context in which the expression is to be evaluated
      Throws:
      TransformerException
    • asNumber

      public double asNumber()
      Convert the result tree fragment to a number
      Overrides:
      asNumber in class NodeSetValue
      Returns:
      the number obtained by evaluating as a String and converting the string to a number
    • asBoolean

      public boolean asBoolean()
      Convert the result tree fragment to a boolean
      Overrides:
      asBoolean in class SingletonNodeSet
      Returns:
      true if the node set is not empty
    • getCount

      public int getCount()
      Count the nodes in the node-set.
      Overrides:
      getCount in class SingletonNodeSet
    • simplify

      public Expression simplify()
      Simplify the expression
      Overrides:
      simplify in class SingletonNodeSet
      Returns:
      the simplified expression
    • getFirst

      public NodeInfo getFirst()
      Get the first node in the nodeset (in document order)
      Overrides:
      getFirst in class SingletonNodeSet
      Returns:
      the first node
    • enumerate

      public NodeEnumeration enumerate() throws XPathException
      Return an enumeration of this nodeset value.
      Overrides:
      enumerate in class SingletonNodeSet
      Throws:
      XPathException
    • equals

      public boolean equals(Value other) throws XPathException
      Test whether a nodeset "equals" another Value
      Overrides:
      equals in class SingletonNodeSet
      Returns:
      a boolean giving the value of the expression, evaluated in the current context
      Throws:
      XPathException
    • notEquals

      public boolean notEquals(Value other) throws XPathException
      Test whether a nodeset "not-equals" another Value
      Overrides:
      notEquals in class SingletonNodeSet
      Returns:
      a boolean giving the value of the expression, evaluated in the current context
      Throws:
      XPathException
    • compare

      public boolean compare(int operator, Value other) throws XPathException
      Test how a FragmentValue compares to another Value under a relational comparison.
      Overrides:
      compare in class NodeSetValue
      Parameters:
      operator - The comparison operator, one of Tokenizer.LE, Tokenizer.LT, Tokenizer.GE, Tokenizer.GT,
      Throws:
      XPathException
    • getType

      public int getType()
      Return the type of the value
      Returns:
      Value.NODESET (always)
    • getDataType

      public int getDataType()
      Determine the data type of the expression, if possible
      Overrides:
      getDataType in class NodeSetValue
      Returns:
      Value.NODESET
    • getRootNode

      public DocumentInfo getRootNode()
      Get the root (document) node
    • copy

      public void copy(Outputter out) throws TransformerException
      Copy the result tree fragment value to a given Outputter
      Throws:
      TransformerException
    • replay

      public void replay(Emitter emitter) throws TransformerException
      Replay the saved emitter events to a new emitter
      Throws:
      TransformerException
    • display

      public void display(int level)
      Diagnostic print of expression structure
      Overrides:
      display in class NodeSetValue