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,
context
- the dynamic evaluation contextns1
- the first operandns2
- the second operand
- an iterator over the nodes in ns1 that are after the first node in ns2
base64BinaryToOctets
public static byte[] base64BinaryToOctets(Base64BinaryValue in)
Convert a base64Binary value to a sequence of integers representing the octets contained in the value
in
- the supplied base64Binary value
- the corresponding array of integers, representing the octet values
base64BinaryToString
public static String base64BinaryToString(XPathContext context,
Base64BinaryValue in,
String encoding)
throws Exception
Convert a base64Binary value to a String, assuming a particular encoding
context
- the XPath dynamic contextin
- the supplied base64Binary valueencoding
- the character encoding
- the string that results from treating the base64binary value as a sequence of octets
that encode a string in the given encoding
compileQuery
public static XQueryExpression compileQuery(XPathContext context,
String query)
throws XPathException
Compile a string containing a source query
transformations
context
- the XPath dynamic evaluation contextquery
- a string containing the query to be compiled
compileStylesheet
public static 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
context
- the XPath dynamic evaluation contextdoc
- the document containing the stylesheet to be compiled
decimalDivide
public static BigDecimal decimalDivide(BigDecimal arg1,
BigDecimal arg2,
int scale)
Perform decimal division to a user-specified precision
arg1
- the numeratorarg2
- the denominatorscale
- the required number of digits in the result of the division
- the result of the division
deepEqual
public static boolean deepEqual(XPathContext context,
SequenceIterator arg1,
SequenceIterator arg2,
String collation,
String flags)
throws XPathException
Perform a parameterized deep-equals() test
context
- The evaluation contextarg1
- The first sequence to be comparedarg2
- The second sequence to be comparedcollation
- 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
- A - compare type annotations
- C - take comments into account
- F - take namespace prefixes into account
- P - take processing instructions into account
- S - compare string values, not typed values
- w - don't take whitespace-only text nodes into account
- true if the sequences are deep equal, otherwise false
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.
context
- the evaluation context (supplied implicitly by the call mechanism)doc
- the document to be released from the document pool
- the document that was released. This allows a call such as
select="saxon:discard-document(document('a.xml'))"
fileLastModified
public static DateTimeValue fileLastModified(XPathContext context,
String fileURI)
throws XPathException
This function determines the file modification time. It can be called from the stylesheet as file-timestamp(fn).
context
- the XPath dynamic evaluation contextfileURI
- the URI of a file. This must be an absolute URI to which Saxon can connect
- file modification time as an xs:dateTime value or an empty sequence if the file is
not found
XPathException
- if an error occurs and the configuration option TRACE_EXTERNAL_FUNCTIONS is true
generateId
public static String generateId(NodeInfo node)
The function saxon:generate-id() is equivalent to the standard XSLT function generate-id().
It is provided as an extension function to make it available in non-XSLT environments, for example
in XQuery.
node
- the node whose identifier is required
- as ASCII alphanumeric string that uniquely identifies this node
getConfiguration
public static Configuration getConfiguration(XPathContext c)
Return the Configuration object
c
- the XPath dynamic context
getContext
public static XPathContext getContext(XPathContext c)
Return the XPathContext object
- the context object (this looks crazy, but it works given that the function is called from an XPath
environment where the context is supplied as an implicit argument)
getController
public static Controller getController(XPathContext c)
Return the Controller object
c
- the XPath dynamic context
getPseudoAttribute
public static String getPseudoAttribute(XPathContext c,
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
c
- the XPath dynamic context. The context item should be a processing instruction,
though it doesn't matter if it isn't: the function will look at the string-value of the context item
whatever it is.name
- the name of the required pseudo-attribute
- the value of the pseudo-attribute if it is present
hasSameNodes
public static boolean hasSameNodes(SequenceIterator p1,
SequenceIterator p2)
throws XPathException
Determine whether two node-sets contain the same nodes
p1
- The first node-set. The iterator must be correctly ordered.p2
- The second node-set. The iterator must be correctly ordered.
- true if p1 and p2 contain the same set of nodes
hexBinaryToOctets
public static byte[] hexBinaryToOctets(HexBinaryValue in)
Convert a hexBinary value to a sequence of integers representing the octets contained in the value
in
- the input hexBinary value
- the corresponding array of integers, representing the octet values
hexBinaryToString
public static String hexBinaryToString(XPathContext context,
HexBinaryValue in,
String encoding)
throws Exception
Convert a hexBinary value to a String, assuming a particular encoding
context
- the XPath dynamic contextin
- the supplied hexBinary valueencoding
- the character encoding
- the string that results from treating the hexBinary value as a sequence of octets
that encode a string in the given encoding
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
context
- the XPath dynamic evaluation contextnsv
- the input sequencepexpression
- the expression whose maximum is to be computed
- an iterator over the items in the input sequence for which the expression takes its maximum value
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
- the node with the maximum numeric value
lastModified
public static DateTimeValue lastModified(XPathContext c)
throws XPathException
This function implements the last-modified()
function without any argument. It returns
the modification time of the file containing the context node.
c
- the dynamic evaluation context supplied by Saxon
- file modification time as an xs:dateTime value, or an empty sequence if the context item is
not a node or if the context node is not present in a local file
lastModified
public static DateTimeValue lastModified(XPathContext context,
NodeInfo node)
throws XPathException
This function implements the last-modified(node)
function with one argument which
must be a node. It returns the modification time of the file containing the context node.
node
- the node supplied by a user
- file modification time as an xs:dateTime value, or an empty sequence if the supplied
node is not present in a local file
XPathException
- if an error occurs and the configuration option TRACE_EXTERNAL_FUNCTIONS is true
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 satisfy the expression.
context
- the XPath dynamic evaluation contextin
- the input sequencepexp
- the expression against which items are to be tested
- an iterator over the items in the input sequence up to and excluding the first
one that doesn't satisfy the expression
lineNumber
public static int lineNumber(XPathContext c)
Return the line number of the context node.
c
- the XPath dynamic context
- the line number, or -1 if not available
lineNumber
public static int lineNumber(NodeInfo node)
Return the line number of the specified node.
node
- the node whose line number is required
- the line number of the node. This is only available if line numbering was switched on.
lowest
public static SequenceIterator lowest(XPathContext context,
SequenceIterator nsv,
Evaluate.PreparedExpression pexpression)
throws XPathException
Get the node with minimum numeric value of the string-value of each of a set of nodes
context
- the XPath dynamic evaluation contextnsv
- the input sequencepexpression
- the expression whose minimum is to be computed
- an iterator over the items in the input sequence for which the expression takes its minimum value
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
- the node with the minimum numeric value
namespaceNode
public static NodeInfo namespaceNode(XPathContext context,
String prefix,
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.
context
- the dynamic evaluation contextprefix
- the name of the namespace nodeuri
- the string value of the namespace node
- the newly constructed namespace node
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
in
- the input array of bytes (octets)
- the corresponding 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
in
- the input array of bytes (octets)
- the corresponding HexBinary value
path
public static String path(XPathContext c)
throws XPathException
Return an XPath expression that identifies the current node
c
- the XPath dynamic context
- a path expression giving a path from the root of the tree to the context node
pauseTracing
public static void pauseTracing(XPathContext c)
Switch tracing off. Only works if tracing was enabled at compile time.
c
- the XPath dynamic context
query
public static SequenceIterator query(XPathContext context,
XQueryExpression query)
throws XPathException
Run a previously-compiled query. The initial context item for the query is taken from the context
in which the query is called (if there is one); no parameters are supplied
context
- The dynamic contextquery
- The compiled query
- the sequence representing the result of the query
query
public static SequenceIterator query(XPathContext context,
XQueryExpression query,
Item source)
throws XPathException
Run a previously-compiled query
context
- The dynamic contextquery
- The compiled querysource
- The initial context item for the query (may be null)
- the sequence representing the result of the query
query
public static SequenceIterator query(XPathContext context,
XQueryExpression query,
Item source,
SequenceIterator params)
throws XPathException
Run a previously-compiled query, supplying parameters to the
transformation.
context
- The dynamic contextquery
- The compiled querysource
- The initial context node for the query (may be null)params
- A sequence of nodes (typically element nodes) supplying values of parameters.
The name of the node should match the name of the parameter, the typed value of the node is
used as the value of the parameter.
- the results of the query (a sequence of items)
resumeTracing
public static void resumeTracing(XPathContext c)
Resume tracing. Only works if tracing was originally enabled
but is currently paused.
c
- the XPath dynamic context
sort
public static SequenceIterator sort(XPathContext context,
SequenceIterator input)
Sort a sequence of nodes or atomic values, using the atomic value itself, or the atomized value of the node,
as the sort key. The values must all be comparable. Strings are compared using
codepoint collation. When nodes are atomized, the result must not be a sequence containing
more than one item.
context
- the XPath dynamic contextinput
- the sequence to be sorted
- an iterator over the sorted sequence
sort
public static SequenceIterator sort(XPathContext context,
SequenceIterator input,
Evaluate.PreparedExpression sortKeyExpression)
Sort a sequence of nodes or atomic values, using a given expression to calculate the sort key.
as the sort key. The values must all be comparable. Strings are compared using
codepoint collation. When nodes are atomized, the result must not be a sequence containing
more than one item.
context
- the XPath dynamic contextinput
- the sequence to be sortedsortKeyExpression
- the expression used to compute the sort keys
- an iterator over the sorted sequence
stringToBase64Binary
public static Base64BinaryValue stringToBase64Binary(String in,
String encoding)
throws IOException
Convert a string to a base64Binary value in a given encoding
in
- the input stringencoding
- the desired encoding
- the base64Binary value that results from encoding the string as a sequence of octets in the
given encoding.
stringToHexBinary
public static HexBinaryValue stringToHexBinary(String in,
String encoding)
throws Exception
Convert a string to a hexBinary value in a given encoding
in
- the input stringencoding
- the desired encoding
- the hexBinary value that results from encoding the string as a sequence of octets in the
given encoding.
stringToUtf8
public static List stringToUtf8(String in)
Get the UTF-8 encoding of a string
- a sequence of integers, each in the range 0-255, representing the octets of the UTF-8
encoding of the given string
systemId
public static String systemId(XPathContext c)
throws XPathException
Return the system identifier of the context node
c
- the XPath dynamic context
transform
public static DocumentInfo transform(XPathContext context,
Templates templates,
NodeInfo source)
throws XPathException
Run a transformation to convert an input tree to an output document
context
- The dynamic contexttemplates
- The compiled stylesheetsource
- The initial context node representing the document to be transformed
- the document that results from the transformation
transform
public static DocumentInfo transform(XPathContext context,
Templates templates,
NodeInfo source,
SequenceIterator params)
throws XPathException
Run a transformation to convert an input tree to an output document, supplying parameters to the
transformation.
context
- The dynamic contexttemplates
- The compiled stylesheetsource
- The initial context node representing the document to be transformedparams
- A sequence of nodes (typically element nodes) supplying values of parameters.
The name of the node should match the name of the parameter, the typed value of the node is
used as the value of the parameter.
- the document that results from the transformation
typeAnnotation
public static QNameValue typeAnnotation(XPathContext context,
Item item)
Display the value of the type annotation of a node or an atomic value
context
- the XPath dynamic contextitem
- the node or atomic value whose type annotation is required
- the type annotation or type label as a QName
validCharacter
public static boolean validCharacter(XPathContext c,
int in)
Test whether a given integer is the codepoint of a valid XML character
c
- the XPath dynamic contextin
- the character to be tested
- true if and only if the character is valid in (the relevant version of) XML