File: PSVIConfiguration.java

package info (click to toggle)
libxerces2-java 2.9.1-2%2Blenny1
  • links: PTS, VCS
  • area: main
  • in suites: lenny
  • size: 11,300 kB
  • ctags: 15,991
  • sloc: java: 119,347; xml: 12,773; sh: 37; makefile: 24
file content (129 lines) | stat: -rw-r--r-- 4,587 bytes parent folder | download | duplicates (2)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
/*
 * Licensed to the Apache Software Foundation (ASF) under one or more
 * contributor license agreements.  See the NOTICE file distributed with
 * this work for additional information regarding copyright ownership.
 * The ASF licenses this file to You under the Apache License, Version 2.0
 * (the "License"); you may not use this file except in compliance with
 * the License.  You may obtain a copy of the License at
 * 
 *      http://www.apache.org/licenses/LICENSE-2.0
 * 
 * Unless required by applicable law or agreed to in writing, software
 * distributed under the License is distributed on an "AS IS" BASIS,
 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
 * See the License for the specific language governing permissions and
 * limitations under the License.
 */

package xni.parser;

import org.apache.xerces.parsers.XIncludeAwareParserConfiguration;
import org.apache.xerces.util.SymbolTable;
import org.apache.xerces.xni.grammars.XMLGrammarPool;
import org.apache.xerces.xni.parser.XMLComponentManager;

import xni.PSVIWriter;

/**
 * This is the DTD/ XML Schema parser configuration that includes PSVIWriter component.
 * The document will be fully assessed and will produce PSVI as required by XML Schema specification
 * configuration including XML Schema Validator in the pipeline.
 * 
 * @author Elena Litani, IBM
 * @version $Id: PSVIConfiguration.java 447690 2006-09-19 02:41:53Z mrglavas $
 */
public class PSVIConfiguration extends XIncludeAwareParserConfiguration {

    /** PSVI Writer */
    protected PSVIWriter fPSVIWriter;
    
    //
    // Constructors
    //

    /**
     * Constructs a document parser using the default symbol table and grammar
     * pool or the ones specified by the application (through the properties).
     */
    public PSVIConfiguration() {
        this(null, null);
    } // <init>()

    /**
     * Constructs a document parser using the specified symbol table.
     *
     * @param symbolTable    The symbol table to use.
     */
    public PSVIConfiguration(SymbolTable symbolTable) {
        this(symbolTable, null);
    } // <init>(SymbolTable)

    /**
     * Constructs a document parser using the specified symbol table and
     * grammar pool.
     * <p>
     * <strong>REVISIT:</strong>
     * Grammar pool will be updated when the new validation engine is
     * implemented.
     *
     * @param symbolTable    The symbol table to use.
     * @param grammarPool    The grammar pool to use.
     */
    public PSVIConfiguration(SymbolTable symbolTable,
                                     XMLGrammarPool grammarPool) {
        this(symbolTable, grammarPool, null);
    } // <init>(SymbolTable,XMLGrammarPool)

    /**
     * Constructs a parser configuration using the specified symbol table,
     * grammar pool, and parent settings.
     * <p>
     * <strong>REVISIT:</strong>
     * Grammar pool will be updated when the new validation engine is
     * implemented.
     *
     * @param symbolTable    The symbol table to use.
     * @param grammarPool    The grammar pool to use.
     * @param parentSettings The parent settings.
     */
    public PSVIConfiguration(SymbolTable symbolTable,
                                    XMLGrammarPool grammarPool,
                                    XMLComponentManager parentSettings) {
        super(symbolTable, grammarPool, parentSettings);
        fPSVIWriter = createPSVIWriter();
        if (fPSVIWriter != null) {
            addCommonComponent(fPSVIWriter);
        }

    } // <init>(SymbolTable,XMLGrammarPool)

    /** Configures the pipeline. */
    protected void configurePipeline() {
        super.configurePipeline();
        addPSVIWriterToPipeline();
    } // configurePipeline()
    
    /** Configures the XML 1.1 pipeline. */
    protected void configureXML11Pipeline() {
        super.configureXML11Pipeline();
        addPSVIWriterToPipeline();
    } // configureXML11Pipeline()
    
    /** Adds PSVI writer to the pipeline. */
    protected void addPSVIWriterToPipeline() {
        if (fSchemaValidator != null) {
            fSchemaValidator.setDocumentHandler(fPSVIWriter);
            fPSVIWriter.setDocumentSource(fSchemaValidator);
            fPSVIWriter.setDocumentHandler(fDocumentHandler);
            if (fDocumentHandler != null) {
                fDocumentHandler.setDocumentSource(fPSVIWriter);
            }
        }
    } // addPSVIWriterToPipeline()

    /** Create a PSVIWriter */
    protected PSVIWriter createPSVIWriter(){
        return new PSVIWriter();
    }

} // class PSVIConfiguration