Esempio n. 1
0
        private XQuerySettings GetStaticContextSettings()
        {
            var staticSettings = new XQuerySettings(NameTable)
            {
                OptimizationLevel   = GetOptimizationLevel(),
                TypeCheckingMode    = GetTypeCheckingMode(),
                Schemas             = SchemaSet,
                ContextItemType     = GetContextItemType(),
                CompilationWarnings =
                    CompilationWarnings.DynamicErrors | CompilationWarnings.EmptySequence |
                    CompilationWarnings.ScriptCompilationWarning,
                ModuleResolver = XmlResolver,
                XmlVersion     = GetXmlVersion(),
                EnableScript   = true,
                CodeGeneration =
                    EnableByteCode ? CodeGeneration.DynamicMethods : CodeGeneration.None,
                XQueryVersion = GetXQueryVersion()
            };

            staticSettings.CompilationError += OnCompilationError;

            staticSettings.ImportModule(XdmModule.ExtensionFunctions);

            var baseUri = new Uri(Path.GetFullPath(Directory.GetCurrentDirectory() + Path.DirectorySeparatorChar));

            staticSettings.BaseURI = new AnyUri(baseUri);

            return(staticSettings);
        }
Esempio n. 2
0
        private XQuery CompileQuery([NotNull] XQuerySettings staticSettings)
        {
            Assert.ArgumentNotNull(staticSettings, "staticSettings");

            var path = XQuery.GetMetadata("FullPath");

            using (var file = File.Open(path, FileMode.Open, FileAccess.Read, FileShare.Read))
                return(XmlPrime.XQuery.Compile(file, staticSettings));
        }