Exemple #1
0
        void RegisterExtensionFunctions(Processor processor, SaxonItemFactory itemFactory)
        {
            ExtensionFunctionDefinition[] precompiledFunctions =
                extensions.exslt.common.Index.GetFunctions()
                .Concat(extensions.w3c.xpath.math.Index.GetFunctions())
                .Concat(extensions.saxon.Index.GetFunctions(itemFactory))
                .ToArray();

            bool[] funcAvailable = FunctionsAvailable(precompiledFunctions.Select(d => d.FunctionName).ToArray(), processor, itemFactory);

            for (int i = 0; i < precompiledFunctions.Length; i++)
            {
                if (!funcAvailable[i])
                {
                    processor.RegisterExtensionFunction(precompiledFunctions[i]);
                }
            }

            Type itemFactoryType = itemFactory.GetType();

            var fnGen = new IntegratedExtensionFunctionGenerator();

            foreach (Type t in fnGen.Generate(XPathModules.Modules))
            {
                ConstructorInfo ctor = t.GetConstructors().First();

                object[] args = ctor.GetParameters().Select(p =>
                                                            p.ParameterType.IsAssignableFrom(typeof(SaxonProcessor)) ? (object)this
               : p.ParameterType.IsAssignableFrom(itemFactoryType) ? (object)itemFactory
               : null
                                                            ).ToArray();

                var def = (ExtensionFunctionDefinition)ctor.Invoke(args);

                processor.RegisterExtensionFunction(def);
            }
        }
Exemple #2
0
        void RegisterExtensionFunctions(Processor processor, SaxonItemFactory itemFactory)
        {
            ExtensionFunctionDefinition[] precompiledFunctions =
            extensions.exslt.common.Index.GetFunctions()
            .Concat(extensions.w3c.xpath.math.Index.GetFunctions())
            .Concat(extensions.saxon.Index.GetFunctions(itemFactory))
            .ToArray();

             bool[] funcAvailable = FunctionsAvailable(precompiledFunctions.Select(d => d.FunctionName).ToArray(), processor, itemFactory);

             for (int i = 0; i < precompiledFunctions.Length; i++) {

            if (!funcAvailable[i]) {
               processor.RegisterExtensionFunction(precompiledFunctions[i]);
            }
             }

             Type itemFactoryType = itemFactory.GetType();

             var fnGen = new IntegratedExtensionFunctionGenerator();

             foreach (Type t in fnGen.Generate(XPathModules.Modules)) {

            ConstructorInfo ctor = t.GetConstructors().First();

            object[] args = ctor.GetParameters().Select(p =>
               p.ParameterType.IsAssignableFrom(typeof(SaxonProcessor)) ? (object)this
               : p.ParameterType.IsAssignableFrom(itemFactoryType) ? (object)itemFactory
               : null
            ).ToArray();

            var def = (ExtensionFunctionDefinition)ctor.Invoke(args);

            processor.RegisterExtensionFunction(def);
             }
        }