Package org.apache.xerces.jaxp.validation

Examples of org.apache.xerces.jaxp.validation.XMLSchemaFactory


    public TestValidator(DocumentBuilderFactory dbf) {
        super(dbf);
    }

    protected void runTest() throws Throwable {
        SchemaFactory factory = new XMLSchemaFactory();
        DocumentBuilder builder = dbf.newDocumentBuilder();
        Schema schema = factory.newSchema(new DOMSource(
                builder.parse(TestValidator.class.getResourceAsStream("ipo.xsd"))));
        Validator validator = schema.newValidator();
        validator.validate(new DOMSource(
                builder.parse(TestValidator.class.getResourceAsStream("ipo_1.xml"))));
    }
View Full Code Here


import org.junit.Test;

public class ValidatorTest {
    @Test
    public void test() throws Exception {
        SchemaFactory factory = new XMLSchemaFactory();
        DocumentBuilderFactory dbf = new DOOMDocumentBuilderFactory();
        DocumentBuilder builder = dbf.newDocumentBuilder();
        Schema schema = factory.newSchema(new DOMSource(
                builder.parse(ValidatorTest.class.getResourceAsStream("ipo.xsd"))));
        Validator validator = schema.newValidator();
        validator.validate(new DOMSource(
                builder.parse(ValidatorTest.class.getResourceAsStream("ipo_1.xml"))));
    }
View Full Code Here

        public void startElement(String uri, String localName, String qName, Attributes atts) throws SAXException {
            if (vHandler == null) {

                this.namespaceURI = uri;
                InputStream schemaStream = findSchemaFromNamespaceURI(uri);
                XMLSchemaFactory sf = new XMLSchemaFactory(); // Xerces
                Schema schema = sf.newSchema(new StreamSource(schemaStream));
                this.vHandler = schema.newValidatorHandler();

                configHandler = new XmlConfigHandler(vHandler.getTypeInfoProvider());
                vHandler.setContentHandler(configHandler);
                vHandler.setErrorHandler(this);
View Full Code Here

        if (validate) {
            ClassLoader origTCCL = Thread.currentThread().getContextClassLoader();
            Thread.currentThread().setContextClassLoader(bindingModelClassLoader);
            try {
                XMLSchemaFactory schemaFactory = new XMLSchemaFactory();

                try {
                    schemaFactory.setProperty("http://apache.org/xml/properties/security-manager", null);   // Need to turn this thing off, otherwise it throws stupid errors.
                } catch (SAXException e) {
                    // Ignore...
                }

                EclipseFragmentXMLValidator validator = new EclipseFragmentXMLValidator(schemaFactory);
View Full Code Here

    public void test_dom_validation_via_resolver() throws IOException, SAXException, ParserConfigurationException, URISyntaxException {
        Document document = XmlUtil.parseStream(getClass().getResourceAsStream("xsdDomValidator-test-01.xml"));
        XsdValidator validator = new XsdValidator();

        validator.setSchemaFactory(new XMLSchemaFactory());

        MyLSResourceResolver schemaSourceResolver = new MyLSResourceResolver();
        schemaSourceResolver.resources.put("http://www.milyn.org/xsd/test-xsd-01.xsd", new StreamSourceLSInput(new StreamSource(getClass().getResourceAsStream("/META-INF/xsd/test-xsd-01.xsd"))));
        schemaSourceResolver.resources.put("http://www.milyn.org/xsd/test-xsd-02.xsd", new StreamSourceLSInput(new StreamSource(getClass().getResourceAsStream("/META-INF/xsd/test-xsd-02.xsd"))));
View Full Code Here

    }

    public void test_stream_validation_via_resolver() throws IOException, SAXException, ParserConfigurationException, URISyntaxException {
        XsdValidator validator = new XsdValidator();

        validator.setSchemaFactory(new XMLSchemaFactory());

        MyLSResourceResolver schemaSourceResolver = new MyLSResourceResolver();
        schemaSourceResolver.resources.put("http://www.milyn.org/xsd/test-xsd-01.xsd", new StreamSourceLSInput(new StreamSource(getClass().getResourceAsStream("/META-INF/xsd/test-xsd-01.xsd"))));
        schemaSourceResolver.resources.put("http://www.milyn.org/xsd/test-xsd-02.xsd", new StreamSourceLSInput(new StreamSource(getClass().getResourceAsStream("/META-INF/xsd/test-xsd-02.xsd"))));
View Full Code Here

import junit.framework.TestCase;

public class ValidatorTest extends TestCase {
    public void test() throws Exception {
        SchemaFactory factory = new XMLSchemaFactory();
        DocumentBuilderFactory dbf = new DOOMDocumentBuilderFactory();
        DocumentBuilder builder = dbf.newDocumentBuilder();
        Schema schema = factory.newSchema(new DOMSource(
                builder.parse(ValidatorTest.class.getResourceAsStream("ipo.xsd"))));
        Validator validator = schema.newValidator();
        validator.validate(new DOMSource(
                builder.parse(ValidatorTest.class.getResourceAsStream("ipo_1.xml"))));
    }
View Full Code Here

TOP

Related Classes of org.apache.xerces.jaxp.validation.XMLSchemaFactory

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.