Package org.apache.cocoon.components.validation

Examples of org.apache.cocoon.components.validation.Schema


            Source schemaSrc = getSourceResolver().resolveURI(schDoc);

            try {
                InputSource is = SourceUtil.getInputSource(schemaSrc);
                SchemaFactory schf = SchemaFactory.lookup(schNS);
                Schema sch = schf.compileSchema(is);

                return sch.newValidator();
            } finally {
                getSourceResolver().release(schemaSrc);
            }
        } catch (Exception e) {
            // couldn't load the validator
View Full Code Here


            Source schemaSrc = getSourceResolver().resolveURI(schDoc);

            try {
                InputSource is = SourceUtil.getInputSource(schemaSrc);
                SchemaFactory schf = SchemaFactory.lookup(schNS);
                Schema sch = schf.compileSchema(is);

                return sch.newValidator();
            } finally {
                getSourceResolver().release(schemaSrc);
            }
        } catch (Exception e) {
            // couldn't load the validator
View Full Code Here

            /* Somehow we have a schema parser, check it supports the gramar */
            String languages[] = parser.getSupportedGrammars();
            for (int x = 0; x < languages.length; x++) {
                if (! language.equals(languages[x])) continue;
                /* Hah! language supported, go ahead and parse now */
                Schema schema = this.getSchema(parser, source, language);
                return schema.createValidator(errorHandler);
            }

            /* Something really odd going on, this should never happen */
            String message = "Schema parser " + parser.getClass().getName() +
                             " does not support grammar " + grammar;
View Full Code Here

        /* Prepare a key, and try to get the cached copy of the schema */
        String uri = source.getURI();
        String key = this.getClass().getName() + "[" + parser.getClass().getName()
                     + ":" + grammar + "]@" + source.getURI();
        Schema schema = null;
        SourceValidity validity = null;
        schema = (Schema) this.store.get(key);

        /* If the schema was found verify its validity and optionally clear */
        if (schema != null) {
            validity = schema.getValidity();
            if (validity == null) {
                /* Why did we cache it in the first place? */
                this.logger.warn("Cached schema " + uri + " has null validity");
                this.store.remove(key);
                schema = null;
            } else if (validity.isValid() != SourceValidity.VALID) {
                if (this.logger.isDebugEnabled()) {
                    this.logger.debug("Cached schema " + uri + " no longer valid");
                }
                this.store.remove(key);
                schema = null;
            } else if (this.logger.isDebugEnabled()) {
                this.logger.debug("Valid cached schema found for " + uri);
            }
        } else if (this.logger.isDebugEnabled()) {
            this.logger.debug("Schema " + uri + " not found in cache");
        }

        /* If the schema was not cached or was cleared, parse and cache it */
        if (schema == null) {
            schema = super.getSchema(parser, source, grammar);
            validity = schema.getValidity();
            if (validity != null) {
                if (validity.isValid() == SourceValidity.VALID) {
                    this.store.store(key, schema);
                }
            }
View Full Code Here

            /* Somehow we have a schema parser, check it supports the gramar */
            String languages[] = parser.getSupportedGrammars();
            for (int x = 0; x < languages.length; x++) {
                if (! language.equals(languages[x])) continue;
                /* Hah! language supported, go ahead and parse now */
                Schema schema = this.getSchema(parser, source, language);
                return schema.createValidator(errorHandler);
            }

            /* Something really odd going on, this should never happen */
            String message = "Schema parser " + parser.getClass().getName() +
                             " does not support grammar " + grammar;
View Full Code Here

        /* Prepare a key, and try to get the cached copy of the schema */
        String uri = source.getURI();
        String key = this.getClass().getName() + "[" + parser.getClass().getName()
                     + ":" + grammar + "]@" + source.getURI();
        Schema schema = null;
        SourceValidity validity = null;
        schema = (Schema) this.store.get(key);

        /* If the schema was found verify its validity and optionally clear */
        if (schema != null) {
            validity = schema.getValidity();
            if (validity == null) {
                /* Why did we cache it in the first place? */
                this.logger.warn("Cached schema " + uri + " has null validity");
                this.store.remove(key);
                schema = null;
            } else if (validity.isValid() != SourceValidity.VALID) {
                if (this.logger.isDebugEnabled()) {
                    this.logger.debug("Cached schema " + uri + " no longer valid");
                }
                this.store.remove(key);
                schema = null;
            } else if (this.logger.isDebugEnabled()) {
                this.logger.debug("Valid cached schema found for " + uri);
            }
        } else if (this.logger.isDebugEnabled()) {
            this.logger.debug("Schema " + uri + " not found in cache");
        }

        /* If the schema was not cached or was cleared, parse and cache it */
        if (schema == null) {
            schema = super.getSchema(parser, source, grammar);
            validity = schema.getValidity();
            if (validity != null) {
                if (validity.isValid() == SourceValidity.VALID) {
                    this.store.store(key, schema);
                }
            }
View Full Code Here

            /* Somehow we have a schema parser, check it supports the gramar */
            String languages[] = parser.getSupportedGrammars();
            for (int x = 0; x < languages.length; x++) {
                if (! language.equals(languages[x])) continue;
                /* Hah! language supported, go ahead and parse now */
                Schema schema = this.getSchema(parser, source, language);
                return schema.createValidator(errorHandler);
            }

            /* Something really odd going on, this should never happen */
            String message = "Schema parser " + parser.getClass().getName() +
                             " does not support grammar " + grammar;
View Full Code Here

        /* Prepare a key, and try to get the cached copy of the schema */
        String uri = source.getURI();
        String key = this.getClass().getName() + "[" + parser.getClass().getName()
                     + ":" + grammar + "]@" + source.getURI();
        Schema schema = null;
        SourceValidity validity = null;
        schema = (Schema) this.store.get(key);

        /* If the schema was found verify its validity and optionally clear */
        if (schema != null) {
            validity = schema.getValidity();
            if (validity == null) {
                /* Why did we cache it in the first place? */
                this.logger.warn("Cached schema " + uri + " has null validity");
                this.store.remove(key);
                schema = null;
            } else if (validity.isValid() != SourceValidity.VALID) {
                if (this.logger.isDebugEnabled()) {
                    this.logger.debug("Cached schema " + uri + " no longer valid");
                }
                this.store.remove(key);
                schema = null;
            } else if (this.logger.isDebugEnabled()) {
                this.logger.debug("Valid cached schema found for " + uri);
            }
        } else if (this.logger.isDebugEnabled()) {
            this.logger.debug("Schema " + uri + " not found in cache");
        }

        /* If the schema was not cached or was cleared, parse and cache it */
        if (schema == null) {
            schema = super.getSchema(parser, source, grammar);
            validity = schema.getValidity();
            if (validity != null) {
                if (validity.isValid() == SourceValidity.VALID) {
                    this.store.store(key, schema);
                }
            }
View Full Code Here

        }

        try {
            InputSource is = new InputSource(in);
            SchemaFactory schf = SchemaFactory.lookup(SchemaFactory.NAMESPACE_SCHEMATRON);
            Schema sch = schf.compileSchema(is);
            Validator validator = sch.newValidator();

            // set preprocessor parameters
            if (phase!=null) {
                validator.setProperty(Validator.PROPERTY_PHASE, phase);
            }
View Full Code Here

            Source schemaSrc = getSourceResolver().resolveURI(schDoc);

            try {
                InputSource is = SourceUtil.getInputSource(schemaSrc);
                SchemaFactory schf = SchemaFactory.lookup(schNS);
                Schema sch = schf.compileSchema(is);

                return sch.newValidator();
            } finally {
                getSourceResolver().release(schemaSrc);
            }
        } catch (Exception e) {
            // couldn't load the validator
View Full Code Here

TOP

Related Classes of org.apache.cocoon.components.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.