Debian Codegraph @

src/main/java/com/ctc/wstx/msv/RelaxNGSchema.java

raw
1 /* Woodstox XML processor
2 *
3 * Copyright (c) 2004- Tatu Saloranta, [email protected]
4 *
5 * Licensed under the License specified in the file LICENSE which is
6 * included with the source code.
7 * You may not use this file except in compliance with the License.
8 *
9 * Unless required by applicable law or agreed to in writing, software
10 * distributed under the License is distributed on an "AS IS" BASIS,
11 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
12 * See the License for the specific language governing permissions and
13 * limitations under the License.
14 */
15
16 package com.ctc.wstx.msv;
17
18 import javax.xml.stream.*;
19
20 import org.codehaus.stax2.validation.*;
21
22 import com.sun.msv.grammar.trex.TREXGrammar;
23 import com.sun.msv.verifier.regexp.REDocumentDeclaration;
24
25 /**
26 * This is a validation schema instance based on a RELAX NG schema. It
27 * serves as a shareable "blueprint" for creating actual validator instances.
28 */
29 public class RelaxNGSchema
30 implements XMLValidationSchema
31 {
32 /**
33 * This is VGM (in MSV lingo); shareable schema blueprint, basically
34 * peer of this schema object. It will be used for creating actual
35 * validator peer, root Acceptor.
36 */
37 protected final TREXGrammar mGrammar;
38
39 public RelaxNGSchema(TREXGrammar grammar)
40 {
41 mGrammar = grammar;
42 }
43
44 @Override
45 public String getSchemaType() {
46 return XMLValidationSchema.SCHEMA_ID_RELAXNG;
47 }
48
49 @Override
50 public XMLValidator createValidator(ValidationContext ctxt)
51 throws XMLStreamException
52 {
53 REDocumentDeclaration dd = new REDocumentDeclaration(mGrammar);
54 return new GenericMsvValidator(this, ctxt, dd);
55 }
56 }