Package javax.xml.validation

Examples of javax.xml.validation.Schema


    }
   
    protected void validateObjectIfNeeded(Marshaller marshaller, Class<?> cls, Object obj)
        throws JAXBException {
        if (validateOutput) {
            Schema theSchema = getSchema(cls);
            if (theSchema != null) {
                marshaller.setEventHandler(eventHandler);
                marshaller.setSchema(theSchema);
                if (validateBeforeWrite) {
                    marshaller.marshal(obj, new DefaultHandler());
View Full Code Here


    }
   
    public static Schema createSchema(List<String> locations, String catalogLocation, final Bus bus) {
       
        SchemaFactory factory = SchemaFactory.newInstance(WSDLConstants.NS_SCHEMA_XSD);
        Schema s = null;
        try {
            List<Source> sources = new ArrayList<Source>();
            for (String loc : locations) {
                URL url = ResourceUtils.getResourceURL(loc, bus);
                if (url == null) {
View Full Code Here

    public void testSetSchemasFromClasspath() {
        JAXBElementProvider<?> provider = new JAXBElementProvider<Object>();
        List<String> locations = new ArrayList<String>();
        locations.add("classpath:/test.xsd");
        provider.setSchemaLocations(locations);
        Schema s = provider.getSchema();
        assertNotNull("schema can not be read from classpath", s);
    }
View Full Code Here

        List<String> locations = new ArrayList<String>();
        String loc = getClass().getClassLoader().getResource("test.xsd").toURI().getPath();
       
        locations.add("file:" + loc);
        provider.setSchemaLocations(locations);
        Schema s = provider.getSchema();
        assertNotNull("schema can not be read from disk", s);
    }
View Full Code Here

        JAXBElementProvider<Book2> provider = new JAXBElementProvider<Book2>();
        List<String> locations = new ArrayList<String>();
        String loc = getClass().getClassLoader().getResource("book1.xsd").toURI().getPath();
        locations.add(loc);
        provider.setSchemaLocations(locations);
        Schema s = provider.getSchema();
        assertNotNull("schema can not be read from disk", s);
       
        provider.setValidateOutput(true);
        provider.setValidateBeforeWrite(true);
       
View Full Code Here

        JAXBElementProvider<Book2> provider = new JAXBElementProvider<Book2>();
        List<String> locations = new ArrayList<String>();
        String loc = getClass().getClassLoader().getResource("test.xsd").toURI().getPath();
        locations.add("file:" + loc);
        provider.setSchemaLocations(locations);
        Schema s = provider.getSchema();
        assertNotNull("schema can not be read from disk", s);
       
        provider.setValidateOutput(true);
        provider.setValidateBeforeWrite(true);
View Full Code Here

        pf.registerUserProvider(provider);
       
        List<String> locations = new ArrayList<String>();
        locations.add("classpath:/test.xsd");
        pf.setSchemaLocations(locations);
        Schema s = provider.getSchema();
        assertNotNull("schema can not be read from classpath", s);
    }
View Full Code Here

        DocumentBuilderFactory factory = DocumentBuilderFactory.newInstance();
        try {
            // XML schema for validation
            SchemaFactory sf = SchemaFactory.newInstance(XMLConstants.W3C_XML_SCHEMA_NS_URI);
            URL xsdUrl = RegistrationDocument.class.getResource(REGISTRATION_DATA_SCHEMA);
            Schema schema = sf.newSchema(xsdUrl);
            Validator validator = schema.newValidator();

            DocumentBuilder builder = factory.newDocumentBuilder();
            Document doc = builder.parse(new InputSource(in));
            validator.validate(new DOMSource(doc));
            return doc;
View Full Code Here

            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();
        reader.setFeature("http://xml.org/sax/features/namespaces", true);
View Full Code Here

            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();
        reader.setFeature("http://xml.org/sax/features/namespaces", true);
View Full Code Here

TOP

Related Classes of javax.xml.validation.Schema

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.