1 16 package org.apache.cocoon.components.validation.jaxp; 17 18 import javax.xml.validation.Schema ; 19 import javax.xml.validation.ValidatorHandler ; 20 21 import org.apache.cocoon.components.validation.ValidationHandler; 22 import org.apache.cocoon.components.validation.impl.AbstractSchema; 23 import org.apache.cocoon.components.validation.impl.DefaultValidationHandler; 24 import org.apache.cocoon.components.validation.impl.DraconianErrorHandler; 25 import org.apache.excalibur.source.SourceValidity; 26 import org.xml.sax.ErrorHandler ; 27 import org.xml.sax.SAXException ; 28 29 35 public class JaxpSchema extends AbstractSchema { 36 37 38 private final Schema schema; 39 40 46 public JaxpSchema(Schema schema, SourceValidity validity) { 47 super(validity); 48 this.schema = schema; 49 } 50 51 67 public ValidationHandler createValidator(ErrorHandler handler) 68 throws SAXException { 69 if (handler == null) handler = DraconianErrorHandler.INSTANCE; 70 ValidatorHandler validator = this.schema.newValidatorHandler(); 71 validator.setErrorHandler(handler); 72 return new DefaultValidationHandler(this.getValidity(), validator); 73 } 74 } 75 | Popular Tags |