com.icl.saxon.expr
Class FragmentValue

java.lang.Object
  |
  +--com.icl.saxon.expr.Expression
        |
        +--com.icl.saxon.expr.Value
              |
              +--com.icl.saxon.expr.NodeSetValue
                    |
                    +--com.icl.saxon.expr.SingletonNodeSet
                          |
                          +--com.icl.saxon.expr.FragmentValue
All Implemented Interfaces:
Emitter

public class FragmentValue
extends SingletonNodeSet
implements Emitter

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.


Fields inherited from class com.icl.saxon.expr.SingletonNodeSet
node
 
Fields inherited from class com.icl.saxon.expr.Value
ANY, BOOLEAN, NODESET, NUMBER, OBJECT, STRING
 
Fields inherited from class com.icl.saxon.expr.Expression
staticContext
 
Constructor Summary
FragmentValue()
           
FragmentValue(java.lang.String value)
          Constructor: create a result tree fragment containing a single text node
 
Method Summary
 void allowConversion(boolean yesOrNo)
          Indicate whether implicit conversion to a node-set is permitted
 boolean asBoolean()
          Convert the result tree fragment to a boolean
 double asNumber()
          Convert the result tree fragment to a number
 java.lang.String asString()
          Convert the result tree fragment to a string.
 void characters(char[] chars, int start, int len)
          Output character data
 void comment(char[] chars, int start, int length)
          Output a comment.
 boolean compare(int operator, Value other)
          Test how a FragmentValue compares to another Value under a relational comparison.
 boolean contains(NodeInfo node)
          Determine whether a particular node is present in the nodeset.
 void copy(Outputter out)
          Copy the result tree fragment value to a given Outputter
 void endDocument()
          Notify document end
 void endElement(int name)
          Output an element end tag
 NodeEnumeration enumerate()
          Return an enumeration of this nodeset value.
 boolean equals(Value other)
          Test whether a nodeset "equals" another Value
 int getCount()
          Count the nodes in the node-set.
 int getDataType()
          Determine the data type of the expression, if possible
 Emitter getEmitter()
          Get an Emitter that can be used to feed data to this result tree fragment
 NodeInfo getFirst()
          Get the first node in the nodeset (in document order)
 NodeInfo[] getNodes()
          Return the nodes in the node-set as an array.
 DocumentInfo getRootNode()
          Get the root (document) node
 int getType()
          Return the type of the value
 boolean isEmpty()
          Determine whether the node-set is empty.
 boolean isSingular()
          Determine whether the node-set is singular, that is, whether it has a single member.
 boolean notEquals(Value other)
          Test whether a nodeset "not-equals" another Value
 void outputStringValue(Outputter out, Context context)
          Evaluate an expression as a String and write the result to the specified outputter.
 void processingInstruction(java.lang.String name, java.lang.String data)
          Output a processing instruction
 void replay(Emitter emitter)
          Replay the saved emitter events to a new emitter
 void setBaseURI(java.lang.String uri)
          Set the Base URI for the nodes in the result tree fragment.
 void setCharacterSet(CharacterSet charset)
          Set the CharacterSet to be used.
 void setDocumentLocator(org.xml.sax.Locator locator)
          Set Document Locator
 void setEscaping(boolean escaping)
          Switch escaping on or off.
 void setNamePool(NamePool pool)
          Provide a namepool
 void setOutputDetails(OutputDetails details)
          Set output details.
 void setUnparsedEntity(java.lang.String name, java.lang.String uri)
          Set Unparsed entity
 void setWriter(java.io.Writer writer)
          Set the Writer to be used.
 Expression simplify()
          Simplify the expression
 void startDocument()
          Notify document start
 void startElement(int name, org.xml.sax.Attributes attributes, int[] namespaces, int nscount)
          Output an element start tag.
 java.lang.String toString()
          Get a string representation of the expression
 
Methods inherited from class com.icl.saxon.expr.SingletonNodeSet
evaluate, evaluateAsNodeSet, isSorted, setSorted, sort
 
Methods inherited from class com.icl.saxon.expr.NodeSetValue
enumerate
 
Methods inherited from class com.icl.saxon.expr.Value
getDependencies, inverse, numericCompare, reduce, stringToNumber
 
Methods inherited from class com.icl.saxon.expr.Expression
containsReferences, evaluateAsBoolean, evaluateAsNumber, evaluateAsString, getStaticContext, make, setStaticContext, usesCurrent
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait
 

Constructor Detail

FragmentValue

public FragmentValue()
              throws org.xml.sax.SAXException

FragmentValue

public FragmentValue(java.lang.String value)
              throws org.xml.sax.SAXException
Constructor: create a result tree fragment containing a single text node
Parameters:
value: - a String containing the value
Method Detail

setBaseURI

public void setBaseURI(java.lang.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.

setNamePool

public void setNamePool(NamePool pool)
Provide a namepool
Specified by:
setNamePool in interface Emitter

allowConversion

public void allowConversion(boolean yesOrNo)
Indicate whether implicit conversion to a node-set is permitted

getEmitter

public Emitter getEmitter()
                   throws org.xml.sax.SAXException
Get an Emitter that can be used to feed data to this result tree fragment

asString

public java.lang.String asString()
                          throws org.xml.sax.SAXException
Convert the result tree fragment to a string.
Overrides:
asString in class SingletonNodeSet
Following copied from class: com.icl.saxon.expr.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 org.xml.sax.SAXException
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

asNumber

public double asNumber()
                throws org.xml.sax.SAXException
Convert the result tree fragment to a number
Overrides:
asNumber in class NodeSetValue
Following copied from class: com.icl.saxon.expr.NodeSetValue
Returns:
the number obtained by evaluating as a String and converting the string to a number

asBoolean

public boolean asBoolean()
                  throws org.xml.sax.SAXException
Convert the result tree fragment to a boolean
Overrides:
asBoolean in class SingletonNodeSet
Following copied from class: com.icl.saxon.expr.SingletonNodeSet
Returns:
true if the node set is not empty

getCount

public int getCount()
             throws org.xml.sax.SAXException
Count the nodes in the node-set.
Overrides:
getCount in class SingletonNodeSet

isEmpty

public boolean isEmpty()
                throws org.xml.sax.SAXException
Determine whether the node-set is empty. This is more efficient than testing getCount()==0, because it doesn't risk triggering a sort.
Overrides:
isEmpty in class SingletonNodeSet

isSingular

public boolean isSingular()
                   throws org.xml.sax.SAXException
Determine whether the node-set is singular, that is, whether it has a single member. This is more efficient that testing getCount()==1, because it doesn't risk triggering a sort.
Overrides:
isSingular in class SingletonNodeSet

contains

public boolean contains(NodeInfo node)
                 throws org.xml.sax.SAXException
Determine whether a particular node is present in the nodeset.
Overrides:
contains in class SingletonNodeSet

simplify

public Expression simplify()
                    throws org.xml.sax.SAXException
Simplify the expression
Overrides:
simplify in class SingletonNodeSet
Following copied from class: com.icl.saxon.expr.Value
Returns:
the simplified expression

getNodes

public NodeInfo[] getNodes()
                    throws org.xml.sax.SAXException
Return the nodes in the node-set as an array.
Overrides:
getNodes in class SingletonNodeSet
Returns:
an array containing the NodeInfo object representing the root

getFirst

public NodeInfo getFirst()
                  throws org.xml.sax.SAXException
Get the first node in the nodeset (in document order)
Overrides:
getFirst in class SingletonNodeSet
Returns:
the first node

enumerate

public NodeEnumeration enumerate()
                          throws org.xml.sax.SAXException
Return an enumeration of this nodeset value.
Overrides:
enumerate in class SingletonNodeSet

equals

public boolean equals(Value other)
               throws org.xml.sax.SAXException
Test whether a nodeset "equals" another Value
Overrides:
equals in class SingletonNodeSet
Following copied from class: com.icl.saxon.expr.Value
Returns:
a boolean giving the value of the expression, evaluated in the current context

notEquals

public boolean notEquals(Value other)
                  throws org.xml.sax.SAXException
Test whether a nodeset "not-equals" another Value
Overrides:
notEquals in class SingletonNodeSet
Following copied from class: com.icl.saxon.expr.Value
Returns:
a boolean giving the value of the expression, evaluated in the current context

compare

public boolean compare(int operator,
                       Value other)
                throws org.xml.sax.SAXException
Test how a FragmentValue compares to another Value under a relational comparison.
Overrides:
compare in class NodeSetValue
Following copied from class: com.icl.saxon.expr.NodeSetValue
Parameters:
operator - The comparison operator, one of Tokenizer.LE, Tokenizer.LT, Tokenizer.GE, Tokenizer.GT,

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

toString

public java.lang.String toString()
Get a string representation of the expression
Overrides:
toString in class java.lang.Object

startDocument

public void startDocument()
                   throws org.xml.sax.SAXException
Notify document start
Specified by:
startDocument in interface Emitter

endDocument

public void endDocument()
                 throws org.xml.sax.SAXException
Notify document end
Specified by:
endDocument in interface Emitter

startElement

public void startElement(int name,
                         org.xml.sax.Attributes attributes,
                         int[] namespaces,
                         int nscount)
                  throws org.xml.sax.SAXException
Output an element start tag.
Specified by:
startElement in interface Emitter
Following copied from interface: com.icl.saxon.output.Emitter
Parameters:
namespaces - Array of namespace codes identifying the namespace prefix/uri pairs associated with this element
nscount - Number of significant entries within namespaces array

endElement

public void endElement(int name)
                throws org.xml.sax.SAXException
Output an element end tag
Specified by:
endElement in interface Emitter

characters

public void characters(char[] chars,
                       int start,
                       int len)
                throws org.xml.sax.SAXException
Output character data
Specified by:
characters in interface Emitter

processingInstruction

public void processingInstruction(java.lang.String name,
                                  java.lang.String data)
                           throws org.xml.sax.SAXException
Output a processing instruction
Specified by:
processingInstruction in interface Emitter

comment

public void comment(char[] chars,
                    int start,
                    int length)
             throws org.xml.sax.SAXException
Output a comment.
(The method signature is borrowed from the SAX2 LexicalHandler interface)
Specified by:
comment in interface Emitter

setWriter

public void setWriter(java.io.Writer writer)
               throws org.xml.sax.SAXException
Set the Writer to be used. This has no effect when writing to a result tree fragment.
Specified by:
setWriter in interface Emitter

setCharacterSet

public void setCharacterSet(CharacterSet charset)
                     throws org.xml.sax.SAXException
Set the CharacterSet to be used. This has no effect when writing to a result tree fragment.
Specified by:
setCharacterSet in interface Emitter

setEscaping

public void setEscaping(boolean escaping)
                 throws org.xml.sax.SAXException
Switch escaping on or off. This is called when the XSLT disable-output-escaping attribute is used to switch escaping on or off.
Specified by:
setEscaping in interface Emitter

setOutputDetails

public void setOutputDetails(OutputDetails details)
                      throws org.xml.sax.SAXException
Set output details. This has no effect when writing to a result tree fragment.
Specified by:
setOutputDetails in interface Emitter
Parameters:
details - The details of the required output

setDocumentLocator

public void setDocumentLocator(org.xml.sax.Locator locator)
Set Document Locator
Specified by:
setDocumentLocator in interface Emitter

setUnparsedEntity

public void setUnparsedEntity(java.lang.String name,
                              java.lang.String uri)
Set Unparsed entity
Specified by:
setUnparsedEntity in interface Emitter

getRootNode

public DocumentInfo getRootNode()
                         throws org.xml.sax.SAXException
Get the root (document) node

copy

public void copy(Outputter out)
          throws org.xml.sax.SAXException
Copy the result tree fragment value to a given Outputter

replay

public void replay(Emitter emitter)
            throws org.xml.sax.SAXException
Replay the saved emitter events to a new emitter