Package org.iso_relax.verifier

Examples of org.iso_relax.verifier.VerifierFactory


        }
        this.uri = source.getSystemId();
        this.type = type;

        try {
            VerifierFactory vf = VerifierFactory.newInstance(type.getLanguage());

            this.compiledSchema = vf.compileSchema(source);
        }
        catch (IOException e) {
            throw e;
        }
        catch (Exception e) {
View Full Code Here


     * Performs validation.
     * @throws Exception Exception
     */
    public void validate() throws Exception
    {
        VerifierFactory verifierFactory = new TheFactoryImpl();

        Verifier verifier = verifierFactory.newVerifier( new File( schema ) );
        verifier.setErrorHandler( new ErrorHandlerImpl() );

        VerifierHandler handler = verifier.getVerifierHandler();

        SAXParserFactory factory = SAXParserFactory.newInstance();
View Full Code Here

            // As of the 20030108 release of jarv this method doesn't
            // work. The new release added a class loader and that
            // seems to screw things up.
//         final VerifierFactory f =
//         VerifierFactory.newInstance("http://relaxng.org/ns/structure/1.0");
        final VerifierFactory f = new com.sun.msv.verifier.jarv.TheFactoryImpl();
        final Verifier verifier = f.newVerifier(schema);
        verifier.setErrorHandler(eh);
        verifier.setEntityResolver(er);
        return verifier;
    }
View Full Code Here

        super.run();

        XdmNode doc = null;

        try {
            VerifierFactory vfactory = new com.sun.msv.verifier.jarv.TheFactoryImpl();
            // FIXME: VerifierFactory.newInstance(language);

            Verifier verifier = null;
            XdmNode schemaNode = schema.read();
            InputSource schemaSource = S9apiUtils.xdmToInputSource(runtime, schemaNode);
            schemaSource.setSystemId(schemaNode.getBaseURI().toASCIIString());

            Schema docSchema = vfactory.compileSchema(schemaSource);
            verifier = docSchema.newVerifier();
            verifier.setErrorHandler(new RNGErrorHandler());

            doc = source.read();
            docBaseURI = doc.getBaseURI();
View Full Code Here

            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

    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

            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

            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

        }
    }

    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

Related Classes of org.iso_relax.verifier.VerifierFactory

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.