home *** CD-ROM | disk | FTP | other *** search
Wrap
package com.ms.xml.parser; import com.ms.xml.om.Element; import com.ms.xml.util.Name; import com.ms.xml.util.QualifiedName; import com.ms.xml.util.XMLOutputStream; import java.io.IOException; import java.util.Enumeration; import java.util.Hashtable; public class DTD { static Hashtable builtin = new Hashtable(); Hashtable entities; Hashtable elementdecls; Hashtable notations; Hashtable shortNameSpaces; Hashtable longNameSpaces; Hashtable loadedNameSpaces; Hashtable ids; IDCheck idCheck; Name docType; static Name nameXML = Name.create("XML"); public final void addLoadedNameSpace(Name var1) { if (this.loadedNameSpaces == null) { this.loadedNameSpaces = new Hashtable(); } this.loadedNameSpaces.put(var1, var1); } public final Name findShortNameSpace(Name var1) { return this.shortNameSpaces == null ? null : (Name)this.shortNameSpaces.get(var1); } public static boolean isReservedNameSpace(Name var0) { return var0 == nameXML; } final Element findID(Name var1) { return this.ids == null ? null : (Element)this.ids.get(var1); } final void addIDCheck(Name var1, int var2, int var3, Object var4) { this.idCheck = new IDCheck(this.idCheck, var1, var2, var3, var4); } public final Name getDocType() { return this.docType; } final void addNotation(Notation var1) { if (this.notations == null) { this.notations = new Hashtable(); } this.notations.put(var1.name, var1); } final void addEntity(Entity var1) { if (this.entities == null) { this.entities = new Hashtable(); } this.entities.put(var1.name, var1); } final void addElementDecl(ElementDecl var1) { if (this.elementdecls == null) { this.elementdecls = new Hashtable(); } this.elementdecls.put(var1.name, var1); } public final void addNameSpace(Name var1, Name var2) { if (this.shortNameSpaces == null) { this.shortNameSpaces = new Hashtable(); this.longNameSpaces = new Hashtable(); } this.shortNameSpaces.put(var2, var1); this.longNameSpaces.put(var1, var2); } public final Name findLongNameSpace(Name var1) { return this.longNameSpaces == null ? null : (Name)this.longNameSpaces.get(var1); } public final Name findLoadedNameSpace(Name var1) { if (var1 == null) { return null; } else { return this.loadedNameSpaces == null ? null : (Name)this.loadedNameSpaces.get(var1); } } static { Name var0 = Name.create("apos"); builtin.put(var0, new Entity(var0, false, 39)); var0 = Name.create("quot"); builtin.put(var0, new Entity(var0, false, 34)); var0 = Name.create("amp"); builtin.put(var0, new Entity(var0, false, 38)); var0 = Name.create("lt"); builtin.put(var0, new Entity(var0, false, 60)); var0 = Name.create("gt"); builtin.put(var0, new Entity(var0, false, 62)); var0 = Name.create("nbsp"); builtin.put(var0, new Entity(var0, false, 160)); } public final void save(XMLOutputStream var1) throws IOException { if (this.notations != null) { Enumeration var2 = this.notations.elements(); while(var2.hasMoreElements()) { Notation var3 = (Notation)var2.nextElement(); var1.writeIndent(); var3.save(var1); } } if (this.entities != null) { Enumeration var4 = this.entities.elements(); while(var4.hasMoreElements()) { Entity var6 = (Entity)var4.nextElement(); var1.writeIndent(); var6.save(var1); } } if (this.elementdecls != null) { Enumeration var5 = this.elementdecls.elements(); while(var5.hasMoreElements()) { ElementDecl var7 = (ElementDecl)var5.nextElement(); var1.writeIndent(); var7.save(var1); } } } public final Enumeration elementDeclarations() { return this.elementdecls == null ? null : this.elementdecls.elements(); } final void addID(Name var1, Element var2) { if (this.ids == null) { this.ids = new Hashtable(); } this.ids.put(var1, var2); } final void checkIDs() throws ParseException { while(this.idCheck != null) { if (this.findID(this.idCheck.name) == null) { throw new ParseException("Couldn't find element with ID '" + this.idCheck.name.toString() + "'", this.idCheck.line, this.idCheck.col, this.idCheck.owner); } this.idCheck = this.idCheck.next; } } public final void clear() { if (this.entities != null) { this.entities.clear(); } if (this.elementdecls != null) { this.elementdecls.clear(); } if (this.notations != null) { this.notations.clear(); } if (this.ids != null) { this.ids.clear(); } this.idCheck = null; } public final ElementDecl findElementDecl(Name var1) { return this.elementdecls == null ? null : (ElementDecl)this.elementdecls.get(var1); } public final Entity findEntity(Name var1) { Object var2; if (var1 instanceof QualifiedName) { var2 = builtin.get(((QualifiedName)var1).getName()); } else { var2 = builtin.get(var1); } if (var2 != null) { return (Entity)var2; } else { return this.entities == null ? null : (Entity)this.entities.get(var1); } } public final Notation findNotation(Name var1) { return this.notations == null ? null : (Notation)this.notations.get(var1); } }