Package net.sf.saxon.functions
Class Extensions
java.lang.Object
net.sf.saxon.functions.Extensions
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
Modifier and TypeMethodDescriptionstatic SequenceIterator
after
(XPathContext context, SequenceIterator ns1, SequenceIterator ns2) Find all the nodes in ns1 that are after the first node in ns2.static byte[]
Convert a base64Binary value to a sequence of integers representing the octets contained in the valuestatic String
base64BinaryToString
(XPathContext context, Base64BinaryValue in, String encoding) Convert a base64Binary value to a String, assuming a particular encodingstatic Templates
compileStylesheet
(XPathContext context, DocumentInfo doc) Compile a document containing a stylesheet module into a stylesheet that can be used to perform transformationsstatic SecondsDurationValue
Get a dayTimeDuration value corresponding to a given number of secondsstatic BigDecimal
decimalDivide
(BigDecimal arg1, BigDecimal arg2, int scale) Perform decimal division to a user-specified precisionstatic boolean
deepEqual
(XPathContext context, SequenceIterator arg1, SequenceIterator arg2, String collation, String flags) Perform a parameterized deep-equals() teststatic DocumentInfo
discardDocument
(XPathContext context, DocumentInfo doc) Remove a document from the document pool.static String
generateId
(NodeInfo node) The function saxon:generate-id() is equivalent to the standard XSLT function generate-id().static Configuration
Return the Configuration objectstatic XPathContext
Return the XPathContext objectstatic Controller
Return the Controller objectstatic String
getPseudoAttribute
(XPathContext c, String name) Get a pseudo-attribute of a processing instruction.static boolean
Determine whether two node-sets contain the same nodesstatic byte[]
Convert a hexBinary value to a sequence of integers representing the octets contained in the valuestatic String
hexBinaryToString
(XPathContext context, HexBinaryValue in, String encoding) Convert a hexBinary value to a String, assuming a particular encodingstatic SequenceIterator
highest
(XPathContext context, SequenceIterator nsv, Evaluate.PreparedExpression pexpression) Get the maximum numeric value of a stored expression over a set of nodesstatic Value
highest
(SequenceIterator nsv) Get the node with maximum numeric value of the string-value of each of a set of nodesstatic 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.static int
Return the line number of the context node.static int
lineNumber
(NodeInfo node) Return the line number of the specified node.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 nodesstatic Value
lowest
(SequenceIterator nsv) Get the node with minimum numeric value of the string-value of each of a set of nodesstatic NodeInfo
namespaceNode
(XPathContext context, String prefix, 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 valuestatic HexBinaryValue
octetsToHexBinary
(byte[] in) Convert a sequence of integers in the range 0-255, representing a sequence of octets, to a hexBinary valuestatic String
path
(XPathContext c) Return an XPath expression that identifies the current nodestatic void
Switch tracing off.static void
Resume tracing.static Base64BinaryValue
stringToBase64Binary
(String in, String encoding) Convert a string to a base64Binary value in a given encodingstatic HexBinaryValue
stringToHexBinary
(String in, String encoding) Convert a string to a hexBinary value in a given encodingstatic List
stringToUtf8
(String in) Get the UTF-8 encoding of a stringstatic String
Return the system identifier of the context nodestatic SequenceIterator
Return a node-set by tokenizing a supplied string.static SequenceIterator
Return a sequence by tokenizing a supplied string.static DocumentInfo
transform
(XPathContext context, Templates templates, NodeInfo source) Run a transformation to convert an input tree to an output documentstatic String
typeAnnotation
(XPathContext context, NodeInfo node) Display the value of the type annotation of a nodestatic boolean
validCharacter
(XPathContext c, int in) Test whether a given integer is the codepoint of a valid XML characterstatic MonthDurationValue
yearMonthDurationFromMonths
(int arg) Get a yearMonthDuration value corresponding to a given number of months
-
Method Details
-
pauseTracing
Switch tracing off. Only works if tracing was enabled at compile time. -
resumeTracing
Resume tracing. Only works if tracing was originally enabled but is currently paused. -
systemId
Return the system identifier of the context node- Throws:
XPathException
-
generateId
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.- Parameters:
node
- the node whose identifier is required- Returns:
- as ASCII alphanumeric string that uniquely identifies this node
-
lineNumber
Return the line number of the context node. -
lineNumber
Return the line number of the specified node. -
discardDocument
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
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
-
highest
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
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 satisfy the expression. -
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
Return a node-set by tokenizing a supplied string. Tokens are delimited by any sequence of whitespace characters. -
tokenize
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
Return an XPath expression that identifies the current node- Throws:
XPathException
-
typeAnnotation
Display the value of the type annotation of a node -
getContext
Return the XPathContext object -
getController
Return the Controller object -
getConfiguration
Return the Configuration object -
getPseudoAttribute
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
Get a dayTimeDuration value corresponding to a given number of seconds- Throws:
XPathException
-
yearMonthDurationFromMonths
Get a yearMonthDuration value corresponding to a given number of months -
decimalDivide
Perform decimal division to a user-specified precision -
stringToUtf8
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
Convert a sequence of integers in the range 0-255, representing a sequence of octets, to a base64Binary value -
octetsToHexBinary
Convert a sequence of integers in the range 0-255, representing a sequence of octets, to a hexBinary value -
base64BinaryToOctets
Convert a base64Binary value to a sequence of integers representing the octets contained in the value -
hexBinaryToOctets
Convert a hexBinary value to a sequence of integers representing the octets contained in the value -
base64BinaryToString
public static String base64BinaryToString(XPathContext context, Base64BinaryValue in, String encoding) throws Exception Convert a base64Binary value to a String, assuming a particular encoding- Throws:
Exception
-
stringToBase64Binary
public static Base64BinaryValue stringToBase64Binary(String in, String encoding) throws UnsupportedEncodingException, IOException Convert a string to a base64Binary value in a given encoding -
hexBinaryToString
public static String hexBinaryToString(XPathContext context, HexBinaryValue in, String encoding) throws Exception Convert a hexBinary value to a String, assuming a particular encoding- Throws:
Exception
-
stringToHexBinary
Convert a string to a hexBinary value in a given encoding- Throws:
Exception
-
validCharacter
Test whether a given integer is the codepoint of a valid XML character -
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.- Throws:
XPathException
-
deepEqual
public static boolean deepEqual(XPathContext context, SequenceIterator arg1, SequenceIterator arg2, String collation, String flags) throws XPathException Perform a parameterized deep-equals() test- Parameters:
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
- Returns:
- true if the sequences are deep equal, otherwise false
- Throws:
XPathException
-
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- Throws:
XPathException
-
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- Parameters:
context
- The dynamic contexttemplates
- The compiled stylesheetsource
- The initial context node representing the document to be transformed- Throws:
XPathException
-