示例#1
0
        /// <summary>
        /// Construct an atomic value of a given built-in or user-defined type
        /// </summary>
        /// <example>
        ///   <code>AtomicValue("abcd", QName.XDT_UNTYPED_ATOMIC)</code>
        ///   <para>creates an untyped atomic value containing the string "abcd"</para>
        /// </example>
        /// <param name="lexicalForm">The string representation of the value (any value that is acceptable
        /// in the lexical space, as defined by XML Schema Part 2). Whitespace normalization as defined by
        /// the target type will be applied to the value.</param>
        /// <param name="type">The QName giving the name of the target type. This must be an atomic
        /// type, and it must not be a type that is namespace-sensitive (QName, NOTATION, or types derived
        /// from these). If the type is a user-defined type then its definition must be present
        /// in the schema cache maintained by the <c>SchemaManager</c>.</param>
        /// <param name="processor">The <c>Processor</c> object. This is needed for looking up user-defined
        /// types, and also because some conversions are context-sensitive, for example they depend on the
        /// implicit timezone or the choice of XML 1.0 versus XML 1.1 for validating names.</param>
        /// <exception name="ArgumentException">Thrown if the type is unknown or unsuitable, or if the supplied string is not
        /// a valid lexical representation of a value of the given type.</exception>

        public XdmAtomicValue(String lexicalForm, QName type, Processor processor)
        {
            JConfiguration jconfig = processor.config;
            int            fp      = jconfig.getNamePool().getFingerprint(type.Uri, type.LocalName);

            if (fp == -1)
            {
                throw new ArgumentException("Unknown name " + type);
            }
            JSchemaType st = jconfig.getSchemaType(fp);

            if (st == null)
            {
                throw new ArgumentException("Unknown type " + type);
            }
            if (!(st is JAtomicType))
            {
                throw new ArgumentException("Specified type " + type + " is not atomic");
            }
            if (((JAtomicType)st).isNamespaceSensitive())
            {
                throw new ArgumentException("Specified type " + type + " is namespace-sensitive");
            }
            JAtomicValue result = new StringValue(lexicalForm).convert(
                (JAtomicType)st,
                jconfig.getConversionContext(),
                true);

            if (result is ValidationErrorValue)
            {
                throw new ArgumentException(((ValidationErrorValue)result).getException().getMessage());
            }
            this.value = result;
        }
示例#2
0
文件: XQuery.cs 项目: orbeon/saxon-he
        // internal constructor: the public interface is a factory method
        // on the Processor object

        internal XQueryCompiler(Processor processor)
        {
            this.processor = processor;
            this.config    = processor.config;
            this.env       = config.newStaticQueryContext();
            env.setModuleURIResolver(new DotNetStandardModuleURIResolver(processor.XmlResolver));
        }
示例#3
0
        /// <summary>
        /// Create a new Processor
        /// </summary>

        public Processor()
        {
            config = new JConfiguration();
            config.setURIResolver(new DotNetURIResolver(new XmlUrlResolver()));
            config.setCollectionURIResolver(new DotNetCollectionURIResolver());
            config.registerExternalObjectModel(new DotNetObjectModelDefinition());
        }
示例#4
0
 private bool AssertSerializationMatches(XdmNode assertion, SingleResultDoc result, XPathCompiler catalogXpc)
 {
     if (IsException())
     {
         return(false);
     }
     else
     {
         //string testSet = catalogXpc.Evaluate("string(/*/@name)", assertion).ToString();
         string flagsAtt = assertion.GetAttributeValue(new QName("flags"));
         if (flagsAtt == null)
         {
             flagsAtt = "";
         }
         string regex = assertion.StringValue;
         //IList warnings = new ArrayList();
         try {
             JRegularExpression re = JConfiguration.getPlatform().compileRegularExpression(regex, flagsAtt, "XP30", new java.util.ArrayList());
             if (re.containsMatch(getPrincipalSerializedResult()))
             {
                 return(true);
             }
             else
             {
                 driver.println("Serialized result:");
                 driver.println(getPrincipalSerializedResult());
                 return(false);
             }
         } catch (DynamicError e) {
             throw e;
         }
     }
 }
示例#5
0
 internal JReceiver GetReceiver(JConfiguration config)
 {
     return(config.getSerializerFactory().getReceiver(
                GetResult(),
                config.makePipelineConfiguration(),
                GetOutputProperties()));
 }
示例#6
0
文件: XQuery.cs 项目: orbeon/saxon-he
        // internal constructor: the public interface is a factory method
        // on the Processor object

        internal XQueryCompiler(Processor processor)
        {
            this.processor = processor;
            this.config    = processor.Implementation;
            compiler       = processor.JProcessor.newXQueryCompiler();
            compiler.setModuleURIResolver(new JDotNetStandardModuleURIResolver(processor.XmlResolver));
        }
示例#7
0
		// internal constructor

        internal SchemaManager(Processor processor)
        {
			this.processor = processor;
			this.schemaManager = processor.JProcessor.getSchemaManager();
			this.config = (JConfiguration)processor.Implementation;
            reporter = null;
        }
示例#8
0
        // internal constructor: the public interface is a factory method
        // on the Processor object

        internal XQueryCompiler(Processor processor)
        {
            this.processor = processor;
            this.config = processor.config;
            this.env = config.newStaticQueryContext();
            env.setModuleURIResolver(new DotNetStandardModuleURIResolver(processor.XmlResolver));
        }
示例#9
0
        /// <summary>
        /// Create a Processor, based on configuration information supplied in a configuration file.
        /// </summary>
        /// <remarks>
        /// Not fully supported in this release: for experimental use only.
        /// </remarks>
        /// <param name="configurationFile">A stream holding the text of the XML configuration file. Details of the file format
        /// can be found in the Saxon documentation.</param>
        ///

        public Processor(Stream configurationFile)
        {
            StreamSource ss = new StreamSource(new DotNetInputStream(configurationFile));

            config = JConfiguration.readConfiguration(ss);
            config.registerExternalObjectModel(new DotNetObjectModelDefinition());
            config.setProcessor(this);
        }
示例#10
0
文件: XPath.cs 项目: fidothe/saxon-he
        // internal constructor

        internal XPathSelector(JXPathExpression exp, JConfiguration config, DotNetIndependentContext env)
        {
            this.exp       = exp.getInternalExpression();
            this.config    = config;
            this.env       = env;
            variableValues = new JValueRepresentation[env.getStackFrameMap().getNumberOfVariables()];
            // TODO: there are some reuse issues here if the compiler/static context has been reused
        }
示例#11
0
文件: XPath.cs 项目: orbeon/saxon-he
        //private ArrayList declaredVariables;

        // internal constructor

        internal XPathExecutable(JXPathExpression exp, JConfiguration config,
                                 JIndependentContext env /*, ArrayList declaredVariables*/)
        {
            this.exp    = exp;
            this.config = config;
            this.env    = env;
            //this.declaredVariables = declaredVariables;
        }
示例#12
0
        // internal constructor

        internal SchemaValidator(Processor processor)
        {
            this.config = processor.Implementation;
            Object obj = config.getConfigurationProperty(JFeatureKeys.USE_XSI_SCHEMA_LOCATION);

            useXsiSchemaLocation = ((java.lang.Boolean)obj).booleanValue();
            invalidityHandler    = new net.sf.saxon.lib.StandardInvalidityHandler(processor.Implementation);
        }
示例#13
0
文件: XPath.cs 项目: orbeon/saxon-he
        private ArrayList declaredVariables; // a list of XPathVariable objects

        // internal constructor

        internal XPathSelector(JXPathExpression exp, JConfiguration config,
                               ArrayList declaredVariables)
        {
            this.exp    = exp;
            this.config = config;
            //this.env = env;
            this.declaredVariables = declaredVariables;
            this.dynamicContext    = exp.createDynamicContext(null);
        }
示例#14
0
        internal JReceiver GetReceiver(JConfiguration config)
        {
            JPipelineConfiguration pipe = config.makePipelineConfiguration();

            return(config.getSerializerFactory().getReceiver(
                       GetResult(pipe),
                       pipe,
                       GetOutputProperties(), characterMap));
        }
示例#15
0
        /// <summary>
        /// Create a Processor.
        /// </summary>
        /// <param name="licensedEdition">Set to true if the Processor is to use a licensed edition of Saxon
        /// (that is, Saxon-PE or Saxon-EE). If true, the Processor will attempt to enable the capabilities
        /// of the licensed edition of Saxon, according to the version of the software that is loaded, and will
        /// verify the license key. If false, the Processor will load a default Configuration that gives restricted
        /// capability and does not require a license, regardless of which version of the software is actually being run.</param>
        /// <param name="loadLocally">This option has no effect at this release.</param>

        public Processor(bool licensedEdition, bool loadLocally)
        {
            if (licensedEdition)
            {
                config        = JConfiguration.newConfiguration();
                schemaManager = new SchemaManager(config);
            }
            else
            {
                config = new JConfiguration();
            }
            config.registerExternalObjectModel(new DotNetObjectModelDefinition());
            config.setProcessor(this);
        }
示例#16
0
文件: XQuery.cs 项目: orbeon/saxon-he
        internal JReceiver GetReceiver(Serializer serializer)
        {
            net.sf.saxon.expr.instruct.Executable executable = exp.getExecutable();
            JConfiguration         config = executable.getConfiguration();
            JPipelineConfiguration pipe   = config.makePipelineConfiguration();

            pipe.setHostLanguage(executable.getHostLanguage());
            JProperties baseProps = new JProperties(executable.getDefaultOutputProperties());

            JCharacterMapIndex charMapIndex = executable.getCharacterMapIndex();
            JCharacterMapIndex characterMap = serializer.GetCharacterMap();

            if (charMapIndex.isEmpty())
            {
                charMapIndex = characterMap;
            }
            else if (characterMap != null && !characterMap.isEmpty() && charMapIndex != characterMap)
            {
                // Merge the character maps
                java.util.Iterator mapIter = characterMap.iterator();
                while (mapIter.hasNext())
                {
                    net.sf.saxon.serialize.CharacterMap map = (net.sf.saxon.serialize.CharacterMap)mapIter.next();
                    charMapIndex.putCharacterMap(map.getName(), map);
                }
            }

            JProperties properties = serializer.GetOutputProperties();

            object [] propSet = properties.entrySet().toArray();

            for (int i = 0; i < properties.size(); i++)
            {
                java.util.Map.Entry             entry = (java.util.Map.Entry)propSet[i];
                net.sf.saxon.om.StructuredQName name  = net.sf.saxon.om.StructuredQName.fromClarkName((String)entry.getKey());
                net.sf.saxon.expr.instruct.ResultDocument.setSerializationProperty(
                    baseProps, name.getURI(), name.getLocalPart(), (String)entry.getValue(), null, true, config);
            }
            serializer.SetDefaultOutputProperties(baseProps);
            serializer.SetCharacterMap(charMapIndex);

            JReceiver target = serializer.GetReceiver(pipe);

            return(target);
        }
示例#17
0
        /// <summary>
        /// Create a Processor, indicating whether it is to be schema-aware.
        /// </summary>
        /// <param name="schemaAware">Set to true if the Processor is to be schema-aware.
        /// This requires the Saxon-SA product to be installed, with a valid license key.</param>
        /// <param name="loadLocally">Set to true if Saxon-SA is to be loaded from the application
        /// directory rather than from the Global Assembly Cache. This option should normally
        /// be set only when troubleshooting, for example when using a locally-patched version
        /// of the software.</param>

        public Processor(bool schemaAware, bool loadLocally)
        {
            if (schemaAware)
            {
                if (loadLocally)
                {
                    Assembly asm = Assembly.Load("saxon8sa");
                }
                else
                {
                    try {
                        int[]        v   = JVersion.getStructuredVersionNumber();
                        AssemblyName asn = new AssemblyName();
                        asn.Name    = "saxon8sa";
                        asn.Version = new Version(v[0], v[1], v[2], v[3]);
                        //asn.Version = new Version(JVersion.getMajorVersion(), JVersion.getMinorVersion());
                        asn.SetPublicKeyToken(new byte[] { 0xe1, 0xfd, 0xd0, 0x02, 0xd5, 0x08, 0x3f, 0xe6 });
                        asn.CultureInfo = new CultureInfo("");
                        Assembly asm = Assembly.Load(asn);
                        // try to load the saxon8sa.dll assembly
                        //Assembly asm = Assembly.Load("saxon8sa, Ver=" + JVersion.getProductVersion() + ".0.1, " +
                        //    @"SN=e1fdd002d5083fe6, Loc=neutral");
                    } catch (Exception e) {
                        Console.WriteLine("Cannot load Saxon-SA software (assembly saxon8sa.dll version " +
                                          JVersion.getProductVersion() + ".0.1)");
                        throw e;
                    }
                }
                config        = JConfiguration.makeSchemaAwareConfiguration(null);
                schemaManager = new SchemaManager(config);
            }
            else
            {
                config = new JConfiguration();
            }
            config.setURIResolver(new DotNetURIResolver(new XmlUrlResolver()));
            config.setCollectionURIResolver(new DotNetCollectionURIResolver());
        }
示例#18
0
        /**
         * Run a test case
         *
         *
         * @param testCase the test case element in the catalog
         * @param xpc      the XPath compiler to be used for compiling XPath expressions against the catalog
         * @
         */

        protected override void runTestCase(XdmNode testCase, XPathCompiler xpc)
        {
            bool          run          = true;
            bool          xpDependency = false;
            string        hostLang;
            string        langVersion;
            Spec          specOpt              = Spec.NULL;
            XPathCompiler xpath                = driverProc.NewXPathCompiler();
            string        testCaseName         = testCase.GetAttributeValue(new QName("name"));
            string        testSetName          = testCase.Parent.GetAttributeValue(new QName("name"));
            bool          needSerializedResult = ((XdmAtomicValue)xpc.EvaluateSingle(
                                                      "exists(./result//assert-serialization-error) or exists(./result//serialization-matches)", testCase)).GetBooleanValue();
            bool needResultValue = true;

            if (needSerializedResult)
            {
                needResultValue = ((XdmAtomicValue)xpc.EvaluateSingle(
                                       "exists(./result//*[not(self::serialization-matches or self::assert-serialization-error or self::any-of or self::all-of)])", testCase)).GetBooleanValue();
            }

            XdmNode alternativeResult = null;
            XdmNode optimization      = null;


            hostLang    = ((SpecAttr)spec.GetAttr()).sname;
            langVersion = ((SpecAttr)spec.GetAttr()).version;


            Environment env = getEnvironment(testCase, xpc);

            if (env == null)
            {
                notrun++;
                return;
            }
            env.xpathCompiler.BackwardsCompatible = false;
            env.processor.XmlVersion = (decimal)1.0;


            //test
            bool icuColCheck = net.sf.saxon.Version.platform.hasICUCollator();
            bool icuNumCheck = net.sf.saxon.Version.platform.hasICUNumberer();

            Console.WriteLine("ICUCol: " + (icuColCheck ? "true" : "false"));
            Console.WriteLine("ICUNum: " + (icuNumCheck ? "true" : "false"));
            //end of test
            foreach (XdmItem dependency in xpc.Evaluate("/*/dependency, ./dependency", testCase))
            {
                string type = ((XdmNode)dependency).GetAttributeValue(new QName("type"));
                if (type == null)
                {
                    // throw new IllegalStateException("dependency/@type is missing"); //TODO
                }
                string value = ((XdmNode)dependency).GetAttributeValue(new QName("value"));
                if (value == null)
                {
                    //throw new IllegalStateException("dependency/@value is missing"); //TODO
                }

                if (type.Equals("spec"))
                {
                    bool applicable = false;
                    if (!value.Contains(((SpecAttr)spec.GetAttr()).sname))
                    {
                        applicable = false;
                    }
                    else if (value.Contains(((SpecAttr)spec.GetAttr()).svname))
                    {
                        applicable = true;
                    }
                    else if (((SpecAttr)spec.GetAttr()).svname.Equals("XQ30") && value.Contains("XQ10+"))
                    {
                        applicable = true;
                    }
                    else if (((SpecAttr)spec.GetAttr()).svname.Equals("XP30") && value.Contains("XP20+"))
                    {
                        applicable = true;
                    }
                    if (!applicable)
                    {
                        writeTestcaseElement(testCaseName, "n/a", "not" + ((SpecAttr)spec.GetAttr()).svname, spec);
                        notrun++;
                        return;
                    }
                }
                if (langVersion.Equals("3.0"))
                {
                    /* EnvironmentVariableResolver resolver = new EnvironmentVariableResolver() {
                     *   public Set<string> getAvailableEnvironmentVariables() {
                     *       Set<string> strings = new HashSet<string>();
                     *       strings.add("QTTEST");
                     *       strings.add("QTTEST2");
                     *       strings.add("QTTESTEMPTY");
                     *       return strings;
                     *   }
                     *
                     *   public string getEnvironmentVariable(string name) {
                     *       if (name.Equals("QTTEST")) {
                     *           return "42";
                     *       } else if (name.Equals("QTTEST2")) {
                     *           return "other";
                     *       } else if (name.Equals("QTTESTEMPTY")) {
                     *           return "";
                     *       } else {
                     *           return null;
                     *       }
                     *   }
                     * }; */
                    //TODO
                    //env.processor.SetProperty(JFeatureKeys.ENVIRONMENT_VARIABLE_RESOLVER, resolver);
                }
                if (type.Equals("feature") && value.Equals("xpath-1.0-compatibility"))
                {
                    hostLang     = "XP";
                    langVersion  = "3.0";
                    xpDependency = true;
                    specOpt      = Spec.XP30;
                }
                if (type.Equals("feature") && value.Equals("namespace-axis"))
                {
                    hostLang     = "XP";
                    langVersion  = "3.0";
                    xpDependency = true;
                    specOpt      = Spec.XP30;
                }
                if (!dependencyIsSatisfied((XdmNode)dependency, env))
                {
                    println("*** Dependency not satisfied: " + ((XdmNode)dependency).GetAttributeValue(new QName("type")));
                    writeTestcaseElement(testCaseName, "n/a", "Dependency not satisfied", spec);
                    run = false;
                    notrun++;
                    return;
                }
            }

            XdmNode exceptionElement;

            try{
                exceptionElement = exceptionsMap[testCaseName];
            } catch (Exception) {
                exceptionElement = null;
            }
            if (exceptionElement != null)
            {
                XdmItem config = xpath.EvaluateSingle("configuration", exceptionElement);

                string runAtt    = exceptionElement.GetAttributeValue(new QName("run"));
                string reasonMsg = xpath.EvaluateSingle("reason", exceptionElement).ToString();
                string reportAtt = exceptionElement.GetAttributeValue(new QName("report"));

                if (config != null)
                {
                    XdmItem paramValue = xpath.EvaluateSingle("param[@name='not-unfolded' and @value='yes']/@name", config);
                    if (unfolded && paramValue != null)
                    {
                        writeTestcaseElement(testCaseName, "notRun", reasonMsg, spec);
                        notrun++;
                        return;
                    }
                }

                if ("false".Equals(runAtt))
                {
                    writeTestcaseElement(testCaseName, reportAtt, reasonMsg, spec);
                    notrun++;
                    return;
                }

                alternativeResult = (XdmNode)xpc.EvaluateSingle("result", exceptionElement);
                optimization      = (XdmNode)xpc.EvaluateSingle("optimization", exceptionElement);
            }

            if (run && (specOpt == Spec.NULL || specOpt == spec))
            {
                TestOutcome outcome = new TestOutcome(this);
                string      exp     = null;
                try
                {
                    exp = xpc.Evaluate("if (test/@file) then unparsed-text(resolve-uri(test/@file, base-uri(.))) else string(test)", testCase).ToString();
                }
                catch (Exception err)
                {
                    println("*** Failed to read query: " + err.Message);
                    outcome.SetException((DynamicError)err);
                }

                //noinspection ThrowableResultOfMethodCallIgnored
                if (outcome.GetException() == null)
                {
                    if (hostLang.Equals("XP") || hostLang.Equals("XT"))
                    {
                        XPathCompiler testXpc = env.xpathCompiler;
                        testXpc.XPathLanguageVersion = langVersion;
                        testXpc.DeclareNamespace("fn", "http://www.w3.org/2005/xpath-functions");
                        testXpc.DeclareNamespace("xs", "http://www.w3.org/2001/XMLSchema");
                        testXpc.DeclareNamespace("map", "http://www.w3.org/2005/xpath-functions/map");
                        //testXpc.DeclareNamespace("math", NamespaceConstant.MATH);
                        //testXpc.DeclareNamespace("Dictionary", NamespaceConstant.Dictionary_FUNCTIONS);

                        try
                        {
                            XPathSelector selector = testXpc.Compile(exp).Load();
                            foreach (QName varName in env.params1.Keys)
                            {
                                selector.SetVariable(varName, env.params1[varName]);
                            }
                            if (env.contextItem != null)
                            {
                                selector.ContextItem = env.contextItem;
                            }
                            selector.InputXmlResolver = new TestUriResolver(env);

                            if (env.unparsedTextResolver != null)
                            {
                                //selector.getUnderlyingXPathContext().setUnparsedTextURIResolver(env.unparsedTextResolver); //TODO
                            }
                            XdmValue result = selector.Evaluate();
                            outcome.SetPrincipalResult(result);
                        }
                        catch (Exception err)
                        {
                            println(err.Message);

                            outcome.SetException(err);
                        }
                    }
                    else if (hostLang.Equals("XQ"))
                    {
                        XQueryCompiler testXqc = env.xqueryCompiler;
                        testXqc.XQueryLanguageVersion = langVersion;
                        testXqc.DeclareNamespace("fn", "http://www.w3.org/2005/xpath-functions");
                        testXqc.DeclareNamespace("xs", "http://www.w3.org/2001/XMLSchema");
                        //testXqc.DeclareNamespace("math", NamespaceConstant.MATH);
                        testXqc.DeclareNamespace("map", "http://www.w3.org/2005/xpath-functions/map");
                        // ErrorCollector errorCollector = new ErrorCollector();
                        testXqc.ErrorList = new ArrayList();
                        string decVars = env.paramDecimalDeclarations.ToString();
                        if (decVars.Length != 0)
                        {
                            int x = (exp.IndexOf("(:%DECL%:)"));
                            if (x < 0)
                            {
                                exp = decVars + exp;
                            }
                            else
                            {
                                exp = exp.Substring(0, x) + decVars + exp.Substring(x + 13);
                            }
                        }
                        string vars = env.paramDeclarations.ToString();
                        if (vars.Length != 0)
                        {
                            int x = (exp.IndexOf("(:%VARDECL%:)"));
                            if (x < 0)
                            {
                                exp = vars + exp;
                            }
                            else
                            {
                                exp = exp.Substring(0, x) + vars + exp.Substring(x + 13);
                            }
                        }
                        ModuleResolver mr = new ModuleResolver(xpc);
                        mr.setTestCase(testCase);
                        //  testXqc.QueryResolver = mr;// .setModuleURIResolver(mr); //TODO
                        testXqc.QueryResolver = mr;
                        try
                        {
                            XQueryExecutable q = testXqc.Compile(exp);
                            if (optimization != null)
                            {
                                // Test whether required optimizations have been performed
                                XdmDestination expDest = new XdmDestination();
                                JConfiguration config  = driverProc.Implementation;
                                //ExpressionPresenter presenter = new ExpressionPresenter(config, expDest.getReceiver(config));
                                //q.getUnderlyingCompiledQuery().explain(presenter);
                                //presenter.close();
                                XdmNode explanation = expDest.XdmNode;
                                XdmItem optResult   = xpc.EvaluateSingle(optimization.GetAttributeValue(new QName("assert")), explanation);
                                if (((XdmAtomicValue)optResult).GetBooleanValue())
                                {
                                    println("Optimization result OK");
                                }
                                else
                                {
                                    println("Failed optimization test");
                                    Serializer ser = new Serializer();
                                    ser.SetOutputStream((Stream)System.Console.OpenStandardError());
                                    driverProc.WriteXdmValue(explanation, ser);
                                    writeTestcaseElement(testCaseName, "fail", "Failed optimization assertions", spec);
                                    failures++;
                                    return;
                                }
                            }
                            XQueryEvaluator selector = q.Load();
                            foreach (QName varName in env.params1.Keys)
                            {
                                selector.SetExternalVariable(varName, env.params1[varName]);
                            }
                            if (env.contextItem != null)
                            {
                                selector.ContextItem = env.contextItem;
                            }
                            selector.InputXmlResolver = env;
                            //selector.InputXmlResolver =  .SetURIResolver(new TestURIResolver(env)); //TODO
                            if (env.unparsedTextResolver != null)
                            {
                                selector.Implementation.setUnparsedTextURIResolver(env.unparsedTextResolver);// TODO
                            }
                            if (needSerializedResult)
                            {
                                StringWriter sw         = new StringWriter();
                                Serializer   serializer = new Serializer(); //env.processor.NewSerializer(sw); //TODO
                                serializer.SetOutputWriter(sw);
                                selector.Run(serializer);
                                outcome.SetPrincipalSerializedResult(sw.ToString());
                            }
                            if (needResultValue)
                            {
                                XdmValue result = selector.Evaluate();
                                outcome.SetPrincipalResult(result);
                            }
                        }
                        catch (Exception err)
                        {
                            println("in TestSet " + testSetName + err.StackTrace);
                            println(err.Message);
                            outcome.SetException(err);
                            outcome.SetErrorsReported((IList)testXqc.ErrorList);
                        }
                    }
                    else
                    {
                        writeTestcaseElement(testCaseName, "notRun", "No processor found", spec);
                        notrun++;
                        return;
                    }
                }

                if (env.resetAction != null)
                {
                    env.resetAction.reset(env);
                }
                XdmNode assertion;
                if (alternativeResult != null)
                {
                    assertion = (XdmNode)xpc.EvaluateSingle("*[1]", alternativeResult);
                }
                else
                {
                    assertion = (XdmNode)xpc.EvaluateSingle("result/*[1]", testCase);
                }
                if (assertion == null)
                {
                    println("*** No assertions found for test case " + testCaseName);
                    writeTestcaseElement(testCaseName, "disputed", "No assertions in test case", spec);
                    feedback.Feedback(successes, failures++, total);
                    return;
                }
                XPathCompiler assertXpc = env.processor.NewXPathCompiler();
                assertXpc.XPathLanguageVersion = "3.1";
                assertXpc.DeclareNamespace("fn", "http://www.w3.org/2005/xpath-functions");
                assertXpc.DeclareNamespace("xs", "http://www.w3.org/2001/XMLSchema");
                assertXpc.DeclareNamespace("math", "http://www.w3.org/2005/xpath-functions/math");
                assertXpc.DeclareNamespace("MAP_FUNCTIONS", "http://www.w3.org/2005/xpath-functions/map");
                assertXpc.DeclareVariable(new QName("result"));

                bool b = outcome.TestAssertion(assertion, outcome.GetPrincipalResultDoc(), assertXpc, xpc, debug);
                if (b)
                {
                    //println("OK");
                    writeTestcaseElement(testCaseName, "pass", null, spec);
                    feedback.Feedback(successes++, failures, total);
                }
                else
                {
                    if (outcome.IsException())
                    {
                        XdmItem expectedError = xpc.EvaluateSingle("result//error/@code", testCase);

                        if (expectedError == null)
                        {
                            //                        if (debug) {
                            //                            outcome.getException().printStackTrace(System.out);
                            //                        }

                            writeTestcaseElement(testCaseName, "fail", "Expected success, got ", spec);
                            println("*** fail, result " + outcome.GetException() +
                                    " Expected success.");
                            feedback.Feedback(successes, failures++, total);
                        }
                        else
                        {
                            writeTestcaseElement(testCaseName, "wrongError",
                                                 "Expected error:" + expectedError.ToString() + ", got " + outcome.GetErrorCode().LocalName, spec);
                            println("*** fail, result " + outcome.GetErrorCode().LocalName +
                                    " Expected error:" + expectedError.ToString());
                            wrongErrorResults++;
                            feedback.Feedback(successes++, failures, total);
                        }
                    }
                    else
                    {
                        writeTestcaseElement(testCaseName, "fail", "Wrong results, got " +
                                             truncate(outcome.Serialize(assertXpc.Processor, outcome.GetPrincipalResultDoc())), spec);
                        feedback.Feedback(successes, failures++, total);
                        if (debug)
                        {
                            try
                            {
                                println("Result:");
                                driverProc.WriteXdmValue(outcome.GetPrincipalResult(), driverSerializer);
                                println("<=======");
                            }
                            catch (Exception err)
                            {
                            }
                            //println(outcome.getResult());
                        }
                        else
                        {
                            println("*** fail (use -debug to show actual result)");
                            //failures++;
                        }
                    }
                }
            }
        }
示例#19
0
        /// <summary>
        /// Create a new Processor. This Processor will have capabilities that depend on the version
        /// of the software that has been loaded, and on the features that have been licensed.
        /// </summary>

        public Processor()
        {
            config = JConfiguration.newConfiguration();
            config.registerExternalObjectModel(new DotNetObjectModelDefinition());
            config.setProcessor(this);
        }
示例#20
0
 internal DocumentBuilder(Processor processor)
 {
     this.processor   = processor;
     this.config      = processor.Implementation;
     this.xmlResolver = new XmlUrlResolver();
 }
示例#21
0
文件: Schema.cs 项目: orbeon/saxon-he
        // internal constructor

        internal SchemaValidator(JSchemaValidator validator, Processor processor)
        {
            this.processor       = processor;
            this.schemaValidator = validator;
            this.config          = processor.Implementation;
        }
示例#22
0
文件: XPath.cs 项目: orbeon/saxon-he
        // internal constructor: the public interface is a factory method
        // on the Processor object

        internal XPathCompiler(Processor proc)
        {
            this.processor = proc;
            this.config    = proc.Implementation;
            this.env       = new JIndependentContext(config);
        }
示例#23
0
        /// <summary>
        /// Create a new Processor
        /// </summary>

        public Processor()
        {
            config = new JConfiguration();
            config.setURIResolver(new DotNetURIResolver(new XmlUrlResolver()));
            config.setCollectionURIResolver(new DotNetCollectionURIResolver());
        }
        // internal constructor

        internal XPathExecutable(JXPathExpression exp, JConfiguration config, DotNetIndependentContext env) {
            this.exp = exp;
            this.config = config;
            this.env = env;
        }
        // internal constructor: the public interface is a factory method
        // on the Processor object

        internal XPathCompiler(JConfiguration config) {
            this.config = config;
            this.env = new DotNetIndependentContext(config);
        }
示例#26
0
 /// <summary>
 /// Gets the receiver.
 /// </summary>
 /// <param name="config">Config.The Saxon configuration. This is supplied so that the destination can
 /// use information from the <code>Configuration</code> (for example, a reference to the name pool)
 /// to construct or configure the returned Receiver.</param>
 /// <returns>The receiver.</returns>
 public JReceiver GetReceiver(JConfiguration config)
 {
     builder.setPipelineConfiguration(config.makePipelineConfiguration());
     return(builder);
 }
示例#27
0
        /// <summary>Set the Processor associated with this Serializer. This will be called automatically if the
        /// serializer is created using one of the <c>Processor.NewSerializer()</c> methods.</summary>
        /// <param name="processor"> processor the associated Processor</param>

        public void SetProcessor(Processor processor)
        {
            this.config = processor.Implementation;
        }
示例#28
0
文件: XPath.cs 项目: nuxleus/saxonica
        // internal constructor: the public interface is a factory method
        // on the Processor object

        internal XPathCompiler(Processor proc)
        {
            this.processor = proc;
            this.config = proc.config;
            this.env = new JIndependentContext(config);
        }
示例#29
0
文件: Model.cs 项目: nuxleus/saxonica
        /// <summary>
        /// Get the internal Saxon fingerprint of this name
        /// </summary>
        /// <param name="config">The Saxon configuration (the fingerprint for a QName is different in different configurations)</param>
        /// <returns>
        /// The integer fingerprint of the name
        /// </returns>

        internal int GetFingerprint(JConfiguration config)
        {
            JNamePool namePool = config.getNamePool();
            if (fingerprint != -1 && pool == namePool)
            {
                return fingerprint;
            }
            return namePool.allocate(prefix, uri, local) & 0xfffff;
        }
示例#30
0
文件: XPath.cs 项目: nuxleus/saxonica
        //private ArrayList declaredVariables;

        // internal constructor

        internal XPathExecutable(JXPathExpression exp, JConfiguration config,
            JIndependentContext env /*, ArrayList declaredVariables*/)
        {
            this.exp = exp;
            this.config = config;
            this.env = env;
            //this.declaredVariables = declaredVariables;
        }
示例#31
0
文件: XPath.cs 项目: fidothe/saxon-he
        // internal constructor

        internal XPathExecutable(JXPathExpression exp, JConfiguration config, DotNetIndependentContext env)
        {
            this.exp    = exp;
            this.config = config;
            this.env    = env;
        }
示例#32
0
文件: XPath.cs 项目: orbeon/saxon-he
        // internal constructor: the public interface is a factory method
        // on the Processor object

        internal XPathCompiler(JConfiguration config)
        {
            this.config = config;
            this.env    = new JIndependentContext(config);
        }
示例#33
0
        // internal constructor: the public interface is a factory method
        // on the Processor object

        internal SchemaManager(net.sf.saxon.Configuration config)
        {
            this.config = (JConfiguration)config;
        }
示例#34
0
文件: XPath.cs 项目: nuxleus/saxonica
        private ArrayList declaredVariables; // a list of XPathVariable objects

        // internal constructor

        internal XPathSelector(JXPathExpression exp, JConfiguration config,
            ArrayList declaredVariables)
        {
            this.exp = exp;
            this.config = config;
            //this.env = env;
            this.declaredVariables = declaredVariables;
            this.dynamicContext = exp.createDynamicContext(null);
        }
 internal DocumentBuilder(Processor processor) {
     this.processor = processor;
     this.config = processor.Implementation;
 }
        /// <summary>
        /// Create a Processor, indicating whether it is to be schema-aware.
        /// </summary>
        /// <param name="schemaAware">Set to true if the Processor is to be schema-aware.
        /// This requires the Saxon-SA product to be installed, with a valid license key.</param>
        /// <param name="loadLocally">Set to true if Saxon-SA is to be loaded from the application
        /// directory rather than from the Global Assembly Cache. This option should normally
        /// be set only when troubleshooting, for example when using a locally-patched version
        /// of the software.</param>

        public Processor(bool schemaAware, bool loadLocally) {
            if (schemaAware) {
                if (loadLocally) {
                    Assembly asm = Assembly.Load("saxon8sa");
                } else {
                    try {
                        int[] v = JVersion.getStructuredVersionNumber();
                        AssemblyName asn = new AssemblyName();
                        asn.Name = "saxon8sa";
                        asn.Version = new Version(v[0], v[1], v[2], v[3]);
                        //asn.Version = new Version(JVersion.getMajorVersion(), JVersion.getMinorVersion());
                        asn.SetPublicKeyToken(new byte[] { 0xe1, 0xfd, 0xd0, 0x02, 0xd5, 0x08, 0x3f, 0xe6 });
                        asn.CultureInfo = new CultureInfo("");
                        Assembly asm = Assembly.Load(asn);
                        // try to load the saxon8sa.dll assembly
                        //Assembly asm = Assembly.Load("saxon8sa, Ver=" + JVersion.getProductVersion() + ".0.1, " +
                        //    @"SN=e1fdd002d5083fe6, Loc=neutral");
                    } catch (Exception e) {
                        Console.WriteLine("Cannot load Saxon-SA software (assembly saxon8sa.dll version " +
                            JVersion.getProductVersion() + ".0.1)");
                        throw e;
                    }
                }
                config = JConfiguration.makeSchemaAwareConfiguration(null);
                schemaManager = new SchemaManager(config);
            } else {
                config = new JConfiguration();
            }
            config.setURIResolver(new DotNetURIResolver(new XmlUrlResolver()));
            config.setCollectionURIResolver(new DotNetCollectionURIResolver());
        }
示例#37
0
 public void setConfiguration(JConfiguration config)
 {
     this.config = config;
 }
        // internal constructor

        internal XPathSelector(JXPathExpression exp, JConfiguration config, DotNetIndependentContext env) {
            this.exp = exp.getInternalExpression();
            this.config = config;
            this.env = env;
            variableValues = new JValueRepresentation[env.getStackFrameMap().getNumberOfVariables()];
            // TODO: there are some reuse issues here if the compiler/static context has been reused
        }
        /// <summary>
        /// Create a new Processor
        /// </summary>

        public Processor() {
            config = new JConfiguration();
            config.setURIResolver(new DotNetURIResolver(new XmlUrlResolver()));
            config.setCollectionURIResolver(new DotNetCollectionURIResolver());
        }
        internal JReceiver GetReceiver(JConfiguration config) {
            return config.getSerializerFactory().getReceiver(
                    GetResult(),
                    config.makePipelineConfiguration(),
                    GetOutputProperties());

        }
示例#41
0
 internal DocumentBuilder(Processor processor)
 {
     this.processor = processor;
     this.config    = processor.Implementation;
 }
示例#42
0
 /**
  * <summary>Set the Processor associated with this Serializer. This will be called automatically if the
  * serializer is created using one of the <c>Processor.NewSerializer()</c> methods.</summary>
  *
  * <param name="processor"> processor the associated Processor</param>
  */
 public void SetProcessor(Processor processor)
 {
     this.config = processor.config;
 }