Class ProfessionalConfiguration
- java.lang.Object
-
- net.sf.saxon.Configuration
-
- com.saxonica.config.ProfessionalConfiguration
-
- All Implemented Interfaces:
SourceResolver
,NotationSet
- Direct Known Subclasses:
EnterpriseConfiguration
public class ProfessionalConfiguration extends Configuration
This class holds details of user-selected configuration options for a set of transformations and/or queries. When running XSLT, the preferred way of setting configuration options is via the JAXP TransformerFactory interface, but the Configuration object provides a finer level of control. As yet there is no standard API for XQuery, so the only way of setting Configuration information is to use the methods on this class directly.As well as holding configuration settings, this class acts as a factory for classes providing service in particular areas: error handling, URI resolution, and the like. Some of these services are chosen on the basis of the current platform (Java or .NET), some vary depending whether the environment is schema-aware or not.
The
Configuration
provides access to aNamePool
which is used to manage all the names used in stylesheets, queries, schemas, and source and documents: the NamePool allocates integer codes to these names allowing efficient storage and comparison. Normally there will be a one-to-one relationship between aNamePool
and aConfiguration
. It is possible, however, for severalConfiguration
objects to share the sameNamePool
. Until Saxon 8.9, by default allConfiguration
objects shared a singleNamePool
unless configured otherwise; this changed in 8.9 so that the default is to allocate a newNamePool
for eachConfiguration
.The
Configuration
establishes the scope within which node identity is managed. Every document belongs to aConfiguration
, and every node has a distinct identity within thatConfiguration
. In consequence, it is not possible for any query or transformation to manipulate multiple documents unless they all belong to the sameConfiguration
.Saxon-EE has a subclass of the
Configuration
class which provides the additional services needed for schema-aware processing. TheEnterpriseConfiguration
also holds a cache of loaded schema components used for compiling schema-aware transformations and queries, and for validating instance documents.Since Saxon 8.4, the JavaDoc documentation for Saxon attempts to identify interfaces that are considered stable, and will only be changed in a backwards-incompatible way if there is an overriding reason to do so. These interfaces and methods are labelled with the JavaDoc "since" tag. The value 8.n indicates a method in this category that was introduced in Saxon version 8.n: or in the case of 8.4, that was present in Saxon 8.4 and possibly in earlier releases. (In some cases, these methods have been unchanged for a long time.) Methods without a "since" tag, although public, are provided for internal use or for use by advanced users, and are subject to change from one release to the next. The presence of a "since" tag on a class or interface indicates that there are one or more methods in the class that are considered stable; it does not mean that all methods are stable.
- Since:
- 9.2
-
-
Nested Class Summary
-
Nested classes/interfaces inherited from class net.sf.saxon.Configuration
Configuration.ApiProvider, Configuration.LicenseFeature
-
-
Field Summary
Fields Modifier and Type Field Description protected BuiltInFunctionSet
vendorFunctionSet
-
Fields inherited from class net.sf.saxon.Configuration
booleanFeatures, builtInExtensionLibraryList, byteCodeThreshold, defaultStaticQueryContext, defaultXsltCompilerInfo, optimizer, optimizerOptions, staticContextForSystemFunctions, typeHierarchy, XML10, XML11, XSD10, XSD11, xsdVersion
-
-
Constructor Summary
Constructors Constructor Description ProfessionalConfiguration()
Create a Saxon Professional Edition configuration object with default settings for all options.
-
Method Summary
All Methods Static Methods Instance Methods Concrete Methods Modifier and Type Method Description void
addExtensionBinders(FunctionLibraryList list)
Add the registered extension binders to a function library.void
bindExtensions(java.lang.String uri, cli.System.Type type)
Declare a mapping from a specific namespace URI to a .NET classSystemFunction
bindSaxonExtensionFunction(java.lang.String localName, int arity)
Instantiate a Saxon extension function.void
checkLicensedFeature(int feature, java.lang.String name, int localLicenseId)
Check whether a particular feature is licensed, with a fatal error if it is notvoid
declareBuiltInExtensionElementNamespaces()
Declare the built-in XSLT extension element namespacesvoid
declareBuiltInExtensionFunctions()
Declare built-in extension functionsvoid
disableLicensing()
Instruct Saxon to run as if no license is available.void
displayLicenseMessage()
Display a message about the license status.MapItem
externalObjectAsMap(ObjectValue value, java.lang.String required)
Convert a Java object to a mapprotected void
forceLoadLicense()
FunctionLibraryList
getBuiltInExtensionLibraryList()
java.lang.String
getEditionCode()
Get the edition code identifying this configuration: "HE", "PE" or "EE"FunctionLibrary
getExtensionBinder(java.lang.String scheme)
Get the FunctionLibrary used to bind calls on extension functions on the specified platform.ExtensionElementFactory
getExtensionElementFactory(java.lang.String namespace)
Get the XSLT extension element factory for a given namespaceprotected java.lang.String
getFeature(java.lang.String name)
This method is called to read a feature of the license.JavaExternalObjectType
getJavaExternalObjectType(java.lang.Class theClass)
Get the JavaExternalObjectType object representing a particular Java classjava.lang.String
getLicenseFeature(java.lang.String name)
Get the value of a named license featureFunction
getSystemFunction(StructuredQName name, int arity)
Get a system function.TypeHierarchy
getTypeHierarchy()
Get the TypeHierarchy: a cache holding type informationBuiltInFunctionSet
getVendorFunctionSet()
BuiltInFunctionSet
getXQueryUpdateFunctionSet()
void
importLicenseDetails(Configuration other)
Share licensing data stored in one configuration with another configuration.boolean
isExtensionElementAvailable(StructuredQName qName)
Ask whether an extension element with a particular name is availableboolean
isFeatureAllowedBySecondaryLicense(int localLicenseId, int feature)
Ask whether a particular feature is enabled by an embedded license (embedded in a SEF file)boolean
isLicensedFeature(int feature)
Determine if a particular feature is licensed.boolean
isLicenseFound()
Ask if the configuration is known to be licensedboolean
isLicenseNotFound()
Ask if the configuration is known to be unlicensedprotected void
loadLicense()
Attempt to load the license file.protected ConfigurationReader
makeConfigurationReader()
java.util.Map<java.lang.String,Function>
makeMethodMap(java.lang.Class javaClass, java.lang.String required)
Make a map representing the methods defined in a class.SimpleMode
makeMode(StructuredQName modeName, CompilerInfo compilerInfo)
Make a new Mode - this can be overridden in subclasses to produce optimized variantsExpression
makeObjectLookupExpression(Expression lhs, Expression rhs)
Make an object lookup expression: supports the construct X?Y where X is an external Java object.PackageLoaderPE
makePackageLoader()
Create a package loader, for reloading SEF files, appropriate to the Saxon edition being usedstatic Configuration
makeProfessionalConfiguration(java.lang.ClassLoader classLoader, java.lang.String className)
Static method to instantiate a professional configuration.StyleNodeFactory
makeStyleNodeFactory(Compilation compilation)
Factory method to make a StyleNodeFactory, used for constructing elements in a stylesheet documentTypeAliasManager
makeTypeAliasManager()
Make a TypeAliasManager appropriate to the type of Configurationprotected BuiltInFunctionSet
makeVendorFunctionSet()
XPathParser
newExpressionParser(java.lang.String language, boolean updating, int languageVersion)
Make an expression Parser for a specified version of XPath or XQueryprotected Configuration
readConfigurationFile(javax.xml.transform.Source source)
Read the configuration file and construct a new Configuration (the real one)int
registerLocalLicense(java.lang.String dmk)
Register a local license file (for use within a single transformation (etc))protected void
reportIfMissingLicenseFeature(int feature, java.lang.String name)
javax.xml.transform.Source
resolveSource(javax.xml.transform.Source source, Configuration config)
Resolve a Source.void
setConfigurationProperty(java.lang.String name, java.lang.Object value)
Set a property of the configuration.<T> void
setConfigurationProperty(Feature<T> feature, T value)
Set a property of the configuration.void
setExtensionBinder(java.lang.String scheme, FunctionLibrary binder)
Set the FunctionLibrary used to bind calls on extension functions.void
setExtensionElementNamespace(java.lang.String namespace, java.lang.String className)
Set a namespace used to refer to a library of XSLT extension elementsprotected void
setLicensedFeatures()
void
supplyLicenseKey(java.io.BufferedReader reader)
This method allows the contents of a license key to be supplied programmatically.protected boolean
testFeature(int feature)
Test whether a particular feature is available, given that a valid license has been successfully loaded.-
Methods inherited from class net.sf.saxon.Configuration
addSchemaForBuiltInNamespace, addSchemaSource, addSchemaSource, buildDocumentTree, buildDocumentTree, checkStrictStreamability, checkTypeDerivationIsOK, clearSchemaCache, close, compileRegularExpression, createByteCodeReport, createValidityReporter, createXMLParser, exportComponents, getAllowedUriTest, getAnnotationStripper, getAttributeDeclaration, getAttributeDeclaration, getBooleanProperty, getCharacterSetFactory, getClass, getCollation, getCollation, getCollation, getCollationURIResolver, getCollectionFinder, getConfiguration, getConfigurationProperty, getConfigurationProperty, getConversionContext, getConversionRules, getCountDown, getDebugger, getDeclaredSchemaParameters, getDefaultCollationName, getDefaultCollection, getDefaultContextItemStaticInfo, getDefaultCountry, getDefaultLanguage, getDefaultRegexEngine, getDefaultSerializationProperties, getDefaultStaticQueryContext, getDefaultXsltCompilerInfo, getDocumentNumberAllocator, getDocumentValidator, getDynamicLoader, getElementDeclaration, getElementDeclaration, getElementValidator, getExtensionsOfType, getExternalObjectModel, getExternalObjectModel, getExternalObjectModels, getFocusTrackerFactory, getFunctionAnnotationHandler, getGlobalDocumentPool, getImportedNamespaces, getInstance, getIntegratedFunctionLibrary, getLabel, getLocalizerFactory, getLogger, getMediaQueryEvaluator, getMediaTypeForFileExtension, getMessageEmitterClass, getModuleURIResolver, getMultithreadedItemMappingIterator, getNamePool, getOptimizerOptions, getOutputURIResolver, getParseOptions, getProcessor, getProductTitle, getResourceFactoryForMediaType, getSchemaAsFunctionItem, getSchemaComponentAsFunctionItem, getSchemaType, getSchemaValidationMode, getSerializerFactory, getSourceParser, getSourceParserClass, getSourceResolver, getStandardCollectionFinder, getStandardErrorOutput, getStandardModuleURIResolver, getStyleParser, getStyleParserClass, getSystemURIResolver, getTraceListener, getTraceListenerClass, getTraceListenerOutputFile, getTreeModel, getTreeStatistics, getTypeChecker, getUnparsedTextURIResolver, getURIResolver, getUseWhenFunctionSet, getValidCharacterChecker, getXMLVersion, getXPath30FunctionSet, getXPath31FunctionSet, getXsdVersion, getXSLT30FunctionSet, importComponents, init, instantiateClassName, instantiateConfiguration, internalSetBooleanProperty, isAssertionsEnabled, isCompatible, isCompileWithTracing, isDeclaredNotation, isDeferredByteCode, isExpandAttributeDefaults, isGenerateByteCode, isJITEnabled, isLineNumbering, isSchemaAvailable, isStreamabilityEnabled, isStreamedNode, isStripsAllWhiteSpace, isTiming, isValidation, isValidationWarnings, isVersionWarning, isXIncludeAware, loadSchema, locateResource, locateResourceSource, makeAccumulatorRegistry, makeClosure, makeCompilerInfo, makeCompilerService, makeContextItemStaticInfo, makeDocumentProjector, makeDocumentProjector, makeEmitter, makeErrorReporter, makeEvaluateInstruction, makeLicensedConfiguration, makeNumberer, makeParser, makePipelineConfiguration, makeSchemaURIResolver, makeSequenceExtent, makeSlotManager, makeStaticQueryContext, makeStreamingTransformer, makeStreamInstruction, makeStylesheetPackage, makeSystemFunction, makeTemplateRule, makeThreadManager, makeTraceListener, makeTraceListener, makeURIResolver, makeUserUnionType, makeXQueryExpression, needEnterpriseEdition, newConfiguration, newExpressionExporter, newPendingUpdateList, newStaticQueryContext, newUserFunction, obtainDefaultSerializationProperties, obtainOptimizer, obtainOptimizer, prepareValidationReporting, processResultDocument, readConfiguration, readConfiguration, readConfigurationFile, readInlineSchema, readMultipleSchemas, readSchema, registerCollation, registerCollection, registerExtensionFunction, registerExternalObjectModel, registerFileExtension, registerFunctionAnnotationHandler, registerMediaType, reportFatalError, requireBoolean, requireInteger, requireProfessionalLicense, requireString, reuseSourceParser, reuseStyleParser, sealNamespace, setAllowedUriTest, setBooleanProperty, setBooleanProperty, setCollationURIResolver, setCollectionFinder, setCompileWithTracing, setConversionRules, setDebugger, setDefaultCollection, setDefaultCountry, setDefaultLanguage, setDefaultRegexEngine, setDefaultSerializationProperties, setDocumentNumberAllocator, setDynamicLoader, setErrorReporterFactory, setExpandAttributeDefaults, setLabel, setLineNumbering, setLocalizerFactory, setLogger, setMediaQueryEvaluator, setMessageEmitterClass, setModuleURIResolver, setModuleURIResolver, setNamePool, setOutputURIResolver, setParameterizedURIResolver, setProcessor, setSchemaValidationMode, setSerializerFactory, setSourceParserClass, setSourceResolver, setStandardErrorOutput, setStaticQueryContextFactory, setStyleParserClass, setTiming, setTraceListener, setTraceListenerClass, setTraceListenerOutputFile, setTreeModel, setUnparsedTextURIResolver, setURIResolver, setValidation, setValidationWarnings, setVersionWarning, setXIncludeAware, setXMLVersion, unravel, validateAttribute
-
-
-
-
Field Detail
-
vendorFunctionSet
protected BuiltInFunctionSet vendorFunctionSet
-
-
Method Detail
-
readConfigurationFile
protected Configuration readConfigurationFile(javax.xml.transform.Source source) throws XPathException
Read the configuration file and construct a new Configuration (the real one)- Overrides:
readConfigurationFile
in classConfiguration
- Parameters:
source
- the source of the configuration file- Returns:
- the Configuration that will be used for real work
- Throws:
XPathException
- if, for example, the configuration file is invalid
-
makeConfigurationReader
protected ConfigurationReader makeConfigurationReader()
- Overrides:
makeConfigurationReader
in classConfiguration
-
makeProfessionalConfiguration
public static Configuration makeProfessionalConfiguration(java.lang.ClassLoader classLoader, java.lang.String className) throws java.lang.RuntimeException
Static method to instantiate a professional configuration.On the .NET platform, this method should not be called unless it is known that the assembly saxon9sa.dll has already been loaded. This can be achieved by an appropriate call on Assembly.Load(): for an example, see the C# Configuration.cs class in the Saxon.Api namespace.
This method fails if Saxon-EE cannot be loaded, but it does not fail if there is no license available. In that case it returns a schema-aware configuration object, but any attempt to use schema-aware processing will fail.
- Parameters:
classLoader
- - the class loader to be used. If null, the context class loader for the current thread is used.className
- - the name of the schema aware configuration class. Defaults to "com.saxonica.config.ProfessionalConfiguration" if null is supplied. This allows an assembly qualified name to be supplied under .NET. The class, once instantiated, must be an instance of Configuration, but despite the name of this method there is nothing that requires it to be schema-aware.- Returns:
- the new ProfessionalConfiguration
- Throws:
java.lang.RuntimeException
- if the Saxon-PE product cannot be loaded- Since:
- 9.2 (renamed from makeSchemaAwareConfiguration)
-
bindExtensions
public void bindExtensions(java.lang.String uri, cli.System.Type type)
Declare a mapping from a specific namespace URI to a .NET class- Overrides:
bindExtensions
in classConfiguration
- Parameters:
uri
- - the namespace URI of the function nametype
- - the .NET class that implements the functions in this namespace
-
getEditionCode
public java.lang.String getEditionCode()
Get the edition code identifying this configuration: "HE", "PE" or "EE"- Overrides:
getEditionCode
in classConfiguration
- Returns:
- the code identifying the Saxon edition associated with this configuration
-
getTypeHierarchy
public TypeHierarchy getTypeHierarchy()
Get the TypeHierarchy: a cache holding type information- Overrides:
getTypeHierarchy
in classConfiguration
- Returns:
- the type hierarchy cache
-
makeTypeAliasManager
public TypeAliasManager makeTypeAliasManager()
Make a TypeAliasManager appropriate to the type of Configuration- Overrides:
makeTypeAliasManager
in classConfiguration
- Returns:
- a new TypeAliasManager
-
makePackageLoader
public PackageLoaderPE makePackageLoader()
Description copied from class:Configuration
Create a package loader, for reloading SEF files, appropriate to the Saxon edition being used- Overrides:
makePackageLoader
in classConfiguration
- Returns:
- a package loader
-
setConfigurationProperty
public void setConfigurationProperty(java.lang.String name, java.lang.Object value)
Set a property of the configuration. This method underpins the setAttribute() method of the TransformerFactory implementation, and is provided to enable setting of Configuration properties using URIs without instantiating a TransformerFactory: specifically, this may be useful when running XQuery, and it is also used by the Validator APIFrom Saxon 9.9, an alternative interface is available:
setConfigurationProperty(Feature, Object)
. The new interface is more efficient because it avoids expensive string comparisons. The old interface is retained mainly for compatibility, and also because there are a few cases where it cannot easily be replaced, for example when using composite feature URIs to delegate configuration options to the XML parser.- Overrides:
setConfigurationProperty
in classConfiguration
- Parameters:
name
- the URI identifying the property to be set. See the classFeatureKeys
for constants representing the property names that can be set.value
- the value of the property- Throws:
java.lang.IllegalArgumentException
- if the property name is not recognized or if the value is not a valid value for the named property
-
setConfigurationProperty
public <T> void setConfigurationProperty(Feature<T> feature, T value)
Description copied from class:Configuration
Set a property of the configuration. This method underpins the setAttribute() method of the TransformerFactory implementation, and is provided to enable setting of Configuration properties using URIs without instantiating a TransformerFactory: specifically, this may be useful when running XQuery, and it is also used by the Validator API- Overrides:
setConfigurationProperty
in classConfiguration
- Type Parameters:
T
- the type of value required for this particular feature- Parameters:
feature
- the property to be set. See the classFeature
for constants representing the property names that can be set.value
- the value of the property. Note that boolean values may be supplied either as a Boolean, or as one of the strings "0", "1", "true", "false", "yes", "no", "on", or "off".
-
supplyLicenseKey
public void supplyLicenseKey(java.io.BufferedReader reader)
This method allows the contents of a license key to be supplied programmatically. This must be a license file as issued to authorized OEM distributors of Saxon-EE.- Parameters:
reader
- A reader that will be used to read the contents of the license file (for example, a StringReader)- Throws:
java.lang.IllegalArgumentException
- if the key supplied is not a valid OEM license key
-
forceLoadLicense
protected final void forceLoadLicense() throws LicenseException
- Throws:
LicenseException
-
importLicenseDetails
public void importLicenseDetails(Configuration other)
Share licensing data stored in one configuration with another configuration. Where many configurations are created, this reduces the cost of repeatedly reading and analysing license key information.- Overrides:
importLicenseDetails
in classConfiguration
- Parameters:
other
- another Configuration, whose license information will be imported into this Configuration.
-
getFeature
protected java.lang.String getFeature(java.lang.String name)
This method is called to read a feature of the license. This method should be called only if the caller requires access to the feature.- Parameters:
name
- the name of the requested feature- Returns:
- the feature value of the license.
- Throws:
java.lang.RuntimeException
- if no license is available
-
checkLicensedFeature
public void checkLicensedFeature(int feature, java.lang.String name, int localLicenseId) throws LicenseException
Check whether a particular feature is licensed, with a fatal error if it is not- Overrides:
checkLicensedFeature
in classConfiguration
- Parameters:
feature
- the feature in question, identified by a constant in classConfiguration.LicenseFeature
name
- the name of the feature for use in diagnosticslocalLicenseId
- identifies a local license held within a SEF file, or -1 if not appicable- Throws:
LicenseException
- if the feature is not licensed
-
disableLicensing
public void disableLicensing()
Instruct Saxon to run as if no license is available. This method is provided for testing purposes, so that tests with and without a license can be run without making changes to the classpath.- Overrides:
disableLicensing
in classConfiguration
-
isFeatureAllowedBySecondaryLicense
public boolean isFeatureAllowedBySecondaryLicense(int localLicenseId, int feature)
Description copied from class:Configuration
Ask whether a particular feature is enabled by an embedded license (embedded in a SEF file)- Overrides:
isFeatureAllowedBySecondaryLicense
in classConfiguration
- Parameters:
localLicenseId
- the identifier of the embedded licensefeature
- the feature in question, identified by a constant in classConfiguration.LicenseFeature
- Returns:
- true if the embedded license exists and enables the requested feature
-
reportIfMissingLicenseFeature
protected void reportIfMissingLicenseFeature(int feature, java.lang.String name)
-
isLicensedFeature
public final boolean isLicensedFeature(int feature) throws LicenseException
Determine if a particular feature is licensed. If this requires reading the license file to find out, and the license file cannot be read, then a message is output to the standard error output if and only if the configuration optionFeatureKeys.TIMING
is set (corresponding to -t on the command line).- Overrides:
isLicensedFeature
in classConfiguration
- Parameters:
feature
- the feature in question, identified by a constant in classConfiguration.LicenseFeature
- Returns:
- true if the feature is available for use.
- Throws:
LicenseException
-
getLicenseFeature
public final java.lang.String getLicenseFeature(java.lang.String name)
Get the value of a named license feature- Overrides:
getLicenseFeature
in classConfiguration
- Parameters:
name
- the name of the feature- Returns:
- the value of the feature if present, or null otherwise
-
loadLicense
protected final void loadLicense() throws LicenseException
Attempt to load the license file. If it is an evaluation license, set the appropriate restrictions.- Throws:
LicenseException
- if the license cannot be loaded.
-
setLicensedFeatures
protected void setLicensedFeatures()
-
registerLocalLicense
public int registerLocalLicense(java.lang.String dmk)
Register a local license file (for use within a single transformation (etc))- Overrides:
registerLocalLicense
in classConfiguration
- Parameters:
dmk
- the license in encoded form- Returns:
- an integer identifying this license uniquely within the configuration, or -1 if not accepted
-
testFeature
protected boolean testFeature(int feature)
Test whether a particular feature is available, given that a valid license has been successfully loaded.- Parameters:
feature
- a constant in classConfiguration.LicenseFeature
- Returns:
- true if the feature is available, otherwise false
-
isLicenseNotFound
public boolean isLicenseNotFound()
Ask if the configuration is known to be unlicensed- Returns:
- true if a previous attempt to load a license was made, and no license was found
-
isLicenseFound
public boolean isLicenseFound()
Ask if the configuration is known to be licensed- Returns:
- true if a previous attempt to load a license was made, and the license was found (and found to be valid)
-
displayLicenseMessage
public void displayLicenseMessage()
Display a message about the license status. Used from command-line tools only.- Overrides:
displayLicenseMessage
in classConfiguration
-
makeStyleNodeFactory
public StyleNodeFactory makeStyleNodeFactory(Compilation compilation)
Factory method to make a StyleNodeFactory, used for constructing elements in a stylesheet document- Overrides:
makeStyleNodeFactory
in classConfiguration
- Parameters:
compilation
- the XSLT compilation object- Returns:
- the StyleNodeFactory used in this Configuration
-
newExpressionParser
public XPathParser newExpressionParser(java.lang.String language, boolean updating, int languageVersion) throws XPathException
Make an expression Parser for a specified version of XPath or XQuery- Overrides:
newExpressionParser
in classConfiguration
- Parameters:
language
- set to "XP" (XPath) or "XQ" (XQuery) or "PATTERN" (XSLT Patterns)updating
- indicates whether or not XQuery update syntax may be used. Note that XQuery Update is supported only in Saxon-EElanguageVersion
- the required version (e.g 10 for "1.0", 30 for "3.0", 31 for "3.1"). A request for XQuery 1.0 or 3.0 delivers an XQuery 3.1 parser. The values supported for XPath are 20 (=2.0), 30 (=3.0), 31 (=3.1), and 305 (=XPath 3.0 plus the syntax extensions defined in XSLT 3.0).- Returns:
- the XPath or Query Parser
- Throws:
XPathException
- if this version of Saxon does not support the requested options
-
getXQueryUpdateFunctionSet
public BuiltInFunctionSet getXQueryUpdateFunctionSet()
- Overrides:
getXQueryUpdateFunctionSet
in classConfiguration
-
setExtensionBinder
public void setExtensionBinder(java.lang.String scheme, FunctionLibrary binder)
Set the FunctionLibrary used to bind calls on extension functions. This allows the rules for identifying extension functions to be customized (in principle, it would allow support for extension functions in other languages to be provided).When an application supplies its own FunctionLibrary for binding extension functions, this replaces the default binding mechanism for Java extension functions, namely
JavaExtensionLibrary
. It thus disables the function libraries for built-in Saxon extensions and for EXSLT extensions. It is possible to create a function library that adds to the existing mechanisms, rather than replacing them, by supplying as the FunctionLibrary aFunctionLibraryList
that itself contains two FunctionLibrary objects: a JavaExtensionLibrary, and a user-written FunctionLibrary.- Parameters:
scheme
- The scheme served by the extension binder. Typically this will be one of "java" or "clitype". However, user-defined extension binders for other schemes can be registered. Note that the scheme name does not have to be related to the actual namespace used in function calls; all registered function libraries have the opportunity to bind any extension function call. The significance is purely local to this class: setting an extension binder for a given scheme replaces the existing extension binder for that scheme. The two schemes used by Saxon itself are "java" for dynamically-bound Java extension functions, and "clitype" for dynamically-bound .NET extension functionsbinder
- The FunctionLibrary object used to locate implementations of extension functions, based on their name and arity
-
getExtensionBinder
public FunctionLibrary getExtensionBinder(java.lang.String scheme)
Get the FunctionLibrary used to bind calls on extension functions on the specified platform.This mechanism is for advanced users only, and the details are subject to change.
- Parameters:
scheme
- The URI scheme served by the extension binder. This will typically be one of "java" or "clitype". On the Java platform, the only scheme currently supported is "java"; on the .NET platform, the "java" and "clitype" schemes coexist.- Returns:
- the registered FunctionLibrary for extension functions if one has been registered; or null otherwise
-
bindSaxonExtensionFunction
public SystemFunction bindSaxonExtensionFunction(java.lang.String localName, int arity) throws XPathException
Instantiate a Saxon extension function. This generally requires Saxon-PE or higher, so it will fail with this Configuration- Overrides:
bindSaxonExtensionFunction
in classConfiguration
- Parameters:
localName
- the local name of the function in the Saxon namespacearity
- the function arity- Returns:
- the system function with this name and arity
- Throws:
XPathException
-
addExtensionBinders
public void addExtensionBinders(FunctionLibraryList list)
Add the registered extension binders to a function library. This method is intended primarily for internal use- Overrides:
addExtensionBinders
in classConfiguration
- Parameters:
list
- the function library list
-
getSystemFunction
public Function getSystemFunction(StructuredQName name, int arity)
Get a system function. This can be any function defined in XPath 3.1 functions and operators, including functions in the math, map, and array namespaces. It can also be a Saxon extension function, provided a licensed Processor is used.- Overrides:
getSystemFunction
in classConfiguration
- Parameters:
name
- the name of the required functionarity
- the arity of the required function- Returns:
- the requested function, or null if there is no such function. Note that some functions (those with particular context dependencies) may be unsuitable for dynamic calling.
-
getBuiltInExtensionLibraryList
public FunctionLibraryList getBuiltInExtensionLibraryList()
- Overrides:
getBuiltInExtensionLibraryList
in classConfiguration
-
makeVendorFunctionSet
protected BuiltInFunctionSet makeVendorFunctionSet()
-
getVendorFunctionSet
public BuiltInFunctionSet getVendorFunctionSet()
-
declareBuiltInExtensionFunctions
public void declareBuiltInExtensionFunctions()
Declare built-in extension functions
-
declareBuiltInExtensionElementNamespaces
public void declareBuiltInExtensionElementNamespaces()
Declare the built-in XSLT extension element namespaces
-
setExtensionElementNamespace
public void setExtensionElementNamespace(java.lang.String namespace, java.lang.String className) throws XPathException
Set a namespace used to refer to a library of XSLT extension elements- Parameters:
namespace
- the namespace used for the extension elementsclassName
- the classname of the implementation of the ExtensionElementFactory that instantiates extension elements in this namespace- Throws:
XPathException
- if (for example) the supplied class does not implement the ExtensionElementFactory interface- Since:
- 9.2
-
getExtensionElementFactory
public ExtensionElementFactory getExtensionElementFactory(java.lang.String namespace)
Get the XSLT extension element factory for a given namespace- Parameters:
namespace
- the namespace URI of the extension element- Returns:
- the corresponding extension element factory if one has been registered, or null otherwise
- Since:
- 9.2
-
isExtensionElementAvailable
public boolean isExtensionElementAvailable(StructuredQName qName)
Ask whether an extension element with a particular name is available- Overrides:
isExtensionElementAvailable
in classConfiguration
- Parameters:
qName
- the extension element name- Returns:
- true if the extension element is available
-
getJavaExternalObjectType
public JavaExternalObjectType getJavaExternalObjectType(java.lang.Class theClass)
Get the JavaExternalObjectType object representing a particular Java class- Overrides:
getJavaExternalObjectType
in classConfiguration
- Parameters:
theClass
- the class in question- Returns:
- the corresponding JavaExternalObjectType
-
makeMethodMap
public java.util.Map<java.lang.String,Function> makeMethodMap(java.lang.Class javaClass, java.lang.String required)
Make a map representing the methods defined in a class. This map is specific to the class, not to a particular instance. The functions present in this map take an extra first argument representing the target instance; the functions returned in the final instance-level map will be partial applications of the functions in the class-level map.- Overrides:
makeMethodMap
in classConfiguration
- Parameters:
javaClass
- the Java class whose methods are requiredrequired
- if non-null, indicates the key of the entry that is required in the map. If this parameter is supplied, then the map will be limited to a single entry with this key, since it is known that the other entries would never be used- Returns:
- a map whose entries represent public instance-level methods in the supplied Java class, to the extent that these methods have unique names.
-
externalObjectAsMap
public MapItem externalObjectAsMap(ObjectValue value, java.lang.String required)
Convert a Java object to a map- Overrides:
externalObjectAsMap
in classConfiguration
- Parameters:
value
- the (wrapped) Java object to be convertedrequired
- if non-null, indicates the key of the entry that is required in the map. If this parameter is supplied, then the map will be limited to a single entry with this key, since it is known that the other entries would never be used.- Returns:
- an XDM map containing entries representing the public instance-level methods available in the object, to the extent that they have unique names.
-
makeObjectLookupExpression
public Expression makeObjectLookupExpression(Expression lhs, Expression rhs) throws XPathException
Make an object lookup expression: supports the construct X?Y where X is an external Java object. Requires Saxon-PE or higher- Overrides:
makeObjectLookupExpression
in classConfiguration
- Parameters:
lhs
- the left-hand operandrhs
- the right-hand operand- Returns:
- the constructed expression
- Throws:
XPathException
- if anything goes wrong
-
resolveSource
public javax.xml.transform.Source resolveSource(javax.xml.transform.Source source, Configuration config) throws XPathException
Resolve a Source.- Specified by:
resolveSource
in interfaceSourceResolver
- Overrides:
resolveSource
in classConfiguration
- Parameters:
source
- A source object, typically the source supplied as the first argument toTransformer.transform(javax.xml.transform.Source, javax.xml.transform.Result)
or similar methods.config
- The Configuration. This provides the SourceResolver with access to configuration information; it also allows the SourceResolver to invoke the resolveSource() method on the Configuration object as a fallback implementation.- Returns:
- a source object that Saxon knows how to process. This must be an instance of one
of the classes StreamSource, SAXSource, DOMSource,
AugmentedSource
,NodeInfo
, orPullSource
. Return null if the Source object is not recognized - Throws:
XPathException
- if the Source object is recognized but cannot be processed
-
makeMode
public SimpleMode makeMode(StructuredQName modeName, CompilerInfo compilerInfo)
Make a new Mode - this can be overridden in subclasses to produce optimized variants- Overrides:
makeMode
in classConfiguration
- Parameters:
modeName
- the name of the modecompilerInfo
- information on the compiler, that can alter rule optimization- Returns:
- an instantiated Mode
-
-