1 16 package org.apache.cocoon.components.validation.jing; 17 18 import org.apache.cocoon.components.validation.ValidationHandler; 19 import org.apache.cocoon.components.validation.impl.AbstractSchema; 20 import org.apache.cocoon.components.validation.impl.DefaultValidationHandler; 21 import org.apache.cocoon.components.validation.impl.DraconianErrorHandler; 22 import org.apache.excalibur.source.SourceValidity; 23 import org.xml.sax.ContentHandler ; 24 import org.xml.sax.ErrorHandler ; 25 import org.xml.sax.SAXException ; 26 27 import com.thaiopensource.util.PropertyMap; 28 import com.thaiopensource.util.PropertyMapBuilder; 29 import com.thaiopensource.validate.Schema; 30 import com.thaiopensource.validate.ValidateProperty; 31 import com.thaiopensource.validate.Validator; 32 33 39 public class JingSchema extends AbstractSchema { 40 41 42 private final Schema schema; 43 44 50 protected JingSchema(Schema schema, SourceValidity validity) { 51 super(validity); 52 this.schema = schema; 53 } 54 55 67 public ValidationHandler createValidator(ErrorHandler errorHandler) 68 throws SAXException { 69 if (errorHandler == null) errorHandler = DraconianErrorHandler.INSTANCE; 70 final PropertyMapBuilder builder = new PropertyMapBuilder(); 71 ValidateProperty.ERROR_HANDLER.put(builder, errorHandler); 72 final PropertyMap properties = builder.toPropertyMap(); 73 final Validator validator = this.schema.createValidator(properties); 74 final ContentHandler handler = validator.getContentHandler(); 75 return new DefaultValidationHandler(this.getValidity(), handler); 76 } 77 } | Popular Tags |