Package com.saxonica.config

Examples of com.saxonica.config.EnterpriseConfiguration


//            parser = SAXParserFactory.newInstance().newSAXParser().getXMLReader();
//            if (!parser.getFeature("http://xml.org/sax/features/xml-1.1")) {
//                System.err.println("Warning: XML parser does not support XML 1.1 - " + parser.getClass());
//            };
            NamePool pool = new NamePool();
            saConfig = new EnterpriseConfiguration();
            saConfig.setNamePool(pool);
            saConfig.setHostLanguage(Configuration.XQUERY);
            //saConfig.setSourceParserClass("com.sun.org.apache.xerces.internal.parsers.SAXParser");
            XMLReader parser = saConfig.getSourceParser();
View Full Code Here


                "' options='" + options + "' when='" + when + "'>");

        for (int f=0; f<tests.length; f++) {
            File file = new File(dir + tests[f]);

            Configuration config = (saproduct ? new EnterpriseConfiguration() : new Configuration());
            if (lazy) {
                config.setLazyConstructionMode(true);
            }
            if (satests) {
                config.setSchemaValidationMode(Validation.STRICT);
View Full Code Here

        }

        try {

            NamePool pool = new NamePool();
            catalogConfig = new EnterpriseConfiguration();
            catalogConfig.setNamePool(pool);
            catalogConfig.setHostLanguage(Configuration.XML_SCHEMA);
            parser = catalogConfig.getSourceParser();

            xlinkHref = pool.allocate("", "http://www.w3.org/1999/xlink", "href");

            int testCaseFP = pool.allocate("", "", "testcase") & NamePool.FP_MASK;
            NameTest testCaseNT = new NameTest(Type.ELEMENT, testCaseFP, pool);
            int commentFP = pool.allocate("", "", "comment") & NamePool.FP_MASK;
            NameTest commentNT = new NameTest(Type.ELEMENT, commentFP, pool);

            NameTest testSetRefNT = elementNameTest(pool, "testSetRef");
            NameTest testGroupNT = elementNameTest(pool, "testGroup");
            NameTest testSetNT = elementNameTest(pool, "testSet");
            NameTest schemaTestNT = elementNameTest(pool, "schemaTest");
            NameTest instanceTestNT = elementNameTest(pool, "instanceTest");
            NameTest schemaDocumentNT = elementNameTest(pool, "schemaDocument");
            NameTest instanceDocumentNT = elementNameTest(pool, "instanceDocument");
            NameTest expectedNT = elementNameTest(pool, "expected");
            NameTest currentNT = elementNameTest(pool, "current");

            int validityAtt = pool.allocate("", "", "validity") & NamePool.FP_MASK;
            int nameAtt = pool.allocate("", "", "name") & NamePool.FP_MASK;
            int contributorAtt = pool.allocate("", "", "contributor") & NamePool.FP_MASK;
            int setAtt = pool.allocate("", "", "set") & NamePool.FP_MASK;
            int groupAtt = pool.allocate("", "", "group") & NamePool.FP_MASK;
            int statusAtt = pool.allocate("", "", "status") & NamePool.FP_MASK;
            int bugzillaAtt = pool.allocate("", "", "bugzilla") & NamePool.FP_MASK;
            int targetNamespaceAtt = pool.allocate("", "", "targetNamespace") & NamePool.FP_MASK;
            int schemaVersionAtt = pool.allocate("saxon", NamespaceConstant.SAXON, "schemaVersion") & NamePool.FP_MASK;


            DocumentInfo catalog = catalogConfig.buildDocument(
                    new StreamSource(new File(testSuiteDir + "/suite.xml"))
            );

            results = new BufferedWriter(new FileWriter(new File(testSuiteDir + "/SaxonResults"
                        + Version.getProductVersion() + ".xml")));

            results.write("<testSuiteResults xmlns='" + testNS + "' xmlns:saxon='http://saxon.sf.net/' " +
                    "suite='TS_2006' " +
                    "processor='Saxon-EE (Java) 9.2' submitDate='2007-01-05' publicationPermission='public'>\n");

            DocumentInfo exceptionsDoc = catalogConfig.buildDocument(
                    new StreamSource(new File(testSuiteDir + "/exceptions.xml"))
            );

            AxisIterator exceptionTestCases = exceptionsDoc.iterateAxis(Axis.DESCENDANT, testCaseNT);
            while (true) {
                NodeInfo testCase = (NodeInfo)exceptionTestCases.next();
                if (testCase == null) {
                    break;
                }
                String set = testCase.getAttributeValue(setAtt);
                String group = testCase.getAttributeValue(groupAtt);
                String comment = getChildElement(testCase, commentNT).getStringValue();
                exceptions.put(set + "#" + group, comment);
            }

            long startTime = (new Date()).getTime();

            AxisIterator testSets = catalog.iterateAxis(Axis.DESCENDANT, testSetRefNT);
            while (true) {
                NodeInfo testSetRef = (NodeInfo)testSets.next();
                if (testSetRef == null) {
                    break;
                }

                DocumentInfo testSetDoc = getLinkedDocument(testSetRef, catalogConfig, false);
                NodeInfo testSetElement = getChildElement(testSetDoc, testSetNT);

                if (testSetElement == null) {
                    System.err.println("test set doc has no TestSet child: " + testSetDoc.getBaseURI());
                    continue;
                }

                String testSetName = testSetElement.getAttributeValue(nameAtt);
                System.err.println("Test set " + testSetName);
                if (testSetPattern != null && !testSetPattern.matcher(testSetName).matches()) {
                    continue;
                }
                if (contributor != null && !contributor.equals(testSetElement.getAttributeValue(contributorAtt))) {
                    continue;
                }

                boolean allow11throughout = "1.1".equals(testSetElement.getAttributeValue(schemaVersionAtt));

                AxisIterator testGroups = testSetElement.iterateAxis(Axis.CHILD, testGroupNT);
                while (true) {
                    NodeInfo testGroup = (NodeInfo)testGroups.next();
                    if (testGroup == null) {
                        break;
                    }

                    boolean allow11here = "1.1".equals(testGroup.getAttributeValue(schemaVersionAtt));
                    String testGroupName = testGroup.getAttributeValue(nameAtt);
                    String exception = (String)exceptions.get(testSetName + "#" + testGroupName);

                    if (testGroupPattern != null && !testGroupPattern.matcher(testGroupName).matches()) {
                        continue;
                    }
                    System.err.println("TEST SET " + testSetName + " GROUP " + testGroupName);
                    if (onwards) {
                        testGroupPattern = null;
                        testSetPattern = null;
                    }
                    EnterpriseConfiguration testConfig = new EnterpriseConfiguration();
                    testConfig.setHostLanguage(Configuration.XML_SCHEMA);
                    testConfig.setValidationWarnings(true);
                    if (allow11throughout || allow11here) {
                        testConfig.setConfigurationProperty(FeatureKeys.XSD_VERSION, "1.1");
                    }
                    AxisIterator schemaTests = testGroup.iterateAxis(Axis.CHILD, schemaTestNT);
                    boolean schemaQueried = false;
                    String bugzillaRef = null;
View Full Code Here

        return success;
    }

    private boolean loadSchemasViaSCM(NameTest schemaDocumentNT, int targetNamespaceAtt, EnterpriseConfiguration testConfig, NodeInfo schemaTest, boolean success)
    throws XPathException, URISyntaxException {
        EnterpriseConfiguration tempConfig = new EnterpriseConfiguration();
        String xsdVersion = (String)testConfig.getConfigurationProperty(FeatureKeys.XSD_VERSION);
        tempConfig.setConfigurationProperty(FeatureKeys.XSD_VERSION, xsdVersion);
        AxisIterator schemata = schemaTest.iterateAxis(Axis.CHILD, schemaDocumentNT);
        while (true) {
            NodeInfo schemaDocumentRef = (NodeInfo)schemata.next();
            if (schemaDocumentRef == null) {
                break;
            }
            System.err.println("Loading schema at " + schemaDocumentRef.getAttributeValue(xlinkHref));
            DocumentInfo schemaDoc = getLinkedDocument(schemaDocumentRef, testConfig, false);
            NodeInfo schemaElement =
                    (NodeInfo)schemaDoc.iterateAxis(Axis.CHILD, NodeKindTest.ELEMENT).next();
            String targetNamespace = schemaElement.getAttributeValue(targetNamespaceAtt);
            if (targetNamespace != null && tempConfig.isSchemaAvailable(targetNamespace)) {
                // do nothing
            } else {
                try {
                    tempConfig.addSchemaSource(schemaDoc); // TODO: use an ErrorListener
                } catch (SchemaException err) {
                    return false;
                }
            }
        }
        try {
            StringWriter sw = new StringWriter();
            Result result = new StreamResult(sw);
            Receiver serializer = tempConfig.getSerializerFactory().getReceiver(
                    result, tempConfig.makePipelineConfiguration(), new Properties());

            tempConfig.exportComponents(serializer);
            String scm = sw.toString();
            try {
                scmValidator.validate(new StreamSource(new StringReader(scm)));
            } catch (SaxonApiException e) {
                System.err.println("*** SCM does not validate against schema for SCM ***");
 
View Full Code Here

                            return new InputSource(new StringReader(""));
                        }
                    }
            );
            fragmentParser = config.getSourceParser();
            EnterpriseConfiguration sconfig = new EnterpriseConfiguration();
            sconfig.setExtensionElementNamespace(
                        NamespaceConstant.SQL, "net.sf.saxon.option.sql.SQLElementFactory");
            ProfessionalConfiguration pconfig = new ProfessionalConfiguration();
            pconfig.setExtensionElementNamespace(
                        NamespaceConstant.SQL, "net.sf.saxon.option.sql.SQLElementFactory");
            EnterpriseConfiguration sasconfig = new EnterpriseConfiguration();
            Configuration config11 = new Configuration();
            config11.setXMLVersion(Configuration.XML11);
            config.setNamePool(pool);
            sconfig.setNamePool(pool);
            pconfig.setNamePool(pool);
View Full Code Here

        StreamResult sr = new StreamResult(new File(out));
        TransformerFactory f;
        if (noCacheTests.contains(testName) || testName.startsWith("schemaas20") ||
                testName.startsWith("striptype20") || testName.startsWith("notation20")) {
            f = new EnterpriseTransformerFactory();
            EnterpriseConfiguration sconfig = new EnterpriseConfiguration();
            sconfig.setNamePool(factory.getConfiguration().getNamePool());
            ((EnterpriseTransformerFactory)f).setConfiguration(sconfig);
            f.setAttribute(FeatureKeys.XSLT_SCHEMA_AWARE, true);
        } else {
            if (schemaAware) {
                f = sfactory;
View Full Code Here

     * Validate a document that is supplied via the pull interface
     * (This requires the schema-aware version of Saxon)
     */

    public void validate(PullProvider in) throws XPathException, IOException {
        EnterpriseConfiguration config = new EnterpriseConfiguration();
        in.getPipelineConfiguration().setConfiguration(config);
        in.getPipelineConfiguration().setSchemaURIResolver(config.getSchemaURIResolver());
        Receiver sink = new Sink();
        sink.setPipelineConfiguration(in.getPipelineConfiguration());
        Receiver validator = config.getDocumentValidator(
                sink, in.getSourceLocator().getSystemId(), Validation.STRICT, Whitespace.NONE, null, -1);
        validator.setPipelineConfiguration(in.getPipelineConfiguration());
        //in = new PullTracer(in);
        new PullPushCopier(in, validator).copy();
        System.out.println("Done.");
View Full Code Here

                "' options='" + options + "' when='" + when + "'>");

        for (int f=0; f<tests.length; f++) {
            File file = new File(dir + tests[f]);

            Configuration config = (saproduct ? new EnterpriseConfiguration() : new Configuration());
            if (lazy) {
                config.setLazyConstructionMode(true);
            }
            if (satests) {
                config.setSchemaValidationMode(Validation.STRICT);
View Full Code Here

     * Validate a document that is supplied via the pull interface
     * (This requires the schema-aware version of Saxon)
     */

    public void validate(PullProvider in) throws XPathException, IOException {
        EnterpriseConfiguration config = new EnterpriseConfiguration();
        PipelineConfiguration pipe = in.getPipelineConfiguration();
        pipe.setConfiguration(config);
        pipe.setSchemaURIResolver(config.getSchemaURIResolver());
        Receiver sink = new Sink(pipe);
        Receiver validator = config.getDocumentValidator(
                sink, in.getSourceLocator().getSystemId(), Validation.STRICT, Whitespace.NONE, null, -1);
        new PullPushCopier(in, validator).copy();
        System.out.println("Done.");
    }
View Full Code Here

TOP

Related Classes of com.saxonica.config.EnterpriseConfiguration

Copyright © 2018 www.massapicom. All rights reserved.
All source code are property of their respective owners. Java is a trademark of Sun Microsystems, Inc and owned by ORACLE Inc. Contact coftware#gmail.com.