S9API interface
With the DocumentBuilder class, when DTD or schema validation is
requested, the WhitespaceStrippingPolicy setting
was previously ignored (although the documentation didn't make this clear): whatever the setting, whitespace nodes were stripped if and
only if they appeared in elements with element-only content. This has changed so that any explicit setting other than
WhitespaceStrippingPolicy.IGNORABLE
results in an exception reporting the error.
It is now possible to define a custom WhitespaceStrippingPolicy
by supplying a callback predicate which indicates whether
whitespace for a particular element name is to be stripped or preserved. This provides XQuery users with a mechanism comparable to
XSLT's xsl:strip-space
and xsl:preserve-space
, and allows fine-grained control of whitespace stripping
to be taken out of the control of the transformation.
The constructors for the Serializer class (deprecated since 9.6) have been removed; the factory methods on
Processor must now be used instead. This change ensures that the Serializer
is always bound to a specific
Processor
.
New classes XdmMap and XdmArray have been added as subclasses of XdmFunctionItem,
making it easier to pass maps and arrays as parameters to queries or stylesheets. Maps and arrays are also now supported
in the s9api ItemType and ItemTypeFactory classes. The XdmMap
class implements
the interface java.util.Map<XdmAtomicValue, XdmValue>
, allowing it to be used directly in contexts where a Java map
is expected (it is immutable, however).
The class XdmAtomicValue now has equals()
and
hashCode()
methods that reflect the semantics
of the op:is-same-key()
relation which is used to compare keys in maps. (Without this, the XdmItem.asMap()
method was not very useful).
Static methods have been added to XdmValue
, XdmAtomicValue
, XdmMap
, and XdmArray
,
to allow conversion from ordinary Java values. For example, XdmArray.makeArray()
will construct an array of xs:int
values from a Java int[]
array.
A static method XdmFunctionItem.getSystemFunction() allows a function item representing a built-in function to be obtained. This can then be used for direct calls on system functions from the Java application without the inconvenience of parsing an XPath expression to represent the function call.
The method XdmFunctionItem.call() has been enhanced to
apply the function conversion rules to the supplied
arguments, and to return a clean error message (rather than a ClassCastException
) if the supplied arguments are of the wrong type.
The method Xslt30Transformer.setMessageListener()
is
supplemented with a variant that accepts a MessageListener2
as its parameter; the MessageListener2
interface allows the xsl:message
error code to be reported along with the message
itself.