org.enhydra.xml.xmlc.dom
Class DocTypeBuilder

java.lang.Object
  |
  +--org.enhydra.xml.xmlc.dom.DocTypeBuilder

public class DocTypeBuilder
extends Object

Class for building a DOM DocumentType. Used by XMLC parsers to build a document DOM.

Since the DOM level 1 does not address storing all of the information from the DOCTYPE and DTDs required by XMLC, routine are provided to add this information. Only a subset of the information is actually saved. The internal subset is needed to reproduce the DOCTYPE declaration in the compiled document. The attribute declarations from the external subset are needed to build the table of ID attributes used to generate access methods.


Constructor Summary
DocTypeBuilder(XMLCDomFactory domFactory)
          Constructor.
 
Method Summary
 void addAttributeDecl(String elementName, String attrName, String attrType, String attrEnum, String defaultDecl, boolean internalSubset)
          Add an attribute declaration.
 void addElementDecl(String name, String contentSpec, boolean internalSubset)
          Add a document type declaration.
 void addEntityReference(String name, boolean internalSubset)
          Add an EntityReference object.
 void addExternalEntityDecl(String name, String systemId, String publicId, boolean paramEntity, boolean internalSubset)
          Add an external entity.
 void addIdAttribute(String elementName, String attributeName, boolean internalSubset)
          Define an element id attribute.
 void addInternalEntityDecl(String name, String entityValue, boolean paramEntity, boolean internalSubset)
          Add an internal entity.
 void addNotationDecl(String name, String systemId, String publicId, boolean internalSubset)
          Add a notation.
 void addUnparsedEntityDecl(String name, String notationName, boolean internalSubset)
          Add an unparsed entity.
 DocumentType getCreateDocType()
          Get the document type object, creating if necessary.
 String getDocumentTypeName()
          Get the document type name (rootElement).
 String getIdAttribute(String elementName)
          Get the id attribute name for an element.
 String getInternalSubset()
          Get the internal subset as a single string.
 String getPublicId()
          Get the publicId.
 String getSystemId()
          Get the systemId.
 void setDocumentTypeName(String name)
          Set the document type name (rootElement).
 void setInternalSubset(String subsetStr)
          Add internal subset as a single string.
 void setPublicId(String publicId)
          Set the publicId.
 void setSystemId(String systemId)
          Set the systemId.
 
Methods inherited from class java.lang.Object
, clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

DocTypeBuilder

public DocTypeBuilder(XMLCDomFactory domFactory)
Constructor.
Parameters:
domFactory - Factory class for Documents.
Method Detail

getCreateDocType

public DocumentType getCreateDocType()
Get the document type object, creating if necessary. Once created, no modifications can be made to this object. If setDocumentTypeName() has not been called, null is return. This is the cause when a document doesn't have a DTD.

setDocumentTypeName

public void setDocumentTypeName(String name)
Set the document type name (rootElement).
Parameters:
name - The Document type name (also root node name).

getDocumentTypeName

public String getDocumentTypeName()
Get the document type name (rootElement).

setPublicId

public void setPublicId(String publicId)
Set the publicId.
Parameters:
publicId - Document type public id or null if standalone.

getPublicId

public String getPublicId()
Get the publicId.

setSystemId

public void setSystemId(String systemId)
Set the systemId.
Parameters:
systemId - Document type system id or null if standalone.

getSystemId

public String getSystemId()
Get the systemId.

addIdAttribute

public void addIdAttribute(String elementName,
                           String attributeName,
                           boolean internalSubset)
Define an element id attribute.
Parameters:
elementName - The name of the element.
attributeName - The name of the ID attribute.
internalSubset - Is this part of the internal or external subset? Internal declarations take precedence.

getIdAttribute

public String getIdAttribute(String elementName)
Get the id attribute name for an element. XML only allows one id attribute per element type.
Parameters:
elementName - The name of the element.
Returns:
The attribute name or null if no ID attribute is defined.

addEntityReference

public void addEntityReference(String name,
                               boolean internalSubset)
Add an EntityReference object.
Parameters:
entity - The name of the entity.
internalSubset - Is this part of the internal or external subset?

addElementDecl

public void addElementDecl(String name,
                           String contentSpec,
                           boolean internalSubset)
Add a document type declaration.
Parameters:
name - The element name.
contentSpec - The content specification.
internalSubset - Is this part of the internal or external subset?

addAttributeDecl

public void addAttributeDecl(String elementName,
                             String attrName,
                             String attrType,
                             String attrEnum,
                             String defaultDecl,
                             boolean internalSubset)
Add an attribute declaration.
Parameters:
elementName - The element name.
attrName - The attribute name.
attrType - The attribute type specification: CDATA, ID, IDREF, IDREFS, NMTOKEN, NMTOKENS, ENTITY, ENTITIES, NOTATION or ENUMERATION.
attrEnum - - Enumeration for NOTATION and ENUMERATION.
defaultDecl - The default value declaration, REQUIRED, IMPLIED, FIXED (or DEFAULT).
internalSubset - Is this part of the internal or external subset?

addInternalEntityDecl

public void addInternalEntityDecl(String name,
                                  String entityValue,
                                  boolean paramEntity,
                                  boolean internalSubset)
Add an internal entity.
Parameters:
name - The entity name.
entityValue - The value of the entity.
paramEntity - Is this a parameter or general entity?
internalSubset - Is this part of the internal or external subset?

addExternalEntityDecl

public void addExternalEntityDecl(String name,
                                  String systemId,
                                  String publicId,
                                  boolean paramEntity,
                                  boolean internalSubset)
Add an external entity.
Parameters:
name - The entity name.
systemId - Document type system id.
publicId - Document type public id, or null if not specified.
paramEntity - Is this a parameter or general entity?
internalSubset - Is this part of the internal or external subset?

addUnparsedEntityDecl

public void addUnparsedEntityDecl(String name,
                                  String notationName,
                                  boolean internalSubset)
Add an unparsed entity.
Parameters:
name - The entity name.
notationName - The notation the entity references.
internalSubset - Is this part of the internal or external subset?

addNotationDecl

public void addNotationDecl(String name,
                            String systemId,
                            String publicId,
                            boolean internalSubset)
Add a notation.
Parameters:
name - The notation name.
systemId - Document type system id.
publicId - Document type public id, or null if not specified.
internalSubset - Is this part of the internal or external subset?

setInternalSubset

public void setInternalSubset(String subsetStr)
Add internal subset as a single string.

getInternalSubset

public String getInternalSubset()
Get the internal subset as a single string.


Copyright © 1999-2002 enhydra.org (Mark Diekhans, David Li, Richard Kunze). All Rights reserved.