01: /*
02: * Licensed to the Apache Software Foundation (ASF) under one or more
03: * contributor license agreements. See the NOTICE file distributed with
04: * this work for additional information regarding copyright ownership.
05: * The ASF licenses this file to You under the Apache License, Version 2.0
06: * (the "License"); you may not use this file except in compliance with
07: * the License. You may obtain a copy of the License at
08: *
09: * http://www.apache.org/licenses/LICENSE-2.0
10: *
11: * Unless required by applicable law or agreed to in writing, software
12: * distributed under the License is distributed on an "AS IS" BASIS,
13: * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
14: * See the License for the specific language governing permissions and
15: * limitations under the License.
16: */
17: package org.apache.cocoon.components.validation;
18:
19: import java.io.IOException;
20:
21: import org.apache.excalibur.source.Source;
22: import org.xml.sax.SAXException;
23:
24: /**
25: * <p>The {@link SchemaParser} interface defines the abstraction of a component able
26: * to parse sources and produce {@link Schema} instances suitable for validation of
27: * XML documents.</p>
28: *
29: * <p>A {@link SchemaParser} might be able to understand more than one grammar
30: * language at the same time. The list of all supported grammar languages must be
31: * returned by the {@link #getSupportedGrammars()} method.</p>
32: *
33: */
34: public interface SchemaParser {
35:
36: /** <p>Avalon Role name of {@link SchemaParser} components.</p> */
37: public static final String ROLE = SchemaParser.class.getName();
38:
39: /**
40: * <p>Parse the specified {@link Source} and return a new {@link Schema}.</p>
41: *
42: * <p>The returned {@link Schema} must be able to validate multiple documents
43: * via multiple invocations of {@link Schema#createValidator(ErrorHandler)}.</p>
44: *
45: * @param source the {@link Source} associated with the {@link Schema} to return.
46: * @return a <b>non-null</b> {@link Schema} instance.
47: * @throws SAXException if a grammar error occurred parsing the schema.
48: * @throws IOException if an I/O error occurred parsing the schema.
49: * @throws IllegalArgumentException if the specified grammar type is not one
50: * of the grammar types returned by the
51: * {@link #getSupportedGrammars()} method.
52: */
53: public Schema parseSchema(Source source, String grammar)
54: throws SAXException, IOException, IllegalArgumentException;
55:
56: /**
57: * <p>Return an array of {@link String}s containing all the grammar languages
58: * supported by this {@link SchemaParser}.</p>
59: *
60: * @return a <b>non-null</b> array of {@link String}s.
61: */
62: public String[] getSupportedGrammars();
63:
64: }
|