FileDocCategorySizeDatePackage
DOMASBuilderImpl.javaAPI DocJava SE 5 API13868Fri Aug 26 14:55:54 BST 2005com.sun.org.apache.xerces.internal.parsers

DOMASBuilderImpl

public class DOMASBuilderImpl extends DOMParserImpl implements com.sun.org.apache.xerces.internal.dom3.as.DOMASBuilder
This is Abstract Schema DOM Builder class. It extends the DOMParserImpl class. Provides support for preparsing schemas.
deprecated
author
Pavani Mukthipudi, Sun Microsystems Inc.
author
Neil Graham, IBM
version
$Id: DOMASBuilderImpl.java,v 1.24 2003/11/17 13:48:41 venu Exp $

Fields Summary
protected static final String
SCHEMA_FULL_CHECKING
protected static final String
ERROR_REPORTER
protected static final String
SYMBOL_TABLE
protected static final String
ENTITY_MANAGER
protected XSGrammarBucket
fGrammarBucket
protected com.sun.org.apache.xerces.internal.dom.ASModelImpl
fAbstractSchema
Constructors Summary
public DOMASBuilderImpl()
Constructs a DOM Builder using the dtd/xml schema parser configuration.


    //
    // Constructors
    //

                   
      
        super(new XMLGrammarCachingConfiguration());
    
public DOMASBuilderImpl(XMLGrammarCachingConfiguration config)
Constructs a DOM Builder using the specified parser configuration. We must demand that the configuration extend XMLGrammarCachingConfiguration to make sure all relevant methods/features are available.

        super(config);
    
public DOMASBuilderImpl(SymbolTable symbolTable)
Constructs a DOM Builder using the specified symbol table.

        super(new XMLGrammarCachingConfiguration(symbolTable));
    
public DOMASBuilderImpl(SymbolTable symbolTable, XMLGrammarPool grammarPool)
Constructs a DOM Builder using the specified symbol table and grammar pool. The grammarPool implementation should extent the default implementation; otherwise, correct functioning of this class may not occur.

        super(new XMLGrammarCachingConfiguration(symbolTable, grammarPool));
    
Methods Summary
private voidaddGrammars(com.sun.org.apache.xerces.internal.dom.ASModelImpl model, com.sun.org.apache.xerces.internal.impl.xs.XSGrammarBucket grammarBucket)

        SchemaGrammar [] grammarList = grammarBucket.getGrammars();
        for(int i=0; i<grammarList.length; i++) {
            ASModelImpl newModel = new ASModelImpl();
            newModel.setGrammar(grammarList[i]);
            model.addASModel(newModel);
        }
    
public com.sun.org.apache.xerces.internal.dom3.as.ASModelgetAbstractSchema()
Associate an ASModel with a document instance. This ASModel will be used by the " validate-if-schema" and " datatype-normalization" options during the load of a new Document.

        return fAbstractSchema;
    
private voidinitGrammarBucket()

        fGrammarBucket.reset();
        if (fAbstractSchema != null)
            initGrammarBucketRecurse(fAbstractSchema);
    
private voidinitGrammarBucketRecurse(com.sun.org.apache.xerces.internal.dom.ASModelImpl currModel)

        if(currModel.getGrammar() != null) {
            fGrammarBucket.putGrammar(currModel.getGrammar());
        }
        for(int i = 0; i < currModel.getInternalASModels().size(); i++) {
            ASModelImpl nextModel = (ASModelImpl)(currModel.getInternalASModels().elementAt(i));
            initGrammarBucketRecurse(nextModel);
        }
    
private voidinitGrammarPool(com.sun.org.apache.xerces.internal.dom.ASModelImpl currModel, com.sun.org.apache.xerces.internal.xni.grammars.XMLGrammarPool grammarPool)

        // put all the grammars in fAbstractSchema into the grammar pool.
        // grammarPool must never be null!
        Grammar[] grammars = new Grammar[1];
        if ((grammars[0] = (Grammar)currModel.getGrammar()) != null) {
            grammarPool.cacheGrammars(grammars[0].getGrammarDescription().getGrammarType(), grammars);
        }
        Vector modelStore = currModel.getInternalASModels();
        for (int i = 0; i < modelStore.size(); i++) {
            initGrammarPool((ASModelImpl)modelStore.elementAt(i), grammarPool);
        }
    
public com.sun.org.apache.xerces.internal.dom3.as.ASModelparseASInputSource(org.w3c.dom.ls.LSInput is)
Parse a Abstract Schema from a location identified by an LSInput.

param
is The LSInput from which the source Abstract Schema is to be read.
return
The newly created ASModel.
exception
DOMASException Exceptions raised by parseASURI() originate with the installed ErrorHandler, and thus depend on the implementation of the DOMErrorHandler interfaces. The default error handlers will raise a DOMASException if any form of Abstract Schema inconsistencies or warning occurs during the parse, but application defined errorHandlers are not required to do so.
WRONG_MIME_TYPE_ERR: Raised when mimeTypeCheck is true and the inputsource has an incorrect MIME Type. See attribute mimeTypeCheck.
exception
DOMSystemException Exceptions raised by parseURI() originate with the installed ErrorHandler, and thus depend on the implementation of the DOMErrorHandler interfaces. The default error handlers will raise a DOMSystemException if any form I/O or other system error occurs during the parse, but application defined error handlers are not required to do so.

                                      
        // need to wrap the LSInput with an XMLInputSource
        XMLInputSource xis = this.dom2xmlInputSource(is);
        try {
            return parseASInputSource(xis);
        }
        catch (XNIException e) {
            Exception ex = e.getException();
            throw ex;
        }
    
com.sun.org.apache.xerces.internal.dom3.as.ASModelparseASInputSource(com.sun.org.apache.xerces.internal.xni.parser.XMLInputSource is)

                                      
        if (fGrammarBucket == null) {
            fGrammarBucket = new XSGrammarBucket();
        }

        initGrammarBucket();

        // actually do the parse:
        // save some casting
        XMLGrammarCachingConfiguration gramConfig = (XMLGrammarCachingConfiguration)fConfiguration;
        // ensure grammarPool doesn't absorb grammars while it's parsing
        gramConfig.lockGrammarPool();
        SchemaGrammar grammar = gramConfig.parseXMLSchema(is);
        gramConfig.unlockGrammarPool();

        ASModelImpl newAsModel = null;
        if (grammar != null) {
            newAsModel = new ASModelImpl();
            fGrammarBucket.putGrammar (grammar, true);
            addGrammars(newAsModel, fGrammarBucket);
        }
        return newAsModel;
    
public com.sun.org.apache.xerces.internal.dom3.as.ASModelparseASURI(java.lang.String uri)
Parse a Abstract Schema from a location identified by an URI.

param
uri The location of the Abstract Schema to be read.
return
The newly created Abstract Schema.
exception
DOMASException Exceptions raised by parseASURI() originate with the installed ErrorHandler, and thus depend on the implementation of the DOMErrorHandler interfaces. The default error handlers will raise a DOMASException if any form of Abstract Schema inconsistencies or warning occurs during the parse, but application defined errorHandlers are not required to do so.
WRONG_MIME_TYPE_ERR: Raised when mimeTypeCheck is true and the inputsource has an incorrect MIME Type. See attribute mimeTypeCheck.
exception
DOMSystemException Exceptions raised by parseURI() originate with the installed ErrorHandler, and thus depend on the implementation of the DOMErrorHandler interfaces. The default error handlers will raise a DOMSystemException if any form I/O or other system error occurs during the parse, but application defined error handlers are not required to do so.

        XMLInputSource source = new XMLInputSource(null, uri, null);
        return parseASInputSource(source);
    
public voidsetAbstractSchema(com.sun.org.apache.xerces.internal.dom3.as.ASModel abstractSchema)
Associate an ASModel with a document instance. This ASModel will be used by the " validate-if-schema" and " datatype-normalization" options during the load of a new Document.


        // since the ASModel associated with this object is an attribute
        // according to the DOM IDL, we must obliterate anything
        // that was set before, rather than adding to it.
        // REVISIT:  so shouldn't we attempt to clear the
        // grammarPool before adding stuff to it?  - NG
        fAbstractSchema = (ASModelImpl)abstractSchema;

        // make sure the GrammarPool is properly initialized.
        XMLGrammarPool grammarPool = (XMLGrammarPool)fConfiguration.getProperty(StandardParserConfiguration.XMLGRAMMAR_POOL);
        // if there is no grammar pool, create one
        // REVISIT: ASBuilder should always create one.
        if (grammarPool == null) {
            // something's not right in this situation...
            grammarPool = new XMLGrammarPoolImpl();
            fConfiguration.setProperty(StandardParserConfiguration.XMLGRAMMAR_POOL,
                                       grammarPool);
        }
        if (fAbstractSchema != null) {
            initGrammarPool(fAbstractSchema, grammarPool);
        }