Examples of VerifierFactory


Examples of org.iso_relax.verifier.VerifierFactory

    protected SAXReader createSAXReader(String schemaURI) throws Exception {

        System.out.println("Loaded schema document: " + schemaURI);

        // use autodetection of schemas
        VerifierFactory factory = new com.sun.msv.verifier.jarv.TheFactoryImpl();
        Schema schema = factory.compileSchema(schemaURI);

        Verifier verifier = schema.newVerifier();
        verifier.setErrorHandler(new ErrorHandler() {
            public void error(SAXParseException e) {
                System.out.println("ERROR: " + e);
View Full Code Here

Examples of org.iso_relax.verifier.VerifierFactory

            return;
        };
       
        // see JARVDemo for more about how you "properly" use JARV.
       
        VerifierFactory factory = new com.sun.msv.verifier.jarv.TheFactoryImpl();
        Verifier verifier = factory.newVerifier(new File(args[0]));
       
        // create a SAX Parser
        SAXParserFactory spf = SAXParserFactory.newInstance();
        spf.setNamespaceAware(true);
        XMLReader reader = spf.newSAXParser().getXMLReader();
View Full Code Here

Examples of org.iso_relax.verifier.VerifierFactory

            System.out.println(
                "Usage: FactoryLoaderTester <language> <schema> <instance> ...\n");
            return;
        }
       
        VerifierFactory factory = getFactory(args[0]);
        if(factory==null) {
            System.out.println("unable to find an implementation");
            return;
        }
       
        Schema schema = factory.compileSchema(args[1]);
        if(schema==null) {
            System.out.println("unable to parse this schema");
            return;
        }
       
View Full Code Here

Examples of org.iso_relax.verifier.VerifierFactory

        }
    }

    private Schema getSchema(Source source, ThreadContext context) {
        InputStream is = null;
        VerifierFactory factory = new com.thaiopensource.relaxng.jarv.VerifierFactoryImpl();
        if (source instanceof StreamSource) {
            StreamSource ss = (StreamSource)source;
            is = ss.getInputStream();
        } else { //if (this.source instanceof DOMSource)
            DOMSource ds = (DOMSource)source;
            StringWriter xmlAsWriter = new StringWriter();
            StreamResult result = new StreamResult(xmlAsWriter);
            try {
                TransformerFactory.newInstance().newTransformer().transform(ds, result);
            } catch (TransformerConfigurationException ex) {
                throw context.getRuntime()
                    .newRuntimeError("Could not parse document: "+ex.getMessage());
            } catch (TransformerException ex) {
                throw context.getRuntime()
                    .newRuntimeError("Could not parse document: "+ex.getMessage());
            }
            try {
                is = new ByteArrayInputStream(xmlAsWriter.toString().getBytes("UTF-8"));
            } catch (UnsupportedEncodingException ex) {
                throw context.getRuntime()
                    .newRuntimeError("Could not parse document: "+ex.getMessage());
            }
        }

        try {
            return factory.compileSchema(is);
        } catch (VerifierConfigurationException ex) {
            throw context.getRuntime()
                .newRuntimeError("Could not parse document: "+ex.getMessage());
        } catch (SAXException ex) {
            throw context.getRuntime()
View Full Code Here
TOP
Copyright © 2018 www.massapi.com. 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.