|
XML Parser for Java 1.1.9 | ||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | ||||||||
SUMMARY: INNER | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |
java.lang.Object | +--com.ibm.xml.parser.Child | +--com.ibm.xml.parser.Parent | +--com.ibm.xml.parser.DTD
The DTD class implements the DocumentType interface as defined by the Document Object Model (DOM).
The DTD defines the document class (type) and indicates where to find its syntactic grammar definition.
The external DTD subset is outside the XML document. Typically, it is a standardized document. The internal DTD subset forms part of the XML document itself. The internal DTD subset often contains entity declarations that are used throughout the XML document as well as other document-specific declarations.
When an XML document has both internal and external DTD subsets, the internal subset definitions are processed first, and take precedence over external subset definitions.
The following examples illustrate an external DTD reference, an internal DTD subset, and an external DTD reference combined with an internal DTD subset:
<!DOCTYPE PGML SYSTEM "http://www.ibm.com/pgml.xml"> <!DOCTYPE PGML [ internal DTD subset ]> <!DOCTYPE PGML SYSTEM "http://www.ibm.com/pgml.xml" [ internal DTD subset ]>
DocumentType
,
Parent
,
Child
,
ExternalID
, Serialized FormField Summary | |
static java.lang.String |
CM_EOC
A constant symbol for use by getInsertableElements() and getAppendableElements() methods. |
static java.lang.String |
CM_ERROR
A constant symbol for use by getInsertableElements() and getAppendableElements() methods. |
static java.lang.String |
CM_PCDATA
A constant symbol for use by getInsertableElements() and getAppendableElements() methods. |
Fields inherited from class com.ibm.xml.parser.Child |
ATTDEF,
ATTLIST,
ELEMENT_DECL,
NAME_ATTDEF,
NAME_ATTLIST,
NAME_CDATA,
NAME_COMMENT,
NAME_DOCFRAGMENT,
NAME_DOCUMENT,
NAME_ELEMENT_DECL,
NAME_PSEUDONODE,
NAME_TEXT,
PSEUDONODE |
Constructor Summary | |
DTD()
Constructor. |
|
DTD(java.lang.String name,
ExternalID externalID)
Constructor. |
Method Summary | |
void |
acceptPost(Visitor visitor)
Implements the accept operation of the visitor design pattern when the end of a DTD Node is recognized when traversing the document object tree. |
void |
acceptPre(Visitor visitor)
Implements the accept operation of the visitor design pattern when the start of a DTD Node is recognized when traversing the document object tree. |
protected void |
checkChildType(Node child)
Check whether child is allowed to be insered in this node or not. |
boolean |
checkContent(TXElement element)
Returns whether the specified element is declared in this DTD's internal and external subsets, AND whether it currently adheres to its defined content model (see ElementDecl for details). |
Element |
checkID(java.lang.String id)
Returns the Element associated with the specified id in the XML document. |
java.lang.Object |
clone()
Clone this DTD Node and its children using the appropriate factories. |
Node |
cloneNode(boolean deep)
|
boolean |
equals(Node arg,
boolean deep)
|
java.util.Enumeration |
externalElements()
Returns an Enumeration instance of all external subset children of this DTD. |
java.util.Hashtable |
getAppendableElements(Element element,
java.util.Hashtable hashtable)
Returns a hash table which defines what kind of Element you can append onto specified element according to the document grammar specified by this DTD's internal and external subset. |
AttDef |
getAttributeDeclaration(java.lang.String elementName,
java.lang.String attributeName)
Return an AttDef instance that matches the specified elementName and attributeName in this DTD's internal and external subsets. |
java.util.Enumeration |
getAttributeDeclarations(java.lang.String elementName)
Return an Enumeration instance of all attribute list declarations for the the specified elementName in this DTD's internal and external subsets. |
ContentModel |
getContentModel(java.lang.String elementName)
Returns the ContentModel for the specified elementName in this DTD's internal and external subset (see ElementDecl for details). |
int |
getContentType(java.lang.String elementName)
Returns the content model type for the specified elementName in this DTD's internal and external subset (see ElementDecl for details). |
ElementDecl |
getElementDeclaration(java.lang.String elementName)
Return an ElementDecl instance that matches the specified elementName in this DTD's internal and external subsets. |
java.util.Enumeration |
getElementDeclarations()
Return an Enumeration instance of all element declarations in this DTD's internal and external subsets. |
NamedNodeMap |
getEntities()
This method is defined by DOM. |
EntityDecl |
getEntityDecl(java.lang.String name,
boolean isParameter)
Returns an EntityDecl in this DTD's internal and external subsets that matches the specified name and is of the specified isParameter type. |
java.util.Enumeration |
getEntityEnumeration()
Returns an Enumeration of all entities defined in this DTD's internal and external subsets. |
ExternalID |
getExternalID()
Returns the external ID associated with this DTD. |
int |
getExternalSize()
Return a number of Nodes in an external subset. |
java.util.Hashtable |
getInsertableElements(Element element,
int index,
java.util.Hashtable hashtable)
Returns a hash table which defines what kind of Element you can insert into the specified index of element according to the document grammar specified by this DTD's internal and external subset. |
java.util.Hashtable |
getInsertableElementsForValidContent(Element element,
int index,
java.util.Hashtable hashtable)
Returns a hash table which defines what kind of Element you can insert into the specified index of element according to the document grammar specified by this DTD's internal and external subset. |
int |
getInternalSize()
Return a number of Nodes in an internal subset. |
java.lang.String |
getName()
Returns this DTD's name. |
java.lang.String |
getNodeName()
This method is defined by DOM. |
short |
getNodeType()
Returns that this object is a DTD Node. |
Notation |
getNotation(java.lang.String notationName)
Return an Notation instance that matches the specified notationName in this DTD's internal and external subsets. |
java.util.Enumeration |
getNotationEnumeration()
Return an Enumeration instance of all notation declarations ( TXNotation )
in this DTD's internal and external subsets. |
NamedNodeMap |
getNotations()
Returns the NamedNodeMap which has the set of notations that were defined within this DTD's external and internal subset. |
java.util.Enumeration |
IDs()
Returns an Enumeration of all Element IDs currently registered in the XML document. |
java.util.Enumeration |
internalElements()
Returns an Enumeration instance of all internal subset children of this DTD. |
boolean |
isAttributeDeclared(java.lang.String elementName,
java.lang.String attributeName)
Return whether an attribute definition exists that matches the specified elementName and attributeName in this DTD's internal and external subsets. |
boolean |
isElementDeclared(java.lang.String elementName)
Return whether an element definition exists that matches the specified elementName in this DTD's internal and external subsets. |
boolean |
isParsingExternal()
Returns whether the internal of external DTD subset is currently being parsed. |
boolean |
isPrintInternalDTD()
Returns whether the print() method prints internal subse. |
java.util.Vector |
makeContentElementList(java.lang.String elementDeclName)
Returns a Vector of the children of the specified elementDeclName as defined by this DTD's internal and external subset. |
java.util.Hashtable |
prepareTable(java.lang.String elementName)
Prepare a hash table for use by the getInsertableElements() and
getAppendableElements() methods. |
void |
printExternal(java.io.Writer pw,
java.lang.String encoding)
Print this DTD's external subset in XML format using the specified character encoding. |
protected void |
realInsert(Node newChild,
int index)
Insert a Child Node into the specified position in this Node's list of children. |
boolean |
registID(Element element,
java.lang.String id)
Register the identifier attribute associated with the specified element in the XML document. |
void |
setEncoding(java.lang.String xmlEncoding)
Sets the value of the XML encoding parameter from the XML prolog declaration (e.g. |
void |
setExternalID(ExternalID externalID)
Sets the external ID associated with this DTD. |
void |
setName(java.lang.String name)
Deprecated. This method is removed in the next release. |
void |
setParsingExternal(boolean flag)
Sets the flag which indicates if the internal of external DTD subset is currently being parsed. |
void |
setPrintInternalDTD(boolean flag)
Sets the flag which indicates if the print() method prints the internal
subset. |
Methods inherited from class com.ibm.xml.parser.Parent |
addElement,
appendChild,
elements,
expandEntityReferences,
getChildNodes,
getChildrenArray,
getFirstChild,
getFirstWithoutReference,
getLastChild,
getLastWithoutReference,
getText,
hasChildNodes,
insert,
insertAfter,
insertBefore,
insertFirst,
insertLast,
processAfterRemove,
removeChild,
replaceChild |
Methods inherited from class com.ibm.xml.parser.Child |
clearDigest,
getAttributes,
getDigest,
getFactory,
getNextSibling,
getNextWithoutReference,
getNodeValue,
getOwnerDocument,
getParentNode,
getParentWithoutReference,
getPreviousSibling,
getPreviousWithoutReference,
makeXPointer,
print,
print,
searchAncestors,
searchAncestors,
setFactory,
setNodeValue,
toXMLString,
toXMLString |
Methods inherited from class java.lang.Object |
equals,
finalize,
getClass,
hashCode,
notify,
notifyAll,
toString,
wait,
wait,
wait |
Field Detail |
public static final java.lang.String CM_EOC
getInsertableElements()
and getAppendableElements()
methods.public static final java.lang.String CM_ERROR
getInsertableElements()
and getAppendableElements()
methods.public static final java.lang.String CM_PCDATA
getInsertableElements()
and getAppendableElements()
methods.Constructor Detail |
public DTD()
public DTD(java.lang.String name, ExternalID externalID)
name
- The name of this DTD. This value is also known as the DOCTYPE
and the root Element Name.externalID
- The external ID associated with this DTD.getName()
,
setName(java.lang.String)
,
ExternalID
Method Detail |
public java.lang.Object clone()
This method is defined by Child.
Child.clone()
,
checkID(java.lang.String)
public Node cloneNode(boolean deep)
public boolean equals(Node arg, boolean deep)
public short getNodeType()
This method is defined by DOM.
public java.lang.String getNodeName()
This method is defined by DOM.
public java.lang.String getName()
DOCTYPE
and the root Element Name.
This method is defined by DOM.
public void setName(java.lang.String name)
DOCTYPE
and the root Element Name.name
- This DTD's name.getName()
protected void realInsert(Node newChild, int index) throws DOMException
newChild
- The Node being inserted.index
- 0-based index into the list of children.setParsingExternal(boolean)
,
isParsingExternal()
,
Parent.insert(org.w3c.dom.Node, int)
public void setParsingExternal(boolean flag)
flag
- =true if parsing the external DTD subset; =false if parsing in the
internal DTD subset.isParsingExternal()
,
Parent.addElement(com.ibm.xml.parser.Child)
public boolean isParsingExternal()
setParsingExternal(boolean)
,
Parent.addElement(com.ibm.xml.parser.Child)
public java.util.Enumeration internalElements()
Parent.getChildNodes()
,
Parent.elements()
,
Parent.addElement(com.ibm.xml.parser.Child)
,
externalElements()
public java.util.Enumeration externalElements()
Parent.addElement(com.ibm.xml.parser.Child)
,
internalElements()
public ExternalID getExternalID()
setExternalID(com.ibm.xml.parser.ExternalID)
,
ExternalID
public void setExternalID(ExternalID externalID)
externalID
- The external ID associated with this DTD.getExternalID()
,
ExternalID
public java.util.Enumeration getAttributeDeclarations(java.lang.String elementName)
elementName
- The Element name to match in the internal and external DTD subsets.Parent.addElement(com.ibm.xml.parser.Child)
,
getAttributeDeclaration(java.lang.String, java.lang.String)
,
isAttributeDeclared(java.lang.String, java.lang.String)
public AttDef getAttributeDeclaration(java.lang.String elementName, java.lang.String attributeName)
elementName
- The Element name to match in the internal and external DTD subsets.attributeName
- The Attribute name to match in elementName.Parent.addElement(com.ibm.xml.parser.Child)
,
getAttributeDeclarations(java.lang.String)
,
isAttributeDeclared(java.lang.String, java.lang.String)
public boolean isAttributeDeclared(java.lang.String elementName, java.lang.String attributeName)
elementName
- The Element name to match in the internal and external DTD subsets.attributeName
- The Attribute name to match in elementName.Parent.addElement(com.ibm.xml.parser.Child)
,
getAttributeDeclarations(java.lang.String)
,
getAttributeDeclaration(java.lang.String, java.lang.String)
public java.util.Enumeration getElementDeclarations()
Parent.addElement(com.ibm.xml.parser.Child)
,
getElementDeclaration(java.lang.String)
,
isElementDeclared(java.lang.String)
,
makeContentElementList(java.lang.String)
public ElementDecl getElementDeclaration(java.lang.String elementName)
elementName
- The Element name to match in the internal and external DTD subsets.Parent.addElement(com.ibm.xml.parser.Child)
,
getElementDeclarations()
,
isElementDeclared(java.lang.String)
,
makeContentElementList(java.lang.String)
public boolean isElementDeclared(java.lang.String elementName)
elementName
- The Element name to match in the internal and external DTD subsets.Parent.addElement(com.ibm.xml.parser.Child)
,
getElementDeclarations()
,
getElementDeclaration(java.lang.String)
,
makeContentElementList(java.lang.String)
public java.util.Vector makeContentElementList(java.lang.String elementDeclName)
elementDeclName
- The element definition name to match in the internal and
external DTD subsets.Parent.addElement(com.ibm.xml.parser.Child)
,
getElementDeclarations()
,
getElementDeclaration(java.lang.String)
,
ElementDecl
public java.util.Enumeration getNotationEnumeration()
TXNotation
)
in this DTD's internal and external subsets.getNotation(java.lang.String)
public Notation getNotation(java.lang.String notationName)
notationName
- The Notation name to match in the internal and external DTD subsets.getNotations()
,
getNotationEnumeration()
public NamedNodeMap getNotations()
This method is defined by DOM.
public void setEncoding(java.lang.String xmlEncoding)
<?xml encoding="...">
).
This value is used when printing the DTD external subset.
The supported XML encodings are the intersection of XML-supported code sets and those supported in JDK 1.1:
xmlEncoding
- Value of the XML encoding parameter.MIME2Java.convert(java.lang.String)
,
printExternal(java.io.Writer, java.lang.String)
,
TXDocument.setEncoding(java.lang.String)
public void printExternal(java.io.Writer pw, java.lang.String encoding) throws java.io.IOException
pw
- The character output stream to use.encoding
- Java character encoding in use by pw.public boolean checkContent(TXElement element)
element
- The Element to check in this DTD's internal and external subset.ElementDecl
,
getContentModel(java.lang.String)
,
prepareTable(java.lang.String)
,
getInsertableElements(org.w3c.dom.Element, int, java.util.Hashtable)
,
getAppendableElements(org.w3c.dom.Element, java.util.Hashtable)
public ContentModel getContentModel(java.lang.String elementName)
elementName
- The name of element definition to check in this DTD's
internal and external subset.ElementDecl
,
checkContent(com.ibm.xml.parser.TXElement)
,
getContentType(java.lang.String)
,
prepareTable(java.lang.String)
,
getInsertableElements(org.w3c.dom.Element, int, java.util.Hashtable)
,
getAppendableElements(org.w3c.dom.Element, java.util.Hashtable)
public int getContentType(java.lang.String elementName)
elementName
- The name of element definition to check in this DTD's
internal and external subset.ElementDecl
,
checkContent(com.ibm.xml.parser.TXElement)
,
getContentModel(java.lang.String)
,
prepareTable(java.lang.String)
,
getInsertableElements(org.w3c.dom.Element, int, java.util.Hashtable)
,
getAppendableElements(org.w3c.dom.Element, java.util.Hashtable)
public java.util.Hashtable prepareTable(java.lang.String elementName)
getInsertableElements()
and
getAppendableElements()
methods. Refer to getInsertableElements
for details on how this table is used.elementName
- The name of Element to use in building the hash table.getInsertableElements(org.w3c.dom.Element, int, java.util.Hashtable)
,
getAppendableElements(org.w3c.dom.Element, java.util.Hashtable)
,
InsertableElement
public java.util.Hashtable getInsertableElements(Element element, int index, java.util.Hashtable hashtable)
Usage:
DTD dtd = ...;
Hashtable table = dtd.prepareTable(element.getName());
dtd.getInsertableElements(element, index, table);
The resulting table instance consists of Element names as keys and InsertableElement as values. The following information is available about table:
insertableElement = (InsertableElement)hashtable.get("elementName")
insertableElement != null
AND insertableElement.status == true
you can insert elementName Elements under element.
Note that this does not mean that element will be guaranteed to have
correct contents after the insertion. Otherwise, the elementName
may not be inserted.
insertableElement == null
,
elementName may be inserted. Otherwise, elementName may
not be inserted.
insertableElement = (InsertableElement)hashtable.get(DTD.CM_PCDATA)
insertableElement.status == true
, you can insert any
a TXText Node under element. Note that this does not mean
that element will be guaranteed to have correct contents after the
insertion. Otherwise, a TXText Node may not be inserted.
insertableElement = (InsertableElement)hashtable.get(DTD.CM_EOC)
insertableElement.status
indicates whether element has
correct and complete contents in the subsequence of children [0, index-1].
insertableElement = (InsertableElement)hashtable.get(DTD.CM_ERROR)
=true
,
insertableElement.index is the index of the first incorrect Child
Node of the specified element. Note that you might still be able to
insert Elements under element even if
insertableElement.status
is =true
.
element
- The Element to use in building the hash table.index
- The 0-based index of element's children which are
to be examined for validity in preparation for insertion.hashtable
- The hash table built by prepareTable
.prepareTable(java.lang.String)
,
getAppendableElements(org.w3c.dom.Element, java.util.Hashtable)
,
getInsertableElementsForValidContent(org.w3c.dom.Element, int, java.util.Hashtable)
,
InsertableElement
public java.util.Hashtable getAppendableElements(Element element, java.util.Hashtable hashtable)
getInsertableElements
for details on how this table is used.element
- The Element to use in building the hash table.hashtable
- The hash table built by prepareTable
.prepareTable(java.lang.String)
,
getInsertableElements(org.w3c.dom.Element, int, java.util.Hashtable)
,
InsertableElement
public java.util.Hashtable getInsertableElementsForValidContent(Element element, int index, java.util.Hashtable hashtable)
This method can be used when element already has valid content. After insertion of returned element to element, element will have valid content.
element
- The Element to use in building the hash table.index
- The 0-based index of element's children which are
to be examined for validity in preparation for insertion.hashtable
- The hash table built by prepareTable
.prepareTable(java.lang.String)
,
getInsertableElements(org.w3c.dom.Element, int, java.util.Hashtable)
,
InsertableElement
public boolean registID(Element element, java.lang.String id)
The XML4J parser automatically invokes this method when parsing a document with DTD.
element
- Element to be registered.id
- Identifier to be registered.checkID(java.lang.String)
,
IDs()
public Element checkID(java.lang.String id)
id
- Identifier to be matched.registID(org.w3c.dom.Element, java.lang.String)
,
IDs()
public java.util.Enumeration IDs()
checkID(java.lang.String)
,
IDs()
public java.util.Enumeration getEntityEnumeration()
EntityDecl
public EntityDecl getEntityDecl(java.lang.String name, boolean isParameter)
name
- The entity name to match against in this DTD's internal and external
DTD subset.isParameter
- =true if a parameter entity; otherwise =false.getEntityEnumeration()
public NamedNodeMap getEntities()
This method is defined by DOM.
getEntityEnumeration()
public int getInternalSize()
public int getExternalSize()
public void setPrintInternalDTD(boolean flag)
print()
method prints the internal
subset. By default, the internal DTD subset is printed.isPrintInternalDTD()
,
Child.print(java.io.Writer, java.lang.String)
public boolean isPrintInternalDTD()
print()
method prints internal subse.setPrintInternalDTD(boolean)
,
Child.print(java.io.Writer, java.lang.String)
public void acceptPre(Visitor visitor) throws java.lang.Exception
visitor
- The implemention of the Visitor operation (toXMLString, digest, ...)Visitor
,
TreeTraversal
,
NonRecursivePreorderTreeTraversal
,
TreeTraversalException
public void acceptPost(Visitor visitor) throws java.lang.Exception
visitor
- The implemention of the Visitor operation (toXMLString, digest, ...)Visitor
,
TreeTraversal
,
NonRecursivePreorderTreeTraversal
,
TreeTraversalException
protected void checkChildType(Node child) throws DOMException
|
XML Parser for Java 1.1.9 | ||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | ||||||||
SUMMARY: INNER | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |