## org.apache.xerces.impl.xs
Class SchemaGrammar

    java.lang.Object
      |
      +--org.apache.xerces.impl.xs.SchemaGrammar

All Implemented Interfaces:
  org.apache.xerces.xni.grammars.Grammar, org.apache.xerces.xni.grammars.XSGrammar, org.apache.xerces.xs.XSNamespaceItem

Direct Known Subclasses:
  SchemaGrammar.BuiltinSchemaGrammar, SchemaGrammar.Schema4Annotations

public class SchemaGrammar
extends java.lang.Object
implements org.apache.xerces.xni.grammars.XSGrammar, org.apache.xerces.xs.XSNamespaceItem

This class is to hold all schema component declaration that are declared within one namespace. The Grammar class this class extends contains what little commonality there is between XML Schema and DTD grammars. It's useful to distinguish grammar objects from other kinds of object when they exist in pools or caches.

# INTERNAL:

  Usage of this class is not supported. It may be altered or removed at any time.

Version:
  $Id: SchemaGrammar.java 1024038 2010-10-18 22:06:35Z sandygao $
Author:
  Sandy Gao, IBM, Elena Litani, IBM

Inner Class Summary
`static class` `SchemaGrammar.BuiltinSchemaGrammar`
`static class` `SchemaGrammar.Schema4Annotations` A partial schema for schemas for validating annotations.

Field Summary
`static XSSimpleType` `fAnySimpleType`
`static XSComplexTypeDecl` `fAnyType`
`static SchemaGrammar.BuiltinSchemaGrammar` `SG_SchemaNS`
`static SchemaGrammar.BuiltinSchemaGrammar` `SG_XSI`

Constructor Summary
`protected` `SchemaGrammar()`
`` `SchemaGrammar(SchemaGrammar grammar)`
`` `SchemaGrammar(java.lang.String targetNamespace, XSDDescription grammarDesc, SymbolTable symbolTable)` Default constructor.

Method Summary
`void` `addAnnotation(XSAnnotationImpl annotation)`
`void` `addComplexTypeDecl(XSComplexTypeDecl decl, SimpleLocator locator)` add one complex type decl: for later constraint checking
`void` `addDocument(java.lang.Object document, java.lang.String location)`
`void` `addGlobalAttributeDecl(XSAttributeDecl decl)` register one global attribute
`void` `addGlobalAttributeDecl(XSAttributeDecl decl, java.lang.String location)`
`void` `addGlobalAttributeGroupDecl(XSAttributeGroupDecl decl)` register one global attribute group
`void` `addGlobalAttributeGroupDecl(XSAttributeGroupDecl decl, java.lang.String location)`
`void` `addGlobalComplexTypeDecl(XSComplexTypeDecl decl)` register one global complex type
`void` `addGlobalComplexTypeDecl(XSComplexTypeDecl decl, java.lang.String location)`
`void` `addGlobalElementDecl(XSElementDecl decl)`
`void` `addGlobalElementDecl(XSElementDecl decl, java.lang.String location)`
`void` `addGlobalElementDeclAll(XSElementDecl decl)` register one global element
`void` `addGlobalGroupDecl(XSGroupDecl decl)` register one global group
`void` `addGlobalGroupDecl(XSGroupDecl decl, java.lang.String location)`
`void` `addGlobalNotationDecl(XSNotationDecl decl)` register one global notation
`void` `addGlobalNotationDecl(XSNotationDecl decl, java.lang.String location)`
`void` `addGlobalSimpleTypeDecl(XSSimpleType decl)` register one global simple type
`void` `addGlobalSimpleTypeDecl(XSSimpleType decl, java.lang.String location)`
`void` `addGlobalTypeDecl(org.apache.xerces.xs.XSTypeDefinition decl)` register one global type
`void` `addGlobalTypeDecl(org.apache.xerces.xs.XSTypeDefinition decl, java.lang.String location)`
`void` `addIDConstraintDecl(XSElementDecl elmDecl, IdentityConstraint decl)` register one identity constraint
`void` `addIDConstraintDecl(XSElementDecl elmDecl, IdentityConstraint decl, java.lang.String location)`
`void` `addRedefinedGroupDecl(XSGroupDecl derived, XSGroupDecl base, SimpleLocator locator)` add a group redefined by restriction: for later constraint checking
`org.apache.xerces.xs.XSObjectList` `getAnnotations()` [annotations]: a set of annotations if it exists, otherwise an empty `XSObjectList`.
`org.apache.xerces.xs.XSAttributeDeclaration` `getAttributeDeclaration(java.lang.String name)` Convenience method.
`org.apache.xerces.xs.XSAttributeGroupDefinition` `getAttributeGroup(java.lang.String name)` Convenience method.
`org.apache.xerces.xs.XSNamedMap` `getComponents(short objectType)` [schema components]: a list of top-level components, i.e.
`org.apache.xerces.xs.datatypes.ObjectList` `getComponentsExt(short objectType)`
`org.apache.xerces.xs.StringList` `getDocumentLocations()` [document location]
`org.apache.xerces.xs.XSElementDeclaration` `getElementDeclaration(java.lang.String name)` Convenience method.
`XSAttributeDecl` `getGlobalAttributeDecl(java.lang.String declName)` get one global attribute
`XSAttributeDecl` `getGlobalAttributeDecl(java.lang.String declName, java.lang.String location)`
`XSAttributeGroupDecl` `getGlobalAttributeGroupDecl(java.lang.String declName)` get one global attribute group
`XSAttributeGroupDecl` `getGlobalAttributeGroupDecl(java.lang.String declName, java.lang.String location)`
`XSElementDecl` `getGlobalElementDecl(java.lang.String declName)` get one global element
`XSElementDecl` `getGlobalElementDecl(java.lang.String declName, java.lang.String location)`
`XSGroupDecl` `getGlobalGroupDecl(java.lang.String declName)` get one global group
`XSGroupDecl` `getGlobalGroupDecl(java.lang.String declName, java.lang.String location)`
`XSNotationDecl` `getGlobalNotationDecl(java.lang.String declName)` get one global notation
`XSNotationDecl` `getGlobalNotationDecl(java.lang.String declName, java.lang.String location)`
`org.apache.xerces.xs.XSTypeDefinition` `getGlobalTypeDecl(java.lang.String declName)` get one global type
`org.apache.xerces.xs.XSTypeDefinition` `getGlobalTypeDecl(java.lang.String declName, java.lang.String location)`
`org.apache.xerces.xni.grammars.XMLGrammarDescription` `getGrammarDescription()` get the `XMLGrammarDescription` associated with this object
`org.apache.xerces.xs.XSIDCDefinition` `getIDCDefinition(java.lang.String name)` Convenience method.
`IdentityConstraint` `getIDConstraintDecl(java.lang.String declName)` get one identity constraint
`IdentityConstraint` `getIDConstraintDecl(java.lang.String declName, java.lang.String location)`
`java.util.Vector` `getImportedGrammars()`
`org.apache.xerces.xs.XSModelGroupDefinition` `getModelGroupDefinition(java.lang.String name)` Convenience method.
`org.apache.xerces.xs.XSNotationDeclaration` `getNotationDeclaration(java.lang.String name)` Convenience method.
`static SchemaGrammar` `getS4SGrammar(short schemaVersion)`
`java.lang.String` `getSchemaNamespace()` [schema namespace]
`java.lang.String` `getTargetNamespace()` Returns this grammar's target namespace.
`org.apache.xerces.xs.XSTypeDefinition` `getTypeDefinition(java.lang.String name)` Convenience method.
`boolean` `hasIDConstraints()` get one identity constraint
`boolean` `isImmutable()`
`boolean` `isNamespaceAware()`
`void` `removeDocument(int index)`
`void` `resetComponents()`
`void` `setImmutable(boolean isImmutable)`
`void` `setImportedGrammars(java.util.Vector importedGrammars)`
`org.apache.xerces.xs.XSModel` `toXSModel()` Return an `XSModel` that represents components in this schema grammar.
`org.apache.xerces.xs.XSModel` `toXSModel(org.apache.xerces.xni.grammars.XSGrammar[] grammars)` Return an `XSModel` that represents components in this schema grammar and the grammars in the `grammars`parameter, any schema grammars that are imported by them directly or indirectly.

Methods inherited from class java.lang.Object
`clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait`

Field Detail

### fAnyType

    public static final XSComplexTypeDecl fAnyType

### SG_SchemaNS

    public static final SchemaGrammar.BuiltinSchemaGrammar SG_SchemaNS

### fAnySimpleType

    public static final XSSimpleType fAnySimpleType

### SG_XSI

    public static final SchemaGrammar.BuiltinSchemaGrammar SG_XSI

Constructor Detail

### SchemaGrammar

    protected SchemaGrammar()

### SchemaGrammar

    public SchemaGrammar(java.lang.String targetNamespace,
                         XSDDescription grammarDesc,
                         SymbolTable symbolTable)

  Default constructor.
  Parameters:
    `targetNamespace` -
    `grammarDesc` - the XMLGrammarDescription corresponding to this objec at the least a systemId should always be known.
    `symbolTable` - needed for annotation support

### SchemaGrammar

    public SchemaGrammar(SchemaGrammar grammar)

Method Detail

### getGrammarDescription

    public org.apache.xerces.xni.grammars.XMLGrammarDescription getGrammarDescription()

  Description copied from interface: `org.apache.xerces.xni.grammars.Grammar`
  get the `XMLGrammarDescription` associated with this object
  Specified by:
    `getGrammarDescription` in interface `org.apache.xerces.xni.grammars.Grammar`

### isNamespaceAware

    public boolean isNamespaceAware()

### setImportedGrammars

    public void setImportedGrammars(java.util.Vector importedGrammars)

### getImportedGrammars

    public java.util.Vector getImportedGrammars()

### getTargetNamespace

    public final java.lang.String getTargetNamespace()

  Returns this grammar's target namespace.

### addGlobalAttributeDecl

    public void addGlobalAttributeDecl(XSAttributeDecl decl)

  register one global attribute

### addGlobalAttributeDecl

    public void addGlobalAttributeDecl(XSAttributeDecl decl,
                                       java.lang.String location)

### addGlobalAttributeGroupDecl

    public void addGlobalAttributeGroupDecl(XSAttributeGroupDecl decl)

  register one global attribute group

### addGlobalAttributeGroupDecl

    public void addGlobalAttributeGroupDecl(XSAttributeGroupDecl decl,
                                            java.lang.String location)

### addGlobalElementDeclAll

    public void addGlobalElementDeclAll(XSElementDecl decl)

  register one global element

### addGlobalElementDecl

    public void addGlobalElementDecl(XSElementDecl decl)

### addGlobalElementDecl

    public void addGlobalElementDecl(XSElementDecl decl,
                                     java.lang.String location)

### addGlobalGroupDecl

    public void addGlobalGroupDecl(XSGroupDecl decl)

  register one global group

### addGlobalGroupDecl

    public void addGlobalGroupDecl(XSGroupDecl decl,
                                   java.lang.String location)

### addGlobalNotationDecl

    public void addGlobalNotationDecl(XSNotationDecl decl)

  register one global notation

### addGlobalNotationDecl

    public void addGlobalNotationDecl(XSNotationDecl decl,
                                      java.lang.String location)

### addGlobalTypeDecl

    public void addGlobalTypeDecl(org.apache.xerces.xs.XSTypeDefinition decl)

  register one global type

### addGlobalTypeDecl

    public void addGlobalTypeDecl(org.apache.xerces.xs.XSTypeDefinition decl,
                                  java.lang.String location)

### addGlobalComplexTypeDecl

    public void addGlobalComplexTypeDecl(XSComplexTypeDecl decl)

  register one global complex type

### addGlobalComplexTypeDecl

    public void addGlobalComplexTypeDecl(XSComplexTypeDecl decl,
                                         java.lang.String location)

### addGlobalSimpleTypeDecl

    public void addGlobalSimpleTypeDecl(XSSimpleType decl)

  register one global simple type

### addGlobalSimpleTypeDecl

    public void addGlobalSimpleTypeDecl(XSSimpleType decl,
                                        java.lang.String location)

### addIDConstraintDecl

    public final void addIDConstraintDecl(XSElementDecl elmDecl,
                                          IdentityConstraint decl)

  register one identity constraint

### addIDConstraintDecl

    public final void addIDConstraintDecl(XSElementDecl elmDecl,
                                          IdentityConstraint decl,
                                          java.lang.String location)

### getGlobalAttributeDecl

    public final XSAttributeDecl getGlobalAttributeDecl(java.lang.String declName)

  get one global attribute

### getGlobalAttributeDecl

    public final XSAttributeDecl getGlobalAttributeDecl(java.lang.String declName,
                                                        java.lang.String location)

### getGlobalAttributeGroupDecl

    public final XSAttributeGroupDecl getGlobalAttributeGroupDecl(java.lang.String declName)

  get one global attribute group

### getGlobalAttributeGroupDecl

    public final XSAttributeGroupDecl getGlobalAttributeGroupDecl(java.lang.String declName,
                                                                  java.lang.String location)

### getGlobalElementDecl

    public final XSElementDecl getGlobalElementDecl(java.lang.String declName)

  get one global element

### getGlobalElementDecl

    public final XSElementDecl getGlobalElementDecl(java.lang.String declName,
                                                    java.lang.String location)

### getGlobalGroupDecl

    public final XSGroupDecl getGlobalGroupDecl(java.lang.String declName)

  get one global group

### getGlobalGroupDecl

    public final XSGroupDecl getGlobalGroupDecl(java.lang.String declName,
                                                java.lang.String location)

### getGlobalNotationDecl

    public final XSNotationDecl getGlobalNotationDecl(java.lang.String declName)

  get one global notation

### getGlobalNotationDecl

    public final XSNotationDecl getGlobalNotationDecl(java.lang.String declName,
                                                      java.lang.String location)

### getGlobalTypeDecl

    public final org.apache.xerces.xs.XSTypeDefinition getGlobalTypeDecl(java.lang.String declName)

  get one global type

### getGlobalTypeDecl

    public final org.apache.xerces.xs.XSTypeDefinition getGlobalTypeDecl(java.lang.String declName,
                                                                         java.lang.String location)

### getIDConstraintDecl

    public final IdentityConstraint getIDConstraintDecl(java.lang.String declName)

  get one identity constraint

### getIDConstraintDecl

    public final IdentityConstraint getIDConstraintDecl(java.lang.String declName,
                                                        java.lang.String location)

### hasIDConstraints

    public final boolean hasIDConstraints()

  get one identity constraint

### addComplexTypeDecl

    public void addComplexTypeDecl(XSComplexTypeDecl decl,
                                   SimpleLocator locator)

  add one complex type decl: for later constraint checking

### addRedefinedGroupDecl

    public void addRedefinedGroupDecl(XSGroupDecl derived,
                                      XSGroupDecl base,
                                      SimpleLocator locator)

  add a group redefined by restriction: for later constraint checking

### getS4SGrammar

    public static SchemaGrammar getS4SGrammar(short schemaVersion)

### addDocument

    public void addDocument(java.lang.Object document,
                            java.lang.String location)

### removeDocument

    public void removeDocument(int index)

### getSchemaNamespace

    public java.lang.String getSchemaNamespace()

  [schema namespace]
  Specified by:
    `getSchemaNamespace` in interface `org.apache.xerces.xs.XSNamespaceItem`
  Returns:
    The target namespace of this item.
  See Also:
    [schema namespace]

### getComponents

    public org.apache.xerces.xs.XSNamedMap getComponents(short objectType)

  [schema components]: a list of top-level components, i.e. element declarations, attribute declarations, etc.
  Specified by:
    `getComponents` in interface `org.apache.xerces.xs.XSNamespaceItem`
  Parameters:
    `objectType` - The type of the declaration, i.e. `ELEMENT_DECLARATION`. Note that `XSTypeDefinition.SIMPLE_TYPE` and `XSTypeDefinition.COMPLEX_TYPE` can also be used as the `objectType` to retrieve only complex types or simple types, instead of all types.
  Returns:
    A list of top-level definition of the specified type in `objectType` or an empty `XSNamedMap` if no such definitions exist.

### getComponentsExt

    public org.apache.xerces.xs.datatypes.ObjectList getComponentsExt(short objectType)

### resetComponents

    public void resetComponents()

### getTypeDefinition

    public org.apache.xerces.xs.XSTypeDefinition getTypeDefinition(java.lang.String name)

  Convenience method. Returns a top-level simple or complex type definition.
  Specified by:
    `getTypeDefinition` in interface `org.apache.xerces.xs.XSNamespaceItem`
  Parameters:
    `name` - The name of the definition.
  Returns:
    An `XSTypeDefinition` or null if such definition does not exist.

### getAttributeDeclaration

    public org.apache.xerces.xs.XSAttributeDeclaration getAttributeDeclaration(java.lang.String name)

  Convenience method. Returns a top-level attribute declaration.
  Specified by:
    `getAttributeDeclaration` in interface `org.apache.xerces.xs.XSNamespaceItem`
  Parameters:
    `name` - The name of the declaration.
  Returns:
    A top-level attribute declaration or null if such declaration does not exist.

### getElementDeclaration

    public org.apache.xerces.xs.XSElementDeclaration getElementDeclaration(java.lang.String name)

  Convenience method. Returns a top-level element declaration.
  Specified by:
    `getElementDeclaration` in interface `org.apache.xerces.xs.XSNamespaceItem`
  Parameters:
    `name` - The name of the declaration.
  Returns:
    A top-level element declaration or null if such declaration does not exist.

### getAttributeGroup

    public org.apache.xerces.xs.XSAttributeGroupDefinition getAttributeGroup(java.lang.String name)

  Convenience method. Returns a top-level attribute group definition.
  Specified by:
    `getAttributeGroup` in interface `org.apache.xerces.xs.XSNamespaceItem`
  Parameters:
    `name` - The name of the definition.
  Returns:
    A top-level attribute group definition or null if such definition does not exist.

### getModelGroupDefinition

    public org.apache.xerces.xs.XSModelGroupDefinition getModelGroupDefinition(java.lang.String name)

  Convenience method. Returns a top-level model group definition.
  Specified by:
    `getModelGroupDefinition` in interface `org.apache.xerces.xs.XSNamespaceItem`
  Parameters:
    `name` - The name of the definition.
  Returns:
    A top-level model group definition definition or null if such definition does not exist.

### getNotationDeclaration

    public org.apache.xerces.xs.XSNotationDeclaration getNotationDeclaration(java.lang.String name)

  Convenience method. Returns a top-level notation declaration.
  Specified by:
    `getNotationDeclaration` in interface `org.apache.xerces.xs.XSNamespaceItem`
  Parameters:
    `name` - The name of the declaration.
  Returns:
    A top-level notation declaration or null if such declaration does not exist.

### getIDCDefinition

    public org.apache.xerces.xs.XSIDCDefinition getIDCDefinition(java.lang.String name)

  Description copied from interface: `org.apache.xerces.xs.XSNamespaceItem`
  Convenience method. Returns an identity-constraint definition.
  Specified by:
    `getIDCDefinition` in interface `org.apache.xerces.xs.XSNamespaceItem`
  Following copied from interface: `org.apache.xerces.xs.XSNamespaceItem`
  Parameters:
    `name` - The name of the definition.
  Returns:
    An identity-constraint definition or `null` if such a declaration does not exist.

### getDocumentLocations

    public org.apache.xerces.xs.StringList getDocumentLocations()

  [document location]
  Specified by:
    `getDocumentLocations` in interface `org.apache.xerces.xs.XSNamespaceItem`
  Returns:
    a list of document information item
  See Also:
    [document location]

### toXSModel

    public org.apache.xerces.xs.XSModel toXSModel()

  Return an `XSModel` that represents components in this schema grammar.
  Specified by:
    `toXSModel` in interface `org.apache.xerces.xni.grammars.XSGrammar`
  Returns:
    an `XSModel` representing this schema grammar

### toXSModel

    public org.apache.xerces.xs.XSModel toXSModel(org.apache.xerces.xni.grammars.XSGrammar[] grammars)

  Description copied from interface: `org.apache.xerces.xni.grammars.XSGrammar`
  Return an `XSModel` that represents components in this schema grammar and the grammars in the `grammars`parameter, any schema grammars that are imported by them directly or indirectly.
  Specified by:
    `toXSModel` in interface `org.apache.xerces.xni.grammars.XSGrammar`
  Following copied from interface: `org.apache.xerces.xni.grammars.XSGrammar`
  Returns:
    an `XSModel` representing these schema grammars

### getAnnotations

    public org.apache.xerces.xs.XSObjectList getAnnotations()

  Description copied from interface: `org.apache.xerces.xs.XSNamespaceItem`
  [annotations]: a set of annotations if it exists, otherwise an empty `XSObjectList`.
  Specified by:
    `getAnnotations` in interface `org.apache.xerces.xs.XSNamespaceItem`
  See Also:
    `XSNamespaceItem.getAnnotations()`

### addAnnotation

    public void addAnnotation(XSAnnotationImpl annotation)

### setImmutable

    public void setImmutable(boolean isImmutable)

### isImmutable

    public boolean isImmutable()

Copyright © 1999-2010 The Apache Software Foundation. All Rights Reserved.