net.sf.saxon.functions
Class Extensions

java.lang.Object
  extended bynet.sf.saxon.functions.Extensions

public class Extensions
extends java.lang.Object

This class implements functions that are supplied as standard with SAXON, but which are not defined in the XSLT or XPath specifications.

To invoke these functions, use a function call of the form prefix:name() where name is the method name, and prefix maps to a URI such as http://saxon.sf.net/net.sf.saxon.functions.Extensions (only the part of the URI after the last slash is important).


Method Summary
static SequenceIterator after(XPathContext context, SequenceIterator ns1, SequenceIterator ns2)
          Find all the nodes in ns1 that are after the first node in ns2.
static byte[] base64BinaryToOctets(Base64BinaryValue in)
          Convert a base64Binary value to a sequence of integers representing the octets contained in the value
static java.lang.String base64BinaryToString(XPathContext context, Base64BinaryValue in, java.lang.String encoding)
          Convert a base64Binary value to a String, assuming a particular encoding
static javax.xml.transform.Templates compileStylesheet(XPathContext context, DocumentInfo doc)
          Compile a document containing a stylesheet module into a stylesheet that can be used to perform transformations
static SecondsDurationValue dayTimeDurationFromSeconds(java.math.BigDecimal arg)
          Get a dayTimeDuration value corresponding to a given number of seconds
static java.math.BigDecimal decimalDivide(java.math.BigDecimal arg1, java.math.BigDecimal arg2, int scale)
          Perform decimal division to a user-specified precision
static boolean deepEqual(XPathContext context, SequenceIterator arg1, SequenceIterator arg2, java.lang.String collation, java.lang.String flags)
          Perform a parameterized deep-equals() test
static DocumentInfo discardDocument(XPathContext context, DocumentInfo doc)
          Remove a document from the document pool.
static Configuration getConfiguration(XPathContext c)
          Return the Configuration object
static XPathContext getContext(XPathContext c)
          Return the XPathContext object
static Controller getController(XPathContext c)
          Return the Controller object
static java.lang.String getPseudoAttribute(XPathContext c, java.lang.String name)
          Get a pseudo-attribute of a processing instruction.
static boolean hasSameNodes(SequenceIterator p1, SequenceIterator p2)
          Determine whether two node-sets contain the same nodes
static byte[] hexBinaryToOctets(HexBinaryValue in)
          Convert a hexBinary value to a sequence of integers representing the octets contained in the value
static java.lang.String hexBinaryToString(XPathContext context, HexBinaryValue in, java.lang.String encoding)
          Convert a hexBinary value to a String, assuming a particular encoding
static Value highest(SequenceIterator nsv)
          Get the node with maximum numeric value of the string-value of each of a set of nodes
static SequenceIterator highest(XPathContext context, SequenceIterator nsv, Evaluate.PreparedExpression pexpression)
          Get the maximum numeric value of a stored expression over a set of nodes
static SequenceIterator leading(XPathContext context, SequenceIterator in, Evaluate.PreparedExpression pexp)
          Get the items that satisfy the given expression, up to and excluding the first one (in sequence order) that doesn't
static int lineNumber(NodeInfo node)
          Return the line number of the specified node.
static int lineNumber(XPathContext c)
          Return the line number of the context node.
static Value lowest(SequenceIterator nsv)
          Get the node with minimum numeric value of the string-value of each of a set of nodes
static SequenceIterator lowest(XPathContext context, SequenceIterator nsv, Evaluate.PreparedExpression pexpression)
          Get the node with minimum numeric value of a stored expression over a set of nodes
static double max(XPathContext context, SequenceIterator nsv, Evaluate.PreparedExpression pexpression)
          Get the maximum numeric value of a stored expression over a set of nodes
static double min(XPathContext context, SequenceIterator nsv, Evaluate.PreparedExpression pexpression)
          Get the minimum numeric value of a stored expression over a set of nodes
static NodeInfo namespaceNode(XPathContext context, java.lang.String prefix, java.lang.String uri)
          Create a parentless namespace node.
static Base64BinaryValue octetsToBase64Binary(byte[] in)
          Convert a sequence of integers in the range 0-255, representing a sequence of octets, to a base64Binary value
static HexBinaryValue octetsToHexBinary(byte[] in)
          Convert a sequence of integers in the range 0-255, representing a sequence of octets, to a hexBinary value
static java.lang.String path(XPathContext c)
          Return an XPath expression that identifies the current node
static void pauseTracing(XPathContext c)
          Switch tracing off.
static void resumeTracing(XPathContext c)
          Resume tracing.
static Base64BinaryValue stringToBase64Binary(java.lang.String in, java.lang.String encoding)
          Convert a string to a base64Binary value in a given encoding
static HexBinaryValue stringToHexBinary(java.lang.String in, java.lang.String encoding)
          Convert a string to a hexBinary value in a given encoding
static java.util.List stringToUtf8(java.lang.String in)
          Get the UTF-8 encoding of a string
static double sum(XPathContext context, SequenceIterator nsv, Evaluate.PreparedExpression pexpression)
          Total a stored expression over a set of nodes
static java.lang.String systemId(XPathContext c)
          Return the system identifier of the context node
static SequenceIterator tokenize(java.lang.String s)
          Return a node-set by tokenizing a supplied string.
static SequenceIterator tokenize(java.lang.String s, java.lang.String delim)
          Return a sequence by tokenizing a supplied string.
static DocumentInfo transform(XPathContext context, javax.xml.transform.Templates templates, NodeInfo source)
          Run a transformation to convert an input tree to an output document
static java.lang.String typeAnnotation(XPathContext context, NodeInfo node)
          Display the value of the type annotation of a node
static boolean validCharacter(XPathContext c, int in)
          Test whether a given integer is the codepoint of a valid XML character
static MonthDurationValue yearMonthDurationFromMonths(int arg)
          Get a yearMonthDuration value corresponding to a given number of months
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Method Detail

pauseTracing

public static void pauseTracing(XPathContext c)
Switch tracing off. Only works if tracing is enabled.


resumeTracing

public static void resumeTracing(XPathContext c)
Resume tracing. Only works if tracing was originally enabled but is currently paused.


systemId

public static java.lang.String systemId(XPathContext c)
                                 throws XPathException
Return the system identifier of the context node

Throws:
XPathException

lineNumber

public static int lineNumber(XPathContext c)
Return the line number of the context node.


lineNumber

public static int lineNumber(NodeInfo node)
Return the line number of the specified node.


discardDocument

public static DocumentInfo discardDocument(XPathContext context,
                                           DocumentInfo doc)
Remove a document from the document pool. The effect is that the document becomes eligible for garbage collection, allowing memory to be released when processing of the document has finished. The downside is that a subsequent call on document() with the same URI causes the document to be reloaded and reparsed, and the new nodes will have different node identity from the old.

Parameters:
context - the evaluation context (supplied implicitly by the call mechanism)
doc - the document to be released from the document pool
Returns:
the document that was released. This allows a call such as select="saxon:discard-document(document('a.xml'))"

hasSameNodes

public static boolean hasSameNodes(SequenceIterator p1,
                                   SequenceIterator p2)
                            throws XPathException
Determine whether two node-sets contain the same nodes

Parameters:
p1 - The first node-set. The iterator must be correctly ordered.
p2 - The second node-set. The iterator must be correctly ordered.
Returns:
true if p1 and p2 contain the same set of nodes
Throws:
XPathException

sum

public static double sum(XPathContext context,
                         SequenceIterator nsv,
                         Evaluate.PreparedExpression pexpression)
                  throws XPathException
Total a stored expression over a set of nodes

Throws:
XPathException

max

public static double max(XPathContext context,
                         SequenceIterator nsv,
                         Evaluate.PreparedExpression pexpression)
                  throws XPathException
Get the maximum numeric value of a stored expression over a set of nodes

Throws:
XPathException

min

public static double min(XPathContext context,
                         SequenceIterator nsv,
                         Evaluate.PreparedExpression pexpression)
                  throws XPathException
Get the minimum numeric value of a stored expression over a set of nodes

Throws:
XPathException

highest

public static Value highest(SequenceIterator nsv)
                     throws XPathException
Get the node with maximum numeric value of the string-value of each of a set of nodes

Throws:
XPathException

highest

public static SequenceIterator highest(XPathContext context,
                                       SequenceIterator nsv,
                                       Evaluate.PreparedExpression pexpression)
                                throws XPathException
Get the maximum numeric value of a stored expression over a set of nodes

Throws:
XPathException

lowest

public static Value lowest(SequenceIterator nsv)
                    throws XPathException
Get the node with minimum numeric value of the string-value of each of a set of nodes

Throws:
XPathException

lowest

public static SequenceIterator lowest(XPathContext context,
                                      SequenceIterator nsv,
                                      Evaluate.PreparedExpression pexpression)
                               throws XPathException
Get the node with minimum numeric value of a stored expression over a set of nodes

Throws:
XPathException

leading

public static SequenceIterator leading(XPathContext context,
                                       SequenceIterator in,
                                       Evaluate.PreparedExpression pexp)
Get the items that satisfy the given expression, up to and excluding the first one (in sequence order) that doesn't


after

public static SequenceIterator after(XPathContext context,
                                     SequenceIterator ns1,
                                     SequenceIterator ns2)
                              throws XPathException
Find all the nodes in ns1 that are after the first node in ns2. Return ns1 if ns2 is empty,

Throws:
XPathException

tokenize

public static SequenceIterator tokenize(java.lang.String s)
Return a node-set by tokenizing a supplied string. Tokens are delimited by any sequence of whitespace characters.


tokenize

public static SequenceIterator tokenize(java.lang.String s,
                                        java.lang.String delim)
Return a sequence by tokenizing a supplied string. The argument delim is a String, any character in this string is considered to be a delimiter character, and any sequence of delimiter characters acts as a separator between tokens.


path

public static java.lang.String path(XPathContext c)
                             throws XPathException
Return an XPath expression that identifies the current node

Throws:
XPathException

typeAnnotation

public static java.lang.String typeAnnotation(XPathContext context,
                                              NodeInfo node)
Display the value of the type annotation of a node


getContext

public static XPathContext getContext(XPathContext c)
Return the XPathContext object


getController

public static Controller getController(XPathContext c)
Return the Controller object


getConfiguration

public static Configuration getConfiguration(XPathContext c)
Return the Configuration object


getPseudoAttribute

public static java.lang.String getPseudoAttribute(XPathContext c,
                                                  java.lang.String name)
                                           throws XPathException
Get a pseudo-attribute of a processing instruction. Return an empty string if the pseudo-attribute is not present. Character references and built-in entity references are expanded

Throws:
XPathException

dayTimeDurationFromSeconds

public static SecondsDurationValue dayTimeDurationFromSeconds(java.math.BigDecimal arg)
                                                       throws XPathException
Get a dayTimeDuration value corresponding to a given number of seconds

Throws:
XPathException

yearMonthDurationFromMonths

public static MonthDurationValue yearMonthDurationFromMonths(int arg)
Get a yearMonthDuration value corresponding to a given number of months


decimalDivide

public static java.math.BigDecimal decimalDivide(java.math.BigDecimal arg1,
                                                 java.math.BigDecimal arg2,
                                                 int scale)
Perform decimal division to a user-specified precision


stringToUtf8

public static java.util.List stringToUtf8(java.lang.String in)
Get the UTF-8 encoding of a string

Parameters:
in - the supplied string
Returns:
a sequence of integers, each in the range 0-255, representing the octets of the UTF-8 encoding of the given string

octetsToBase64Binary

public static Base64BinaryValue octetsToBase64Binary(byte[] in)
Convert a sequence of integers in the range 0-255, representing a sequence of octets, to a base64Binary value


octetsToHexBinary

public static HexBinaryValue octetsToHexBinary(byte[] in)
Convert a sequence of integers in the range 0-255, representing a sequence of octets, to a hexBinary value


base64BinaryToOctets

public static byte[] base64BinaryToOctets(Base64BinaryValue in)
Convert a base64Binary value to a sequence of integers representing the octets contained in the value


hexBinaryToOctets

public static byte[] hexBinaryToOctets(HexBinaryValue in)
Convert a hexBinary value to a sequence of integers representing the octets contained in the value


base64BinaryToString

public static java.lang.String base64BinaryToString(XPathContext context,
                                                    Base64BinaryValue in,
                                                    java.lang.String encoding)
                                             throws java.lang.Exception
Convert a base64Binary value to a String, assuming a particular encoding

Throws:
java.lang.Exception

stringToBase64Binary

public static Base64BinaryValue stringToBase64Binary(java.lang.String in,
                                                     java.lang.String encoding)
                                              throws java.io.UnsupportedEncodingException,
                                                     java.io.IOException
Convert a string to a base64Binary value in a given encoding

Throws:
java.io.UnsupportedEncodingException
java.io.IOException

hexBinaryToString

public static java.lang.String hexBinaryToString(XPathContext context,
                                                 HexBinaryValue in,
                                                 java.lang.String encoding)
                                          throws java.lang.Exception
Convert a hexBinary value to a String, assuming a particular encoding

Throws:
java.lang.Exception

stringToHexBinary

public static HexBinaryValue stringToHexBinary(java.lang.String in,
                                               java.lang.String encoding)
                                        throws java.lang.Exception
Convert a string to a hexBinary value in a given encoding

Throws:
java.lang.Exception

validCharacter

public static boolean validCharacter(XPathContext c,
                                     int in)
Test whether a given integer is the codepoint of a valid XML character


namespaceNode

public static NodeInfo namespaceNode(XPathContext context,
                                     java.lang.String prefix,
                                     java.lang.String uri)
                              throws XPathException
Create a parentless namespace node. This function is useful in XQuery when namespaces need to be created dynamically. The effect is the same as that of the xsl:namespace instruction in XSLT.

Throws:
XPathException

deepEqual

public static boolean deepEqual(XPathContext context,
                                SequenceIterator arg1,
                                SequenceIterator arg2,
                                java.lang.String collation,
                                java.lang.String flags)
                         throws XPathException
Perform a parameterized deep-equals() test

Parameters:
context - The evaluation context
arg1 - The first sequence to be compared
arg2 - The second sequence to be compared
collation - The collation to be used (null if the default collation is to be used)
flags - A string whose characters select options that cause the comparison to vary from the standard fn:deep-equals() function. The flags are:
  • N - take namespace nodes into account
  • C - take comments into account
  • P - take processing instructions into account
  • w - don't take whitespace-only text nodes into account
Returns:
true if the sequences are deep equal, otherwise false
Throws:
XPathException

compileStylesheet

public static javax.xml.transform.Templates compileStylesheet(XPathContext context,
                                                              DocumentInfo doc)
                                                       throws XPathException
Compile a document containing a stylesheet module into a stylesheet that can be used to perform transformations

Throws:
XPathException

transform

public static DocumentInfo transform(XPathContext context,
                                     javax.xml.transform.Templates templates,
                                     NodeInfo source)
                              throws XPathException
Run a transformation to convert an input tree to an output document

Parameters:
context - The dynamic context
templates - The compiled stylesheet
source - The initial context node representing the document to be transformed
Throws:
XPathException