Package javax.xml.validation

Examples of javax.xml.validation.SchemaFactory


                connection.setUseCaches(false);
                sources[i] = new StreamSource(connection.getInputStream(), uri);
            }
           
            // Create an aggregated validation schemas from all the XSDs
            SchemaFactory schemaFactory = SchemaFactory.newInstance(XMLConstants.W3C_XML_SCHEMA_NS_URI);
            aggregatedSchema= schemaFactory.newSchema(sources);
           
        } catch (Error e) {
            //FIXME Log this, some old JDKs don't support XMLSchema validation
            //e.printStackTrace();
        } catch (SAXParseException e) {
View Full Code Here


    public void tearDown() throws Exception {
    }
   
    public void testValidateAssembly() throws Exception {
       
        SchemaFactory schemaFactory;
        try {
            schemaFactory = SchemaFactory.newInstance(XMLConstants.W3C_XML_SCHEMA_NS_URI);
        } catch (Error e) {
            // Some old JDKs don't support XMLSchema validation
            return;
        } catch (Exception e) {
            // Some old JDKs don't support XMLSchema validation
            return;
        }
        Schema schema = schemaFactory.newSchema(getClass().getClassLoader().getResource("tuscany-sca.xsd"));
        ValidatorHandler handler = schema.newValidatorHandler();
       
        SAXParserFactory parserFactory = SAXParserFactory.newInstance();
        URL url = getClass().getResource("Calculator.composite");
        XMLReader reader = parserFactory.newSAXParser().getXMLReader();
View Full Code Here

        reader.parse(new InputSource(url.openStream()));
    }

    public void testValidateImplementation() throws Exception {
       
        SchemaFactory schemaFactory;
        try {
            schemaFactory = SchemaFactory.newInstance(XMLConstants.W3C_XML_SCHEMA_NS_URI);
        } catch (Error e) {
            // Some old JDKs don't support XMLSchema validation
            return;
        } catch (Exception e) {
            // Some old JDKs don't support XMLSchema validation
            return;
        }
        Schema schema = schemaFactory.newSchema(getClass().getClassLoader().getResource("tuscany-sca.xsd"));
        ValidatorHandler handler = schema.newValidatorHandler();
       
        SAXParserFactory parserFactory = SAXParserFactory.newInstance();
        URL url = getClass().getResource("JavaScriptReference.composite");
        XMLReader reader = parserFactory.newSAXParser().getXMLReader();
View Full Code Here

        assertNotNull(composite);
    }
       
    public void testValidateBinding() throws Exception {
       
        SchemaFactory schemaFactory;
        try {
            schemaFactory = SchemaFactory.newInstance(XMLConstants.W3C_XML_SCHEMA_NS_URI);
        } catch (Error e) {
            // Some old JDKs don't support XMLSchema validation
            return;
        } catch (Exception e) {
            // Some old JDKs don't support XMLSchema validation
            return;
        }
        Schema schema = schemaFactory.newSchema(getClass().getClassLoader().getResource("tuscany-sca.xsd"));
        ValidatorHandler handler = schema.newValidatorHandler();
       
        SAXParserFactory parserFactory = SAXParserFactory.newInstance();
        URL url = getClass().getResource("RMIBindingTest.composite");
        XMLReader reader = parserFactory.newSAXParser().getXMLReader();
View Full Code Here

    // Implementation methods
    // -----------------------------------------------------------------------

    protected SchemaFactory createSchemaFactory() {
        SchemaFactory factory = SchemaFactory.newInstance(schemaLanguage);
        if (getResourceResolver() != null) {
            factory.setResourceResolver(getResourceResolver());
        }
        return factory;
    }
View Full Code Here

    protected Source createSchemaSource() throws IOException {
        throw new IllegalArgumentException("You must specify either a schema, schemaFile, schemaSource or schemaUrl property");
    }

    protected Schema createSchema() throws SAXException, IOException {
        SchemaFactory factory = getSchemaFactory();

        URL url = getSchemaUrl();
        if (url != null) {
            return factory.newSchema(url);
        }
        File file = getSchemaFile();
        if (file != null) {
            return factory.newSchema(file);
        }
        return factory.newSchema(getSchemaSource());
    }
View Full Code Here

    private COORDINATORAPP getCoordinator(Path path) throws Exception {
        String bundleStr = readFile(path);

        Unmarshaller unmarshaller = JAXBContext.newInstance(COORDINATORAPP.class).createUnmarshaller();
        SchemaFactory schemaFactory = SchemaFactory.newInstance("http://www.w3.org/2001/XMLSchema");
        Schema schema = schemaFactory.newSchema(this.getClass().getResource("/oozie-coordinator-0.3.xsd"));
        unmarshaller.setSchema(schema);
        JAXBElement<COORDINATORAPP> jaxbBundle = unmarshaller.unmarshal(
                new StreamSource(new ByteArrayInputStream(bundleStr.trim().getBytes())), COORDINATORAPP.class);
        return jaxbBundle.getValue();
    }
View Full Code Here

    private BUNDLEAPP getBundle(Path path) throws Exception {
        String bundleStr = readFile(new Path(path, "bundle.xml"));

        Unmarshaller unmarshaller = JAXBContext.newInstance(BUNDLEAPP.class).createUnmarshaller();
        SchemaFactory schemaFactory = SchemaFactory.newInstance("http://www.w3.org/2001/XMLSchema");
        Schema schema = schemaFactory.newSchema(this.getClass().getResource("/oozie-bundle-0.1.xsd"));
        unmarshaller.setSchema(schema);
        JAXBElement<BUNDLEAPP> jaxbBundle = unmarshaller.unmarshal(
                new StreamSource(new ByteArrayInputStream(bundleStr.trim().getBytes())), BUNDLEAPP.class);
        return jaxbBundle.getValue();
    }
View Full Code Here

    @Test
    public void testValidCoordinatorUnamrashalling() throws JAXBException, SAXException {
        Unmarshaller unmarshaller = JAXBContext.newInstance(org.apache.falcon.oozie.coordinator.COORDINATORAPP.class)
                .createUnmarshaller();
        SchemaFactory schemaFactory = SchemaFactory.newInstance("http://www.w3.org/2001/XMLSchema");
        Schema schema = schemaFactory.newSchema(this.getClass().getResource("/oozie-coordinator-0.3.xsd"));
        unmarshaller.setSchema(schema);
        JAXBElement<COORDINATORAPP> coordinatorApp = (JAXBElement<COORDINATORAPP>) unmarshaller
                .unmarshal(CoordinatorUnmarshallingTest.class.getResourceAsStream("/oozie/xmls/coordinator.xml"));
        COORDINATORAPP app = coordinatorApp.getValue();
        Assert.assertEquals(app.getName(), "test");
View Full Code Here

    @Test
    public void testValidWorkflowUnamrashalling() throws JAXBException, SAXException {
        Unmarshaller unmarshaller = JAXBContext.newInstance(
                org.apache.falcon.oozie.workflow.WORKFLOWAPP.class).createUnmarshaller();
        SchemaFactory schemaFactory = SchemaFactory.newInstance("http://www.w3.org/2001/XMLSchema");
        Schema schema = schemaFactory.newSchema(this.getClass().getResource("/oozie-workflow-0.3.xsd"));
        unmarshaller.setSchema(schema);
        JAXBElement<WORKFLOWAPP> workflowApp = (JAXBElement<WORKFLOWAPP>) unmarshaller.unmarshal(
                WorkflowUnmarshallingTest.class
                        .getResourceAsStream("/oozie/xmls/workflow.xml"));
        WORKFLOWAPP app = workflowApp.getValue();
View Full Code Here

TOP

Related Classes of javax.xml.validation.SchemaFactory

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.