Project

Profile

Help

Revision e5cb4f89

Added by Michael Kay 10 months ago

Fix bug (feature) #4775

View differences:

latest10/hej/net/sf/saxon/Configuration.java
162 162
    private IntSet enabledProperties = new IntHashSet(64);
163 163

  
164 164
    private List<ExternalObjectModel> externalObjectModels = new ArrayList<>(4);
165
    protected IndependentContext staticContextForSystemFunctions;
165 166

  
166 167
    private DocumentPool globalDocumentPool = new DocumentPool();
167 168
    private IntegratedFunctionLibrary integratedFunctionLibrary = new IntegratedFunctionLibrary();
......
1511 1512
     * @param arity the arity of the required function
1512 1513
     * @return the requested function, or null if there is no such function. Note that some functions
1513 1514
     * (those with particular context dependencies) may be unsuitable for dynamic calling.
1514
     * @throws XPathException if dynamic function calls are not permitted by this Saxon Configuration
1515 1515
     */
1516 1516

  
1517
    public Function getSystemFunction(StructuredQName name, int arity) throws XPathException {
1518
        throw new XPathException("Dynamic functions require Saxon-PE or higher");
1517
    public Function getSystemFunction(StructuredQName name, int arity)  {
1518
        try {
1519
            if (staticContextForSystemFunctions == null) {
1520
                staticContextForSystemFunctions = new IndependentContext(this);
1521
            }
1522
            FunctionLibraryList lib = new FunctionLibraryList();
1523
            lib.addFunctionLibrary(XPath31FunctionSet.getInstance());
1524
            lib.addFunctionLibrary(getBuiltInExtensionLibraryList());
1525
            lib.addFunctionLibrary(new ConstructorFunctionLibrary(this));
1526
            lib.addFunctionLibrary(getIntegratedFunctionLibrary());
1527
            SymbolicName.F symbolicName = new SymbolicName.F(name, arity);
1528
            return lib.getFunctionItem(symbolicName, staticContextForSystemFunctions);
1529
        } catch (XPathException e) {
1530
            return null;
1531
        }
1519 1532
    }
1520 1533

  
1521 1534
    /**
latest10/hej/net/sf/saxon/s9api/XdmFunctionItem.java
72 72
     * function, provided a licensed Processor is used.
73 73
     * @return the requested function, or null if there is no such function. Note that some functions
74 74
     * (those with particular context dependencies) may be unsuitable for dynamic calling.
75
     * @throws SaxonApiException if dynamic function calls are not permitted by this Saxon Configuration
75
     * @throws SaxonApiException no longer thrown, but retained in the declaration for backwards compatibility
76 76
     */
77 77

  
78 78
    public static XdmFunctionItem getSystemFunction(Processor processor, QName name, int arity) throws SaxonApiException {
79
        try {
80
            Configuration config = processor.getUnderlyingConfiguration();
81
            Function f = config.getSystemFunction(name.getStructuredQName(), arity);
82
            return f==null ? null : new XdmFunctionItem(f);
83
        } catch (XPathException e) {
84
            throw new SaxonApiException(e);
85
        }
79
        Configuration config = processor.getUnderlyingConfiguration();
80
        Function f = config.getSystemFunction(name.getStructuredQName(), arity);
81
        return f==null ? null : new XdmFunctionItem(f);
86 82
    }
87 83

  
88 84
    /**

Also available in: Unified diff