[llvm-commits] [llvm-gcc-4.2] r43913 [29/80] - in /llvm-gcc-4.2/trunk: boehm-gc/ boehm-gc/Mac_files/ boehm-gc/cord/ boehm-gc/doc/ boehm-gc/include/ boehm-gc/include/private/ boehm-gc/tests/ libffi/ libffi/include/ libffi/src/ libffi/src/alpha/ libffi/src/arm/ libffi/src/cris/ libffi/src/frv/ libffi/src/ia64/ libffi/src/m32r/ libffi/src/m68k/ libffi/src/mips/ libffi/src/pa/ libffi/src/powerpc/ libffi/src/s390/ libffi/src/sh/ libffi/src/sh64/ libffi/src/sparc/ libffi/src/x86/ libffi/testsuite/ libffi/testsuite/config/ li...
Bill Wendling
isanbard at gmail.com
Thu Nov 8 14:57:11 PST 2007
Added: llvm-gcc-4.2/trunk/libjava/classpath/gnu/javax/swing/text/html/parser/HTML_401F.java
URL: http://llvm.org/viewvc/llvm-project/llvm-gcc-4.2/trunk/libjava/classpath/gnu/javax/swing/text/html/parser/HTML_401F.java?rev=43913&view=auto
==============================================================================
--- llvm-gcc-4.2/trunk/libjava/classpath/gnu/javax/swing/text/html/parser/HTML_401F.java (added)
+++ llvm-gcc-4.2/trunk/libjava/classpath/gnu/javax/swing/text/html/parser/HTML_401F.java Thu Nov 8 16:56:19 2007
@@ -0,0 +1,3736 @@
+/* HTML_401F.java -- HTML 4.01 FRAMESET DTD java conception.
+ Copyright (C) 2005 Free Software Foundation, Inc.
+
+This file is part of GNU Classpath.
+
+GNU Classpath is free software; you can redistribute it and/or modify
+it under the terms of the GNU General Public License as published by
+the Free Software Foundation; either version 2, or (at your option)
+any later version.
+
+GNU Classpath is distributed in the hope that it will be useful, but
+WITHOUT ANY WARRANTY; without even the implied warranty of
+MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+General Public License for more details.
+
+You should have received a copy of the GNU General Public License
+along with GNU Classpath; see the file COPYING. If not, write to the
+Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA
+02110-1301 USA.
+
+Linking this library statically or dynamically with other modules is
+making a combined work based on this library. Thus, the terms and
+conditions of the GNU General Public License cover the whole
+combination.
+
+As a special exception, the copyright holders of this library give you
+permission to link this library with independent modules to produce an
+executable, regardless of the license terms of these independent
+modules, and to copy and distribute the resulting executable under
+terms of your choice, provided that you also meet, for each linked
+independent module, the terms and conditions of the license of that
+module. An independent module is a module which is not derived from
+or based on this library. If you modify this library, you may extend
+this exception to your version of the library, but you are not
+obligated to do so. If you do not wish to do so, delete this
+exception statement from your version. */
+
+
+package gnu.javax.swing.text.html.parser;
+
+import gnu.javax.swing.text.html.parser.models.PCDATAonly_model;
+import gnu.javax.swing.text.html.parser.models.TableRowContentModel;
+import gnu.javax.swing.text.html.parser.models.noTagModel;
+
+import java.io.IOException;
+import java.io.Serializable;
+
+import javax.swing.text.html.parser.*;
+import javax.swing.text.html.parser.ContentModel;
+import javax.swing.text.html.parser.DTDConstants;
+
+/**
+ * This class represents the java implementation of the HTML 4.01
+ * ( -//W3C//DTD HTML 4.01 Frameset//EN ) Frameset version. The
+ * Frameset version includes as recommended, as obsoleted features and
+ * also the frameset support. This the default DTD to parse HTML
+ * documents in this implementation, containing 315 pre-defined general
+ * entities and 92 elements.
+ *
+ * @author Audrius Meskauskas, Lithuania (AudriusA at Bioinformatics.org)
+ */
+public class HTML_401F
+ extends gnuDTD
+ implements DTDConstants, Serializable
+{
+ private static final long serialVersionUID = 1;
+
+ /**
+ * The standard name of this DTD,
+ * '-//W3C//DTD HTML 4.01 Frameset//EN'
+ */
+ public static final String DTD_NAME = "-//W3C//DTD HTML 4.01 Frameset//EN";
+
+ /**
+ * The integer representing length in pixels.
+ */
+ static final int PIXELS = NUMBER;
+
+ static final String[] NONE = new String[0];
+
+ /* Define the HTML tags. */
+ static final String PCDATA = "#pcdata";
+ static final String A = "a";
+ static final String ABBR = "abbr";
+ static final String ACRONYM = "acronym";
+ static final String ADDRESS = "address";
+ static final String APPLET = "applet";
+ static final String AREA = "area";
+ static final String B = "b";
+ static final String BASE = "base";
+ static final String BASEFONT = "basefont";
+ static final String BDO = "bdo";
+ static final String BIG = "big";
+ static final String BLOCKQUOTE = "blockquote";
+ static final String BODY = "body";
+ static final String BR = "br";
+ static final String BUTTON = "button";
+ static final String CAPTION = "caption";
+ static final String CENTER = "center";
+ static final String CITE = "cite";
+ static final String CODE = "code";
+ static final String COL = "col";
+ static final String COLGROUP = "colgroup";
+ static final String DEFAULTS = "default";
+ static final String DD = "dd";
+ static final String DEL = "del";
+ static final String DFN = "dfn";
+ static final String DIR = "dir";
+ static final String DIV = "div";
+ static final String DL = "dl";
+ static final String DT = "dt";
+ static final String EM = "em";
+ static final String FIELDSET = "fieldset";
+ static final String FONT = "font";
+ static final String FORM = "form";
+ static final String FRAME = "frame";
+ static final String FRAMESET = "frameset";
+ static final String H1 = "h1";
+ static final String H2 = "h2";
+ static final String H3 = "h3";
+ static final String H4 = "h4";
+ static final String H5 = "h5";
+ static final String H6 = "h6";
+ static final String HEAD = "head";
+ static final String HR = "hr";
+ static final String HTML = "html";
+ static final String I = "i";
+ static final String IFRAME = "iframe";
+ static final String IMG = "img";
+ static final String INPUT = "input";
+ static final String INS = "ins";
+ static final String ISINDEX = "isindex";
+ static final String KBD = "kbd";
+ static final String LABEL = "label";
+ static final String LEGEND = "legend";
+ static final String LI = "li";
+ static final String LINK = "link";
+ static final String MAP = "map";
+ static final String MENU = "menu";
+ static final String META = "meta";
+ static final String NOFRAMES = "noframes";
+ static final String NOSCRIPT = "noscript";
+ static final String NONES = "none";
+ static final String sNAME = "name";
+ static final String OBJECT = "object";
+ static final String OL = "ol";
+ static final String OPTGROUP = "optgroup";
+ static final String OPTION = "option";
+ static final String P = "p";
+ static final String PARAM = "param";
+ static final String PRE = "pre";
+ static final String Q = "q";
+ static final String S = "s";
+ static final String SAMP = "samp";
+ static final String SCRIPT = "script";
+ static final String SELECT = "select";
+ static final String SMALL = "small";
+ static final String SPAN = "span";
+ static final String STRIKE = "strike";
+ static final String STRONG = "strong";
+ static final String STYLE = "style";
+ static final String SUB = "sub";
+ static final String SUP = "sup";
+ static final String TABLE = "table";
+ static final String TBODY = "tbody";
+ static final String TD = "td";
+ static final String TEXTAREA = "textarea";
+ static final String TFOOT = "tfoot";
+ static final String TH = "th";
+ static final String THEAD = "thead";
+ static final String TITLE = "title";
+ static final String TR = "tr";
+ static final String TT = "tt";
+ static final String U = "u";
+ static final String UL = "ul";
+ static final String VAR = "var";
+
+ /* Define the attribute constants. */
+ static final String C_0 = "0";
+ static final String C_1 = "1";
+ static final String CHECKBOX = "checkbox";
+ static final String DATA = "data";
+ static final String FILE = "file";
+ static final String GET = "get";
+ static final String HIDDEN = "hidden";
+ static final String IMAGE = "image";
+ static final String PASSWORD = "password";
+ static final String POST = "post";
+ static final String RADIO = "radio";
+ static final String REF = "ref";
+ static final String RESET = "reset";
+ static final String SUBMIT = "submit";
+ static final String TEXT = "text";
+ static final String ABOVE = "above";
+ static final String ACCEPT = "accept";
+ static final String ACCEPTCHARSET = "accept-charset";
+ static final String ACCESSKEY = "accesskey";
+ static final String ACTION = "action";
+ static final String ALIGN = "align";
+ static final String ALINK = "alink";
+ static final String ALL = "all";
+ static final String ALT = "alt";
+ static final String APPLICATION_X_WWW_FORM_URLENCODED
+ = "application/x-www-form-urlencoded";
+ static final String ARCHIVE = "archive";
+ static final String AUTO = "auto";
+ static final String AXIS = "axis";
+ static final String BACKGROUND = "background";
+ static final String BASELINE = "baseline";
+ static final String BELOW = "below";
+ static final String BGCOLOR = "bgcolor";
+ static final String BORDER = "border";
+ static final String BOTTOM = "bottom";
+ static final String BOX = "box";
+ static final String CELLPADDING = "cellpadding";
+ static final String CELLSPACING = "cellspacing";
+ static final String CHAR = "char";
+ static final String CHAROFF = "charoff";
+ static final String CHARSET = "charset";
+ static final String CHECKED = "checked";
+ static final String CIRCLE = "circle";
+ static final String CLASS = "class";
+ static final String CLASSID = "classid";
+ static final String CLEAR = "clear";
+ static final String CODEBASE = "codebase";
+ static final String CODETYPE = "codetype";
+ static final String COLOR = "color";
+ static final String COLS = "cols";
+ static final String COLSPAN = "colspan";
+ static final String COMPACT = "compact";
+ static final String CONTENT = "content";
+ static final String COORDS = "coords";
+ static final String DATAPAGESIZE = "datapagesize";
+ static final String DATETIME = "datetime";
+ static final String DECLARE = "declare";
+ static final String DEFER = "defer";
+ static final String DISABLED = "disabled";
+ static final String DISC = "disc";
+ static final String ENCTYPE = "enctype";
+ static final String EVENT = "event";
+ static final String FACE = "face";
+ static final String FOR = "for";
+ static final String FRAMEBORDER = "frameborder";
+ static final String GROUPS = "groups";
+ static final String HEADERS = "headers";
+ static final String HEIGHT = "height";
+ static final String HREF = "href";
+ static final String HREFLANG = "hreflang";
+ static final String HSIDES = "hsides";
+ static final String HSPACE = "hspace";
+ static final String HTTPEQUIV = "http-equiv";
+ static final String sID = "id";
+ static final String ISMAP = "ismap";
+ static final String JUSTIFY = "justify";
+ static final String LANG = "lang";
+ static final String LANGUAGE = "language";
+ static final String LEFT = "left";
+ static final String LHS = "lhs";
+ static final String LONGDESC = "longdesc";
+ static final String LTR = "ltr";
+ static final String MARGINHEIGHT = "marginheight";
+ static final String MARGINWIDTH = "marginwidth";
+ static final String MAXLENGTH = "maxlength";
+ static final String MEDIA = "media";
+ static final String METHOD = "method";
+ static final String MIDDLE = "middle";
+ static final String MULTIPLE = "multiple";
+ static final String NO = "no";
+ static final String NOHREF = "nohref";
+ static final String NORESIZE = "noresize";
+ static final String NOSHADE = "noshade";
+ static final String NOWRAP = "nowrap";
+ static final String ONBLUR = "onblur";
+ static final String ONCHANGE = "onchange";
+ static final String ONCLICK = "onclick";
+ static final String ONDBLCLICK = "ondblclick";
+ static final String ONFOCUS = "onfocus";
+ static final String ONKEYDOWN = "onkeydown";
+ static final String ONKEYPRESS = "onkeypress";
+ static final String ONKEYUP = "onkeyup";
+ static final String ONLOAD = "onload";
+ static final String ONMOUSEDOWN = "onmousedown";
+ static final String ONMOUSEMOVE = "onmousemove";
+ static final String ONMOUSEOUT = "onmouseout";
+ static final String ONMOUSEOVER = "onmouseover";
+ static final String ONMOUSEUP = "onmouseup";
+ static final String ONRESET = "onreset";
+ static final String ONSELECT = "onselect";
+ static final String ONSUBMIT = "onsubmit";
+ static final String ONUNLOAD = "onunload";
+ static final String POLY = "poly";
+ static final String PROFILE = "profile";
+ static final String PROMPT = "prompt";
+ static final String READONLY = "readonly";
+ static final String RECT = "rect";
+ static final String REL = "rel";
+ static final String REV = "rev";
+ static final String RHS = "rhs";
+ static final String RIGHT = "right";
+ static final String ROW = "row";
+ static final String ROWGROUP = "rowgroup";
+ static final String ROWS = "rows";
+ static final String ROWSPAN = "rowspan";
+ static final String RTL = "rtl";
+ static final String RULES = "rules";
+ static final String SCHEME = "scheme";
+ static final String SCOPE = "scope";
+ static final String SCROLLING = "scrolling";
+ static final String SELECTED = "selected";
+ static final String SHAPE = "shape";
+ static final String SIZE = "size";
+ static final String SQUARE = "square";
+ static final String SRC = "src";
+ static final String STANDBY = "standby";
+ static final String START = "start";
+ static final String SUMMARY = "summary";
+ static final String TABINDEX = "tabindex";
+ static final String TARGET = "target";
+ static final String TOP = "top";
+ static final String TYPE = "type";
+ static final String USEMAP = "usemap";
+ static final String VALIGN = "valign";
+ static final String VALUE = "value";
+ static final String VALUETYPE = "valuetype";
+ static final String VERSION = "version";
+ static final String VLINK = "vlink";
+ static final String VOID = "void";
+ static final String VSIDES = "vsides";
+ static final String VSPACE = "vspace";
+ static final String WIDTH = "width";
+ static final String YES = "yes";
+
+ static final String[] BLOCK =
+ new String[] {
+ ADDRESS, BLOCKQUOTE, CENTER, DIR,
+ DIV, DL, FIELDSET, FORM,
+ H1, H2, H3, H4, H5, H6,
+ HR, ISINDEX, MENU, NOFRAMES, NOSCRIPT,
+ OL, P, PRE, TABLE, UL
+ };
+
+ /**
+ * Creates this DTD, filling in the entities and attributes data
+ * as defined in -//W3C//DTD HTML 4.01 Frameset//EN.
+ */
+ protected HTML_401F()
+ {
+ super(DTD_NAME);
+ defineEntities();
+ defineElements();
+ }
+
+ /**
+ * Either takes the document (by name) from DTD table, or
+ * creates a new instance and registers it in the tabe.
+ * The document is registerd under name "-//W3C//DTD HTML 4.01 Frameset//EN".
+ * @return The new or existing DTD for parsing HTML 4.01 Frameset.
+ */
+ public static DTD getInstance()
+ {
+ try
+ {
+ DTD dtd = getDTD(DTD_NAME);
+ if (dtd == null || dtd.getClass().equals(DTD.class))
+ {
+ dtd = new HTML_401F();
+ putDTDHash(DTD_NAME, dtd);
+ }
+ return dtd;
+ }
+ catch (IOException ex)
+ {
+ throw new Error("This should never happen. Report the bug.", ex);
+ }
+ }
+
+ /**
+ * Define all elements of this DTD.
+ */
+ protected void defineElements()
+ {
+ /* Define the elements. */
+ defElement(PCDATA, 0, false, false, null, NONE, NONE,
+ new AttributeList[ 0 ]);
+
+ defElement(A, 0, false, false, null,
+ new String[] {
+ A
+ }
+ ,
+ new String[] {
+ PCDATA, ABBR, ACRONYM, APPLET,
+ B, BASEFONT, BDO, BIG, BR,
+ BUTTON, CITE, CODE, DFN, EM,
+ FONT, I, IFRAME, IMG, INPUT,
+ KBD, LABEL, MAP, OBJECT, Q,
+ S, SAMP, SCRIPT, SELECT, SMALL,
+ SPAN, STRIKE, STRONG, SUB, SUP,
+ TEXTAREA, TT, U, VAR
+ }
+ ,
+ new AttributeList[] {
+ attr(sID, null, null, ID, IMPLIED),
+ attr(CLASS, null, null, 0, IMPLIED),
+ attr(STYLE, null, null, 0, IMPLIED),
+ attr(TITLE, null, null, 0, IMPLIED),
+ attr(LANG, null, null, 0, IMPLIED),
+ attr(DIR, null, new String[] { LTR, RTL }, 0, IMPLIED),
+ attr(ONCLICK, null, null, 0, IMPLIED),
+ attr(ONDBLCLICK, null, null, 0, IMPLIED),
+ attr(ONMOUSEDOWN, null, null, 0, IMPLIED),
+ attr(ONMOUSEUP, null, null, 0, IMPLIED),
+ attr(ONMOUSEOVER, null, null, 0, IMPLIED),
+ attr(ONMOUSEMOVE, null, null, 0, IMPLIED),
+ attr(ONMOUSEOUT, null, null, 0, IMPLIED),
+ attr(ONKEYPRESS, null, null, 0, IMPLIED),
+ attr(ONKEYDOWN, null, null, 0, IMPLIED),
+ attr(ONKEYUP, null, null, 0, IMPLIED),
+ attr(CHARSET, null, null, 0, IMPLIED),
+ attr(TYPE, null, null, 0, IMPLIED),
+ attr(sNAME, null, null, 0, IMPLIED),
+ attr(HREF, null, null, 0, IMPLIED),
+ attr(HREFLANG, null, null, 0, IMPLIED),
+ attr(TARGET, null, null, 0, IMPLIED),
+ attr(REL, null, null, 0, IMPLIED),
+ attr(REV, null, null, 0, IMPLIED),
+ attr(ACCESSKEY, null, null, 0, IMPLIED),
+ attr(SHAPE, RECT, new String[] { RECT, CIRCLE, POLY, DEFAULTS },
+ 0, DEFAULT),
+ attr(COORDS, null, null, 0, IMPLIED),
+ attr(TABINDEX, null, null, NUMBER, IMPLIED),
+ attr(ONFOCUS, null, null, 0, IMPLIED),
+ attr(ONBLUR, null, null, 0, IMPLIED)
+ }
+ );
+ defElement(ABBR, 0, false, false, null,
+ NONE
+ ,
+ new String[] {
+ PCDATA, A, ABBR, ACRONYM,
+ APPLET, B, BASEFONT, BDO, BIG,
+ BR, BUTTON, CITE, CODE, DFN,
+ EM, FONT, I, IFRAME, IMG,
+ INPUT, KBD, LABEL, MAP, OBJECT,
+ Q, S, SAMP, SCRIPT, SELECT,
+ SMALL, SPAN, STRIKE, STRONG, SUB,
+ SUP, TEXTAREA, TT, U, VAR
+ }
+ ,
+ new AttributeList[] {
+ attr(sID, null, null, ID, IMPLIED),
+ attr(CLASS, null, null, 0, IMPLIED),
+ attr(STYLE, null, null, 0, IMPLIED),
+ attr(TITLE, null, null, 0, IMPLIED),
+ attr(LANG, null, null, 0, IMPLIED),
+ attr(DIR, null, new String[] { LTR, RTL }, 0, IMPLIED),
+ attr(ONCLICK, null, null, 0, IMPLIED),
+ attr(ONDBLCLICK, null, null, 0, IMPLIED),
+ attr(ONMOUSEDOWN, null, null, 0, IMPLIED),
+ attr(ONMOUSEUP, null, null, 0, IMPLIED),
+ attr(ONMOUSEOVER, null, null, 0, IMPLIED),
+ attr(ONMOUSEMOVE, null, null, 0, IMPLIED),
+ attr(ONMOUSEOUT, null, null, 0, IMPLIED),
+ attr(ONKEYPRESS, null, null, 0, IMPLIED),
+ attr(ONKEYDOWN, null, null, 0, IMPLIED),
+ attr(ONKEYUP, null, null, 0, IMPLIED)
+ }
+ );
+ defElement(ACRONYM, 0, false, false, null,
+ NONE
+ ,
+ new String[] {
+ PCDATA, A, ABBR, ACRONYM,
+ APPLET, B, BASEFONT, BDO, BIG,
+ BR, BUTTON, CITE, CODE, DFN,
+ EM, FONT, I, IFRAME, IMG,
+ INPUT, KBD, LABEL, MAP, OBJECT,
+ Q, S, SAMP, SCRIPT, SELECT,
+ SMALL, SPAN, STRIKE, STRONG, SUB,
+ SUP, TEXTAREA, TT, U, VAR
+ }
+ ,
+ new AttributeList[] {
+ attr(sID, null, null, ID, IMPLIED),
+ attr(CLASS, null, null, 0, IMPLIED),
+ attr(STYLE, null, null, 0, IMPLIED),
+ attr(TITLE, null, null, 0, IMPLIED),
+ attr(LANG, null, null, 0, IMPLIED),
+ attr(DIR, null, new String[] { LTR, RTL }, 0, IMPLIED),
+ attr(ONCLICK, null, null, 0, IMPLIED),
+ attr(ONDBLCLICK, null, null, 0, IMPLIED),
+ attr(ONMOUSEDOWN, null, null, 0, IMPLIED),
+ attr(ONMOUSEUP, null, null, 0, IMPLIED),
+ attr(ONMOUSEOVER, null, null, 0, IMPLIED),
+ attr(ONMOUSEMOVE, null, null, 0, IMPLIED),
+ attr(ONMOUSEOUT, null, null, 0, IMPLIED),
+ attr(ONKEYPRESS, null, null, 0, IMPLIED),
+ attr(ONKEYDOWN, null, null, 0, IMPLIED),
+ attr(ONKEYUP, null, null, 0, IMPLIED)
+ }
+ );
+ defElement(ADDRESS, 0, false, false, null,
+ NONE
+ ,
+ new String[] {
+ PCDATA, A, ABBR, ACRONYM,
+ APPLET, B, BASEFONT, BDO, BIG,
+ BR, BUTTON, CITE, CODE, DFN,
+ EM, FONT, I, IFRAME, IMG,
+ INPUT, KBD, LABEL, MAP, OBJECT,
+ Q, S, SAMP, SCRIPT, SELECT,
+ SMALL, SPAN, STRIKE, STRONG, SUB,
+ SUP, TEXTAREA, TT, U, VAR,
+ P
+ }
+ ,
+ new AttributeList[] {
+ attr(sID, null, null, ID, IMPLIED),
+ attr(CLASS, null, null, 0, IMPLIED),
+ attr(STYLE, null, null, 0, IMPLIED),
+ attr(TITLE, null, null, 0, IMPLIED),
+ attr(LANG, null, null, 0, IMPLIED),
+ attr(DIR, null, new String[] { LTR, RTL }, 0, IMPLIED),
+ attr(ONCLICK, null, null, 0, IMPLIED),
+ attr(ONDBLCLICK, null, null, 0, IMPLIED),
+ attr(ONMOUSEDOWN, null, null, 0, IMPLIED),
+ attr(ONMOUSEUP, null, null, 0, IMPLIED),
+ attr(ONMOUSEOVER, null, null, 0, IMPLIED),
+ attr(ONMOUSEMOVE, null, null, 0, IMPLIED),
+ attr(ONMOUSEOUT, null, null, 0, IMPLIED),
+ attr(ONKEYPRESS, null, null, 0, IMPLIED),
+ attr(ONKEYDOWN, null, null, 0, IMPLIED),
+ attr(ONKEYUP, null, null, 0, IMPLIED)
+ }
+ );
+ defElement(APPLET, 0, false, false, null,
+ NONE
+ ,
+ new String[] {
+ PCDATA, A, ABBR, ACRONYM,
+ APPLET, B, BASEFONT, BDO, BIG,
+ BR, BUTTON, CITE, CODE, DFN,
+ EM, FONT, I, IFRAME, IMG,
+ INPUT, KBD, LABEL, MAP, OBJECT,
+ Q, S, SAMP, SCRIPT, SELECT,
+ SMALL, SPAN, STRIKE, STRONG, SUB,
+ SUP, TEXTAREA, TT, U, VAR,
+ ADDRESS, BLOCKQUOTE, CENTER, DIR, DIV,
+ DL, FIELDSET, FORM, H1, H2,
+ H3, H4, H5, H6, HR,
+ ISINDEX, MENU, NOFRAMES, NOSCRIPT, OL,
+ P, PRE, TABLE, UL, PARAM
+ }
+ ,
+ new AttributeList[] {
+ attr(sID, null, null, ID, IMPLIED),
+ attr(CLASS, null, null, 0, IMPLIED),
+ attr(STYLE, null, null, 0, IMPLIED),
+ attr(TITLE, null, null, 0, IMPLIED),
+ attr(CODEBASE, null, null, 0, IMPLIED),
+ attr(ARCHIVE, null, null, 0, IMPLIED),
+ attr(CODE, null, null, 0, IMPLIED),
+ attr(OBJECT, null, null, 0, IMPLIED),
+ attr(ALT, null, null, 0, IMPLIED),
+ attr(sNAME, null, null, 0, IMPLIED),
+ attr(WIDTH, null, null, 0, REQUIRED),
+ attr(HEIGHT, null, null, 0, REQUIRED),
+ attr(ALIGN, null, new String[] { TOP, MIDDLE, BOTTOM, LEFT, RIGHT },
+ 0, IMPLIED),
+ attr(HSPACE, null, null, 0, IMPLIED),
+ attr(VSPACE, null, null, 0, IMPLIED)
+ }
+ );
+ defElement(AREA, EMPTY, false, true, null,
+ NONE
+ ,
+ NONE
+ ,
+ new AttributeList[] {
+ attr(sID, null, null, ID, IMPLIED),
+ attr(CLASS, null, null, 0, IMPLIED),
+ attr(STYLE, null, null, 0, IMPLIED),
+ attr(TITLE, null, null, 0, IMPLIED),
+ attr(LANG, null, null, 0, IMPLIED),
+ attr(DIR, null, new String[] { LTR, RTL }, 0, IMPLIED),
+ attr(ONCLICK, null, null, 0, IMPLIED),
+ attr(ONDBLCLICK, null, null, 0, IMPLIED),
+ attr(ONMOUSEDOWN, null, null, 0, IMPLIED),
+ attr(ONMOUSEUP, null, null, 0, IMPLIED),
+ attr(ONMOUSEOVER, null, null, 0, IMPLIED),
+ attr(ONMOUSEMOVE, null, null, 0, IMPLIED),
+ attr(ONMOUSEOUT, null, null, 0, IMPLIED),
+ attr(ONKEYPRESS, null, null, 0, IMPLIED),
+ attr(ONKEYDOWN, null, null, 0, IMPLIED),
+ attr(ONKEYUP, null, null, 0, IMPLIED),
+ attr(SHAPE, RECT, new String[] { RECT, CIRCLE, POLY, DEFAULTS },
+ 0, DEFAULT),
+ attr(COORDS, null, null, 0, IMPLIED),
+ attr(HREF, null, null, 0, IMPLIED),
+ attr(TARGET, null, null, 0, IMPLIED),
+ attr(NOHREF, null, new String[] { NOHREF }, 0, IMPLIED),
+ attr(ALT, null, null, 0, REQUIRED),
+ attr(TABINDEX, null, null, NUMBER, IMPLIED),
+ attr(ACCESSKEY, null, null, 0, IMPLIED),
+ attr(ONFOCUS, null, null, 0, IMPLIED),
+ attr(ONBLUR, null, null, 0, IMPLIED)
+ }
+ );
+ defElement(B, 0, false, false, null,
+ NONE
+ ,
+ new String[] {
+ PCDATA, A, ABBR, ACRONYM,
+ APPLET, B, BASEFONT, BDO, BIG,
+ BR, BUTTON, CITE, CODE, DFN,
+ EM, FONT, I, IFRAME, IMG,
+ INPUT, KBD, LABEL, MAP, OBJECT,
+ Q, S, SAMP, SCRIPT, SELECT,
+ SMALL, SPAN, STRIKE, STRONG, SUB,
+ SUP, TEXTAREA, TT, U, VAR
+ }
+ ,
+ new AttributeList[] {
+ attr(sID, null, null, ID, IMPLIED),
+ attr(CLASS, null, null, 0, IMPLIED),
+ attr(STYLE, null, null, 0, IMPLIED),
+ attr(TITLE, null, null, 0, IMPLIED),
+ attr(LANG, null, null, 0, IMPLIED),
+ attr(DIR, null, new String[] { LTR, RTL }, 0, IMPLIED),
+ attr(ONCLICK, null, null, 0, IMPLIED),
+ attr(ONDBLCLICK, null, null, 0, IMPLIED),
+ attr(ONMOUSEDOWN, null, null, 0, IMPLIED),
+ attr(ONMOUSEUP, null, null, 0, IMPLIED),
+ attr(ONMOUSEOVER, null, null, 0, IMPLIED),
+ attr(ONMOUSEMOVE, null, null, 0, IMPLIED),
+ attr(ONMOUSEOUT, null, null, 0, IMPLIED),
+ attr(ONKEYPRESS, null, null, 0, IMPLIED),
+ attr(ONKEYDOWN, null, null, 0, IMPLIED),
+ attr(ONKEYUP, null, null, 0, IMPLIED)
+ }
+ );
+ defElement(BASE, EMPTY, false, true, null,
+ NONE
+ ,
+ NONE
+ ,
+ new AttributeList[] {
+ attr(HREF, null, null, 0, IMPLIED),
+ attr(TARGET, null, null, 0, IMPLIED)
+ }
+ );
+ defElement(BASEFONT, EMPTY, false, true, null,
+ NONE
+ ,
+ NONE
+ ,
+ new AttributeList[] {
+ attr(sID, null, null, ID, IMPLIED),
+ attr(SIZE, null, null, 0, REQUIRED),
+ attr(COLOR, null, null, 0, IMPLIED),
+ attr(FACE, null, null, 0, IMPLIED)
+ }
+ );
+ defElement(BDO, 0, false, false, null,
+ NONE
+ ,
+ new String[] {
+ PCDATA, A, ABBR, ACRONYM,
+ APPLET, B, BASEFONT, BDO, BIG,
+ BR, BUTTON, CITE, CODE, DFN,
+ EM, FONT, I, IFRAME, IMG,
+ INPUT, KBD, LABEL, MAP, OBJECT,
+ Q, S, SAMP, SCRIPT, SELECT,
+ SMALL, SPAN, STRIKE, STRONG, SUB,
+ SUP, TEXTAREA, TT, U, VAR
+ }
+ ,
+ new AttributeList[] {
+ attr(sID, null, null, ID, IMPLIED),
+ attr(CLASS, null, null, 0, IMPLIED),
+ attr(STYLE, null, null, 0, IMPLIED),
+ attr(TITLE, null, null, 0, IMPLIED),
+ attr(LANG, null, null, 0, IMPLIED),
+ attr(DIR, null, new String[] { LTR, RTL }, 0, REQUIRED)
+ }
+ );
+ defElement(BIG, 0, false, false, null,
+ NONE
+ ,
+ new String[] {
+ PCDATA, A, ABBR, ACRONYM,
+ APPLET, B, BASEFONT, BDO, BIG,
+ BR, BUTTON, CITE, CODE, DFN,
+ EM, FONT, I, IFRAME, IMG,
+ INPUT, KBD, LABEL, MAP, OBJECT,
+ Q, S, SAMP, SCRIPT, SELECT,
+ SMALL, SPAN, STRIKE, STRONG, SUB,
+ SUP, TEXTAREA, TT, U, VAR
+ }
+ ,
+ new AttributeList[] {
+ attr(sID, null, null, ID, IMPLIED),
+ attr(CLASS, null, null, 0, IMPLIED),
+ attr(STYLE, null, null, 0, IMPLIED),
+ attr(TITLE, null, null, 0, IMPLIED),
+ attr(LANG, null, null, 0, IMPLIED),
+ attr(DIR, null, new String[] { LTR, RTL }, 0, IMPLIED),
+ attr(ONCLICK, null, null, 0, IMPLIED),
+ attr(ONDBLCLICK, null, null, 0, IMPLIED),
+ attr(ONMOUSEDOWN, null, null, 0, IMPLIED),
+ attr(ONMOUSEUP, null, null, 0, IMPLIED),
+ attr(ONMOUSEOVER, null, null, 0, IMPLIED),
+ attr(ONMOUSEMOVE, null, null, 0, IMPLIED),
+ attr(ONMOUSEOUT, null, null, 0, IMPLIED),
+ attr(ONKEYPRESS, null, null, 0, IMPLIED),
+ attr(ONKEYDOWN, null, null, 0, IMPLIED),
+ attr(ONKEYUP, null, null, 0, IMPLIED)
+ }
+ );
+ defElement(BLOCKQUOTE, 0, false, false, null,
+ NONE
+ ,
+ new String[] {
+ PCDATA, A, ABBR, ACRONYM,
+ APPLET, B, BASEFONT, BDO, BIG,
+ BR, BUTTON, CITE, CODE, DFN,
+ EM, FONT, I, IFRAME, IMG,
+ INPUT, KBD, LABEL, MAP, OBJECT,
+ Q, S, SAMP, SCRIPT, SELECT,
+ SMALL, SPAN, STRIKE, STRONG, SUB,
+ SUP, TEXTAREA, TT, U, VAR,
+ ADDRESS, BLOCKQUOTE, CENTER, DIR, DIV,
+ DL, FIELDSET, FORM, H1, H2,
+ H3, H4, H5, H6, HR,
+ ISINDEX, MENU, NOFRAMES, NOSCRIPT, OL,
+ P, PRE, TABLE, UL
+ }
+ ,
+ new AttributeList[] {
+ attr(sID, null, null, ID, IMPLIED),
+ attr(CLASS, null, null, 0, IMPLIED),
+ attr(STYLE, null, null, 0, IMPLIED),
+ attr(TITLE, null, null, 0, IMPLIED),
+ attr(LANG, null, null, 0, IMPLIED),
+ attr(DIR, null, new String[] { LTR, RTL }, 0, IMPLIED),
+ attr(ONCLICK, null, null, 0, IMPLIED),
+ attr(ONDBLCLICK, null, null, 0, IMPLIED),
+ attr(ONMOUSEDOWN, null, null, 0, IMPLIED),
+ attr(ONMOUSEUP, null, null, 0, IMPLIED),
+ attr(ONMOUSEOVER, null, null, 0, IMPLIED),
+ attr(ONMOUSEMOVE, null, null, 0, IMPLIED),
+ attr(ONMOUSEOUT, null, null, 0, IMPLIED),
+ attr(ONKEYPRESS, null, null, 0, IMPLIED),
+ attr(ONKEYDOWN, null, null, 0, IMPLIED),
+ attr(ONKEYUP, null, null, 0, IMPLIED),
+ attr(CITE, null, null, 0, IMPLIED)
+ }
+ );
+ defElement(BODY, 0, true, true, null,
+ NONE
+ ,
+ getBodyElements()
+ ,
+ new AttributeList[] {
+ attr(sID, null, null, ID, IMPLIED),
+ attr(CLASS, null, null, 0, IMPLIED),
+ attr(STYLE, null, null, 0, IMPLIED),
+ attr(TITLE, null, null, 0, IMPLIED),
+ attr(LANG, null, null, 0, IMPLIED),
+ attr(DIR, null, new String[] { LTR, RTL }, 0, IMPLIED),
+ attr(ONCLICK, null, null, 0, IMPLIED),
+ attr(ONDBLCLICK, null, null, 0, IMPLIED),
+ attr(ONMOUSEDOWN, null, null, 0, IMPLIED),
+ attr(ONMOUSEUP, null, null, 0, IMPLIED),
+ attr(ONMOUSEOVER, null, null, 0, IMPLIED),
+ attr(ONMOUSEMOVE, null, null, 0, IMPLIED),
+ attr(ONMOUSEOUT, null, null, 0, IMPLIED),
+ attr(ONKEYPRESS, null, null, 0, IMPLIED),
+ attr(ONKEYDOWN, null, null, 0, IMPLIED),
+ attr(ONKEYUP, null, null, 0, IMPLIED),
+ attr(ONLOAD, null, null, 0, IMPLIED),
+ attr(ONUNLOAD, null, null, 0, IMPLIED),
+ attr(BACKGROUND, null, null, 0, IMPLIED),
+ attr(BGCOLOR, null, null, 0, IMPLIED),
+ attr(TEXT, null, null, 0, IMPLIED),
+ attr(LINK, null, null, 0, IMPLIED),
+ attr(VLINK, null, null, 0, IMPLIED),
+ attr(ALINK, null, null, 0, IMPLIED)
+ }
+ );
+ defElement(BR, EMPTY, false, true, null,
+ NONE
+ ,
+ NONE
+ ,
+ new AttributeList[] {
+ attr(sID, null, null, ID, IMPLIED),
+ attr(CLASS, null, null, 0, IMPLIED),
+ attr(STYLE, null, null, 0, IMPLIED),
+ attr(TITLE, null, null, 0, IMPLIED),
+ attr(CLEAR, "NONE", new String[] { LEFT, ALL, RIGHT, NONES },
+ 0, DEFAULT)
+ }
+ );
+ defElement(BUTTON, 0, false, false, null,
+ new String[] {
+ A, BUTTON, IFRAME, INPUT,
+ LABEL, SELECT, TEXTAREA, FIELDSET, FORM,
+ ISINDEX
+ }
+ ,
+ new String[] {
+ PCDATA, ABBR, ACRONYM, APPLET,
+ B, BASEFONT, BDO, BIG, BR,
+ CITE, CODE, DFN, EM, FONT,
+ I, IMG, KBD, MAP, OBJECT,
+ Q, S, SAMP, SCRIPT, SMALL,
+ SPAN, STRIKE, STRONG, SUB, SUP,
+ TT, U, VAR, ADDRESS, BLOCKQUOTE,
+ CENTER, DIR, DIV, DL, H1,
+ H2, H3, H4, H5, H6,
+ HR, MENU, NOFRAMES, NOSCRIPT, OL,
+ P, PRE, TABLE, UL
+ }
+ ,
+ new AttributeList[] {
+ attr(sID, null, null, ID, IMPLIED),
+ attr(CLASS, null, null, 0, IMPLIED),
+ attr(STYLE, null, null, 0, IMPLIED),
+ attr(TITLE, null, null, 0, IMPLIED),
+ attr(LANG, null, null, 0, IMPLIED),
+ attr(DIR, null, new String[] { LTR, RTL }, 0, IMPLIED),
+ attr(ONCLICK, null, null, 0, IMPLIED),
+ attr(ONDBLCLICK, null, null, 0, IMPLIED),
+ attr(ONMOUSEDOWN, null, null, 0, IMPLIED),
+ attr(ONMOUSEUP, null, null, 0, IMPLIED),
+ attr(ONMOUSEOVER, null, null, 0, IMPLIED),
+ attr(ONMOUSEMOVE, null, null, 0, IMPLIED),
+ attr(ONMOUSEOUT, null, null, 0, IMPLIED),
+ attr(ONKEYPRESS, null, null, 0, IMPLIED),
+ attr(ONKEYDOWN, null, null, 0, IMPLIED),
+ attr(ONKEYUP, null, null, 0, IMPLIED),
+ attr(sNAME, null, null, 0, IMPLIED),
+ attr(VALUE, null, null, 0, IMPLIED),
+ attr(TYPE, SUBMIT, new String[] { BUTTON, SUBMIT, RESET }, 0, DEFAULT),
+ attr(DISABLED, null, new String[] { DISABLED }, 0, IMPLIED),
+ attr(TABINDEX, null, null, NUMBER, IMPLIED),
+ attr(ACCESSKEY, null, null, 0, IMPLIED),
+ attr(ONFOCUS, null, null, 0, IMPLIED),
+ attr(ONBLUR, null, null, 0, IMPLIED)
+ }
+ );
+ defElement(CAPTION, 0, false, false, null,
+ NONE
+ ,
+ new String[] {
+ PCDATA, A, ABBR, ACRONYM,
+ APPLET, B, BASEFONT, BDO, BIG,
+ BR, BUTTON, CITE, CODE, DFN,
+ EM, FONT, I, IFRAME, IMG,
+ INPUT, KBD, LABEL, MAP, OBJECT,
+ Q, S, SAMP, SCRIPT, SELECT,
+ SMALL, SPAN, STRIKE, STRONG, SUB,
+ SUP, TEXTAREA, TT, U, VAR
+ }
+ ,
+ new AttributeList[] {
+ attr(sID, null, null, ID, IMPLIED),
+ attr(CLASS, null, null, 0, IMPLIED),
+ attr(STYLE, null, null, 0, IMPLIED),
+ attr(TITLE, null, null, 0, IMPLIED),
+ attr(LANG, null, null, 0, IMPLIED),
+ attr(DIR, null, new String[] { LTR, RTL }, 0, IMPLIED),
+ attr(ONCLICK, null, null, 0, IMPLIED),
+ attr(ONDBLCLICK, null, null, 0, IMPLIED),
+ attr(ONMOUSEDOWN, null, null, 0, IMPLIED),
+ attr(ONMOUSEUP, null, null, 0, IMPLIED),
+ attr(ONMOUSEOVER, null, null, 0, IMPLIED),
+ attr(ONMOUSEMOVE, null, null, 0, IMPLIED),
+ attr(ONMOUSEOUT, null, null, 0, IMPLIED),
+ attr(ONKEYPRESS, null, null, 0, IMPLIED),
+ attr(ONKEYDOWN, null, null, 0, IMPLIED),
+ attr(ONKEYUP, null, null, 0, IMPLIED),
+ attr(ALIGN, null, new String[] { TOP, BOTTOM, LEFT, RIGHT },
+ 0, IMPLIED)
+ }
+ );
+ defElement(CENTER, 0, false, false, null,
+ NONE
+ ,
+ new String[] {
+ PCDATA, A, ABBR, ACRONYM,
+ APPLET, B, BASEFONT, BDO, BIG,
+ BR, BUTTON, CITE, CODE, DFN,
+ EM, FONT, I, IFRAME, IMG,
+ INPUT, KBD, LABEL, MAP, OBJECT,
+ Q, S, SAMP, SCRIPT, SELECT,
+ SMALL, SPAN, STRIKE, STRONG, SUB,
+ SUP, TEXTAREA, TT, U, VAR,
+ ADDRESS, BLOCKQUOTE, CENTER, DIR, DIV,
+ DL, FIELDSET, FORM, H1, H2,
+ H3, H4, H5, H6, HR,
+ ISINDEX, MENU, NOFRAMES, NOSCRIPT, OL,
+ P, PRE, TABLE, UL
+ }
+ ,
+ new AttributeList[] {
+ attr(sID, null, null, ID, IMPLIED),
+ attr(CLASS, null, null, 0, IMPLIED),
+ attr(STYLE, null, null, 0, IMPLIED),
+ attr(TITLE, null, null, 0, IMPLIED),
+ attr(LANG, null, null, 0, IMPLIED),
+ attr(DIR, null, new String[] { LTR, RTL }, 0, IMPLIED),
+ attr(ONCLICK, null, null, 0, IMPLIED),
+ attr(ONDBLCLICK, null, null, 0, IMPLIED),
+ attr(ONMOUSEDOWN, null, null, 0, IMPLIED),
+ attr(ONMOUSEUP, null, null, 0, IMPLIED),
+ attr(ONMOUSEOVER, null, null, 0, IMPLIED),
+ attr(ONMOUSEMOVE, null, null, 0, IMPLIED),
+ attr(ONMOUSEOUT, null, null, 0, IMPLIED),
+ attr(ONKEYPRESS, null, null, 0, IMPLIED),
+ attr(ONKEYDOWN, null, null, 0, IMPLIED),
+ attr(ONKEYUP, null, null, 0, IMPLIED)
+ }
+ );
+ defElement(CITE, 0, false, false, null,
+ NONE
+ ,
+ new String[] {
+ PCDATA, A, ABBR, ACRONYM,
+ APPLET, B, BASEFONT, BDO, BIG,
+ BR, BUTTON, CITE, CODE, DFN,
+ EM, FONT, I, IFRAME, IMG,
+ INPUT, KBD, LABEL, MAP, OBJECT,
+ Q, S, SAMP, SCRIPT, SELECT,
+ SMALL, SPAN, STRIKE, STRONG, SUB,
+ SUP, TEXTAREA, TT, U, VAR
+ }
+ ,
+ new AttributeList[] {
+ attr(sID, null, null, ID, IMPLIED),
+ attr(CLASS, null, null, 0, IMPLIED),
+ attr(STYLE, null, null, 0, IMPLIED),
+ attr(TITLE, null, null, 0, IMPLIED),
+ attr(LANG, null, null, 0, IMPLIED),
+ attr(DIR, null, new String[] { LTR, RTL }, 0, IMPLIED),
+ attr(ONCLICK, null, null, 0, IMPLIED),
+ attr(ONDBLCLICK, null, null, 0, IMPLIED),
+ attr(ONMOUSEDOWN, null, null, 0, IMPLIED),
+ attr(ONMOUSEUP, null, null, 0, IMPLIED),
+ attr(ONMOUSEOVER, null, null, 0, IMPLIED),
+ attr(ONMOUSEMOVE, null, null, 0, IMPLIED),
+ attr(ONMOUSEOUT, null, null, 0, IMPLIED),
+ attr(ONKEYPRESS, null, null, 0, IMPLIED),
+ attr(ONKEYDOWN, null, null, 0, IMPLIED),
+ attr(ONKEYUP, null, null, 0, IMPLIED)
+ }
+ );
+ defElement(CODE, 0, false, false, null,
+ NONE
+ ,
+ new String[] {
+ PCDATA, A, ABBR, ACRONYM,
+ APPLET, B, BASEFONT, BDO, BIG,
+ BR, BUTTON, CITE, CODE, DFN,
+ EM, FONT, I, IFRAME, IMG,
+ INPUT, KBD, LABEL, MAP, OBJECT,
+ Q, S, SAMP, SCRIPT, SELECT,
+ SMALL, SPAN, STRIKE, STRONG, SUB,
+ SUP, TEXTAREA, TT, U, VAR
+ }
+ ,
+ new AttributeList[] {
+ attr(sID, null, null, ID, IMPLIED),
+ attr(CLASS, null, null, 0, IMPLIED),
+ attr(STYLE, null, null, 0, IMPLIED),
+ attr(TITLE, null, null, 0, IMPLIED),
+ attr(LANG, null, null, 0, IMPLIED),
+ attr(DIR, null, new String[] { LTR, RTL }, 0, IMPLIED),
+ attr(ONCLICK, null, null, 0, IMPLIED),
+ attr(ONDBLCLICK, null, null, 0, IMPLIED),
+ attr(ONMOUSEDOWN, null, null, 0, IMPLIED),
+ attr(ONMOUSEUP, null, null, 0, IMPLIED),
+ attr(ONMOUSEOVER, null, null, 0, IMPLIED),
+ attr(ONMOUSEMOVE, null, null, 0, IMPLIED),
+ attr(ONMOUSEOUT, null, null, 0, IMPLIED),
+ attr(ONKEYPRESS, null, null, 0, IMPLIED),
+ attr(ONKEYDOWN, null, null, 0, IMPLIED),
+ attr(ONKEYUP, null, null, 0, IMPLIED)
+ }
+ );
+ defElement(COL, EMPTY, false, true, null,
+ NONE
+ ,
+ NONE
+ ,
+ new AttributeList[] {
+ attr(sID, null, null, ID, IMPLIED),
+ attr(CLASS, null, null, 0, IMPLIED),
+ attr(STYLE, null, null, 0, IMPLIED),
+ attr(TITLE, null, null, 0, IMPLIED),
+ attr(LANG, null, null, 0, IMPLIED),
+ attr(DIR, null, new String[] { LTR, RTL }, 0, IMPLIED),
+ attr(ONCLICK, null, null, 0, IMPLIED),
+ attr(ONDBLCLICK, null, null, 0, IMPLIED),
+ attr(ONMOUSEDOWN, null, null, 0, IMPLIED),
+ attr(ONMOUSEUP, null, null, 0, IMPLIED),
+ attr(ONMOUSEOVER, null, null, 0, IMPLIED),
+ attr(ONMOUSEMOVE, null, null, 0, IMPLIED),
+ attr(ONMOUSEOUT, null, null, 0, IMPLIED),
+ attr(ONKEYPRESS, null, null, 0, IMPLIED),
+ attr(ONKEYDOWN, null, null, 0, IMPLIED),
+ attr(ONKEYUP, null, null, 0, IMPLIED),
+ attr(SPAN, C_1, null, NUMBER, DEFAULT),
+ attr(WIDTH, null, null, 0, IMPLIED),
+ attr(ALIGN, null, new String[] { LEFT, CENTER, RIGHT, JUSTIFY, CHAR },
+ 0, IMPLIED),
+ attr(CHAR, null, null, 0, IMPLIED),
+ attr(CHAROFF, null, null, 0, IMPLIED),
+ attr(VALIGN, null, new String[] { TOP, MIDDLE, BOTTOM, BASELINE },
+ 0, IMPLIED)
+ }
+ );
+ defElement(COLGROUP, 0, false, true, null,
+ NONE
+ ,
+ new String[] {
+ COL
+ }
+ ,
+ new AttributeList[] {
+ attr(sID, null, null, ID, IMPLIED),
+ attr(CLASS, null, null, 0, IMPLIED),
+ attr(STYLE, null, null, 0, IMPLIED),
+ attr(TITLE, null, null, 0, IMPLIED),
+ attr(LANG, null, null, 0, IMPLIED),
+ attr(DIR, null, new String[] { LTR, RTL }, 0, IMPLIED),
+ attr(ONCLICK, null, null, 0, IMPLIED),
+ attr(ONDBLCLICK, null, null, 0, IMPLIED),
+ attr(ONMOUSEDOWN, null, null, 0, IMPLIED),
+ attr(ONMOUSEUP, null, null, 0, IMPLIED),
+ attr(ONMOUSEOVER, null, null, 0, IMPLIED),
+ attr(ONMOUSEMOVE, null, null, 0, IMPLIED),
+ attr(ONMOUSEOUT, null, null, 0, IMPLIED),
+ attr(ONKEYPRESS, null, null, 0, IMPLIED),
+ attr(ONKEYDOWN, null, null, 0, IMPLIED),
+ attr(ONKEYUP, null, null, 0, IMPLIED),
+ attr(SPAN, C_1, null, NUMBER, DEFAULT),
+ attr(WIDTH, null, null, 0, IMPLIED),
+ attr(ALIGN, null, new String[] { LEFT, CENTER, RIGHT, JUSTIFY, CHAR },
+ 0, IMPLIED),
+ attr(CHAR, null, null, 0, IMPLIED),
+ attr(CHAROFF, null, null, 0, IMPLIED),
+ attr(VALIGN, null, new String[] { TOP, MIDDLE, BOTTOM, BASELINE },
+ 0, IMPLIED)
+ }
+ );
+ defElement(DD, 0, false, true, new ContentModel(0,
+ new noTagModel( new String[] { DD, DT } ), null ),
+ NONE
+ ,
+ new String[] {
+ PCDATA, A, ABBR, ACRONYM,
+ APPLET, B, BASEFONT, BDO, BIG,
+ BR, BUTTON, CITE, CODE, DFN,
+ EM, FONT, I, IFRAME, IMG,
+ INPUT, KBD, LABEL, MAP, OBJECT,
+ Q, S, SAMP, SCRIPT, SELECT,
+ SMALL, SPAN, STRIKE, STRONG, SUB,
+ SUP, TEXTAREA, TT, U, VAR,
+ ADDRESS, BLOCKQUOTE, CENTER, DIR, DIV,
+ DL, FIELDSET, FORM, H1, H2,
+ H3, H4, H5, H6, HR,
+ ISINDEX, MENU, NOFRAMES, NOSCRIPT, OL,
+ P, PRE, TABLE, UL
+ }
+ ,
+ new AttributeList[] {
+ attr(sID, null, null, ID, IMPLIED),
+ attr(CLASS, null, null, 0, IMPLIED),
+ attr(STYLE, null, null, 0, IMPLIED),
+ attr(TITLE, null, null, 0, IMPLIED),
+ attr(LANG, null, null, 0, IMPLIED),
+ attr(DIR, null, new String[] { LTR, RTL }, 0, IMPLIED),
+ attr(ONCLICK, null, null, 0, IMPLIED),
+ attr(ONDBLCLICK, null, null, 0, IMPLIED),
+ attr(ONMOUSEDOWN, null, null, 0, IMPLIED),
+ attr(ONMOUSEUP, null, null, 0, IMPLIED),
+ attr(ONMOUSEOVER, null, null, 0, IMPLIED),
+ attr(ONMOUSEMOVE, null, null, 0, IMPLIED),
+ attr(ONMOUSEOUT, null, null, 0, IMPLIED),
+ attr(ONKEYPRESS, null, null, 0, IMPLIED),
+ attr(ONKEYDOWN, null, null, 0, IMPLIED),
+ attr(ONKEYUP, null, null, 0, IMPLIED)
+ }
+ );
+ defElement(DEL, 0, false, false, null,
+ NONE
+ ,
+ new String[] {
+ PCDATA, A, ABBR, ACRONYM,
+ APPLET, B, BASEFONT, BDO, BIG,
+ BR, BUTTON, CITE, CODE, DFN,
+ EM, FONT, I, IFRAME, IMG,
+ INPUT, KBD, LABEL, MAP, OBJECT,
+ Q, S, SAMP, SCRIPT, SELECT,
+ SMALL, SPAN, STRIKE, STRONG, SUB,
+ SUP, TEXTAREA, TT, U, VAR,
+ ADDRESS, BLOCKQUOTE, CENTER, DIR, DIV,
+ DL, FIELDSET, FORM, H1, H2,
+ H3, H4, H5, H6, HR,
+ ISINDEX, MENU, NOFRAMES, NOSCRIPT, OL,
+ P, PRE, TABLE, UL
+ }
+ ,
+ new AttributeList[] {
+ attr(sID, null, null, ID, IMPLIED),
+ attr(CLASS, null, null, 0, IMPLIED),
+ attr(STYLE, null, null, 0, IMPLIED),
+ attr(TITLE, null, null, 0, IMPLIED),
+ attr(LANG, null, null, 0, IMPLIED),
+ attr(DIR, null, new String[] { LTR, RTL }, 0, IMPLIED),
+ attr(ONCLICK, null, null, 0, IMPLIED),
+ attr(ONDBLCLICK, null, null, 0, IMPLIED),
+ attr(ONMOUSEDOWN, null, null, 0, IMPLIED),
+ attr(ONMOUSEUP, null, null, 0, IMPLIED),
+ attr(ONMOUSEOVER, null, null, 0, IMPLIED),
+ attr(ONMOUSEMOVE, null, null, 0, IMPLIED),
+ attr(ONMOUSEOUT, null, null, 0, IMPLIED),
+ attr(ONKEYPRESS, null, null, 0, IMPLIED),
+ attr(ONKEYDOWN, null, null, 0, IMPLIED),
+ attr(ONKEYUP, null, null, 0, IMPLIED),
+ attr(CITE, null, null, 0, IMPLIED),
+ attr(DATETIME, null, null, 0, IMPLIED)
+ }
+ );
+ defElement(DFN, 0, false, false, null,
+ NONE
+ ,
+ new String[] {
+ PCDATA, A, ABBR, ACRONYM,
+ APPLET, B, BASEFONT, BDO, BIG,
+ BR, BUTTON, CITE, CODE, DFN,
+ EM, FONT, I, IFRAME, IMG,
+ INPUT, KBD, LABEL, MAP, OBJECT,
+ Q, S, SAMP, SCRIPT, SELECT,
+ SMALL, SPAN, STRIKE, STRONG, SUB,
+ SUP, TEXTAREA, TT, U, VAR
+ }
+ ,
+ new AttributeList[] {
+ attr(sID, null, null, ID, IMPLIED),
+ attr(CLASS, null, null, 0, IMPLIED),
+ attr(STYLE, null, null, 0, IMPLIED),
+ attr(TITLE, null, null, 0, IMPLIED),
+ attr(LANG, null, null, 0, IMPLIED),
+ attr(DIR, null, new String[] { LTR, RTL }, 0, IMPLIED),
+ attr(ONCLICK, null, null, 0, IMPLIED),
+ attr(ONDBLCLICK, null, null, 0, IMPLIED),
+ attr(ONMOUSEDOWN, null, null, 0, IMPLIED),
+ attr(ONMOUSEUP, null, null, 0, IMPLIED),
+ attr(ONMOUSEOVER, null, null, 0, IMPLIED),
+ attr(ONMOUSEMOVE, null, null, 0, IMPLIED),
+ attr(ONMOUSEOUT, null, null, 0, IMPLIED),
+ attr(ONKEYPRESS, null, null, 0, IMPLIED),
+ attr(ONKEYDOWN, null, null, 0, IMPLIED),
+ attr(ONKEYUP, null, null, 0, IMPLIED)
+ }
+ );
+ defElement(DIR, 0, false, false, createListModel(),
+ new String[] {
+ ADDRESS, BLOCKQUOTE, CENTER, DIR,
+ DIV, DL, FIELDSET, FORM, H1,
+ H2, H3, H4, H5, H6,
+ HR, ISINDEX, MENU, NOFRAMES, NOSCRIPT,
+ OL, P, PRE, TABLE, UL
+ }
+ ,
+ new String[] {
+ LI, UL, OL
+ }
+ ,
+ new AttributeList[] {
+ attr(sID, null, null, ID, IMPLIED),
+ attr(CLASS, null, null, 0, IMPLIED),
+ attr(STYLE, null, null, 0, IMPLIED),
+ attr(TITLE, null, null, 0, IMPLIED),
+ attr(LANG, null, null, 0, IMPLIED),
+ attr(DIR, null, new String[] { LTR, RTL }, 0, IMPLIED),
+ attr(ONCLICK, null, null, 0, IMPLIED),
+ attr(ONDBLCLICK, null, null, 0, IMPLIED),
+ attr(ONMOUSEDOWN, null, null, 0, IMPLIED),
+ attr(ONMOUSEUP, null, null, 0, IMPLIED),
+ attr(ONMOUSEOVER, null, null, 0, IMPLIED),
+ attr(ONMOUSEMOVE, null, null, 0, IMPLIED),
+ attr(ONMOUSEOUT, null, null, 0, IMPLIED),
+ attr(ONKEYPRESS, null, null, 0, IMPLIED),
+ attr(ONKEYDOWN, null, null, 0, IMPLIED),
+ attr(ONKEYUP, null, null, 0, IMPLIED),
+ attr(COMPACT, null, new String[] { COMPACT }, 0, IMPLIED)
+ }
+ );
+ defElement(DIV, 0, false, false, null,
+ NONE
+ ,
+ new String[] {
+ PCDATA, A, ABBR, ACRONYM,
+ APPLET, B, BASEFONT, BDO, BIG,
+ BR, BUTTON, CITE, CODE, DFN,
+ EM, FONT, I, IFRAME, IMG,
+ INPUT, KBD, LABEL, MAP, OBJECT,
+ Q, S, SAMP, SCRIPT, SELECT,
+ SMALL, SPAN, STRIKE, STRONG, SUB,
+ SUP, TEXTAREA, TT, U, VAR,
+ ADDRESS, BLOCKQUOTE, CENTER, DIR, DIV,
+ DL, FIELDSET, FORM, H1, H2,
+ H3, H4, H5, H6, HR,
+ ISINDEX, MENU, NOFRAMES, NOSCRIPT, OL,
+ P, PRE, TABLE, UL
+ }
+ ,
+ new AttributeList[] {
+ attr(sID, null, null, ID, IMPLIED),
+ attr(CLASS, null, null, 0, IMPLIED),
+ attr(STYLE, null, null, 0, IMPLIED),
+ attr(TITLE, null, null, 0, IMPLIED),
+ attr(LANG, null, null, 0, IMPLIED),
+ attr(DIR, null, new String[] { LTR, RTL }, 0, IMPLIED),
+ attr(ONCLICK, null, null, 0, IMPLIED),
+ attr(ONDBLCLICK, null, null, 0, IMPLIED),
+ attr(ONMOUSEDOWN, null, null, 0, IMPLIED),
+ attr(ONMOUSEUP, null, null, 0, IMPLIED),
+ attr(ONMOUSEOVER, null, null, 0, IMPLIED),
+ attr(ONMOUSEMOVE, null, null, 0, IMPLIED),
+ attr(ONMOUSEOUT, null, null, 0, IMPLIED),
+ attr(ONKEYPRESS, null, null, 0, IMPLIED),
+ attr(ONKEYDOWN, null, null, 0, IMPLIED),
+ attr(ONKEYUP, null, null, 0, IMPLIED),
+ attr(ALIGN, null, new String[] { LEFT, CENTER, RIGHT, JUSTIFY },
+ 0, IMPLIED)
+ }
+ );
+ defElement(DL, 0, false, false, createDefListModel(),
+ NONE
+ ,
+ new String[] {
+ DD, DT
+ }
+ ,
+ new AttributeList[] {
+ attr(sID, null, null, ID, IMPLIED),
+ attr(CLASS, null, null, 0, IMPLIED),
+ attr(STYLE, null, null, 0, IMPLIED),
+ attr(TITLE, null, null, 0, IMPLIED),
+ attr(LANG, null, null, 0, IMPLIED),
+ attr(DIR, null, new String[] { LTR, RTL }, 0, IMPLIED),
+ attr(ONCLICK, null, null, 0, IMPLIED),
+ attr(ONDBLCLICK, null, null, 0, IMPLIED),
+ attr(ONMOUSEDOWN, null, null, 0, IMPLIED),
+ attr(ONMOUSEUP, null, null, 0, IMPLIED),
+ attr(ONMOUSEOVER, null, null, 0, IMPLIED),
+ attr(ONMOUSEMOVE, null, null, 0, IMPLIED),
+ attr(ONMOUSEOUT, null, null, 0, IMPLIED),
+ attr(ONKEYPRESS, null, null, 0, IMPLIED),
+ attr(ONKEYDOWN, null, null, 0, IMPLIED),
+ attr(ONKEYUP, null, null, 0, IMPLIED),
+ attr(COMPACT, null, new String[] { COMPACT }, 0, IMPLIED)
+ }
+ );
+ defElement(DT, 0, false, true,
+ new ContentModel(0,
+ new noTagModel( new String[] { DT, DD } ), null),
+ BLOCK
+ ,
+ new String[] {
+ PCDATA, A, ABBR, ACRONYM,
+ APPLET, B, BASEFONT, BDO, BIG,
+ BR, BUTTON, CITE, CODE, DFN,
+ EM, FONT, I, IFRAME, IMG,
+ INPUT, KBD, LABEL, MAP, OBJECT,
+ Q, S, SAMP, SCRIPT, SELECT,
+ SMALL, SPAN, STRIKE, STRONG, SUB,
+ SUP, TEXTAREA, TT, U, VAR
+ }
+ ,
+ new AttributeList[] {
+ attr(sID, null, null, ID, IMPLIED),
+ attr(CLASS, null, null, 0, IMPLIED),
+ attr(STYLE, null, null, 0, IMPLIED),
+ attr(TITLE, null, null, 0, IMPLIED),
+ attr(LANG, null, null, 0, IMPLIED),
+ attr(DIR, null, new String[] { LTR, RTL }, 0, IMPLIED),
+ attr(ONCLICK, null, null, 0, IMPLIED),
+ attr(ONDBLCLICK, null, null, 0, IMPLIED),
+ attr(ONMOUSEDOWN, null, null, 0, IMPLIED),
+ attr(ONMOUSEUP, null, null, 0, IMPLIED),
+ attr(ONMOUSEOVER, null, null, 0, IMPLIED),
+ attr(ONMOUSEMOVE, null, null, 0, IMPLIED),
+ attr(ONMOUSEOUT, null, null, 0, IMPLIED),
+ attr(ONKEYPRESS, null, null, 0, IMPLIED),
+ attr(ONKEYDOWN, null, null, 0, IMPLIED),
+ attr(ONKEYUP, null, null, 0, IMPLIED)
+ }
+ );
+ defElement(EM, 0, false, false, null,
+ NONE
+ ,
+ new String[] {
+ PCDATA, A, ABBR, ACRONYM,
+ APPLET, B, BASEFONT, BDO, BIG,
+ BR, BUTTON, CITE, CODE, DFN,
+ EM, FONT, I, IFRAME, IMG,
+ INPUT, KBD, LABEL, MAP, OBJECT,
+ Q, S, SAMP, SCRIPT, SELECT,
+ SMALL, SPAN, STRIKE, STRONG, SUB,
+ SUP, TEXTAREA, TT, U, VAR
+ }
+ ,
+ new AttributeList[] {
+ attr(sID, null, null, ID, IMPLIED),
+ attr(CLASS, null, null, 0, IMPLIED),
+ attr(STYLE, null, null, 0, IMPLIED),
+ attr(TITLE, null, null, 0, IMPLIED),
+ attr(LANG, null, null, 0, IMPLIED),
+ attr(DIR, null, new String[] { LTR, RTL }, 0, IMPLIED),
+ attr(ONCLICK, null, null, 0, IMPLIED),
+ attr(ONDBLCLICK, null, null, 0, IMPLIED),
+ attr(ONMOUSEDOWN, null, null, 0, IMPLIED),
+ attr(ONMOUSEUP, null, null, 0, IMPLIED),
+ attr(ONMOUSEOVER, null, null, 0, IMPLIED),
+ attr(ONMOUSEMOVE, null, null, 0, IMPLIED),
+ attr(ONMOUSEOUT, null, null, 0, IMPLIED),
+ attr(ONKEYPRESS, null, null, 0, IMPLIED),
+ attr(ONKEYDOWN, null, null, 0, IMPLIED),
+ attr(ONKEYUP, null, null, 0, IMPLIED)
+ }
+ );
+ defElement(FIELDSET, 0, false, false, null,
+ NONE
+ ,
+ new String[] {
+ PCDATA, A, ABBR, ACRONYM,
+ APPLET, B, BASEFONT, BDO, BIG,
+ BR, BUTTON, CITE, CODE, DFN,
+ EM, FONT, I, IFRAME, IMG,
+ INPUT, KBD, LABEL, MAP, OBJECT,
+ Q, S, SAMP, SCRIPT, SELECT,
+ SMALL, SPAN, STRIKE, STRONG, SUB,
+ SUP, TEXTAREA, TT, U, VAR,
+ ADDRESS, BLOCKQUOTE, CENTER, DIR, DIV,
+ DL, FIELDSET, FORM, H1, H2,
+ H3, H4, H5, H6, HR,
+ ISINDEX, MENU, NOFRAMES, NOSCRIPT, OL,
+ P, PRE, TABLE, UL, LEGEND
+ }
+ ,
+ new AttributeList[] {
+ attr(sID, null, null, ID, IMPLIED),
+ attr(CLASS, null, null, 0, IMPLIED),
+ attr(STYLE, null, null, 0, IMPLIED),
+ attr(TITLE, null, null, 0, IMPLIED),
+ attr(LANG, null, null, 0, IMPLIED),
+ attr(DIR, null, new String[] { LTR, RTL }, 0, IMPLIED),
+ attr(ONCLICK, null, null, 0, IMPLIED),
+ attr(ONDBLCLICK, null, null, 0, IMPLIED),
+ attr(ONMOUSEDOWN, null, null, 0, IMPLIED),
+ attr(ONMOUSEUP, null, null, 0, IMPLIED),
+ attr(ONMOUSEOVER, null, null, 0, IMPLIED),
+ attr(ONMOUSEMOVE, null, null, 0, IMPLIED),
+ attr(ONMOUSEOUT, null, null, 0, IMPLIED),
+ attr(ONKEYPRESS, null, null, 0, IMPLIED),
+ attr(ONKEYDOWN, null, null, 0, IMPLIED),
+ attr(ONKEYUP, null, null, 0, IMPLIED)
+ }
+ );
+ defElement(FONT, 0, false, false, null,
+ NONE
+ ,
+ new String[] {
+ PCDATA, A, ABBR, ACRONYM,
+ APPLET, B, BASEFONT, BDO, BIG,
+ BR, BUTTON, CITE, CODE, DFN,
+ EM, FONT, I, IFRAME, IMG,
+ INPUT, KBD, LABEL, MAP, OBJECT,
+ Q, S, SAMP, SCRIPT, SELECT,
+ SMALL, SPAN, STRIKE, STRONG, SUB,
+ SUP, TEXTAREA, TT, U, VAR
+ }
+ ,
+ new AttributeList[] {
+ attr(sID, null, null, ID, IMPLIED),
+ attr(CLASS, null, null, 0, IMPLIED),
+ attr(STYLE, null, null, 0, IMPLIED),
+ attr(TITLE, null, null, 0, IMPLIED),
+ attr(LANG, null, null, 0, IMPLIED),
+ attr(DIR, null, new String[] { LTR, RTL }, 0, IMPLIED),
+ attr(SIZE, null, null, 0, IMPLIED),
+ attr(COLOR, null, null, 0, IMPLIED),
+ attr(FACE, null, null, 0, IMPLIED)
+ }
+ );
+ defElement(FORM, 0, false, false, null,
+ new String[] {
+ FORM
+ }
+ ,
+ new String[] {
+ PCDATA, A, ABBR, ACRONYM,
+ APPLET, B, BASEFONT, BDO, BIG,
+ BR, BUTTON, CITE, CODE, DFN,
+ EM, FONT, I, IFRAME, IMG,
+ INPUT, KBD, LABEL, MAP, OBJECT,
+ Q, S, SAMP, SCRIPT, SELECT,
+ SMALL, SPAN, STRIKE, STRONG, SUB,
+ SUP, TEXTAREA, TT, U, VAR,
+ ADDRESS, BLOCKQUOTE, CENTER, DIR, DIV,
+ DL, FIELDSET, H1, H2, H3,
+ H4, H5, H6, HR, ISINDEX,
+ MENU, NOFRAMES, NOSCRIPT, OL, P,
+ PRE, TABLE, UL
+ }
+ ,
+ new AttributeList[] {
+ attr(sID, null, null, ID, IMPLIED),
+ attr(CLASS, null, null, 0, IMPLIED),
+ attr(STYLE, null, null, 0, IMPLIED),
+ attr(TITLE, null, null, 0, IMPLIED),
+ attr(LANG, null, null, 0, IMPLIED),
+ attr(DIR, null, new String[] { LTR, RTL }, 0, IMPLIED),
+ attr(ONCLICK, null, null, 0, IMPLIED),
+ attr(ONDBLCLICK, null, null, 0, IMPLIED),
+ attr(ONMOUSEDOWN, null, null, 0, IMPLIED),
+ attr(ONMOUSEUP, null, null, 0, IMPLIED),
+ attr(ONMOUSEOVER, null, null, 0, IMPLIED),
+ attr(ONMOUSEMOVE, null, null, 0, IMPLIED),
+ attr(ONMOUSEOUT, null, null, 0, IMPLIED),
+ attr(ONKEYPRESS, null, null, 0, IMPLIED),
+ attr(ONKEYDOWN, null, null, 0, IMPLIED),
+ attr(ONKEYUP, null, null, 0, IMPLIED),
+ attr(ACTION, null, null, 0, REQUIRED),
+ attr(METHOD, GET, new String[] { GET, POST }, 0, DEFAULT),
+ attr(ENCTYPE, APPLICATION_X_WWW_FORM_URLENCODED, null, 0, DEFAULT),
+ attr(ACCEPT, null, null, 0, IMPLIED),
+ attr(sNAME, null, null, 0, IMPLIED),
+ attr(ONSUBMIT, null, null, 0, IMPLIED),
+ attr(ONRESET, null, null, 0, IMPLIED),
+ attr(TARGET, null, null, 0, IMPLIED),
+ attr(ACCEPTCHARSET, null, null, 0, IMPLIED)
+ }
+ );
+ defElement(FRAME, EMPTY, false, true, null,
+ NONE
+ ,
+ NONE
+ ,
+ new AttributeList[] {
+ attr(sID, null, null, ID, IMPLIED),
+ attr(CLASS, null, null, 0, IMPLIED),
+ attr(STYLE, null, null, 0, IMPLIED),
+ attr(TITLE, null, null, 0, IMPLIED),
+ attr(LONGDESC, null, null, 0, IMPLIED),
+ attr(sNAME, null, null, 0, IMPLIED),
+ attr(SRC, null, null, 0, IMPLIED),
+ attr(FRAMEBORDER, C_1, new String[] { C_1, C_0 }, 0, DEFAULT),
+ attr(MARGINWIDTH, null, null, PIXELS, IMPLIED),
+ attr(MARGINHEIGHT, null, null, PIXELS, IMPLIED),
+ attr(NORESIZE, null, new String[] { NORESIZE }, 0, IMPLIED),
+ attr(SCROLLING, AUTO, new String[] { YES, NO, AUTO }, 0, DEFAULT)
+ }
+ );
+ defElement(FRAMESET, 0, false, false, null,
+ NONE
+ ,
+ new String[] {
+ NOFRAMES, FRAME, FRAMESET
+ }
+ ,
+ new AttributeList[] {
+ attr(sID, null, null, ID, IMPLIED),
+ attr(CLASS, null, null, 0, IMPLIED),
+ attr(STYLE, null, null, 0, IMPLIED),
+ attr(TITLE, null, null, 0, IMPLIED),
+ attr(ROWS, null, null, 0, IMPLIED),
+ attr(COLS, null, null, 0, IMPLIED),
+ attr(ONLOAD, null, null, 0, IMPLIED),
+ attr(ONUNLOAD, null, null, 0, IMPLIED)
+ }
+ );
+ defElement(H1, 0, false, false, null,
+ NONE
+ ,
+ new String[] {
+ PCDATA, A, ABBR, ACRONYM,
+ APPLET, B, BASEFONT, BDO, BIG,
+ BR, BUTTON, CITE, CODE, DFN,
+ EM, FONT, I, IFRAME, IMG,
+ INPUT, KBD, LABEL, MAP, OBJECT,
+ Q, S, SAMP, SCRIPT, SELECT,
+ SMALL, SPAN, STRIKE, STRONG, SUB,
+ SUP, TEXTAREA, TT, U, VAR
+ }
+ ,
+ new AttributeList[] {
+ attr(sID, null, null, ID, IMPLIED),
+ attr(CLASS, null, null, 0, IMPLIED),
+ attr(STYLE, null, null, 0, IMPLIED),
+ attr(TITLE, null, null, 0, IMPLIED),
+ attr(LANG, null, null, 0, IMPLIED),
+ attr(DIR, null, new String[] { LTR, RTL }, 0, IMPLIED),
+ attr(ONCLICK, null, null, 0, IMPLIED),
+ attr(ONDBLCLICK, null, null, 0, IMPLIED),
+ attr(ONMOUSEDOWN, null, null, 0, IMPLIED),
+ attr(ONMOUSEUP, null, null, 0, IMPLIED),
+ attr(ONMOUSEOVER, null, null, 0, IMPLIED),
+ attr(ONMOUSEMOVE, null, null, 0, IMPLIED),
+ attr(ONMOUSEOUT, null, null, 0, IMPLIED),
+ attr(ONKEYPRESS, null, null, 0, IMPLIED),
+ attr(ONKEYDOWN, null, null, 0, IMPLIED),
+ attr(ONKEYUP, null, null, 0, IMPLIED),
+ attr(ALIGN, null, new String[] { LEFT, CENTER, RIGHT, JUSTIFY },
+ 0, IMPLIED)
+ }
+ );
+ defElement(H2, 0, false, false, null,
+ NONE
+ ,
+ new String[] {
+ PCDATA, A, ABBR, ACRONYM,
+ APPLET, B, BASEFONT, BDO, BIG,
+ BR, BUTTON, CITE, CODE, DFN,
+ EM, FONT, I, IFRAME, IMG,
+ INPUT, KBD, LABEL, MAP, OBJECT,
+ Q, S, SAMP, SCRIPT, SELECT,
+ SMALL, SPAN, STRIKE, STRONG, SUB,
+ SUP, TEXTAREA, TT, U, VAR
+ }
+ ,
+ new AttributeList[] {
+ attr(sID, null, null, ID, IMPLIED),
+ attr(CLASS, null, null, 0, IMPLIED),
+ attr(STYLE, null, null, 0, IMPLIED),
+ attr(TITLE, null, null, 0, IMPLIED),
+ attr(LANG, null, null, 0, IMPLIED),
+ attr(DIR, null, new String[] { LTR, RTL }, 0, IMPLIED),
+ attr(ONCLICK, null, null, 0, IMPLIED),
+ attr(ONDBLCLICK, null, null, 0, IMPLIED),
+ attr(ONMOUSEDOWN, null, null, 0, IMPLIED),
+ attr(ONMOUSEUP, null, null, 0, IMPLIED),
+ attr(ONMOUSEOVER, null, null, 0, IMPLIED),
+ attr(ONMOUSEMOVE, null, null, 0, IMPLIED),
+ attr(ONMOUSEOUT, null, null, 0, IMPLIED),
+ attr(ONKEYPRESS, null, null, 0, IMPLIED),
+ attr(ONKEYDOWN, null, null, 0, IMPLIED),
+ attr(ONKEYUP, null, null, 0, IMPLIED),
+ attr(ALIGN, null, new String[] { LEFT, CENTER, RIGHT, JUSTIFY },
+ 0, IMPLIED)
+ }
+ );
+ defElement(H3, 0, false, false, null,
+ NONE
+ ,
+ new String[] {
+ PCDATA, A, ABBR, ACRONYM,
+ APPLET, B, BASEFONT, BDO, BIG,
+ BR, BUTTON, CITE, CODE, DFN,
+ EM, FONT, I, IFRAME, IMG,
+ INPUT, KBD, LABEL, MAP, OBJECT,
+ Q, S, SAMP, SCRIPT, SELECT,
+ SMALL, SPAN, STRIKE, STRONG, SUB,
+ SUP, TEXTAREA, TT, U, VAR
+ }
+ ,
+ new AttributeList[] {
+ attr(sID, null, null, ID, IMPLIED),
+ attr(CLASS, null, null, 0, IMPLIED),
+ attr(STYLE, null, null, 0, IMPLIED),
+ attr(TITLE, null, null, 0, IMPLIED),
+ attr(LANG, null, null, 0, IMPLIED),
+ attr(DIR, null, new String[] { LTR, RTL }, 0, IMPLIED),
+ attr(ONCLICK, null, null, 0, IMPLIED),
+ attr(ONDBLCLICK, null, null, 0, IMPLIED),
+ attr(ONMOUSEDOWN, null, null, 0, IMPLIED),
+ attr(ONMOUSEUP, null, null, 0, IMPLIED),
+ attr(ONMOUSEOVER, null, null, 0, IMPLIED),
+ attr(ONMOUSEMOVE, null, null, 0, IMPLIED),
+ attr(ONMOUSEOUT, null, null, 0, IMPLIED),
+ attr(ONKEYPRESS, null, null, 0, IMPLIED),
+ attr(ONKEYDOWN, null, null, 0, IMPLIED),
+ attr(ONKEYUP, null, null, 0, IMPLIED),
+ attr(ALIGN, null, new String[] { LEFT, CENTER, RIGHT, JUSTIFY },
+ 0, IMPLIED)
+ }
+ );
+ defElement(H4, 0, false, false, null,
+ NONE
+ ,
+ new String[] {
+ PCDATA, A, ABBR, ACRONYM,
+ APPLET, B, BASEFONT, BDO, BIG,
+ BR, BUTTON, CITE, CODE, DFN,
+ EM, FONT, I, IFRAME, IMG,
+ INPUT, KBD, LABEL, MAP, OBJECT,
+ Q, S, SAMP, SCRIPT, SELECT,
+ SMALL, SPAN, STRIKE, STRONG, SUB,
+ SUP, TEXTAREA, TT, U, VAR
+ }
+ ,
+ new AttributeList[] {
+ attr(sID, null, null, ID, IMPLIED),
+ attr(CLASS, null, null, 0, IMPLIED),
+ attr(STYLE, null, null, 0, IMPLIED),
+ attr(TITLE, null, null, 0, IMPLIED),
+ attr(LANG, null, null, 0, IMPLIED),
+ attr(DIR, null, new String[] { LTR, RTL }, 0, IMPLIED),
+ attr(ONCLICK, null, null, 0, IMPLIED),
+ attr(ONDBLCLICK, null, null, 0, IMPLIED),
+ attr(ONMOUSEDOWN, null, null, 0, IMPLIED),
+ attr(ONMOUSEUP, null, null, 0, IMPLIED),
+ attr(ONMOUSEOVER, null, null, 0, IMPLIED),
+ attr(ONMOUSEMOVE, null, null, 0, IMPLIED),
+ attr(ONMOUSEOUT, null, null, 0, IMPLIED),
+ attr(ONKEYPRESS, null, null, 0, IMPLIED),
+ attr(ONKEYDOWN, null, null, 0, IMPLIED),
+ attr(ONKEYUP, null, null, 0, IMPLIED),
+ attr(ALIGN, null, new String[] { LEFT, CENTER, RIGHT, JUSTIFY },
+ 0, IMPLIED)
+ }
+ );
+ defElement(H5, 0, false, false, null,
+ NONE
+ ,
+ new String[] {
+ PCDATA, A, ABBR, ACRONYM,
+ APPLET, B, BASEFONT, BDO, BIG,
+ BR, BUTTON, CITE, CODE, DFN,
+ EM, FONT, I, IFRAME, IMG,
+ INPUT, KBD, LABEL, MAP, OBJECT,
+ Q, S, SAMP, SCRIPT, SELECT,
+ SMALL, SPAN, STRIKE, STRONG, SUB,
+ SUP, TEXTAREA, TT, U, VAR
+ }
+ ,
+ new AttributeList[] {
+ attr(sID, null, null, ID, IMPLIED),
+ attr(CLASS, null, null, 0, IMPLIED),
+ attr(STYLE, null, null, 0, IMPLIED),
+ attr(TITLE, null, null, 0, IMPLIED),
+ attr(LANG, null, null, 0, IMPLIED),
+ attr(DIR, null, new String[] { LTR, RTL }, 0, IMPLIED),
+ attr(ONCLICK, null, null, 0, IMPLIED),
+ attr(ONDBLCLICK, null, null, 0, IMPLIED),
+ attr(ONMOUSEDOWN, null, null, 0, IMPLIED),
+ attr(ONMOUSEUP, null, null, 0, IMPLIED),
+ attr(ONMOUSEOVER, null, null, 0, IMPLIED),
+ attr(ONMOUSEMOVE, null, null, 0, IMPLIED),
+ attr(ONMOUSEOUT, null, null, 0, IMPLIED),
+ attr(ONKEYPRESS, null, null, 0, IMPLIED),
+ attr(ONKEYDOWN, null, null, 0, IMPLIED),
+ attr(ONKEYUP, null, null, 0, IMPLIED),
+ attr(ALIGN, null, new String[] { LEFT, CENTER, RIGHT, JUSTIFY },
+ 0, IMPLIED)
+ }
+ );
+ defElement(H6, 0, false, false, null,
+ NONE
+ ,
+ new String[] {
+ PCDATA, A, ABBR, ACRONYM,
+ APPLET, B, BASEFONT, BDO, BIG,
+ BR, BUTTON, CITE, CODE, DFN,
+ EM, FONT, I, IFRAME, IMG,
+ INPUT, KBD, LABEL, MAP, OBJECT,
+ Q, S, SAMP, SCRIPT, SELECT,
+ SMALL, SPAN, STRIKE, STRONG, SUB,
+ SUP, TEXTAREA, TT, U, VAR
+ }
+ ,
+ new AttributeList[] {
+ attr(sID, null, null, ID, IMPLIED),
+ attr(CLASS, null, null, 0, IMPLIED),
+ attr(STYLE, null, null, 0, IMPLIED),
+ attr(TITLE, null, null, 0, IMPLIED),
+ attr(LANG, null, null, 0, IMPLIED),
+ attr(DIR, null, new String[] { LTR, RTL }, 0, IMPLIED),
+ attr(ONCLICK, null, null, 0, IMPLIED),
+ attr(ONDBLCLICK, null, null, 0, IMPLIED),
+ attr(ONMOUSEDOWN, null, null, 0, IMPLIED),
+ attr(ONMOUSEUP, null, null, 0, IMPLIED),
+ attr(ONMOUSEOVER, null, null, 0, IMPLIED),
+ attr(ONMOUSEMOVE, null, null, 0, IMPLIED),
+ attr(ONMOUSEOUT, null, null, 0, IMPLIED),
+ attr(ONKEYPRESS, null, null, 0, IMPLIED),
+ attr(ONKEYDOWN, null, null, 0, IMPLIED),
+ attr(ONKEYUP, null, null, 0, IMPLIED),
+ attr(ALIGN, null, new String[] { LEFT, CENTER, RIGHT, JUSTIFY },
+ 0, IMPLIED)
+ }
+ );
+ defElement(HEAD, 0, true, true, null,
+ new String[] {
+ BODY
+ }
+ ,
+ new String[] {
+ TITLE, ISINDEX, BASE,
+ SCRIPT, STYLE, META, LINK, OBJECT
+ }
+ ,
+ new AttributeList[] {
+ attr(LANG, null, null, 0, IMPLIED),
+ attr(DIR, null, new String[] { LTR, RTL }, 0, IMPLIED),
+ attr(PROFILE, null, null, 0, IMPLIED)
+ }
+ );
+
+ defElement(HR, EMPTY, false, true, null,
+ NONE
+ ,
+ NONE
+ ,
+ new AttributeList[] {
+ attr(sID, null, null, ID, IMPLIED),
+ attr(CLASS, null, null, 0, IMPLIED),
+ attr(STYLE, null, null, 0, IMPLIED),
+ attr(TITLE, null, null, 0, IMPLIED),
+ attr(LANG, null, null, 0, IMPLIED),
+ attr(DIR, null, new String[] { LTR, RTL }, 0, IMPLIED),
+ attr(ONCLICK, null, null, 0, IMPLIED),
+ attr(ONDBLCLICK, null, null, 0, IMPLIED),
+ attr(ONMOUSEDOWN, null, null, 0, IMPLIED),
+ attr(ONMOUSEUP, null, null, 0, IMPLIED),
+ attr(ONMOUSEOVER, null, null, 0, IMPLIED),
+ attr(ONMOUSEMOVE, null, null, 0, IMPLIED),
+ attr(ONMOUSEOUT, null, null, 0, IMPLIED),
+ attr(ONKEYPRESS, null, null, 0, IMPLIED),
+ attr(ONKEYDOWN, null, null, 0, IMPLIED),
+ attr(ONKEYUP, null, null, 0, IMPLIED),
+ attr(ALIGN, null, new String[] { LEFT, CENTER, RIGHT }, 0, IMPLIED),
+ attr(NOSHADE, null, new String[] { NOSHADE }, 0, IMPLIED),
+ attr(SIZE, null, null, 0, IMPLIED),
+ attr(WIDTH, null, null, 0, IMPLIED)
+ }
+ );
+ defElement(HTML, 0, true, true, createHtmlContentModel(),
+ NONE
+ ,
+ new String[] {
+ HEAD, BODY
+ }
+ ,
+ new AttributeList[] {
+ attr(LANG, null, null, 0, IMPLIED),
+ attr(DIR, null, new String[] { LTR, RTL }, 0, IMPLIED),
+ attr(VERSION, DTD_NAME, null, 0, FIXED)
+ }
+ );
+ defElement(I, 0, false, false, null,
+ NONE
+ ,
+ new String[] {
+ PCDATA, A, ABBR, ACRONYM,
+ APPLET, B, BASEFONT, BDO, BIG,
+ BR, BUTTON, CITE, CODE, DFN,
+ EM, FONT, I, IFRAME, IMG,
+ INPUT, KBD, LABEL, MAP, OBJECT,
+ Q, S, SAMP, SCRIPT, SELECT,
+ SMALL, SPAN, STRIKE, STRONG, SUB,
+ SUP, TEXTAREA, TT, U, VAR
+ }
+ ,
+ new AttributeList[] {
+ attr(sID, null, null, ID, IMPLIED),
+ attr(CLASS, null, null, 0, IMPLIED),
+ attr(STYLE, null, null, 0, IMPLIED),
+ attr(TITLE, null, null, 0, IMPLIED),
+ attr(LANG, null, null, 0, IMPLIED),
+ attr(DIR, null, new String[] { LTR, RTL }, 0, IMPLIED),
+ attr(ONCLICK, null, null, 0, IMPLIED),
+ attr(ONDBLCLICK, null, null, 0, IMPLIED),
+ attr(ONMOUSEDOWN, null, null, 0, IMPLIED),
+ attr(ONMOUSEUP, null, null, 0, IMPLIED),
+ attr(ONMOUSEOVER, null, null, 0, IMPLIED),
+ attr(ONMOUSEMOVE, null, null, 0, IMPLIED),
+ attr(ONMOUSEOUT, null, null, 0, IMPLIED),
+ attr(ONKEYPRESS, null, null, 0, IMPLIED),
+ attr(ONKEYDOWN, null, null, 0, IMPLIED),
+ attr(ONKEYUP, null, null, 0, IMPLIED)
+ }
+ );
+ defElement(IFRAME, 0, false, false, null,
+ NONE
+ ,
+ new String[] {
+ PCDATA, A, ABBR, ACRONYM,
+ APPLET, B, BASEFONT, BDO, BIG,
+ BR, BUTTON, CITE, CODE, DFN,
+ EM, FONT, I, IFRAME, IMG,
+ INPUT, KBD, LABEL, MAP, OBJECT,
+ Q, S, SAMP, SCRIPT, SELECT,
+ SMALL, SPAN, STRIKE, STRONG, SUB,
+ SUP, TEXTAREA, TT, U, VAR,
+ ADDRESS, BLOCKQUOTE, CENTER, DIR, DIV,
+ DL, FIELDSET, FORM, H1, H2,
+ H3, H4, H5, H6, HR,
+ ISINDEX, MENU, NOFRAMES, NOSCRIPT, OL,
+ P, PRE, TABLE, UL
+ }
+ ,
+ new AttributeList[] {
+ attr(sID, null, null, ID, IMPLIED),
+ attr(CLASS, null, null, 0, IMPLIED),
+ attr(STYLE, null, null, 0, IMPLIED),
+ attr(TITLE, null, null, 0, IMPLIED),
+ attr(LONGDESC, null, null, 0, IMPLIED),
+ attr(sNAME, null, null, 0, IMPLIED),
+ attr(SRC, null, null, 0, IMPLIED),
+ attr(FRAMEBORDER, C_1, new String[] { C_1, C_0 }, 0, DEFAULT),
+ attr(MARGINWIDTH, null, null, PIXELS, IMPLIED),
+ attr(MARGINHEIGHT, null, null, PIXELS, IMPLIED),
+ attr(SCROLLING, AUTO, new String[] { YES, NO, AUTO }, 0, DEFAULT),
+ attr(ALIGN, null, new String[] { TOP, MIDDLE, BOTTOM, LEFT, RIGHT },
+ 0, IMPLIED),
+ attr(HEIGHT, null, null, 0, IMPLIED),
+ attr(WIDTH, null, null, 0, IMPLIED)
+ }
+ );
+ defElement(IMG, EMPTY, false, true, null,
+ NONE
+ ,
+ NONE
+ ,
+ new AttributeList[] {
+ attr(sID, null, null, ID, IMPLIED),
+ attr(CLASS, null, null, 0, IMPLIED),
+ attr(STYLE, null, null, 0, IMPLIED),
+ attr(TITLE, null, null, 0, IMPLIED),
+ attr(LANG, null, null, 0, IMPLIED),
+ attr(DIR, null, new String[] { LTR, RTL }, 0, IMPLIED),
+ attr(ONCLICK, null, null, 0, IMPLIED),
+ attr(ONDBLCLICK, null, null, 0, IMPLIED),
+ attr(ONMOUSEDOWN, null, null, 0, IMPLIED),
+ attr(ONMOUSEUP, null, null, 0, IMPLIED),
+ attr(ONMOUSEOVER, null, null, 0, IMPLIED),
+ attr(ONMOUSEMOVE, null, null, 0, IMPLIED),
+ attr(ONMOUSEOUT, null, null, 0, IMPLIED),
+ attr(ONKEYPRESS, null, null, 0, IMPLIED),
+ attr(ONKEYDOWN, null, null, 0, IMPLIED),
+ attr(ONKEYUP, null, null, 0, IMPLIED),
+ attr(SRC, null, null, 0, REQUIRED),
+ attr(ALT, null, null, 0, REQUIRED),
+ attr(LONGDESC, null, null, 0, IMPLIED),
+ attr(sNAME, null, null, 0, IMPLIED),
+ attr(HEIGHT, null, null, 0, IMPLIED),
+ attr(WIDTH, null, null, 0, IMPLIED),
+ attr(USEMAP, null, null, 0, IMPLIED),
+ attr(ISMAP, null, new String[] { ISMAP }, 0, IMPLIED),
+ attr(ALIGN, null, new String[] { TOP, MIDDLE, BOTTOM, LEFT, RIGHT },
+ 0, IMPLIED),
+ attr(BORDER, null, null, PIXELS, IMPLIED),
+ attr(HSPACE, null, null, 0, IMPLIED),
+ attr(VSPACE, null, null, 0, IMPLIED)
+ }
+ );
+ defElement(INPUT, EMPTY, false, true, null,
+ NONE
+ ,
+ NONE
+ ,
+ new AttributeList[] {
+ attr(sID, null, null, ID, IMPLIED),
+ attr(CLASS, null, null, 0, IMPLIED),
+ attr(STYLE, null, null, 0, IMPLIED),
+ attr(TITLE, null, null, 0, IMPLIED),
+ attr(LANG, null, null, 0, IMPLIED),
+ attr(DIR, null, new String[] { LTR, RTL }, 0, IMPLIED),
+ attr(ONCLICK, null, null, 0, IMPLIED),
+ attr(ONDBLCLICK, null, null, 0, IMPLIED),
+ attr(ONMOUSEDOWN, null, null, 0, IMPLIED),
+ attr(ONMOUSEUP, null, null, 0, IMPLIED),
+ attr(ONMOUSEOVER, null, null, 0, IMPLIED),
+ attr(ONMOUSEMOVE, null, null, 0, IMPLIED),
+ attr(ONMOUSEOUT, null, null, 0, IMPLIED),
+ attr(ONKEYPRESS, null, null, 0, IMPLIED),
+ attr(ONKEYDOWN, null, null, 0, IMPLIED),
+ attr(ONKEYUP, null, null, 0, IMPLIED),
+ attr(TYPE, TEXT, new String[] { TEXT, PASSWORD, CHECKBOX, RADIO,
+ SUBMIT, RESET, FILE, HIDDEN, IMAGE, BUTTON }, 0, DEFAULT),
+ attr(sNAME, null, null, 0, IMPLIED),
+ attr(VALUE, null, null, 0, IMPLIED),
+ attr(CHECKED, null, new String[] { CHECKED }, 0, IMPLIED),
+ attr(DISABLED, null, new String[] { DISABLED }, 0, IMPLIED),
+ attr(READONLY, null, new String[] { READONLY }, 0, IMPLIED),
+ attr(SIZE, null, null, 0, IMPLIED),
+ attr(MAXLENGTH, null, null, 0, IMPLIED),
+ attr(SRC, null, null, 0, IMPLIED),
+ attr(ALT, null, null, 0, IMPLIED),
+ attr(USEMAP, null, null, 0, IMPLIED),
+ attr(ISMAP, null, new String[] { ISMAP }, 0, IMPLIED),
+ attr(TABINDEX, null, null, NUMBER, IMPLIED),
+ attr(ACCESSKEY, null, null, 0, IMPLIED),
+ attr(ONFOCUS, null, null, 0, IMPLIED),
+ attr(ONBLUR, null, null, 0, IMPLIED),
+ attr(ONSELECT, null, null, 0, IMPLIED),
+ attr(ONCHANGE, null, null, 0, IMPLIED),
+ attr(ACCEPT, null, null, 0, IMPLIED),
+ attr(ALIGN, null, new String[] { TOP, MIDDLE, BOTTOM, LEFT, RIGHT },
+ 0, IMPLIED)
+ }
+ );
+ defElement(INS, 0, false, false, null,
+ NONE
+ ,
+ new String[] {
+ PCDATA, A, ABBR, ACRONYM,
+ APPLET, B, BASEFONT, BDO, BIG,
+ BR, BUTTON, CITE, CODE, DFN,
+ EM, FONT, I, IFRAME, IMG,
+ INPUT, KBD, LABEL, MAP, OBJECT,
+ Q, S, SAMP, SCRIPT, SELECT,
+ SMALL, SPAN, STRIKE, STRONG, SUB,
+ SUP, TEXTAREA, TT, U, VAR,
+ ADDRESS, BLOCKQUOTE, CENTER, DIR, DIV,
+ DL, FIELDSET, FORM, H1, H2,
+ H3, H4, H5, H6, HR,
+ ISINDEX, MENU, NOFRAMES, NOSCRIPT, OL,
+ P, PRE, TABLE, UL
+ }
+ ,
+ new AttributeList[] {
+ attr(sID, null, null, ID, IMPLIED),
+ attr(CLASS, null, null, 0, IMPLIED),
+ attr(STYLE, null, null, 0, IMPLIED),
+ attr(TITLE, null, null, 0, IMPLIED),
+ attr(LANG, null, null, 0, IMPLIED),
+ attr(DIR, null, new String[] { LTR, RTL }, 0, IMPLIED),
+ attr(ONCLICK, null, null, 0, IMPLIED),
+ attr(ONDBLCLICK, null, null, 0, IMPLIED),
+ attr(ONMOUSEDOWN, null, null, 0, IMPLIED),
+ attr(ONMOUSEUP, null, null, 0, IMPLIED),
+ attr(ONMOUSEOVER, null, null, 0, IMPLIED),
+ attr(ONMOUSEMOVE, null, null, 0, IMPLIED),
+ attr(ONMOUSEOUT, null, null, 0, IMPLIED),
+ attr(ONKEYPRESS, null, null, 0, IMPLIED),
+ attr(ONKEYDOWN, null, null, 0, IMPLIED),
+ attr(ONKEYUP, null, null, 0, IMPLIED),
+ attr(CITE, null, null, 0, IMPLIED),
+ attr(DATETIME, null, null, 0, IMPLIED)
+ }
+ );
+ defElement(ISINDEX, EMPTY, false, true, null,
+ NONE
+ ,
+ NONE
+ ,
+ new AttributeList[] {
+ attr(sID, null, null, ID, IMPLIED),
+ attr(CLASS, null, null, 0, IMPLIED),
+ attr(STYLE, null, null, 0, IMPLIED),
+ attr(TITLE, null, null, 0, IMPLIED),
+ attr(LANG, null, null, 0, IMPLIED),
+ attr(DIR, null, new String[] { LTR, RTL }, 0, IMPLIED),
+ attr(PROMPT, null, null, 0, IMPLIED)
+ }
+ );
+ defElement(KBD, 0, false, false, null,
+ NONE
+ ,
+ new String[] {
+ PCDATA, A, ABBR, ACRONYM,
+ APPLET, B, BASEFONT, BDO, BIG,
+ BR, BUTTON, CITE, CODE, DFN,
+ EM, FONT, I, IFRAME, IMG,
+ INPUT, KBD, LABEL, MAP, OBJECT,
+ Q, S, SAMP, SCRIPT, SELECT,
+ SMALL, SPAN, STRIKE, STRONG, SUB,
+ SUP, TEXTAREA, TT, U, VAR
+ }
+ ,
+ new AttributeList[] {
+ attr(sID, null, null, ID, IMPLIED),
+ attr(CLASS, null, null, 0, IMPLIED),
+ attr(STYLE, null, null, 0, IMPLIED),
+ attr(TITLE, null, null, 0, IMPLIED),
+ attr(LANG, null, null, 0, IMPLIED),
+ attr(DIR, null, new String[] { LTR, RTL }, 0, IMPLIED),
+ attr(ONCLICK, null, null, 0, IMPLIED),
+ attr(ONDBLCLICK, null, null, 0, IMPLIED),
+ attr(ONMOUSEDOWN, null, null, 0, IMPLIED),
+ attr(ONMOUSEUP, null, null, 0, IMPLIED),
+ attr(ONMOUSEOVER, null, null, 0, IMPLIED),
+ attr(ONMOUSEMOVE, null, null, 0, IMPLIED),
+ attr(ONMOUSEOUT, null, null, 0, IMPLIED),
+ attr(ONKEYPRESS, null, null, 0, IMPLIED),
+ attr(ONKEYDOWN, null, null, 0, IMPLIED),
+ attr(ONKEYUP, null, null, 0, IMPLIED)
+ }
+ );
+ defElement(LABEL, 0, false, false, null,
+ new String[] {
+ LABEL
+ }
+ ,
+ new String[] {
+ PCDATA, A, ABBR, ACRONYM,
+ APPLET, B, BASEFONT, BDO, BIG,
+ BR, BUTTON, CITE, CODE, DFN,
+ EM, FONT, I, IFRAME, IMG,
+ INPUT, KBD, MAP, OBJECT, Q,
+ S, SAMP, SCRIPT, SELECT, SMALL,
+ SPAN, STRIKE, STRONG, SUB, SUP,
+ TEXTAREA, TT, U, VAR
+ }
+ ,
+ new AttributeList[] {
+ attr(sID, null, null, ID, IMPLIED),
+ attr(CLASS, null, null, 0, IMPLIED),
+ attr(STYLE, null, null, 0, IMPLIED),
+ attr(TITLE, null, null, 0, IMPLIED),
+ attr(LANG, null, null, 0, IMPLIED),
+ attr(DIR, null, new String[] { LTR, RTL }, 0, IMPLIED),
+ attr(ONCLICK, null, null, 0, IMPLIED),
+ attr(ONDBLCLICK, null, null, 0, IMPLIED),
+ attr(ONMOUSEDOWN, null, null, 0, IMPLIED),
+ attr(ONMOUSEUP, null, null, 0, IMPLIED),
+ attr(ONMOUSEOVER, null, null, 0, IMPLIED),
+ attr(ONMOUSEMOVE, null, null, 0, IMPLIED),
+ attr(ONMOUSEOUT, null, null, 0, IMPLIED),
+ attr(ONKEYPRESS, null, null, 0, IMPLIED),
+ attr(ONKEYDOWN, null, null, 0, IMPLIED),
+ attr(ONKEYUP, null, null, 0, IMPLIED),
+ attr(FOR, null, null, 0, IMPLIED),
+ attr(ACCESSKEY, null, null, 0, IMPLIED),
+ attr(ONFOCUS, null, null, 0, IMPLIED),
+ attr(ONBLUR, null, null, 0, IMPLIED)
+ }
+ );
+ defElement(LEGEND, 0, false, false, null,
+ NONE
+ ,
+ new String[] {
+ PCDATA, A, ABBR, ACRONYM,
+ APPLET, B, BASEFONT, BDO, BIG,
+ BR, BUTTON, CITE, CODE, DFN,
+ EM, FONT, I, IFRAME, IMG,
+ INPUT, KBD, LABEL, MAP, OBJECT,
+ Q, S, SAMP, SCRIPT, SELECT,
+ SMALL, SPAN, STRIKE, STRONG, SUB,
+ SUP, TEXTAREA, TT, U, VAR
+ }
+ ,
+ new AttributeList[] {
+ attr(sID, null, null, ID, IMPLIED),
+ attr(CLASS, null, null, 0, IMPLIED),
+ attr(STYLE, null, null, 0, IMPLIED),
+ attr(TITLE, null, null, 0, IMPLIED),
+ attr(LANG, null, null, 0, IMPLIED),
+ attr(DIR, null, new String[] { LTR, RTL }, 0, IMPLIED),
+ attr(ONCLICK, null, null, 0, IMPLIED),
+ attr(ONDBLCLICK, null, null, 0, IMPLIED),
+ attr(ONMOUSEDOWN, null, null, 0, IMPLIED),
+ attr(ONMOUSEUP, null, null, 0, IMPLIED),
+ attr(ONMOUSEOVER, null, null, 0, IMPLIED),
+ attr(ONMOUSEMOVE, null, null, 0, IMPLIED),
+ attr(ONMOUSEOUT, null, null, 0, IMPLIED),
+ attr(ONKEYPRESS, null, null, 0, IMPLIED),
+ attr(ONKEYDOWN, null, null, 0, IMPLIED),
+ attr(ONKEYUP, null, null, 0, IMPLIED),
+ attr(ACCESSKEY, null, null, 0, IMPLIED),
+ attr(ALIGN, null, new String[] { TOP, BOTTOM, LEFT, RIGHT },
+ 0, IMPLIED)
+ }
+ );
+ // LI has a special content model that will be resolved into
+ // by transformer.
+ defElement(LI, 0, false, true,
+ new ContentModel(0,
+ new noTagModel(LI), null),
+ NONE
+ ,
+ new String[] {
+ PCDATA, A, ABBR, ACRONYM,
+ APPLET, B, BASEFONT, BDO, BIG,
+ BR, BUTTON, CITE, CODE, DFN,
+ EM, FONT, I, IFRAME, IMG,
+ INPUT, KBD, LABEL, MAP, OBJECT,
+ Q, S, SAMP, SCRIPT, SELECT,
+ SMALL, SPAN, STRIKE, STRONG, SUB,
+ SUP, TEXTAREA, TT, U, VAR,
+ ADDRESS, BLOCKQUOTE, CENTER, DIR, DIV,
+ DL, FIELDSET, FORM, H1, H2,
+ H3, H4, H5, H6, HR,
+ ISINDEX, MENU, NOFRAMES, NOSCRIPT, OL,
+ P, PRE, TABLE, UL
+ }
+ ,
+ new AttributeList[] {
+ attr(sID, null, null, ID, IMPLIED),
+ attr(CLASS, null, null, 0, IMPLIED),
+ attr(STYLE, null, null, 0, IMPLIED),
+ attr(TITLE, null, null, 0, IMPLIED),
+ attr(LANG, null, null, 0, IMPLIED),
+ attr(DIR, null, new String[] { LTR, RTL }, 0, IMPLIED),
+ attr(ONCLICK, null, null, 0, IMPLIED),
+ attr(ONDBLCLICK, null, null, 0, IMPLIED),
+ attr(ONMOUSEDOWN, null, null, 0, IMPLIED),
+ attr(ONMOUSEUP, null, null, 0, IMPLIED),
+ attr(ONMOUSEOVER, null, null, 0, IMPLIED),
+ attr(ONMOUSEMOVE, null, null, 0, IMPLIED),
+ attr(ONMOUSEOUT, null, null, 0, IMPLIED),
+ attr(ONKEYPRESS, null, null, 0, IMPLIED),
+ attr(ONKEYDOWN, null, null, 0, IMPLIED),
+ attr(ONKEYUP, null, null, 0, IMPLIED),
+ attr(TYPE, null, null, 0, IMPLIED),
+ attr(VALUE, null, null, NUMBER, IMPLIED)
+ }
+ );
+ defElement(LINK, EMPTY, false, true, null,
+ NONE
+ ,
+ NONE
+ ,
+ new AttributeList[] {
+ attr(sID, null, null, ID, IMPLIED),
+ attr(CLASS, null, null, 0, IMPLIED),
+ attr(STYLE, null, null, 0, IMPLIED),
+ attr(TITLE, null, null, 0, IMPLIED),
+ attr(LANG, null, null, 0, IMPLIED),
+ attr(DIR, null, new String[] { LTR, RTL }, 0, IMPLIED),
+ attr(ONCLICK, null, null, 0, IMPLIED),
+ attr(ONDBLCLICK, null, null, 0, IMPLIED),
+ attr(ONMOUSEDOWN, null, null, 0, IMPLIED),
+ attr(ONMOUSEUP, null, null, 0, IMPLIED),
+ attr(ONMOUSEOVER, null, null, 0, IMPLIED),
+ attr(ONMOUSEMOVE, null, null, 0, IMPLIED),
+ attr(ONMOUSEOUT, null, null, 0, IMPLIED),
+ attr(ONKEYPRESS, null, null, 0, IMPLIED),
+ attr(ONKEYDOWN, null, null, 0, IMPLIED),
+ attr(ONKEYUP, null, null, 0, IMPLIED),
+ attr(CHARSET, null, null, 0, IMPLIED),
+ attr(HREF, null, null, 0, IMPLIED),
+ attr(HREFLANG, null, null, 0, IMPLIED),
+ attr(TYPE, null, null, 0, IMPLIED),
+ attr(REL, null, null, 0, IMPLIED),
+ attr(REV, null, null, 0, IMPLIED),
+ attr(MEDIA, null, null, 0, IMPLIED),
+ attr(TARGET, null, null, 0, IMPLIED)
+ }
+ );
+ defElement(MAP, 0, false, false, null,
+ NONE
+ ,
+ new String[] {
+ ADDRESS, BLOCKQUOTE, CENTER, DIR,
+ DIV, DL, FIELDSET, FORM, H1,
+ H2, H3, H4, H5, H6,
+ HR, ISINDEX, MENU, NOFRAMES, NOSCRIPT,
+ OL, P, PRE, TABLE, UL,
+ AREA
+ }
+ ,
+ new AttributeList[] {
+ attr(sID, null, null, ID, IMPLIED),
+ attr(CLASS, null, null, 0, IMPLIED),
+ attr(STYLE, null, null, 0, IMPLIED),
+ attr(TITLE, null, null, 0, IMPLIED),
+ attr(LANG, null, null, 0, IMPLIED),
+ attr(DIR, null, new String[] { LTR, RTL }, 0, IMPLIED),
+ attr(ONCLICK, null, null, 0, IMPLIED),
+ attr(ONDBLCLICK, null, null, 0, IMPLIED),
+ attr(ONMOUSEDOWN, null, null, 0, IMPLIED),
+ attr(ONMOUSEUP, null, null, 0, IMPLIED),
+ attr(ONMOUSEOVER, null, null, 0, IMPLIED),
+ attr(ONMOUSEMOVE, null, null, 0, IMPLIED),
+ attr(ONMOUSEOUT, null, null, 0, IMPLIED),
+ attr(ONKEYPRESS, null, null, 0, IMPLIED),
+ attr(ONKEYDOWN, null, null, 0, IMPLIED),
+ attr(ONKEYUP, null, null, 0, IMPLIED),
+ attr(sNAME, null, null, 0, REQUIRED)
+ }
+ );
+ defElement(MENU, 0, false, false, createListModel(),
+ new String[] {
+ ADDRESS, BLOCKQUOTE, CENTER, DIR,
+ DIV, DL, FIELDSET, FORM, H1,
+ H2, H3, H4, H5, H6,
+ HR, ISINDEX, MENU, NOFRAMES, NOSCRIPT,
+ OL, P, PRE, TABLE, UL
+ }
+ ,
+ new String[] {
+ LI, UL, OL
+ }
+ ,
+ new AttributeList[] {
+ attr(sID, null, null, ID, IMPLIED),
+ attr(CLASS, null, null, 0, IMPLIED),
+ attr(STYLE, null, null, 0, IMPLIED),
+ attr(TITLE, null, null, 0, IMPLIED),
+ attr(LANG, null, null, 0, IMPLIED),
+ attr(DIR, null, new String[] { LTR, RTL }, 0, IMPLIED),
+ attr(ONCLICK, null, null, 0, IMPLIED),
+ attr(ONDBLCLICK, null, null, 0, IMPLIED),
+ attr(ONMOUSEDOWN, null, null, 0, IMPLIED),
+ attr(ONMOUSEUP, null, null, 0, IMPLIED),
+ attr(ONMOUSEOVER, null, null, 0, IMPLIED),
+ attr(ONMOUSEMOVE, null, null, 0, IMPLIED),
+ attr(ONMOUSEOUT, null, null, 0, IMPLIED),
+ attr(ONKEYPRESS, null, null, 0, IMPLIED),
+ attr(ONKEYDOWN, null, null, 0, IMPLIED),
+ attr(ONKEYUP, null, null, 0, IMPLIED),
+ attr(COMPACT, null, new String[] { COMPACT }, 0, IMPLIED)
+ }
+ );
+ defElement(META, EMPTY, false, true, null,
+ NONE
+ ,
+ NONE
+ ,
+ new AttributeList[] {
+ attr(LANG, null, null, 0, IMPLIED),
+ attr(DIR, null, new String[] { LTR, RTL }, 0, IMPLIED),
+ attr(HTTPEQUIV, null, null, 0, IMPLIED),
+ attr(sNAME, null, null, NAME, IMPLIED),
+ attr(CONTENT, null, null, 0, REQUIRED),
+ attr(SCHEME, null, null, 0, IMPLIED)
+ }
+ );
+ defElement(NOFRAMES, 0, false, false, null,
+ NONE
+ ,
+ new String[] {
+ PCDATA, A, ABBR, ACRONYM,
+ APPLET, B, BASEFONT, BDO, BIG,
+ BR, BUTTON, CITE, CODE, DFN,
+ EM, FONT, I, IFRAME, IMG,
+ INPUT, KBD, LABEL, MAP, OBJECT,
+ Q, S, SAMP, SCRIPT, SELECT,
+ SMALL, SPAN, STRIKE, STRONG, SUB,
+ SUP, TEXTAREA, TT, U, VAR,
+ ADDRESS, BLOCKQUOTE, CENTER, DIR, DIV,
+ DL, FIELDSET, FORM, H1, H2,
+ H3, H4, H5, H6, HR,
+ ISINDEX, MENU, NOFRAMES, NOSCRIPT, OL,
+ P, PRE, TABLE, UL
+ }
+ ,
+ new AttributeList[] {
+ attr(sID, null, null, ID, IMPLIED),
+ attr(CLASS, null, null, 0, IMPLIED),
+ attr(STYLE, null, null, 0, IMPLIED),
+ attr(TITLE, null, null, 0, IMPLIED),
+ attr(LANG, null, null, 0, IMPLIED),
+ attr(DIR, null, new String[] { LTR, RTL }, 0, IMPLIED),
+ attr(ONCLICK, null, null, 0, IMPLIED),
+ attr(ONDBLCLICK, null, null, 0, IMPLIED),
+ attr(ONMOUSEDOWN, null, null, 0, IMPLIED),
+ attr(ONMOUSEUP, null, null, 0, IMPLIED),
+ attr(ONMOUSEOVER, null, null, 0, IMPLIED),
+ attr(ONMOUSEMOVE, null, null, 0, IMPLIED),
+ attr(ONMOUSEOUT, null, null, 0, IMPLIED),
+ attr(ONKEYPRESS, null, null, 0, IMPLIED),
+ attr(ONKEYDOWN, null, null, 0, IMPLIED),
+ attr(ONKEYUP, null, null, 0, IMPLIED)
+ }
+ );
+ defElement(NOSCRIPT, 0, false, false, null,
+ NONE
+ ,
+ new String[] {
+ PCDATA, A, ABBR, ACRONYM,
+ APPLET, B, BASEFONT, BDO, BIG,
+ BR, BUTTON, CITE, CODE, DFN,
+ EM, FONT, I, IFRAME, IMG,
+ INPUT, KBD, LABEL, MAP, OBJECT,
+ Q, S, SAMP, SCRIPT, SELECT,
+ SMALL, SPAN, STRIKE, STRONG, SUB,
+ SUP, TEXTAREA, TT, U, VAR,
+ ADDRESS, BLOCKQUOTE, CENTER, DIR, DIV,
+ DL, FIELDSET, FORM, H1, H2,
+ H3, H4, H5, H6, HR,
+ ISINDEX, MENU, NOFRAMES, NOSCRIPT, OL,
+ P, PRE, TABLE, UL
+ }
+ ,
+ new AttributeList[] {
+ attr(sID, null, null, ID, IMPLIED),
+ attr(CLASS, null, null, 0, IMPLIED),
+ attr(STYLE, null, null, 0, IMPLIED),
+ attr(TITLE, null, null, 0, IMPLIED),
+ attr(LANG, null, null, 0, IMPLIED),
+ attr(DIR, null, new String[] { LTR, RTL }, 0, IMPLIED),
+ attr(ONCLICK, null, null, 0, IMPLIED),
+ attr(ONDBLCLICK, null, null, 0, IMPLIED),
+ attr(ONMOUSEDOWN, null, null, 0, IMPLIED),
+ attr(ONMOUSEUP, null, null, 0, IMPLIED),
+ attr(ONMOUSEOVER, null, null, 0, IMPLIED),
+ attr(ONMOUSEMOVE, null, null, 0, IMPLIED),
+ attr(ONMOUSEOUT, null, null, 0, IMPLIED),
+ attr(ONKEYPRESS, null, null, 0, IMPLIED),
+ attr(ONKEYDOWN, null, null, 0, IMPLIED),
+ attr(ONKEYUP, null, null, 0, IMPLIED)
+ }
+ );
+ defElement(OBJECT, 0, false, false, null,
+ NONE
+ ,
+ new String[] {
+ PCDATA, A, ABBR, ACRONYM,
+ APPLET, B, BASEFONT, BDO, BIG,
+ BR, BUTTON, CITE, CODE, DFN,
+ EM, FONT, I, IFRAME, IMG,
+ INPUT, KBD, LABEL, MAP, OBJECT,
+ Q, S, SAMP, SCRIPT, SELECT,
+ SMALL, SPAN, STRIKE, STRONG, SUB,
+ SUP, TEXTAREA, TT, U, VAR,
+ ADDRESS, BLOCKQUOTE, CENTER, DIR, DIV,
+ DL, FIELDSET, FORM, H1, H2,
+ H3, H4, H5, H6, HR,
+ ISINDEX, MENU, NOFRAMES, NOSCRIPT, OL,
+ P, PRE, TABLE, UL, PARAM
+ }
+ ,
+ new AttributeList[] {
+ attr(sID, null, null, ID, IMPLIED),
+ attr(CLASS, null, null, 0, IMPLIED),
+ attr(STYLE, null, null, 0, IMPLIED),
+ attr(TITLE, null, null, 0, IMPLIED),
+ attr(LANG, null, null, 0, IMPLIED),
+ attr(DIR, null, new String[] { LTR, RTL }, 0, IMPLIED),
+ attr(ONCLICK, null, null, 0, IMPLIED),
+ attr(ONDBLCLICK, null, null, 0, IMPLIED),
+ attr(ONMOUSEDOWN, null, null, 0, IMPLIED),
+ attr(ONMOUSEUP, null, null, 0, IMPLIED),
+ attr(ONMOUSEOVER, null, null, 0, IMPLIED),
+ attr(ONMOUSEMOVE, null, null, 0, IMPLIED),
+ attr(ONMOUSEOUT, null, null, 0, IMPLIED),
+ attr(ONKEYPRESS, null, null, 0, IMPLIED),
+ attr(ONKEYDOWN, null, null, 0, IMPLIED),
+ attr(ONKEYUP, null, null, 0, IMPLIED),
+ attr(DECLARE, null, new String[] { DECLARE }, 0, IMPLIED),
+ attr(CLASSID, null, null, 0, IMPLIED),
+ attr(CODEBASE, null, null, 0, IMPLIED),
+ attr(DATA, null, null, 0, IMPLIED),
+ attr(TYPE, null, null, 0, IMPLIED),
+ attr(CODETYPE, null, null, 0, IMPLIED),
+ attr(ARCHIVE, null, null, 0, IMPLIED),
+ attr(STANDBY, null, null, 0, IMPLIED),
+ attr(HEIGHT, null, null, 0, IMPLIED),
+ attr(WIDTH, null, null, 0, IMPLIED),
+ attr(USEMAP, null, null, 0, IMPLIED),
+ attr(sNAME, null, null, 0, IMPLIED),
+ attr(TABINDEX, null, null, NUMBER, IMPLIED),
+ attr(ALIGN, null, new String[] { TOP, MIDDLE, BOTTOM, LEFT, RIGHT },
+ 0, IMPLIED),
+ attr(BORDER, null, null, PIXELS, IMPLIED),
+ attr(HSPACE, null, null, 0, IMPLIED),
+ attr(VSPACE, null, null, 0, IMPLIED)
+ }
+ );
+ defElement(OL, 0, false, false, createListModel(),
+ NONE
+ ,
+ new String[] {
+ // See note on the createListModel method
+ LI, UL, OL
+ }
+ ,
+ new AttributeList[] {
+ attr(sID, null, null, ID, IMPLIED),
+ attr(CLASS, null, null, 0, IMPLIED),
+ attr(STYLE, null, null, 0, IMPLIED),
+ attr(TITLE, null, null, 0, IMPLIED),
+ attr(LANG, null, null, 0, IMPLIED),
+ attr(DIR, null, new String[] { LTR, RTL }, 0, IMPLIED),
+ attr(ONCLICK, null, null, 0, IMPLIED),
+ attr(ONDBLCLICK, null, null, 0, IMPLIED),
+ attr(ONMOUSEDOWN, null, null, 0, IMPLIED),
+ attr(ONMOUSEUP, null, null, 0, IMPLIED),
+ attr(ONMOUSEOVER, null, null, 0, IMPLIED),
+ attr(ONMOUSEMOVE, null, null, 0, IMPLIED),
+ attr(ONMOUSEOUT, null, null, 0, IMPLIED),
+ attr(ONKEYPRESS, null, null, 0, IMPLIED),
+ attr(ONKEYDOWN, null, null, 0, IMPLIED),
+ attr(ONKEYUP, null, null, 0, IMPLIED),
+ attr(TYPE, null, null, 0, IMPLIED),
+ attr(COMPACT, null, new String[] { COMPACT }, 0, IMPLIED),
+ attr(START, null, null, 0, IMPLIED)
+ }
+ );
+ defElement(OPTGROUP, 0, false, false, null,
+ NONE
+ ,
+ new String[] {
+ OPTION
+ }
+ ,
+ new AttributeList[] {
+ attr(sID, null, null, ID, IMPLIED),
+ attr(CLASS, null, null, 0, IMPLIED),
+ attr(STYLE, null, null, 0, IMPLIED),
+ attr(TITLE, null, null, 0, IMPLIED),
+ attr(LANG, null, null, 0, IMPLIED),
+ attr(DIR, null, new String[] { LTR, RTL }, 0, IMPLIED),
+ attr(ONCLICK, null, null, 0, IMPLIED),
+ attr(ONDBLCLICK, null, null, 0, IMPLIED),
+ attr(ONMOUSEDOWN, null, null, 0, IMPLIED),
+ attr(ONMOUSEUP, null, null, 0, IMPLIED),
+ attr(ONMOUSEOVER, null, null, 0, IMPLIED),
+ attr(ONMOUSEMOVE, null, null, 0, IMPLIED),
+ attr(ONMOUSEOUT, null, null, 0, IMPLIED),
+ attr(ONKEYPRESS, null, null, 0, IMPLIED),
+ attr(ONKEYDOWN, null, null, 0, IMPLIED),
+ attr(ONKEYUP, null, null, 0, IMPLIED),
+ attr(DISABLED, null, new String[] { DISABLED }, 0, IMPLIED),
+ attr(LABEL, null, null, 0, REQUIRED)
+ }
+ );
+ defElement(OPTION, 0, false, true, new ContentModel(0,
+ new PCDATAonly_model(), null),
+ NONE,
+ new String[] {
+ PCDATA
+ }
+ ,
+ new AttributeList[] {
+ attr(sID, null, null, ID, IMPLIED),
+ attr(CLASS, null, null, 0, IMPLIED),
+ attr(STYLE, null, null, 0, IMPLIED),
+ attr(TITLE, null, null, 0, IMPLIED),
+ attr(LANG, null, null, 0, IMPLIED),
+ attr(DIR, null, new String[] { LTR, RTL }, 0, IMPLIED),
+ attr(ONCLICK, null, null, 0, IMPLIED),
+ attr(ONDBLCLICK, null, null, 0, IMPLIED),
+ attr(ONMOUSEDOWN, null, null, 0, IMPLIED),
+ attr(ONMOUSEUP, null, null, 0, IMPLIED),
+ attr(ONMOUSEOVER, null, null, 0, IMPLIED),
+ attr(ONMOUSEMOVE, null, null, 0, IMPLIED),
+ attr(ONMOUSEOUT, null, null, 0, IMPLIED),
+ attr(ONKEYPRESS, null, null, 0, IMPLIED),
+ attr(ONKEYDOWN, null, null, 0, IMPLIED),
+ attr(ONKEYUP, null, null, 0, IMPLIED),
+ attr(SELECTED, null, new String[] { SELECTED }, 0, IMPLIED),
+ attr(DISABLED, null, new String[] { DISABLED }, 0, IMPLIED),
+ attr(LABEL, null, null, 0, IMPLIED),
+ attr(VALUE, null, null, 0, IMPLIED)
+ }
+ );
+ defElement(P, 0, false, true, new ContentModel( 0,
+ new noTagModel(P), null),
+ NONE
+ ,
+ new String[] {
+ PCDATA, A, ABBR, ACRONYM,
+ APPLET, B, BASEFONT, BDO, BIG,
+ BR, BUTTON, CITE, CODE, DFN,
+ EM, FONT, I, IFRAME, IMG,
+ INPUT, KBD, LABEL, MAP, OBJECT,
+ Q, S, SAMP, SCRIPT, SELECT,
+ SMALL, SPAN, STRIKE, STRONG, SUB,
+ SUP, TEXTAREA, TT, U, VAR
+ }
+ ,
+ new AttributeList[] {
+ attr(sID, null, null, ID, IMPLIED),
+ attr(CLASS, null, null, 0, IMPLIED),
+ attr(STYLE, null, null, 0, IMPLIED),
+ attr(TITLE, null, null, 0, IMPLIED),
+ attr(LANG, null, null, 0, IMPLIED),
+ attr(DIR, null, new String[] { LTR, RTL }, 0, IMPLIED),
+ attr(ONCLICK, null, null, 0, IMPLIED),
+ attr(ONDBLCLICK, null, null, 0, IMPLIED),
+ attr(ONMOUSEDOWN, null, null, 0, IMPLIED),
+ attr(ONMOUSEUP, null, null, 0, IMPLIED),
+ attr(ONMOUSEOVER, null, null, 0, IMPLIED),
+ attr(ONMOUSEMOVE, null, null, 0, IMPLIED),
+ attr(ONMOUSEOUT, null, null, 0, IMPLIED),
+ attr(ONKEYPRESS, null, null, 0, IMPLIED),
+ attr(ONKEYDOWN, null, null, 0, IMPLIED),
+ attr(ONKEYUP, null, null, 0, IMPLIED),
+ attr(ALIGN, null, new String[] { LEFT, CENTER, RIGHT, JUSTIFY },
+ 0, IMPLIED)
+ }
+ );
+ defElement(PARAM, EMPTY, false, true, null,
+ NONE
+ ,
+ NONE
+ ,
+ new AttributeList[] {
+ attr(sID, null, null, ID, IMPLIED),
+ attr(sNAME, null, null, 0, REQUIRED),
+ attr(VALUE, null, null, 0, IMPLIED),
+ attr(VALUETYPE, DATA, new String[] { DATA, REF, OBJECT }, 0, DEFAULT),
+ attr(TYPE, null, null, 0, IMPLIED)
+ }
+ );
+ defElement(PRE, 0, false, false, null,
+ new String[] {
+ APPLET, BASEFONT, BIG, FONT,
+ IMG, OBJECT, SMALL, SUB, SUP
+ }
+ ,
+ new String[] {
+ PCDATA, A, ABBR, ACRONYM,
+ B, BDO, BR, BUTTON, CITE,
+ CODE, DFN, EM, I, IFRAME,
+ INPUT, KBD, LABEL, MAP, Q,
+ S, SAMP, SCRIPT, SELECT, SPAN,
+ STRIKE, STRONG, TEXTAREA, TT, U,
+ VAR
+ }
+ ,
+ new AttributeList[] {
+ attr(sID, null, null, ID, IMPLIED),
+ attr(CLASS, null, null, 0, IMPLIED),
+ attr(STYLE, null, null, 0, IMPLIED),
+ attr(TITLE, null, null, 0, IMPLIED),
+ attr(LANG, null, null, 0, IMPLIED),
+ attr(DIR, null, new String[] { LTR, RTL }, 0, IMPLIED),
+ attr(ONCLICK, null, null, 0, IMPLIED),
+ attr(ONDBLCLICK, null, null, 0, IMPLIED),
+ attr(ONMOUSEDOWN, null, null, 0, IMPLIED),
+ attr(ONMOUSEUP, null, null, 0, IMPLIED),
+ attr(ONMOUSEOVER, null, null, 0, IMPLIED),
+ attr(ONMOUSEMOVE, null, null, 0, IMPLIED),
+ attr(ONMOUSEOUT, null, null, 0, IMPLIED),
+ attr(ONKEYPRESS, null, null, 0, IMPLIED),
+ attr(ONKEYDOWN, null, null, 0, IMPLIED),
+ attr(ONKEYUP, null, null, 0, IMPLIED),
+ attr(WIDTH, null, null, NUMBER, IMPLIED)
+ }
+ );
+ defElement(Q, 0, false, false, null,
+ NONE
+ ,
+ new String[] {
+ PCDATA, A, ABBR, ACRONYM,
+ APPLET, B, BASEFONT, BDO, BIG,
+ BR, BUTTON, CITE, CODE, DFN,
+ EM, FONT, I, IFRAME, IMG,
+ INPUT, KBD, LABEL, MAP, OBJECT,
+ Q, S, SAMP, SCRIPT, SELECT,
+ SMALL, SPAN, STRIKE, STRONG, SUB,
+ SUP, TEXTAREA, TT, U, VAR
+ }
+ ,
+ new AttributeList[] {
+ attr(sID, null, null, ID, IMPLIED),
+ attr(CLASS, null, null, 0, IMPLIED),
+ attr(STYLE, null, null, 0, IMPLIED),
+ attr(TITLE, null, null, 0, IMPLIED),
+ attr(LANG, null, null, 0, IMPLIED),
+ attr(DIR, null, new String[] { LTR, RTL }, 0, IMPLIED),
+ attr(ONCLICK, null, null, 0, IMPLIED),
+ attr(ONDBLCLICK, null, null, 0, IMPLIED),
+ attr(ONMOUSEDOWN, null, null, 0, IMPLIED),
+ attr(ONMOUSEUP, null, null, 0, IMPLIED),
+ attr(ONMOUSEOVER, null, null, 0, IMPLIED),
+ attr(ONMOUSEMOVE, null, null, 0, IMPLIED),
+ attr(ONMOUSEOUT, null, null, 0, IMPLIED),
+ attr(ONKEYPRESS, null, null, 0, IMPLIED),
+ attr(ONKEYDOWN, null, null, 0, IMPLIED),
+ attr(ONKEYUP, null, null, 0, IMPLIED),
+ attr(CITE, null, null, 0, IMPLIED)
+ }
+ );
+ defElement(S, 0, false, false, null,
+ NONE
+ ,
+ new String[] {
+ PCDATA, A, ABBR, ACRONYM,
+ APPLET, B, BASEFONT, BDO, BIG,
+ BR, BUTTON, CITE, CODE, DFN,
+ EM, FONT, I, IFRAME, IMG,
+ INPUT, KBD, LABEL, MAP, OBJECT,
+ Q, S, SAMP, SCRIPT, SELECT,
+ SMALL, SPAN, STRIKE, STRONG, SUB,
+ SUP, TEXTAREA, TT, U, VAR
+ }
+ ,
+ new AttributeList[] {
+ attr(sID, null, null, ID, IMPLIED),
+ attr(CLASS, null, null, 0, IMPLIED),
+ attr(STYLE, null, null, 0, IMPLIED),
+ attr(TITLE, null, null, 0, IMPLIED),
+ attr(LANG, null, null, 0, IMPLIED),
+ attr(DIR, null, new String[] { LTR, RTL }, 0, IMPLIED),
+ attr(ONCLICK, null, null, 0, IMPLIED),
+ attr(ONDBLCLICK, null, null, 0, IMPLIED),
+ attr(ONMOUSEDOWN, null, null, 0, IMPLIED),
+ attr(ONMOUSEUP, null, null, 0, IMPLIED),
+ attr(ONMOUSEOVER, null, null, 0, IMPLIED),
+ attr(ONMOUSEMOVE, null, null, 0, IMPLIED),
+ attr(ONMOUSEOUT, null, null, 0, IMPLIED),
+ attr(ONKEYPRESS, null, null, 0, IMPLIED),
+ attr(ONKEYDOWN, null, null, 0, IMPLIED),
+ attr(ONKEYUP, null, null, 0, IMPLIED)
+ }
+ );
+ defElement(SAMP, 0, false, false, null,
+ NONE
+ ,
+ new String[] {
+ PCDATA, A, ABBR, ACRONYM,
+ APPLET, B, BASEFONT, BDO, BIG,
+ BR, BUTTON, CITE, CODE, DFN,
+ EM, FONT, I, IFRAME, IMG,
+ INPUT, KBD, LABEL, MAP, OBJECT,
+ Q, S, SAMP, SCRIPT, SELECT,
+ SMALL, SPAN, STRIKE, STRONG, SUB,
+ SUP, TEXTAREA, TT, U, VAR
+ }
+ ,
+ new AttributeList[] {
+ attr(sID, null, null, ID, IMPLIED),
+ attr(CLASS, null, null, 0, IMPLIED),
+ attr(STYLE, null, null, 0, IMPLIED),
+ attr(TITLE, null, null, 0, IMPLIED),
+ attr(LANG, null, null, 0, IMPLIED),
+ attr(DIR, null, new String[] { LTR, RTL }, 0, IMPLIED),
+ attr(ONCLICK, null, null, 0, IMPLIED),
+ attr(ONDBLCLICK, null, null, 0, IMPLIED),
+ attr(ONMOUSEDOWN, null, null, 0, IMPLIED),
+ attr(ONMOUSEUP, null, null, 0, IMPLIED),
+ attr(ONMOUSEOVER, null, null, 0, IMPLIED),
+ attr(ONMOUSEMOVE, null, null, 0, IMPLIED),
+ attr(ONMOUSEOUT, null, null, 0, IMPLIED),
+ attr(ONKEYPRESS, null, null, 0, IMPLIED),
+ attr(ONKEYDOWN, null, null, 0, IMPLIED),
+ attr(ONKEYUP, null, null, 0, IMPLIED)
+ }
+ );
+ defElement(SCRIPT, CDATA, false, false, null,
+ NONE
+ ,
+ NONE
+ ,
+ new AttributeList[] {
+ attr(CHARSET, null, null, 0, IMPLIED),
+ attr(TYPE, null, null, 0, REQUIRED),
+ attr(LANGUAGE, null, null, 0, IMPLIED),
+ attr(SRC, null, null, 0, IMPLIED),
+ attr(DEFER, null, new String[] { DEFER }, 0, IMPLIED),
+ attr(EVENT, null, null, 0, IMPLIED),
+ attr(FOR, null, null, 0, IMPLIED)
+ }
+ );
+ defElement(SELECT, 0, false, false, null,
+ NONE
+ ,
+ new String[] {
+ OPTGROUP, OPTION
+ }
+ ,
+ new AttributeList[] {
+ attr(sID, null, null, ID, IMPLIED),
+ attr(CLASS, null, null, 0, IMPLIED),
+ attr(STYLE, null, null, 0, IMPLIED),
+ attr(TITLE, null, null, 0, IMPLIED),
+ attr(LANG, null, null, 0, IMPLIED),
+ attr(DIR, null, new String[] { LTR, RTL }, 0, IMPLIED),
+ attr(ONCLICK, null, null, 0, IMPLIED),
+ attr(ONDBLCLICK, null, null, 0, IMPLIED),
+ attr(ONMOUSEDOWN, null, null, 0, IMPLIED),
+ attr(ONMOUSEUP, null, null, 0, IMPLIED),
+ attr(ONMOUSEOVER, null, null, 0, IMPLIED),
+ attr(ONMOUSEMOVE, null, null, 0, IMPLIED),
+ attr(ONMOUSEOUT, null, null, 0, IMPLIED),
+ attr(ONKEYPRESS, null, null, 0, IMPLIED),
+ attr(ONKEYDOWN, null, null, 0, IMPLIED),
+ attr(ONKEYUP, null, null, 0, IMPLIED),
+ attr(sNAME, null, null, 0, IMPLIED),
+ attr(SIZE, null, null, NUMBER, IMPLIED),
+ attr(MULTIPLE, null, new String[] { MULTIPLE }, 0, IMPLIED),
+ attr(DISABLED, null, new String[] { DISABLED }, 0, IMPLIED),
+ attr(TABINDEX, null, null, NUMBER, IMPLIED),
+ attr(ONFOCUS, null, null, 0, IMPLIED),
+ attr(ONBLUR, null, null, 0, IMPLIED),
+ attr(ONCHANGE, null, null, 0, IMPLIED)
+ }
+ );
+ defElement(SMALL, 0, false, false, null,
+ NONE
+ ,
+ new String[] {
+ PCDATA, A, ABBR, ACRONYM,
+ APPLET, B, BASEFONT, BDO, BIG,
+ BR, BUTTON, CITE, CODE, DFN,
+ EM, FONT, I, IFRAME, IMG,
+ INPUT, KBD, LABEL, MAP, OBJECT,
+ Q, S, SAMP, SCRIPT, SELECT,
+ SMALL, SPAN, STRIKE, STRONG, SUB,
+ SUP, TEXTAREA, TT, U, VAR
+ }
+ ,
+ new AttributeList[] {
+ attr(sID, null, null, ID, IMPLIED),
+ attr(CLASS, null, null, 0, IMPLIED),
+ attr(STYLE, null, null, 0, IMPLIED),
+ attr(TITLE, null, null, 0, IMPLIED),
+ attr(LANG, null, null, 0, IMPLIED),
+ attr(DIR, null, new String[] { LTR, RTL }, 0, IMPLIED),
+ attr(ONCLICK, null, null, 0, IMPLIED),
+ attr(ONDBLCLICK, null, null, 0, IMPLIED),
+ attr(ONMOUSEDOWN, null, null, 0, IMPLIED),
+ attr(ONMOUSEUP, null, null, 0, IMPLIED),
+ attr(ONMOUSEOVER, null, null, 0, IMPLIED),
+ attr(ONMOUSEMOVE, null, null, 0, IMPLIED),
+ attr(ONMOUSEOUT, null, null, 0, IMPLIED),
+ attr(ONKEYPRESS, null, null, 0, IMPLIED),
+ attr(ONKEYDOWN, null, null, 0, IMPLIED),
+ attr(ONKEYUP, null, null, 0, IMPLIED)
+ }
+ );
+ defElement(SPAN, 0, false, false, null,
+ NONE
+ ,
+ new String[] {
+ PCDATA, A, ABBR, ACRONYM,
+ APPLET, B, BASEFONT, BDO, BIG,
+ BR, BUTTON, CITE, CODE, DFN,
+ EM, FONT, I, IFRAME, IMG,
+ INPUT, KBD, LABEL, MAP, OBJECT,
+ Q, S, SAMP, SCRIPT, SELECT,
+ SMALL, SPAN, STRIKE, STRONG, SUB,
+ SUP, TEXTAREA, TT, U, VAR
+ }
+ ,
+ new AttributeList[] {
+ attr(sID, null, null, ID, IMPLIED),
+ attr(CLASS, null, null, 0, IMPLIED),
+ attr(STYLE, null, null, 0, IMPLIED),
+ attr(TITLE, null, null, 0, IMPLIED),
+ attr(LANG, null, null, 0, IMPLIED),
+ attr(DIR, null, new String[] { LTR, RTL }, 0, IMPLIED),
+ attr(ONCLICK, null, null, 0, IMPLIED),
+ attr(ONDBLCLICK, null, null, 0, IMPLIED),
+ attr(ONMOUSEDOWN, null, null, 0, IMPLIED),
+ attr(ONMOUSEUP, null, null, 0, IMPLIED),
+ attr(ONMOUSEOVER, null, null, 0, IMPLIED),
+ attr(ONMOUSEMOVE, null, null, 0, IMPLIED),
+ attr(ONMOUSEOUT, null, null, 0, IMPLIED),
+ attr(ONKEYPRESS, null, null, 0, IMPLIED),
+ attr(ONKEYDOWN, null, null, 0, IMPLIED),
+ attr(ONKEYUP, null, null, 0, IMPLIED)
+ }
+ );
+ defElement(STRIKE, 0, false, false, null,
+ NONE
+ ,
+ new String[] {
+ PCDATA, A, ABBR, ACRONYM,
+ APPLET, B, BASEFONT, BDO, BIG,
+ BR, BUTTON, CITE, CODE, DFN,
+ EM, FONT, I, IFRAME, IMG,
+ INPUT, KBD, LABEL, MAP, OBJECT,
+ Q, S, SAMP, SCRIPT, SELECT,
+ SMALL, SPAN, STRIKE, STRONG, SUB,
+ SUP, TEXTAREA, TT, U, VAR
+ }
+ ,
+ new AttributeList[] {
+ attr(sID, null, null, ID, IMPLIED),
+ attr(CLASS, null, null, 0, IMPLIED),
+ attr(STYLE, null, null, 0, IMPLIED),
+ attr(TITLE, null, null, 0, IMPLIED),
+ attr(LANG, null, null, 0, IMPLIED),
+ attr(DIR, null, new String[] { LTR, RTL }, 0, IMPLIED),
+ attr(ONCLICK, null, null, 0, IMPLIED),
+ attr(ONDBLCLICK, null, null, 0, IMPLIED),
+ attr(ONMOUSEDOWN, null, null, 0, IMPLIED),
+ attr(ONMOUSEUP, null, null, 0, IMPLIED),
+ attr(ONMOUSEOVER, null, null, 0, IMPLIED),
+ attr(ONMOUSEMOVE, null, null, 0, IMPLIED),
+ attr(ONMOUSEOUT, null, null, 0, IMPLIED),
+ attr(ONKEYPRESS, null, null, 0, IMPLIED),
+ attr(ONKEYDOWN, null, null, 0, IMPLIED),
+ attr(ONKEYUP, null, null, 0, IMPLIED)
+ }
+ );
+ defElement(STRONG, 0, false, false, null,
+ NONE
+ ,
+ new String[] {
+ PCDATA, A, ABBR, ACRONYM,
+ APPLET, B, BASEFONT, BDO, BIG,
+ BR, BUTTON, CITE, CODE, DFN,
+ EM, FONT, I, IFRAME, IMG,
+ INPUT, KBD, LABEL, MAP, OBJECT,
+ Q, S, SAMP, SCRIPT, SELECT,
+ SMALL, SPAN, STRIKE, STRONG, SUB,
+ SUP, TEXTAREA, TT, U, VAR
+ }
+ ,
+ new AttributeList[] {
+ attr(sID, null, null, ID, IMPLIED),
+ attr(CLASS, null, null, 0, IMPLIED),
+ attr(STYLE, null, null, 0, IMPLIED),
+ attr(TITLE, null, null, 0, IMPLIED),
+ attr(LANG, null, null, 0, IMPLIED),
+ attr(DIR, null, new String[] { LTR, RTL }, 0, IMPLIED),
+ attr(ONCLICK, null, null, 0, IMPLIED),
+ attr(ONDBLCLICK, null, null, 0, IMPLIED),
+ attr(ONMOUSEDOWN, null, null, 0, IMPLIED),
+ attr(ONMOUSEUP, null, null, 0, IMPLIED),
+ attr(ONMOUSEOVER, null, null, 0, IMPLIED),
+ attr(ONMOUSEMOVE, null, null, 0, IMPLIED),
+ attr(ONMOUSEOUT, null, null, 0, IMPLIED),
+ attr(ONKEYPRESS, null, null, 0, IMPLIED),
+ attr(ONKEYDOWN, null, null, 0, IMPLIED),
+ attr(ONKEYUP, null, null, 0, IMPLIED)
+ }
+ );
+ defElement(STYLE, CDATA, false, false, null,
+ NONE
+ ,
+ NONE
+ ,
+ new AttributeList[] {
+ attr(LANG, null, null, 0, IMPLIED),
+ attr(DIR, null, new String[] { LTR, RTL }, 0, IMPLIED),
+ attr(TYPE, null, null, 0, REQUIRED),
+ attr(MEDIA, null, null, 0, IMPLIED),
+ attr(TITLE, null, null, 0, IMPLIED)
+ }
+ );
+ defElement(SUB, 0, false, false, null,
+ NONE
+ ,
+ new String[] {
+ PCDATA, A, ABBR, ACRONYM,
+ APPLET, B, BASEFONT, BDO, BIG,
+ BR, BUTTON, CITE, CODE, DFN,
+ EM, FONT, I, IFRAME, IMG,
+ INPUT, KBD, LABEL, MAP, OBJECT,
+ Q, S, SAMP, SCRIPT, SELECT,
+ SMALL, SPAN, STRIKE, STRONG, SUB,
+ SUP, TEXTAREA, TT, U, VAR
+ }
+ ,
+ new AttributeList[] {
+ attr(sID, null, null, ID, IMPLIED),
+ attr(CLASS, null, null, 0, IMPLIED),
+ attr(STYLE, null, null, 0, IMPLIED),
+ attr(TITLE, null, null, 0, IMPLIED),
+ attr(LANG, null, null, 0, IMPLIED),
+ attr(DIR, null, new String[] { LTR, RTL }, 0, IMPLIED),
+ attr(ONCLICK, null, null, 0, IMPLIED),
+ attr(ONDBLCLICK, null, null, 0, IMPLIED),
+ attr(ONMOUSEDOWN, null, null, 0, IMPLIED),
+ attr(ONMOUSEUP, null, null, 0, IMPLIED),
+ attr(ONMOUSEOVER, null, null, 0, IMPLIED),
+ attr(ONMOUSEMOVE, null, null, 0, IMPLIED),
+ attr(ONMOUSEOUT, null, null, 0, IMPLIED),
+ attr(ONKEYPRESS, null, null, 0, IMPLIED),
+ attr(ONKEYDOWN, null, null, 0, IMPLIED),
+ attr(ONKEYUP, null, null, 0, IMPLIED)
+ }
+ );
+ defElement(SUP, 0, false, false, null,
+ NONE
+ ,
+ new String[] {
+ PCDATA, A, ABBR, ACRONYM,
+ APPLET, B, BASEFONT, BDO, BIG,
+ BR, BUTTON, CITE, CODE, DFN,
+ EM, FONT, I, IFRAME, IMG,
+ INPUT, KBD, LABEL, MAP, OBJECT,
+ Q, S, SAMP, SCRIPT, SELECT,
+ SMALL, SPAN, STRIKE, STRONG, SUB,
+ SUP, TEXTAREA, TT, U, VAR
+ }
+ ,
+ new AttributeList[] {
+ attr(sID, null, null, ID, IMPLIED),
+ attr(CLASS, null, null, 0, IMPLIED),
+ attr(STYLE, null, null, 0, IMPLIED),
+ attr(TITLE, null, null, 0, IMPLIED),
+ attr(LANG, null, null, 0, IMPLIED),
+ attr(DIR, null, new String[] { LTR, RTL }, 0, IMPLIED),
+ attr(ONCLICK, null, null, 0, IMPLIED),
+ attr(ONDBLCLICK, null, null, 0, IMPLIED),
+ attr(ONMOUSEDOWN, null, null, 0, IMPLIED),
+ attr(ONMOUSEUP, null, null, 0, IMPLIED),
+ attr(ONMOUSEOVER, null, null, 0, IMPLIED),
+ attr(ONMOUSEMOVE, null, null, 0, IMPLIED),
+ attr(ONMOUSEOUT, null, null, 0, IMPLIED),
+ attr(ONKEYPRESS, null, null, 0, IMPLIED),
+ attr(ONKEYDOWN, null, null, 0, IMPLIED),
+ attr(ONKEYUP, null, null, 0, IMPLIED)
+ }
+ );
+ defElement(TABLE, 0, false, false, createTableContentModel(),
+ NONE
+ ,
+ new String[] {
+ CAPTION, COL, COLGROUP, TBODY,
+ TFOOT, THEAD
+ }
+ ,
+ new AttributeList[] {
+ attr(sID, null, null, ID, IMPLIED),
+ attr(CLASS, null, null, 0, IMPLIED),
+ attr(STYLE, null, null, 0, IMPLIED),
+ attr(TITLE, null, null, 0, IMPLIED),
+ attr(LANG, null, null, 0, IMPLIED),
+ attr(DIR, null, new String[] { LTR, RTL }, 0, IMPLIED),
+ attr(ONCLICK, null, null, 0, IMPLIED),
+ attr(ONDBLCLICK, null, null, 0, IMPLIED),
+ attr(ONMOUSEDOWN, null, null, 0, IMPLIED),
+ attr(ONMOUSEUP, null, null, 0, IMPLIED),
+ attr(ONMOUSEOVER, null, null, 0, IMPLIED),
+ attr(ONMOUSEMOVE, null, null, 0, IMPLIED),
+ attr(ONMOUSEOUT, null, null, 0, IMPLIED),
+ attr(ONKEYPRESS, null, null, 0, IMPLIED),
+ attr(ONKEYDOWN, null, null, 0, IMPLIED),
+ attr(ONKEYUP, null, null, 0, IMPLIED),
+ attr(SUMMARY, null, null, 0, IMPLIED),
+ attr(WIDTH, null, null, 0, IMPLIED),
+ attr(BORDER, null, null, PIXELS, IMPLIED),
+ attr(FRAME, null, new String[] { VOID, ABOVE, BELOW, HSIDES, LHS, RHS,
+ VSIDES, BOX, BORDER }, 0, IMPLIED),
+ attr(RULES, null, new String[] { NONES, GROUPS, ROWS, COLS, ALL },
+ 0, IMPLIED),
+ attr(CELLSPACING, null, null, 0, IMPLIED),
+ attr(CELLPADDING, null, null, 0, IMPLIED),
+ attr(ALIGN, null, new String[] { LEFT, CENTER, RIGHT }, 0, IMPLIED),
+ attr(BGCOLOR, null, null, 0, IMPLIED),
+ attr(DATAPAGESIZE, null, null, 0, IMPLIED)
+ }
+ );
+ defElement(TBODY, 0, true, true, model(TR,'+'),
+ NONE
+ ,
+ new String[] {
+ TR
+ }
+ ,
+ new AttributeList[] {
+ attr(sID, null, null, ID, IMPLIED),
+ attr(CLASS, null, null, 0, IMPLIED),
+ attr(STYLE, null, null, 0, IMPLIED),
+ attr(TITLE, null, null, 0, IMPLIED),
+ attr(LANG, null, null, 0, IMPLIED),
+ attr(DIR, null, new String[] { LTR, RTL }, 0, IMPLIED),
+ attr(ONCLICK, null, null, 0, IMPLIED),
+ attr(ONDBLCLICK, null, null, 0, IMPLIED),
+ attr(ONMOUSEDOWN, null, null, 0, IMPLIED),
+ attr(ONMOUSEUP, null, null, 0, IMPLIED),
+ attr(ONMOUSEOVER, null, null, 0, IMPLIED),
+ attr(ONMOUSEMOVE, null, null, 0, IMPLIED),
+ attr(ONMOUSEOUT, null, null, 0, IMPLIED),
+ attr(ONKEYPRESS, null, null, 0, IMPLIED),
+ attr(ONKEYDOWN, null, null, 0, IMPLIED),
+ attr(ONKEYUP, null, null, 0, IMPLIED),
+ attr(ALIGN, null, new String[] { LEFT, CENTER, RIGHT, JUSTIFY, CHAR },
+ 0, IMPLIED),
+ attr(CHAR, null, null, 0, IMPLIED),
+ attr(CHAROFF, null, null, 0, IMPLIED),
+ attr(VALIGN, null, new String[] { TOP, MIDDLE, BOTTOM, BASELINE },
+ 0, IMPLIED)
+ }
+ );
+
+ defElement(TD, 0, false, true,
+ new ContentModel(0,
+ new noTagModel(new String[] {"TD", "TH", "TR" } ), null),
+ NONE
+ ,
+ new String[] {
+ PCDATA, A, ABBR, ACRONYM,
+ APPLET, B, BASEFONT, BDO, BIG,
+ BR, BUTTON, CITE, CODE, DFN,
+ EM, FONT, I, IFRAME, IMG,
+ INPUT, KBD, LABEL, MAP, OBJECT,
+ Q, S, SAMP, SCRIPT, SELECT,
+ SMALL, SPAN, STRIKE, STRONG, SUB,
+ SUP, TEXTAREA, TT, U, VAR,
+ ADDRESS, BLOCKQUOTE, CENTER, DIR, DIV,
+ DL, FIELDSET, FORM, H1, H2,
+ H3, H4, H5, H6, HR,
+ ISINDEX, MENU, NOFRAMES, NOSCRIPT, OL,
+ P, PRE, TABLE, UL
+ }
+ ,
+ new AttributeList[] {
+ attr(sID, null, null, ID, IMPLIED),
+ attr(CLASS, null, null, 0, IMPLIED),
+ attr(STYLE, null, null, 0, IMPLIED),
+ attr(TITLE, null, null, 0, IMPLIED),
+ attr(LANG, null, null, 0, IMPLIED),
+ attr(DIR, null, new String[] { LTR, RTL }, 0, IMPLIED),
+ attr(ONCLICK, null, null, 0, IMPLIED),
+ attr(ONDBLCLICK, null, null, 0, IMPLIED),
+ attr(ONMOUSEDOWN, null, null, 0, IMPLIED),
+ attr(ONMOUSEUP, null, null, 0, IMPLIED),
+ attr(ONMOUSEOVER, null, null, 0, IMPLIED),
+ attr(ONMOUSEMOVE, null, null, 0, IMPLIED),
+ attr(ONMOUSEOUT, null, null, 0, IMPLIED),
+ attr(ONKEYPRESS, null, null, 0, IMPLIED),
+ attr(ONKEYDOWN, null, null, 0, IMPLIED),
+ attr(ONKEYUP, null, null, 0, IMPLIED),
+ attr(ABBR, null, null, 0, IMPLIED),
+ attr(AXIS, null, null, 0, IMPLIED),
+ attr(HEADERS, null, null, 0, IMPLIED),
+ attr(SCOPE, null, new String[] { ROW, COL, ROWGROUP, COLGROUP },
+ 0, IMPLIED),
+ attr(ROWSPAN, C_1, null, NUMBER, DEFAULT),
+ attr(COLSPAN, C_1, null, NUMBER, DEFAULT),
+ attr(ALIGN, null, new String[] { LEFT, CENTER, RIGHT, JUSTIFY, CHAR },
+ 0, IMPLIED),
+ attr(CHAR, null, null, 0, IMPLIED),
+ attr(CHAROFF, null, null, 0, IMPLIED),
+ attr(VALIGN, null, new String[] { TOP, MIDDLE, BOTTOM, BASELINE },
+ 0, IMPLIED),
+ attr(NOWRAP, null, new String[] { NOWRAP }, 0, IMPLIED),
+ attr(BGCOLOR, null, null, 0, IMPLIED),
+ attr(WIDTH, null, null, 0, IMPLIED),
+ attr(HEIGHT, null, null, 0, IMPLIED)
+ }
+ );
+ defElement(TEXTAREA, 0, false, false, null,
+ NONE
+ ,
+ new String[] {
+ PCDATA
+ }
+ ,
+ new AttributeList[] {
+ attr(sID, null, null, ID, IMPLIED),
+ attr(CLASS, null, null, 0, IMPLIED),
+ attr(STYLE, null, null, 0, IMPLIED),
+ attr(TITLE, null, null, 0, IMPLIED),
+ attr(LANG, null, null, 0, IMPLIED),
+ attr(DIR, null, new String[] { LTR, RTL }, 0, IMPLIED),
+ attr(ONCLICK, null, null, 0, IMPLIED),
+ attr(ONDBLCLICK, null, null, 0, IMPLIED),
+ attr(ONMOUSEDOWN, null, null, 0, IMPLIED),
+ attr(ONMOUSEUP, null, null, 0, IMPLIED),
+ attr(ONMOUSEOVER, null, null, 0, IMPLIED),
+ attr(ONMOUSEMOVE, null, null, 0, IMPLIED),
+ attr(ONMOUSEOUT, null, null, 0, IMPLIED),
+ attr(ONKEYPRESS, null, null, 0, IMPLIED),
+ attr(ONKEYDOWN, null, null, 0, IMPLIED),
+ attr(ONKEYUP, null, null, 0, IMPLIED),
+ attr(sNAME, null, null, 0, IMPLIED),
+ attr(ROWS, null, null, NUMBER, REQUIRED),
+ attr(COLS, null, null, NUMBER, REQUIRED),
+ attr(DISABLED, null, new String[] { DISABLED }, 0, IMPLIED),
+ attr(READONLY, null, new String[] { READONLY }, 0, IMPLIED),
+ attr(TABINDEX, null, null, NUMBER, IMPLIED),
+ attr(ACCESSKEY, null, null, 0, IMPLIED),
+ attr(ONFOCUS, null, null, 0, IMPLIED),
+ attr(ONBLUR, null, null, 0, IMPLIED),
+ attr(ONSELECT, null, null, 0, IMPLIED),
+ attr(ONCHANGE, null, null, 0, IMPLIED)
+ }
+ );
+ defElement(TFOOT, 0, false, true, model(TR,'+'),
+ NONE
+ ,
+ new String[] {
+ TR
+ }
+ ,
+ new AttributeList[] {
+ attr(sID, null, null, ID, IMPLIED),
+ attr(CLASS, null, null, 0, IMPLIED),
+ attr(STYLE, null, null, 0, IMPLIED),
+ attr(TITLE, null, null, 0, IMPLIED),
+ attr(LANG, null, null, 0, IMPLIED),
+ attr(DIR, null, new String[] { LTR, RTL }, 0, IMPLIED),
+ attr(ONCLICK, null, null, 0, IMPLIED),
+ attr(ONDBLCLICK, null, null, 0, IMPLIED),
+ attr(ONMOUSEDOWN, null, null, 0, IMPLIED),
+ attr(ONMOUSEUP, null, null, 0, IMPLIED),
+ attr(ONMOUSEOVER, null, null, 0, IMPLIED),
+ attr(ONMOUSEMOVE, null, null, 0, IMPLIED),
+ attr(ONMOUSEOUT, null, null, 0, IMPLIED),
+ attr(ONKEYPRESS, null, null, 0, IMPLIED),
+ attr(ONKEYDOWN, null, null, 0, IMPLIED),
+ attr(ONKEYUP, null, null, 0, IMPLIED),
+ attr(ALIGN, null, new String[] { LEFT, CENTER, RIGHT, JUSTIFY, CHAR },
+ 0, IMPLIED),
+ attr(CHAR, null, null, 0, IMPLIED),
+ attr(CHAROFF, null, null, 0, IMPLIED),
+ attr(VALIGN, null, new String[] { TOP, MIDDLE, BOTTOM, BASELINE },
+ 0, IMPLIED)
+ }
+ );
+ defElement(TH, 0, false, true, null,
+ NONE
+ ,
+ new String[] {
+ PCDATA, A, ABBR, ACRONYM,
+ APPLET, B, BASEFONT, BDO, BIG,
+ BR, BUTTON, CITE, CODE, DFN,
+ EM, FONT, I, IFRAME, IMG,
+ INPUT, KBD, LABEL, MAP, OBJECT,
+ Q, S, SAMP, SCRIPT, SELECT,
+ SMALL, SPAN, STRIKE, STRONG, SUB,
+ SUP, TEXTAREA, TT, U, VAR,
+ ADDRESS, BLOCKQUOTE, CENTER, DIR, DIV,
+ DL, FIELDSET, FORM, H1, H2,
+ H3, H4, H5, H6, HR,
+ ISINDEX, MENU, NOFRAMES, NOSCRIPT, OL,
+ P, PRE, TABLE, UL
+ }
+ ,
+ new AttributeList[] {
+ attr(sID, null, null, ID, IMPLIED),
+ attr(CLASS, null, null, 0, IMPLIED),
+ attr(STYLE, null, null, 0, IMPLIED),
+ attr(TITLE, null, null, 0, IMPLIED),
+ attr(LANG, null, null, 0, IMPLIED),
+ attr(DIR, null, new String[] { LTR, RTL }, 0, IMPLIED),
+ attr(ONCLICK, null, null, 0, IMPLIED),
+ attr(ONDBLCLICK, null, null, 0, IMPLIED),
+ attr(ONMOUSEDOWN, null, null, 0, IMPLIED),
+ attr(ONMOUSEUP, null, null, 0, IMPLIED),
+ attr(ONMOUSEOVER, null, null, 0, IMPLIED),
+ attr(ONMOUSEMOVE, null, null, 0, IMPLIED),
+ attr(ONMOUSEOUT, null, null, 0, IMPLIED),
+ attr(ONKEYPRESS, null, null, 0, IMPLIED),
+ attr(ONKEYDOWN, null, null, 0, IMPLIED),
+ attr(ONKEYUP, null, null, 0, IMPLIED),
+ attr(ABBR, null, null, 0, IMPLIED),
+ attr(AXIS, null, null, 0, IMPLIED),
+ attr(HEADERS, null, null, 0, IMPLIED),
+ attr(SCOPE, null, new String[] { ROW, COL, ROWGROUP, COLGROUP },
+ 0, IMPLIED),
+ attr(ROWSPAN, C_1, null, NUMBER, DEFAULT),
+ attr(COLSPAN, C_1, null, NUMBER, DEFAULT),
+ attr(ALIGN, null, new String[] { LEFT, CENTER, RIGHT, JUSTIFY, CHAR },
+ 0, IMPLIED),
+ attr(CHAR, null, null, 0, IMPLIED),
+ attr(CHAROFF, null, null, 0, IMPLIED),
+ attr(VALIGN, null, new String[] { TOP, MIDDLE, BOTTOM, BASELINE },
+ 0, IMPLIED),
+ attr(NOWRAP, null, new String[] { NOWRAP }, 0, IMPLIED),
+ attr(BGCOLOR, null, null, 0, IMPLIED),
+ attr(WIDTH, null, null, 0, IMPLIED),
+ attr(HEIGHT, null, null, 0, IMPLIED)
+ }
+ );
+ defElement(THEAD, 0, false, true, model(TR,'+'),
+ NONE
+ ,
+ new String[] {
+ TR
+ }
+ ,
+ new AttributeList[] {
+ attr(sID, null, null, ID, IMPLIED),
+ attr(CLASS, null, null, 0, IMPLIED),
+ attr(STYLE, null, null, 0, IMPLIED),
+ attr(TITLE, null, null, 0, IMPLIED),
+ attr(LANG, null, null, 0, IMPLIED),
+ attr(DIR, null, new String[] { LTR, RTL }, 0, IMPLIED),
+ attr(ONCLICK, null, null, 0, IMPLIED),
+ attr(ONDBLCLICK, null, null, 0, IMPLIED),
+ attr(ONMOUSEDOWN, null, null, 0, IMPLIED),
+ attr(ONMOUSEUP, null, null, 0, IMPLIED),
+ attr(ONMOUSEOVER, null, null, 0, IMPLIED),
+ attr(ONMOUSEMOVE, null, null, 0, IMPLIED),
+ attr(ONMOUSEOUT, null, null, 0, IMPLIED),
+ attr(ONKEYPRESS, null, null, 0, IMPLIED),
+ attr(ONKEYDOWN, null, null, 0, IMPLIED),
+ attr(ONKEYUP, null, null, 0, IMPLIED),
+ attr(ALIGN, null, new String[] { LEFT, CENTER, RIGHT, JUSTIFY, CHAR },
+ 0, IMPLIED),
+ attr(CHAR, null, null, 0, IMPLIED),
+ attr(CHAROFF, null, null, 0, IMPLIED),
+ attr(VALIGN, null, new String[] { TOP, MIDDLE, BOTTOM, BASELINE },
+ 0, IMPLIED)
+ }
+ );
+ defElement(TITLE, 0, false, false, null,
+ new String[] {
+ OBJECT, SCRIPT, LINK, META,
+ STYLE
+ }
+ ,
+ new String[] {
+ PCDATA
+ }
+ ,
+ new AttributeList[] {
+ attr(LANG, null, null, 0, IMPLIED),
+ attr(DIR, null, new String[] { LTR, RTL }, 0, IMPLIED)
+ }
+ );
+ defElement(TR, 0, false, true,
+ new ContentModel(0, new TableRowContentModel(this), null),
+ NONE
+ ,
+ new String[] {
+ TD, TH
+ }
+ ,
+ new AttributeList[] {
+ attr(sID, null, null, ID, IMPLIED),
+ attr(CLASS, null, null, 0, IMPLIED),
+ attr(STYLE, null, null, 0, IMPLIED),
+ attr(TITLE, null, null, 0, IMPLIED),
+ attr(LANG, null, null, 0, IMPLIED),
+ attr(DIR, null, new String[] { LTR, RTL }, 0, IMPLIED),
+ attr(ONCLICK, null, null, 0, IMPLIED),
+ attr(ONDBLCLICK, null, null, 0, IMPLIED),
+ attr(ONMOUSEDOWN, null, null, 0, IMPLIED),
+ attr(ONMOUSEUP, null, null, 0, IMPLIED),
+ attr(ONMOUSEOVER, null, null, 0, IMPLIED),
+ attr(ONMOUSEMOVE, null, null, 0, IMPLIED),
+ attr(ONMOUSEOUT, null, null, 0, IMPLIED),
+ attr(ONKEYPRESS, null, null, 0, IMPLIED),
+ attr(ONKEYDOWN, null, null, 0, IMPLIED),
+ attr(ONKEYUP, null, null, 0, IMPLIED),
+ attr(ALIGN, null, new String[] { LEFT, CENTER, RIGHT, JUSTIFY, CHAR },
+ 0, IMPLIED),
+ attr(CHAR, null, null, 0, IMPLIED),
+ attr(CHAROFF, null, null, 0, IMPLIED),
+ attr(VALIGN, null, new String[] { TOP, MIDDLE, BOTTOM, BASELINE },
+ 0, IMPLIED),
+ attr(BGCOLOR, null, null, 0, IMPLIED)
+ }
+ );
+ defElement(TT, 0, false, false, null,
+ NONE
+ ,
+ new String[] {
+ PCDATA, A, ABBR, ACRONYM,
+ APPLET, B, BASEFONT, BDO, BIG,
+ BR, BUTTON, CITE, CODE, DFN,
+ EM, FONT, I, IFRAME, IMG,
+ INPUT, KBD, LABEL, MAP, OBJECT,
+ Q, S, SAMP, SCRIPT, SELECT,
+ SMALL, SPAN, STRIKE, STRONG, SUB,
+ SUP, TEXTAREA, TT, U, VAR
+ }
+ ,
+ new AttributeList[] {
+ attr(sID, null, null, ID, IMPLIED),
+ attr(CLASS, null, null, 0, IMPLIED),
+ attr(STYLE, null, null, 0, IMPLIED),
+ attr(TITLE, null, null, 0, IMPLIED),
+ attr(LANG, null, null, 0, IMPLIED),
+ attr(DIR, null, new String[] { LTR, RTL }, 0, IMPLIED),
+ attr(ONCLICK, null, null, 0, IMPLIED),
+ attr(ONDBLCLICK, null, null, 0, IMPLIED),
+ attr(ONMOUSEDOWN, null, null, 0, IMPLIED),
+ attr(ONMOUSEUP, null, null, 0, IMPLIED),
+ attr(ONMOUSEOVER, null, null, 0, IMPLIED),
+ attr(ONMOUSEMOVE, null, null, 0, IMPLIED),
+ attr(ONMOUSEOUT, null, null, 0, IMPLIED),
+ attr(ONKEYPRESS, null, null, 0, IMPLIED),
+ attr(ONKEYDOWN, null, null, 0, IMPLIED),
+ attr(ONKEYUP, null, null, 0, IMPLIED)
+ }
+ );
+ defElement(U, 0, false, false, null,
+ NONE
+ ,
+ new String[] {
+ PCDATA, A, ABBR, ACRONYM,
+ APPLET, B, BASEFONT, BDO, BIG,
+ BR, BUTTON, CITE, CODE, DFN,
+ EM, FONT, I, IFRAME, IMG,
+ INPUT, KBD, LABEL, MAP, OBJECT,
+ Q, S, SAMP, SCRIPT, SELECT,
+ SMALL, SPAN, STRIKE, STRONG, SUB,
+ SUP, TEXTAREA, TT, U, VAR
+ }
+ ,
+ new AttributeList[] {
+ attr(sID, null, null, ID, IMPLIED),
+ attr(CLASS, null, null, 0, IMPLIED),
+ attr(STYLE, null, null, 0, IMPLIED),
+ attr(TITLE, null, null, 0, IMPLIED),
+ attr(LANG, null, null, 0, IMPLIED),
+ attr(DIR, null, new String[] { LTR, RTL }, 0, IMPLIED),
+ attr(ONCLICK, null, null, 0, IMPLIED),
+ attr(ONDBLCLICK, null, null, 0, IMPLIED),
+ attr(ONMOUSEDOWN, null, null, 0, IMPLIED),
+ attr(ONMOUSEUP, null, null, 0, IMPLIED),
+ attr(ONMOUSEOVER, null, null, 0, IMPLIED),
+ attr(ONMOUSEMOVE, null, null, 0, IMPLIED),
+ attr(ONMOUSEOUT, null, null, 0, IMPLIED),
+ attr(ONKEYPRESS, null, null, 0, IMPLIED),
+ attr(ONKEYDOWN, null, null, 0, IMPLIED),
+ attr(ONKEYUP, null, null, 0, IMPLIED)
+ }
+ );
+ defElement(UL, 0, false, false, createListModel(),
+ NONE
+ ,
+ new String[] {
+ // See note on the createListModel method
+ LI, UL, OL
+ }
+ ,
+ new AttributeList[] {
+ attr(sID, null, null, ID, IMPLIED),
+ attr(CLASS, null, null, 0, IMPLIED),
+ attr(STYLE, null, null, 0, IMPLIED),
+ attr(TITLE, null, null, 0, IMPLIED),
+ attr(LANG, null, null, 0, IMPLIED),
+ attr(DIR, null, new String[] { LTR, RTL }, 0, IMPLIED),
+ attr(ONCLICK, null, null, 0, IMPLIED),
+ attr(ONDBLCLICK, null, null, 0, IMPLIED),
+ attr(ONMOUSEDOWN, null, null, 0, IMPLIED),
+ attr(ONMOUSEUP, null, null, 0, IMPLIED),
+ attr(ONMOUSEOVER, null, null, 0, IMPLIED),
+ attr(ONMOUSEMOVE, null, null, 0, IMPLIED),
+ attr(ONMOUSEOUT, null, null, 0, IMPLIED),
+ attr(ONKEYPRESS, null, null, 0, IMPLIED),
+ attr(ONKEYDOWN, null, null, 0, IMPLIED),
+ attr(ONKEYUP, null, null, 0, IMPLIED),
+ attr(TYPE, null, new String[] { DISC, SQUARE, CIRCLE }, 0, IMPLIED),
+ attr(COMPACT, null, new String[] { COMPACT }, 0, IMPLIED)
+ }
+ );
+ defElement(VAR, 0, false, false, null,
+ NONE
+ ,
+ new String[] {
+ PCDATA, A, ABBR, ACRONYM,
+ APPLET, B, BASEFONT, BDO, BIG,
+ BR, BUTTON, CITE, CODE, DFN,
+ EM, FONT, I, IFRAME, IMG,
+ INPUT, KBD, LABEL, MAP, OBJECT,
+ Q, S, SAMP, SCRIPT, SELECT,
+ SMALL, SPAN, STRIKE, STRONG, SUB,
+ SUP, TEXTAREA, TT, U, VAR
+ }
+ ,
+ new AttributeList[] {
+ attr(sID, null, null, ID, IMPLIED),
+ attr(CLASS, null, null, 0, IMPLIED),
+ attr(STYLE, null, null, 0, IMPLIED),
+ attr(TITLE, null, null, 0, IMPLIED),
+ attr(LANG, null, null, 0, IMPLIED),
+ attr(DIR, null, new String[] { LTR, RTL }, 0, IMPLIED),
+ attr(ONCLICK, null, null, 0, IMPLIED),
+ attr(ONDBLCLICK, null, null, 0, IMPLIED),
+ attr(ONMOUSEDOWN, null, null, 0, IMPLIED),
+ attr(ONMOUSEUP, null, null, 0, IMPLIED),
+ attr(ONMOUSEOVER, null, null, 0, IMPLIED),
+ attr(ONMOUSEMOVE, null, null, 0, IMPLIED),
+ attr(ONMOUSEOUT, null, null, 0, IMPLIED),
+ attr(ONKEYPRESS, null, null, 0, IMPLIED),
+ attr(ONKEYDOWN, null, null, 0, IMPLIED),
+ attr(ONKEYUP, null, null, 0, IMPLIED)
+ }
+ );
+
+ }
+
+ /**
+ * Define all entities in this DTD.
+ */
+ protected void defineEntities()
+ {
+ /* Define general entities */
+ defineEntity("AElig", 198);
+ defineEntity("Aacute", 193);
+ defineEntity("Acirc", 194);
+ defineEntity("Agrave", 192);
+ defineEntity("Alpha", 913);
+ defineEntity("Aring", 197);
+ defineEntity("Atilde", 195);
+ defineEntity("Auml", 196);
+ defineEntity("Beta", 914);
+ defineEntity("Ccedil", 199);
+ defineEntity("Chi", 935);
+ defineEntity("Dagger", 8225);
+ defineEntity("Delta", 916);
+ defineEntity("ETH", 208);
+ defineEntity("Eacute", 201);
+ defineEntity("Ecirc", 202);
+ defineEntity("Egrave", 200);
+ defineEntity("Epsilon", 917);
+ defineEntity("Eta", 919);
+ defineEntity("Euml", 203);
+ defineEntity("Gamma", 915);
+ defineEntity("Iacute", 205);
+ defineEntity("Icirc", 206);
+ defineEntity("Igrave", 204);
+ defineEntity("Iota", 921);
+ defineEntity("Iuml", 207);
+ defineEntity("Kappa", 922);
+ defineEntity("Lambda", 923);
+ defineEntity("Mu", 924);
+ defineEntity("Ntilde", 209);
+ defineEntity("Nu", 925);
+ defineEntity("OElig", 338);
+ defineEntity("Oacute", 211);
+ defineEntity("Ocirc", 212);
+ defineEntity("Ograve", 210);
+ defineEntity("Omega", 937);
+ defineEntity("Omicron", 927);
+ defineEntity("Oslash", 216);
+ defineEntity("Otilde", 213);
+ defineEntity("Ouml", 214);
+ defineEntity("Phi", 934);
+ defineEntity("Pi", 928);
+ defineEntity("Prime", 8243);
+ defineEntity("Psi", 936);
+ defineEntity("Rho", 929);
+ defineEntity("Scaron", 352);
+ defineEntity("Sigma", 931);
+ defineEntity("THORN", 222);
+ defineEntity("Tau", 932);
+ defineEntity("Theta", 920);
+ defineEntity("Uacute", 218);
+ defineEntity("Ucirc", 219);
+ defineEntity("Ugrave", 217);
+ defineEntity("Upsilon", 933);
+ defineEntity("Uuml", 220);
+ defineEntity("Xi", 926);
+ defineEntity("Yacute", 221);
+ defineEntity("Yuml", 376);
+ defineEntity("Zeta", 918);
+ defineEntity("aacute", 225);
+ defineEntity("acirc", 226);
+ defineEntity("acute", 180);
+ defineEntity("aelig", 230);
+ defineEntity("agrave", 224);
+ defineEntity("alefsym", 8501);
+ defineEntity("alpha", 945);
+ defineEntity("amp", 38);
+ defineEntity("and", 8743);
+ defineEntity("ang", 8736);
+ defineEntity("aring", 229);
+ defineEntity("asymp", 8776);
+ defineEntity("atilde", 227);
+ defineEntity("auml", 228);
+ defineEntity("bdquo", 8222);
+ defineEntity("beta", 946);
+ defineEntity("brvbar", 166);
+ defineEntity("bull", 8226);
+ defineEntity("cap", 8745);
+ defineEntity("ccedil", 231);
+ defineEntity("cedil", 184);
+ defineEntity("cent", 162);
+ defineEntity("chi", 967);
+ defineEntity("circ", 710);
+ defineEntity("clubs", 9827);
+ defineEntity("cong", 8773);
+ defineEntity("copy", 169);
+ defineEntity("crarr", 8629);
+ defineEntity("cup", 8746);
+ defineEntity("curren", 164);
+ defineEntity("dArr", 8659);
+ defineEntity("dagger", 8224);
+ defineEntity("darr", 8595);
+ defineEntity("deg", 176);
+ defineEntity("delta", 948);
+ defineEntity("diams", 9830);
+ defineEntity("divide", 247);
+ defineEntity("eacute", 233);
+ defineEntity("ecirc", 234);
+ defineEntity("egrave", 232);
+ defineEntity("empty", 8709);
+ defineEntity("emsp", 8195);
+ defineEntity("ensp", 8194);
+ defineEntity("epsilon", 949);
+ defineEntity("equiv", 8801);
+ defineEntity("eta", 951);
+ defineEntity("eth", 240);
+ defineEntity("euml", 235);
+ defineEntity("euro", 8364);
+ defineEntity("exist", 8707);
+ defineEntity("fnof", 402);
+ defineEntity("forall", 8704);
+ defineEntity("frac12", 189);
+ defineEntity("frac14", 188);
+ defineEntity("frac34", 190);
+ defineEntity("frasl", 8260);
+ defineEntity("gamma", 947);
+ defineEntity("ge", 8805);
+ defineEntity("gt", 62);
+ defineEntity("hArr", 8660);
+ defineEntity("harr", 8596);
+ defineEntity("hearts", 9829);
+ defineEntity("hellip", 8230);
+ defineEntity("iacute", 237);
+ defineEntity("icirc", 238);
+ defineEntity("iexcl", 161);
+ defineEntity("igrave", 236);
+ defineEntity("image", 8465);
+ defineEntity("infin", 8734);
+ defineEntity("int", 8747);
+ defineEntity("iota", 953);
+ defineEntity("iquest", 191);
+ defineEntity("isin", 8712);
+ defineEntity("iuml", 239);
+ defineEntity("kappa", 954);
+ defineEntity("lArr", 8656);
+ defineEntity("lambda", 955);
+ defineEntity("lang", 9001);
+ defineEntity("laquo", 171);
+ defineEntity("larr", 8592);
+ defineEntity("lceil", 8968);
+ defineEntity("ldquo", 8220);
+ defineEntity("le", 8804);
+ defineEntity("lfloor", 8970);
+ defineEntity("lowast", 8727);
+ defineEntity("loz", 9674);
+ defineEntity("lrm", 8206);
+ defineEntity("lsaquo", 8249);
+ defineEntity("lsquo", 8216);
+ defineEntity("lt", 60);
+ defineEntity("macr", 175);
+ defineEntity("mdash", 8212);
+ defineEntity("micro", 181);
+ defineEntity("middot", 183);
+ defineEntity("minus", 8722);
+ defineEntity("mu", 956);
+ defineEntity("nabla", 8711);
+ defineEntity("nbsp", 160);
+ defineEntity("ndash", 8211);
+ defineEntity("ne", 8800);
+ defineEntity("ni", 8715);
+ defineEntity("not", 172);
+ defineEntity("notin", 8713);
+ defineEntity("nsub", 8836);
+ defineEntity("ntilde", 241);
+ defineEntity("nu", 957);
+ defineEntity("oacute", 243);
+ defineEntity("ocirc", 244);
+ defineEntity("oelig", 339);
+ defineEntity("ograve", 242);
+ defineEntity("oline", 8254);
+ defineEntity("omega", 969);
+ defineEntity("omicron", 959);
+ defineEntity("oplus", 8853);
+ defineEntity("or", 8744);
+ defineEntity("ordf", 170);
+ defineEntity("ordm", 186);
+ defineEntity("oslash", 248);
+ defineEntity("otilde", 245);
+ defineEntity("otimes", 8855);
+ defineEntity("ouml", 246);
+ defineEntity("para", 182);
+ defineEntity("part", 8706);
+ defineEntity("permil", 8240);
+ defineEntity("perp", 8869);
+ defineEntity("phi", 966);
+ defineEntity("pi", 960);
+ defineEntity("piv", 982);
+ defineEntity("plusmn", 177);
+ defineEntity("pound", 163);
+ defineEntity("prime", 8242);
+ defineEntity("prod", 8719);
+ defineEntity("prop", 8733);
+ defineEntity("psi", 968);
+ defineEntity("quot", 34);
+ defineEntity("rArr", 8658);
+ defineEntity("radic", 8730);
+ defineEntity("rang", 9002);
+ defineEntity("raquo", 187);
+ defineEntity("rarr", 8594);
+ defineEntity("rceil", 8969);
+ defineEntity("rdquo", 8221);
+ defineEntity("real", 8476);
+ defineEntity("reg", 174);
+ defineEntity("rfloor", 8971);
+ defineEntity("rho", 961);
+ defineEntity("rlm", 8207);
+ defineEntity("rsaquo", 8250);
+ defineEntity("rsquo", 8217);
+ defineEntity("sbquo", 8218);
+ defineEntity("scaron", 353);
+ defineEntity("sdot", 8901);
+ defineEntity("sect", 167);
+ defineEntity("shy", 173);
+ defineEntity("sigma", 963);
+ defineEntity("sigmaf", 962);
+ defineEntity("sim", 8764);
+ defineEntity("spades", 9824);
+ defineEntity("sub", 8834);
+ defineEntity("sube", 8838);
+ defineEntity("sum", 8721);
+ defineEntity("sup", 8835);
+ defineEntity("sup1", 185);
+ defineEntity("sup2", 178);
+ defineEntity("sup3", 179);
+ defineEntity("supe", 8839);
+ defineEntity("szlig", 223);
+ defineEntity("tau", 964);
+ defineEntity("there4", 8756);
+ defineEntity("theta", 952);
+ defineEntity("thetasym", 977);
+ defineEntity("thinsp", 8201);
+ defineEntity("thorn", 254);
+ defineEntity("tilde", 732);
+ defineEntity("times", 215);
+ defineEntity("trade", 8482);
+ defineEntity("uArr", 8657);
+ defineEntity("uacute", 250);
+ defineEntity("uarr", 8593);
+ defineEntity("ucirc", 251);
+ defineEntity("ugrave", 249);
+ defineEntity("uml", 168);
+ defineEntity("upsih", 978);
+ defineEntity("upsilon", 965);
+ defineEntity("uuml", 252);
+ defineEntity("weierp", 8472);
+ defineEntity("xi", 958);
+ defineEntity("yacute", 253);
+ defineEntity("yen", 165);
+ defineEntity("yuml", 255);
+ defineEntity("zeta", 950);
+ defineEntity("zwj", 8205);
+ defineEntity("zwnj", 8204);
+ }
+
+ /**
+ * Crate a content model, consisting of the single
+ * element, specified by name.
+ */
+ protected ContentModel model(String element)
+ {
+ return new ContentModel(getElement(element));
+ }
+
+ /**
+ * Crate a chain from the two content models,
+ * the last containing the given element and
+ * the specified unary operation.
+ */
+ private ContentModel model(String element, int unary)
+ {
+ ContentModel ct = model(element);
+ ct.type = unary;
+ return new ContentModel(0, ct);
+ }
+
+ /**
+ * Create the model HEAD, BODY
+ * @return the HTML content model of the whole document
+ */
+ protected ContentModel createHtmlContentModel()
+ {
+ ContentModel head = model(HEAD);
+ ContentModel body = model(BODY);
+ head.next = body;
+ head.type = ',';
+ return head;
+ }
+
+ /**
+ * Create the model
+ * ( CAPTION ? , ( COL * | COLGROUP * ) , THEAD ? , TFOOT ? , TBODY + )
+ */
+ protected ContentModel createTableContentModel()
+ {
+ ContentModel col_colgroup = new ContentModel
+ ('|', model(COL,'*'), model(COLGROUP,'*') );
+
+ col_colgroup = new ContentModel('*', col_colgroup);
+ col_colgroup = new ContentModel(',', col_colgroup);
+
+ ContentModel caption = model(CAPTION,'?');
+ ContentModel thead = model(THEAD, '?');
+ ContentModel tfoot = model(TFOOT, '?');
+ ContentModel tbody = model(TBODY, '+');
+
+ caption.next = col_colgroup;
+ col_colgroup.next = thead;
+ thead.next = tfoot;
+ tfoot.next = tbody;
+
+ caption.type = col_colgroup.type = thead.type = tfoot.type =
+ tbody.type = ',';
+
+ return caption;
+ }
+
+ /**
+ * Creates a model for <DL> tag:
+ * <code> DT+ | DL+ </code>.
+ * @return
+ */
+ protected ContentModel createDefListModel()
+ {
+ ContentModel dt = model(DT, '+');
+ ContentModel dd = model(DD, '+');
+
+ dt.next = dd;
+ dt.type = dd.type = '|';
+ return dt;
+ }
+
+ /**
+ * This model is used for UL, OL, MENU and DIR.
+ * HTML 4.01 specifies LI only, but the nested
+ * list seems rendered correctly only if
+ * it is not enclosed into <LI>-</LI> of the
+ * parent list.
+ */
+ protected ContentModel createListModel()
+ {
+ ContentModel li = model(LI, '+');
+ ContentModel ul = model(UL, '+');
+ ContentModel ol = model(OL, '+');
+
+ li.next = ul;
+ ul.next = ol;
+ li.type = ul.type = ol.type = '|';
+ return li;
+ }
+
+ /**
+ * Get elements that are allowed in the document body, at the zero level.
+ */
+ protected String[] getBodyElements()
+ {
+ return new String[] {
+ PCDATA, A, ABBR, ACRONYM,
+ APPLET, B, BASEFONT, BDO, BIG,
+ BR, BUTTON, CITE, CODE, DFN,
+ EM, FONT, I, IFRAME, IMG,
+ INPUT, KBD, LABEL, MAP, OBJECT,
+ Q, S, SAMP, SCRIPT, SELECT,
+ SMALL, SPAN, STRIKE, STRONG, SUB,
+ SUP, TEXTAREA, TT, U, VAR,
+ ADDRESS, BLOCKQUOTE, CENTER, DEL, DIR,
+ DIV, DL, FIELDSET, FORM, H1,
+ H2, H3, H4, H5, H6,
+ HR, INS, ISINDEX, MENU, NOFRAMES,
+ NOSCRIPT, OL, P, PRE, TABLE,
+ UL
+ };
+ }
+}
Added: llvm-gcc-4.2/trunk/libjava/classpath/gnu/javax/swing/text/html/parser/HTML_401Swing.java
URL: http://llvm.org/viewvc/llvm-project/llvm-gcc-4.2/trunk/libjava/classpath/gnu/javax/swing/text/html/parser/HTML_401Swing.java?rev=43913&view=auto
==============================================================================
--- llvm-gcc-4.2/trunk/libjava/classpath/gnu/javax/swing/text/html/parser/HTML_401Swing.java (added)
+++ llvm-gcc-4.2/trunk/libjava/classpath/gnu/javax/swing/text/html/parser/HTML_401Swing.java Thu Nov 8 16:56:19 2007
@@ -0,0 +1,91 @@
+/* HTML_401Swing.java -- The HTML 4.01 DTD, adapted for HTML rendering in Swing
+ Copyright (C) 2006 Free Software Foundation, Inc.
+
+This file is part of GNU Classpath.
+
+GNU Classpath is free software; you can redistribute it and/or modify
+it under the terms of the GNU General Public License as published by
+the Free Software Foundation; either version 2, or (at your option)
+any later version.
+
+GNU Classpath is distributed in the hope that it will be useful, but
+WITHOUT ANY WARRANTY; without even the implied warranty of
+MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+General Public License for more details.
+
+You should have received a copy of the GNU General Public License
+along with GNU Classpath; see the file COPYING. If not, write to the
+Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA
+02110-1301 USA.
+
+Linking this library statically or dynamically with other modules is
+making a combined work based on this library. Thus, the terms and
+conditions of the GNU General Public License cover the whole
+combination.
+
+As a special exception, the copyright holders of this library give you
+permission to link this library with independent modules to produce an
+executable, regardless of the license terms of these independent
+modules, and to copy and distribute the resulting executable under
+terms of your choice, provided that you also meet, for each linked
+independent module, the terms and conditions of the license of that
+module. An independent module is a module which is not derived from
+or based on this library. If you modify this library, you may extend
+this exception to your version of the library, but you are not
+obligated to do so. If you do not wish to do so, delete this
+exception statement from your version. */
+
+
+package gnu.javax.swing.text.html.parser;
+
+import javax.swing.text.html.parser.DTD;
+
+/**
+ * This class is necessary because the current implementation of the GNU
+ * Classpath Swing requires always enclose the text into paragraphs.
+ *
+ * @author Audrius Meskauskas (AudriusA at Bioinformatics.org)
+ */
+public class HTML_401Swing extends HTML_401F
+{
+ /**
+ * The singleton instance;
+ */
+ final static HTML_401Swing singleton = new HTML_401Swing();
+
+ /**
+ * Either takes the document (by name) from DTD table, or
+ * creates a new instance and registers it in the tabe.
+ * The document is registerd under name "-//W3C//DTD HTML 4.01 Frameset//EN".
+ * @return The new or existing DTD for parsing HTML 4.01 Frameset.
+ */
+ public static DTD getInstance()
+ {
+ return singleton;
+ }
+
+ /**
+ * Get elements that are allowed in the document body, at the zero level.
+ * This list disallows the text at this level (the implied P tag will be
+ * generated). It also disallows A, B, I, U, CITE and other similar
+ * elements that have the plain text inside. They will also be placed
+ * inside the generated implied P tags.
+ */
+ protected String[] getBodyElements()
+ {
+ return new String[] {
+ APPLET, BASEFONT,
+ BR, BUTTON,
+ IFRAME, IMG,
+ INPUT, LABEL, MAP, OBJECT,
+ SCRIPT, SELECT,
+ TEXTAREA,
+ BLOCKQUOTE, CENTER, DEL, DIR,
+ DIV, DL, FIELDSET, FORM, H1,
+ H2, H3, H4, H5, H6,
+ HR, INS, ISINDEX, MENU, NOFRAMES,
+ NOSCRIPT, OL, P, PRE, TABLE,
+ UL
+ };
+ }
+}
Added: llvm-gcc-4.2/trunk/libjava/classpath/gnu/javax/swing/text/html/parser/SmallHtmlAttributeSet.java
URL: http://llvm.org/viewvc/llvm-project/llvm-gcc-4.2/trunk/libjava/classpath/gnu/javax/swing/text/html/parser/SmallHtmlAttributeSet.java?rev=43913&view=auto
==============================================================================
--- llvm-gcc-4.2/trunk/libjava/classpath/gnu/javax/swing/text/html/parser/SmallHtmlAttributeSet.java (added)
+++ llvm-gcc-4.2/trunk/libjava/classpath/gnu/javax/swing/text/html/parser/SmallHtmlAttributeSet.java Thu Nov 8 16:56:19 2007
@@ -0,0 +1,261 @@
+/* SmallHtmlAttributeSet.java -- Small fixed HTML attribute set
+ Copyright (C) 2006 Free Software Foundation, Inc.
+
+This file is part of GNU Classpath.
+
+GNU Classpath is free software; you can redistribute it and/or modify
+it under the terms of the GNU General Public License as published by
+the Free Software Foundation; either version 2, or (at your option)
+any later version.
+
+GNU Classpath is distributed in the hope that it will be useful, but
+WITHOUT ANY WARRANTY; without even the implied warranty of
+MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+General Public License for more details.
+
+You should have received a copy of the GNU General Public License
+along with GNU Classpath; see the file COPYING. If not, write to the
+Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA
+02110-1301 USA.
+
+Linking this library statically or dynamically with other modules is
+making a combined work based on this library. Thus, the terms and
+conditions of the GNU General Public License cover the whole
+combination.
+
+As a special exception, the copyright holders of this library give you
+permission to link this library with independent modules to produce an
+executable, regardless of the license terms of these independent
+modules, and to copy and distribute the resulting executable under
+terms of your choice, provided that you also meet, for each linked
+independent module, the terms and conditions of the license of that
+module. An independent module is a module which is not derived from
+or based on this library. If you modify this library, you may extend
+this exception to your version of the library, but you are not
+obligated to do so. If you do not wish to do so, delete this
+exception statement from your version. */
+
+
+package gnu.javax.swing.text.html.parser;
+
+import java.io.Serializable;
+import java.util.Enumeration;
+import java.util.NoSuchElementException;
+
+import javax.swing.text.AttributeSet;
+import javax.swing.text.html.HTML.Attribute;
+import javax.swing.text.html.HTML.Tag;
+
+/**
+ * Small fixed HTML attribute set. The most of the HTML elements contain only
+ * several attributes. With four attributes, the number of operations in more
+ * complex algorithms is not larger than using the naive algorithm.
+ *
+ * Same as HtmlAttributeSet, this set allows both strings and non-string as
+ * keys. The strings are case insensitive, the non strings are compared with
+ * .equals.
+ *
+ * @author Audrius Meskauskas (AudriusA at Bioinformatics.org)
+ */
+public class SmallHtmlAttributeSet
+ implements AttributeSet, Cloneable, Serializable
+{
+ private static final long serialVersionUID = 1;
+
+ /**
+ * The keys, stored in this attribute set.
+ */
+ final Object[] keys;
+
+ /**
+ * The values, stored in this attribute set.
+ */
+ final Object[] values;
+
+ /**
+ * The parent, used for resolving the values, not found in this set.
+ */
+ final AttributeSet parent;
+
+ /**
+ * Create a new small fixed attribute set that contains the unchangeable copy
+ * of the passed attribute set and inherits its parent.
+ *
+ * @param copyFrom the attribute set, containing the attribute values to copy.
+ */
+ public SmallHtmlAttributeSet(AttributeSet copyFrom)
+ {
+ int n = copyFrom.getAttributeCount();
+
+ keys = new Object[n];
+ values = new Object[n];
+ parent = copyFrom.getResolveParent();
+
+ Enumeration en = copyFrom.getAttributeNames();
+ Object key;
+ Object value;
+
+ for (int i = 0; i < n; i++)
+ {
+ key = en.nextElement();
+ keys[i] = key;
+ value = copyFrom.getAttribute(key);
+ values[i] = value;
+ }
+ }
+
+ public boolean containsAttribute(Object name, Object value)
+ {
+ Object contains = getAttribute(name);
+ if (value == null)
+ return value == contains;
+ else
+ return value.equals(contains);
+ }
+
+ public boolean containsAttributes(AttributeSet attributes)
+ {
+ if (attributes == this)
+ return true;
+ Object v;
+ for (int i = 0; i < keys.length; i++)
+ {
+ v = attributes.getAttribute(keys[i]);
+ if (v != values[i])
+ {
+ if (values[i] == null)
+ return false;
+ else if (! values[i].equals(v))
+ return false;
+ }
+ }
+ return true;
+ }
+
+ /**
+ * THIS can be safely returned as the set is not mutable.
+ */
+ public AttributeSet copyAttributes()
+ {
+ return this;
+ }
+
+ /**
+ * Get the attribute value, matching this key. If not found in this set, the
+ * call is delegated to parent.
+ *
+ * @return the value, matching key (or null if none).
+ */
+ public Object getAttribute(Object key)
+ {
+ // Null and HTML attributes or tags can be searched by direct comparison.
+ if (key == null || key instanceof Attribute || key instanceof Tag)
+ {
+ for (int i = 0; i < keys.length; i++)
+ {
+ if (keys[i] == key)
+ return values[i];
+ }
+ }
+
+ // Strings are case insensitive. Only string can be match the string.
+ else if (key instanceof String)
+ {
+ String ks = (String) key;
+ for (int i = 0; i < keys.length; i++)
+ {
+ if (keys[i] instanceof String)
+ if (ks.equalsIgnoreCase((String) keys[i]))
+ return values[i];
+ }
+ }
+
+ // Otherwise, defaults to .equals
+ else
+ {
+ for (int i = 0; i < keys.length; i++)
+ {
+ if (key.equals(keys[i]))
+ return values[i];
+ }
+ }
+
+ if (parent != null)
+ return parent.getAttribute(key);
+ else
+ return null;
+ }
+
+ /**
+ * Get the number of the stored attributes.
+ */
+ public int getAttributeCount()
+ {
+ return keys.length;
+ }
+
+ /**
+ * Get enumeration, containing the attribute names. No guard agains the
+ * concurent modification is required as the set is not mutable.
+ */
+ public Enumeration getAttributeNames()
+ {
+ return new Enumeration()
+ {
+ int p = 0;
+
+ public boolean hasMoreElements()
+ {
+ return p < keys.length;
+ }
+
+ public Object nextElement()
+ {
+ if (p < keys.length)
+ return keys[p++];
+ else
+ throw new NoSuchElementException();
+ }
+ };
+ }
+
+ /**
+ * Get the parent that this set uses to resolve the not found attributes.
+ */
+ public AttributeSet getResolveParent()
+ {
+ return parent;
+ }
+
+ /**
+ * Check if the given attribute is defined in this set (not in the parent).
+ */
+ public boolean isDefined(Object attrName)
+ {
+ if (attrName instanceof String)
+ attrName = ((String) attrName).toLowerCase();
+
+ for (int i = 0; i < keys.length; i++)
+ {
+ if (attrName.equals(keys[i]))
+ return true;
+ }
+ return false;
+ }
+
+ /**
+ * Check this set and another set for equality by content.
+ */
+ public boolean isEqual(AttributeSet attr)
+ {
+ return keys.length == attr.getAttributeCount() && containsAttributes(attr);
+ }
+
+ /**
+ * It is safe to return THIS on cloning, if one happens.
+ */
+ protected Object clone()
+ {
+ return this;
+ }
+}
Added: llvm-gcc-4.2/trunk/libjava/classpath/gnu/javax/swing/text/html/parser/gnuDTD.java
URL: http://llvm.org/viewvc/llvm-project/llvm-gcc-4.2/trunk/libjava/classpath/gnu/javax/swing/text/html/parser/gnuDTD.java?rev=43913&view=auto
==============================================================================
--- llvm-gcc-4.2/trunk/libjava/classpath/gnu/javax/swing/text/html/parser/gnuDTD.java (added)
+++ llvm-gcc-4.2/trunk/libjava/classpath/gnu/javax/swing/text/html/parser/gnuDTD.java Thu Nov 8 16:56:19 2007
@@ -0,0 +1,422 @@
+/* gnuDTD.java --
+ Copyright (C) 2005 Free Software Foundation, Inc.
+
+This file is part of GNU Classpath.
+
+GNU Classpath is free software; you can redistribute it and/or modify
+it under the terms of the GNU General Public License as published by
+the Free Software Foundation; either version 2, or (at your option)
+any later version.
+
+GNU Classpath is distributed in the hope that it will be useful, but
+WITHOUT ANY WARRANTY; without even the implied warranty of
+MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+General Public License for more details.
+
+You should have received a copy of the GNU General Public License
+along with GNU Classpath; see the file COPYING. If not, write to the
+Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA
+02110-1301 USA.
+
+Linking this library statically or dynamically with other modules is
+making a combined work based on this library. Thus, the terms and
+conditions of the GNU General Public License cover the whole
+combination.
+
+As a special exception, the copyright holders of this library give you
+permission to link this library with independent modules to produce an
+executable, regardless of the license terms of these independent
+modules, and to copy and distribute the resulting executable under
+terms of your choice, provided that you also meet, for each linked
+independent module, the terms and conditions of the license of that
+module. An independent module is a module which is not derived from
+or based on this library. If you modify this library, you may extend
+this exception to your version of the library, but you are not
+obligated to do so. If you do not wish to do so, delete this
+exception statement from your version. */
+
+
+package gnu.javax.swing.text.html.parser;
+
+import java.io.PrintStream;
+import java.io.Serializable;
+
+import java.util.BitSet;
+import java.util.Collection;
+import java.util.Iterator;
+import java.util.Map;
+import java.util.Vector;
+
+import javax.swing.text.html.parser.AttributeList;
+import javax.swing.text.html.parser.ContentModel;
+import javax.swing.text.html.parser.Element;
+import javax.swing.text.html.parser.Entity;
+
+/**
+ * <p>
+ * The class is derived from {@link gnu.javax.swing.text.html.parser.DTD }
+ * making structure creation methods public. This is required when
+ * creating the DTD by SGML parser that must have access to the structure.
+ *
+ * SGML DTD representation. Provides basis for describing a syntax of the
+ * HTML documents. The fields of this class are NOT initialized in
+ * constructor. You need to do this separately before passing this data
+ * structure to the parser constructor.</p>
+ *
+ * <p>This implementation also provides you the derived class
+ * <code>gnu.javax.swing.text.html.parser.DTD.HTML_4_0_1</code>, where
+ * all fields are initialized to the values, representing HTML 4.01
+ * ("-//W3C//DTD HTML 4.01 Frameset//EN") DTD. You can use it if you do not care
+ * about the portability between different implementations of the core
+ * class libraries. </p>
+ * <p>Use {@link javax.swing.HTML.HTMLEditorKit.Parser#parse }
+ * for parsing in accordance with "-//W3C//DTD HTML 4.01 Frameset//EN"
+ * without specifying DTD separately.</p>
+ *
+ * @author Audrius Meskauskas, Lithuania (AudriusA at Bioinformatics.org)
+ */
+public class gnuDTD
+ extends javax.swing.text.html.parser.DTD
+ implements javax.swing.text.html.parser.DTDConstants, Serializable
+{
+ /* The undocumented element types, used to specify types, not defined
+ in DTDConstants. */
+
+ /**
+ * The URI element type (not defined in DTDConstants).
+ */
+ public static final int URI = 512;
+
+ /**
+ * The Length element type
+ */
+ public static final int Length = 513;
+
+ /**
+ * The Char element type
+ */
+ public static final int Char = 514;
+
+ /**
+ * The Color element type
+ */
+ public static final int Color = 515;
+
+ /**
+ * Creates a new instance of gnuDTD.
+ * @param name the name of the DTD.
+ */
+ public gnuDTD(String name)
+ {
+ super(name);
+ }
+
+ /**
+ * Creates and returns new attribute (not an attribute list).
+ * @param name the name of this attribute
+ * @param type the type of this attribute (FIXED, IMPLIED or
+ * REQUIRED from <code>DTDConstants</code>).
+ * @param modifier the modifier of this attribute
+ * @param default_value the default value of this attribute or null if
+ * it is not specified.
+ * @param allowed_values the allowed values of this attribute. The multiple
+ * possible values in this parameter are supposed to be separated by
+ * '|', same as in SGML DTD <code><!ATTLIST </code>tag. This parameter
+ * can be null if no list of allowed values is specified.
+ * @param atts the previous attribute of this element. This is
+ * placed to the field
+ * {@link javax.swing.text.html.parser.AttributeList#next },
+ * creating a linked list.
+ * @return
+ */
+ public AttributeList defAttributeList(String name, int type, int modifier,
+ String default_value,
+ String allowed_values,
+ AttributeList atts
+ )
+ {
+ return super.defAttributeList(name, type, modifier, default_value,
+ allowed_values, atts
+ );
+ }
+
+ /**
+ * Define the attributes for the element with the given name.
+ * If the element is not exist, it is created. This method is
+ * needed if the element attributes are defined befor the
+ * element itself.
+ * @param forElement
+ * @param attributes
+ */
+ public void defAttrsFor(String forElement, AttributeList attributes)
+ {
+ super.defineAttributes(forElement, attributes);
+ }
+
+ /**
+ * Creates a new content model.
+ * @param type specifies the BNF operation for this content model.
+ * The valid operations are documented in the
+ * {@link javax.swing.text.html.parser.ContentModel#type }.
+ * @param content the content of this content model
+ * @param next if the content model is specified by BNF-like
+ * expression, contains the rest of this expression.
+ * @return The newly created content model.
+ */
+ public ContentModel defContentModel(int type, Object content,
+ ContentModel next
+ )
+ {
+ return super.defContentModel(type, content, next);
+ }
+
+ /**
+ * Defines a new element and adds it to the element table.
+ * If the element alredy exists,
+ * overrides it settings with the specified values.
+ * @param name the name of the new element
+ * @param type the type of the element
+ * @param headless true if the element needs no starting tag
+ * @param tailless true if the element needs no closing tag
+ * @param content the element content.
+ * @param exclusions the elements that must be excluded from the
+ * content of this element, in all levels of the hierarchy.
+ * @param inclusions the elements that can be included as the
+ * content of this element.
+ * @param attributes the element attributes.
+ * @return the created or updated element.
+ */
+ public Element defElement(String name, int type, boolean headless,
+ boolean tailless, ContentModel content,
+ String[] exclusions, String[] inclusions,
+ AttributeList attributes
+ )
+ {
+ return super.defElement(name, type, headless, tailless, content,
+ exclusions, inclusions, attributes
+ );
+ }
+
+ /**
+ * Defines a new element and adds it to the element table.
+ * If the element alredy exists,
+ * overrides it settings with the specified values.
+ * @param name the name of the new element
+ * @param type the type of the element
+ * @param headless true if the element needs no starting tag
+ * @param tailless true if the element needs no closing tag
+ * @param content the element content.
+ * @param exclusions the elements that must be excluded from the
+ * content of this element, in all levels of the hierarchy.
+ * @param inclusions the elements that can be included as the
+ * content of this element.
+ * @param attributes the element attributes.
+ * @return the created or updated element.
+ */
+ public Element defElement(String name, int type, boolean headless,
+ boolean tailless, ContentModel content,
+ Collection exclusions, Collection inclusions,
+ AttributeList attributes
+ )
+ {
+ return super.defElement(name, type, headless, tailless, content,
+ toStringArray(exclusions),
+ toStringArray(inclusions), attributes
+ );
+ }
+
+ /**
+ * Defines a new element and adds it to the element table.
+ * If the element alredy exists,
+ * overrides it settings with the specified values.
+ * @param name the name of the new element
+ * @param type the type of the element
+ * @param headless true if the element needs no starting tag
+ * @param tailless true if the element needs no closing tag
+ * @param content the element content.
+ * @param exclusions the elements that must be excluded from the
+ * content of this element, in all levels of the hierarchy.
+ * @param inclusions the elements that can be included as the
+ * content of this element.
+ * @param attributes the element attributes (an array and not a
+ * linked list). The attributes are chained into the linked list
+ * inside this method.
+ * @return the created or updated element.
+ */
+ public Element defElement(String name, int type, boolean headless,
+ boolean tailless, ContentModel content,
+ String[] exclusions, String[] inclusions,
+ AttributeList[] attributes
+ )
+ {
+ AttributeList list;
+
+ if (attributes == null || attributes.length == 0)
+ list = null;
+ else
+ {
+ if (attributes.length > 1)
+ for (int i = 1; i < attributes.length; i++)
+ {
+ attributes [ i - 1 ].next = attributes [ i ];
+ }
+ list = attributes [ 0 ];
+ }
+
+ Element e =
+ super.defElement(name, type, headless, tailless, content, exclusions,
+ inclusions, list
+ );
+ return e;
+ }
+
+ /**
+ * Creates, adds into the internal table and returns the
+ * character entity like <code><</code>
+ * (means '<code><</code>' );
+ * This method inactivates the recursive refenrences to the same
+ * entity.
+ * @param name The entity name (without heading & and closing ;)
+ * @param type The entity type
+ * @param character The entity value (single character)
+ * @return The created entity
+ */
+ public Entity defEntity(String name, int type, String data)
+ {
+ int r;
+ String eref = "%" + name + ";";
+ do
+ {
+ r = data.indexOf(eref);
+ if (r > 0)
+ {
+ data = data.substring(0, r) + data.substring(r + 1);
+ }
+ }
+ while (r > 0);
+
+ return super.defEntity(name, type, data);
+ }
+
+ /**
+ * Summarises the document content into the given PrintStream.
+ */
+ public void dump(PrintStream p)
+ {
+ Iterator iter = entityHash.entrySet().iterator();
+ while (iter.hasNext())
+ {
+ Map.Entry item = (Map.Entry) iter.next();
+ Entity e = (Entity) item.getValue();
+ if (e.isGeneral())
+ p.println("Entity " + e.getName() + ": " + e.getString());
+ }
+
+ iter = elementHash.entrySet().iterator();
+ while (iter.hasNext())
+ {
+ Map.Entry item = (Map.Entry) iter.next();
+ Element e = (Element) item.getValue();
+ p.println("Element " + e.getName());
+
+ System.out.println(" includes:");
+ dump(e.inclusions);
+ System.out.println(" excludes:");
+ dump(e.exclusions);
+ System.out.println(" attributes:");
+
+ AttributeList atts = e.atts;
+ while (atts != null)
+ {
+ p.print(" " + atts.name + " = " + atts.value);
+ if (atts.values == null || atts.values.size() == 0)
+ p.println();
+ else
+ {
+ Iterator viter = atts.values.iterator();
+ System.out.print(" ( ");
+ while (viter.hasNext())
+ {
+ System.out.print(viter.next());
+ if (viter.hasNext())
+ System.out.print(" | ");
+ }
+ System.out.println(" ) ");
+ }
+ atts = atts.next;
+ }
+ }
+ }
+
+ /**
+ * Prints the content of the given attribute set to the System.out.
+ * @param b
+ */
+ public void dump(BitSet b)
+ {
+ if (b != null)
+ {
+ for (int i = 0; i < b.size(); i++)
+ {
+ if (b.get(i))
+ System.out.println(" " + elements.get(i));
+ }
+ }
+ else
+ System.out.println(" NULL set");
+ }
+
+ /**
+ * Creates the attribute.
+ * @param name The attribute name.
+ * @param type The attribute type.
+ * @param modifier The attribute modifier.
+ * @param defaultValue Default value (or null)
+ * @param allowed_values Allowed values (or null)
+ * @return The newly created AttributeList. The <code>next</code>
+ * field is initialized to null.
+ */
+ protected AttributeList attr(String name, String default_value,
+ String[] allowed_values, int type, int modifier
+ )
+ {
+ Vector allowed = null;
+
+ if (allowed_values != null)
+ {
+ allowed = new Vector(allowed_values.length);
+ for (int i = 0; i < allowed_values.length; i++)
+ {
+ allowed.add(allowed_values [ i ]);
+ }
+ }
+ ;
+
+ AttributeList attr =
+ new AttributeList(name, type, modifier, default_value, allowed, null);
+
+ return attr;
+ }
+
+ /**
+ * Define the general entity, holding a single character.
+ * @param name The entity name (for example, 'amp').
+ * The defined entity <b>is</b> stored into the entity table.
+ * @param character The entity character (for example, '&').
+ */
+ protected void defineEntity(String name, int character)
+ {
+ super.defEntity(name, GENERAL, character);
+ }
+
+ private String[] toStringArray(Collection c)
+ {
+ String[] s = new String[ c.size() ];
+ Iterator iter = c.iterator();
+ for (int i = 0; i < s.length; i++)
+ {
+ s [ i ] = iter.next().toString();
+ }
+ return s;
+ }
+}
Added: llvm-gcc-4.2/trunk/libjava/classpath/gnu/javax/swing/text/html/parser/htmlAttributeSet.java
URL: http://llvm.org/viewvc/llvm-project/llvm-gcc-4.2/trunk/libjava/classpath/gnu/javax/swing/text/html/parser/htmlAttributeSet.java?rev=43913&view=auto
==============================================================================
--- llvm-gcc-4.2/trunk/libjava/classpath/gnu/javax/swing/text/html/parser/htmlAttributeSet.java (added)
+++ llvm-gcc-4.2/trunk/libjava/classpath/gnu/javax/swing/text/html/parser/htmlAttributeSet.java Thu Nov 8 16:56:19 2007
@@ -0,0 +1,183 @@
+/* htmlAttributeSet.java -- A set to store HTML attributes
+ Copyright (C) 2005 Free Software Foundation, Inc.
+
+This file is part of GNU Classpath.
+
+GNU Classpath is free software; you can redistribute it and/or modify
+it under the terms of the GNU General Public License as published by
+the Free Software Foundation; either version 2, or (at your option)
+any later version.
+
+GNU Classpath is distributed in the hope that it will be useful, but
+WITHOUT ANY WARRANTY; without even the implied warranty of
+MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+General Public License for more details.
+
+You should have received a copy of the GNU General Public License
+along with GNU Classpath; see the file COPYING. If not, write to the
+Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA
+02110-1301 USA.
+
+Linking this library statically or dynamically with other modules is
+making a combined work based on this library. Thus, the terms and
+conditions of the GNU General Public License cover the whole
+combination.
+
+As a special exception, the copyright holders of this library give you
+permission to link this library with independent modules to produce an
+executable, regardless of the license terms of these independent
+modules, and to copy and distribute the resulting executable under
+terms of your choice, provided that you also meet, for each linked
+independent module, the terms and conditions of the license of that
+module. An independent module is a module which is not derived from
+or based on this library. If you modify this library, you may extend
+this exception to your version of the library, but you are not
+obligated to do so. If you do not wish to do so, delete this
+exception statement from your version. */
+
+
+package gnu.javax.swing.text.html.parser;
+
+import java.util.Enumeration;
+
+import javax.swing.text.AttributeSet;
+import javax.swing.text.SimpleAttributeSet;
+import javax.swing.text.html.HTML;
+
+/**
+ * A set, adapted to store HTML attributes.
+ *
+ * @author Audrius Meskauskas, Lithuania (AudriusA at Bioinformatics.org)
+ */
+public class htmlAttributeSet
+ extends SimpleAttributeSet
+{
+ public static final htmlAttributeSet EMPTY_HTML_ATTRIBUTE_SET =
+ new htmlAttributeSet();
+
+ AttributeSet parent;
+
+ /**
+ * Looks in this set and, if not found, later looks in the parent set. Calls
+ * toString(), allowing to pass as HTML.Attribute, as String to this method.
+ *
+ * @param _key A key to search for a value.
+ * @return The value, if one is defined.
+ */
+ public Object getAttribute(Object _key)
+ {
+ Object v = super.getAttribute(_key);
+ if (v != null || _key == null)
+ return v;
+
+ Object key = _key.toString().toLowerCase();
+
+ v = super.getAttribute(key);
+ if (v != null)
+ return v;
+
+ key = HTML.getAttributeKey((String) key);
+ v = super.getAttribute(key);
+ if (v != null)
+ return v;
+
+ if (parent != null)
+ return parent.getAttribute(key);
+ else
+ return null;
+ }
+
+ /**
+ * The name set must return HTML.Attribute and not a string,
+ * where applicable.
+ */
+ public Enumeration getAttributeNames()
+ {
+ // Replace the string keys by HTML.attribute, where applicable
+ final Enumeration enumeration = super.getAttributeNames();
+
+ return new Enumeration()
+ {
+ public boolean hasMoreElements()
+ {
+ return enumeration.hasMoreElements();
+ }
+
+ public Object nextElement()
+ {
+ Object key = enumeration.nextElement();
+ if (key instanceof String)
+ {
+ HTML.Attribute hKey = HTML.getAttributeKey((String) key);
+ if (hKey != null)
+ return hKey;
+ }
+ return key;
+ }
+ };
+ }
+
+ /**
+ * Set the parent set, containing the default values.
+ *
+ * @param a_parent
+ */
+ public void setResolveParent(AttributeSet a_parent)
+ {
+ parent = a_parent;
+ }
+
+ /**
+ * Get the parent set, containing the default values.
+ *
+ * @return the parent, used to resolve the attributes.
+ */
+ public AttributeSet getResolveParent()
+ {
+ return parent;
+ }
+
+ /**
+ * Add the attribute to this attribute set.
+ *
+ * @param key Attribute key (if string, it will be case insensitive)
+ * @param value Attribute value
+ */
+ public void addAttribute(Object key, Object value)
+ {
+ if (key instanceof String)
+ super.addAttribute(((String) key).toLowerCase(), value);
+ else
+ super.addAttribute(key, value);
+ }
+
+ /**
+ * Copy attributes. The returned copy does not longer contains the extended
+ * features, needed to participate in the HTML parsing. The returned set may
+ * not be mutable.
+ */
+ public AttributeSet copyAttributes()
+ {
+ if (getAttributeCount() <= 8)
+ // For the small size, typical in HTML tags, the direct iteration is
+ // faster than more complex algorithms.
+ return new SmallHtmlAttributeSet(this);
+ else
+ return (AttributeSet) clone();
+ }
+
+ /**
+ * Returns a clone of the attribute set.
+ *
+ * @return A clone of the attribute set.
+ */
+ public Object clone()
+ {
+ htmlAttributeSet set = new htmlAttributeSet();
+ set.addAttributes(this);
+ AttributeSet parent = getResolveParent();
+ if (parent != null)
+ set.setResolveParent(parent);
+ return set;
+ }
+}
Added: llvm-gcc-4.2/trunk/libjava/classpath/gnu/javax/swing/text/html/parser/htmlValidator.java
URL: http://llvm.org/viewvc/llvm-project/llvm-gcc-4.2/trunk/libjava/classpath/gnu/javax/swing/text/html/parser/htmlValidator.java?rev=43913&view=auto
==============================================================================
--- llvm-gcc-4.2/trunk/libjava/classpath/gnu/javax/swing/text/html/parser/htmlValidator.java (added)
+++ llvm-gcc-4.2/trunk/libjava/classpath/gnu/javax/swing/text/html/parser/htmlValidator.java Thu Nov 8 16:56:19 2007
@@ -0,0 +1,619 @@
+/* tagStack.java -- The HTML tag stack.
+ Copyright (C) 2005 Free Software Foundation, Inc.
+
+This file is part of GNU Classpath.
+
+GNU Classpath is free software; you can redistribute it and/or modify
+it under the terms of the GNU General Public License as published by
+the Free Software Foundation; either version 2, or (at your option)
+any later version.
+
+GNU Classpath is distributed in the hope that it will be useful, but
+WITHOUT ANY WARRANTY; without even the implied warranty of
+MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+General Public License for more details.
+
+You should have received a copy of the GNU General Public License
+along with GNU Classpath; see the file COPYING. If not, write to the
+Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA
+02110-1301 USA.
+
+Linking this library statically or dynamically with other modules is
+making a combined work based on this library. Thus, the terms and
+conditions of the GNU General Public License cover the whole
+combination.
+
+As a special exception, the copyright holders of this library give you
+permission to link this library with independent modules to produce an
+executable, regardless of the license terms of these independent
+modules, and to copy and distribute the resulting executable under
+terms of your choice, provided that you also meet, for each linked
+independent module, the terms and conditions of the license of that
+module. An independent module is a module which is not derived from
+or based on this library. If you modify this library, you may extend
+this exception to your version of the library, but you are not
+obligated to do so. If you do not wish to do so, delete this
+exception statement from your version. */
+
+
+package gnu.javax.swing.text.html.parser;
+
+import gnu.javax.swing.text.html.parser.models.node;
+import gnu.javax.swing.text.html.parser.models.transformer;
+
+import java.util.BitSet;
+import java.util.Enumeration;
+import java.util.LinkedList;
+import java.util.ListIterator;
+
+import javax.swing.text.SimpleAttributeSet;
+import javax.swing.text.html.HTML;
+import javax.swing.text.html.parser.*;
+
+/**
+ * <p>The HTML content validator, is responsible for opening and
+ * closing elements with optional start/end tags, detecting
+ * the wrongly placed html tags and reporting errors. The working instance
+ * is the inner class inside the {@link javax.swing.text.html.parser.Parser }
+ * </p>
+ * <p>This class could potentially
+ * provide basis for automated closing and insertion of the html tags,
+ * correcting the found html errors.
+ * @author Audrius Meskauskas, Lithuania (AudriusA at Bioinformatics.org)
+ */
+public abstract class htmlValidator
+{
+ /**
+ * The tag reference, holding additional information that the tag
+ * has been forcibly closed.
+ */
+ protected class hTag
+ {
+ protected final Element element;
+ protected final HTML.Tag tag;
+ protected final TagElement tgElement;
+ protected boolean forcibly_closed;
+ protected node validationTrace;
+
+ protected hTag(TagElement an_element)
+ {
+ element = an_element.getElement();
+ tag = an_element.getHTMLTag();
+ tgElement = an_element;
+
+ if (element.content != null)
+ validationTrace = transformer.transform(element.content, dtd);
+ }
+
+ /**
+ * This is called when the tag must be forcibly closed because
+ * it would make the newly appearing tag invalid.
+ * The parser is not notified about such event (just the error
+ * is reported). For such tags, the closing message does not
+ * appear when later reaching the end of stream. The exception is
+ * the <head> tag: the parser is notified about its silent closing
+ * when <body> or other html content appears.
+ */
+ protected void forciblyCloseDueContext()
+ {
+ forcibly_closed = true;
+ }
+
+ /**
+ * This is called when the tag must be forcibly closed after
+ * reaching the end of stream. The parser is notified as if
+ * closing the tag explicitly.
+ */
+ protected void forciblyCloseDueEndOfStream()
+ {
+ forcibly_closed = true;
+ handleSupposedEndTag(element);
+ }
+ }
+
+ /**
+ * The DTD, providing information about the valid document structure.
+ */
+ protected final DTD dtd;
+
+ /**
+ * The stack, holding the current tag context.
+ */
+ protected final LinkedList stack = new LinkedList();
+
+ /**
+ * Creates a new tag stack, using the given DTD.
+ * @param a_dtd A DTD, providing the information about the valid
+ * tag content.
+ */
+ public htmlValidator(DTD a_dtd)
+ {
+ dtd = a_dtd;
+ }
+
+ /**
+ * Close all opened tags (called at the end of parsing).
+ */
+ public void closeAll()
+ {
+ hTag h;
+ while (!stack.isEmpty())
+ {
+ h = (hTag) stack.getLast();
+ if (!h.forcibly_closed && !h.element.omitEnd())
+ s_error("Unclosed <" + h.tag + ">, closing at the end of stream");
+
+ handleSupposedEndTag(h.element);
+
+ closeTag(h.tgElement);
+ }
+ }
+
+ /**
+ * Remove the given tag from the stack or (if found) from the list
+ * of the forcibly closed tags.
+ */
+ public void closeTag(TagElement tElement)
+ {
+ HTML.Tag tag = tElement.getHTMLTag();
+ hTag x;
+ hTag close;
+
+ if (!stack.isEmpty())
+ {
+ ListIterator iter = stack.listIterator(stack.size());
+
+ while (iter.hasPrevious())
+ {
+ x = (hTag) iter.previous();
+ if (tag.equals(x.tag))
+ {
+ if (x.forcibly_closed && !x.element.omitEnd())
+ s_error("The tag <" + x.tag +
+ "> has already been forcibly closed"
+ );
+
+
+ // If the tag has a content model defined, forcibly close all
+ // tags that were opened after the tag being currently closed.
+ closing:
+ if (x.element.content != null)
+ {
+ iter = stack.listIterator(stack.size());
+ while (iter.hasPrevious())
+ {
+ close = (hTag) iter.previous();
+ if (close == x)
+ break closing;
+ handleSupposedEndTag(close.element);
+ iter.remove();
+ }
+ }
+
+ stack.remove(x);
+ return;
+ }
+ }
+ }
+ s_error("Closing unopened <" + tag + ">");
+ }
+
+ /**
+ * Add the given HTML tag to the stack of the opened tags. Forcibly closes
+ * all tags in the stack that does not allow this tag in they content (error
+ * is reported).
+ * @param element
+ */
+ public void openTag(TagElement tElement, htmlAttributeSet parameters)
+ {
+ // If this is a fictional call, the message from the parser
+ // has recursively returned - ignore.
+ if (tElement.fictional())
+ return;
+
+ validateParameters(tElement, parameters);
+
+ // If the stack is empty, start from HTML
+ if (stack.isEmpty() && tElement.getHTMLTag() != HTML.Tag.HTML)
+ {
+ Element html = dtd.getElement(HTML.Tag.HTML.toString());
+ openFictionalTag(html);
+ }
+
+ Object v = tagIsValidForContext(tElement);
+ if (v != Boolean.TRUE)
+ {
+ // The tag is not valid for context, the content
+ // model suggest to open another tag.
+ if (v instanceof Element)
+ {
+ int n = 0;
+ while (v instanceof Element && (n++ < 100))
+ {
+ Element fe = (Element) v;
+
+ // notify the content model that we add the proposed tag
+ node ccm = getCurrentContentModel();
+ if (ccm != null)
+ ccm.show(fe);
+ openFictionalTag(fe);
+
+ Object vv = tagIsValidForContext(tElement);
+ if (vv instanceof Element) // One level of nesting is supported.
+ {
+ openFictionalTag((Element) vv);
+
+ Object vx = tagIsValidForContext(tElement);
+ if (vx instanceof Element)
+ openFictionalTag((Element) vx);
+ }
+ else if (vv == Boolean.FALSE)
+ {
+ // The tag is still not valid for the current
+ // content after opening a fictional element.
+ if (fe.omitEnd())
+ {
+ // close the previously opened fictional tag.
+ closeLast();
+ vv = tagIsValidForContext(tElement);
+ if (vv instanceof Element)
+
+ // another tag was suggested by the content model
+ openFictionalTag((Element) vv);
+ }
+ }
+ v = tagIsValidForContext(tElement);
+ }
+ }
+ else // If the current element has the optional end tag, close it.
+ {
+ if (!stack.isEmpty())
+ {
+ closing:
+ do
+ {
+ hTag last = (hTag) stack.getLast();
+ if (last.element.omitEnd())
+ {
+ closeLast();
+ v = tagIsValidForContext(tElement);
+ if (v instanceof Element) // another tag was suggested by the content model
+ {
+ openFictionalTag((Element) v);
+ break closing;
+ }
+ }
+ else
+ break closing;
+ }
+ while (v == Boolean.FALSE && !stack.isEmpty());
+ }
+ }
+ }
+
+ stack.add(new hTag(tElement));
+ }
+
+ /**
+ * Clear the stack.
+ */
+ public void restart()
+ {
+ stack.clear();
+ }
+
+ /**
+ * Check if this tag is valid for the current context. Return Boolean.True if
+ * it is OK, Boolean.False if it is surely not OK or the Element that the
+ * content model recommends to insert making the situation ok. If Boolean.True
+ * is returned, the content model current position is moved forward. Otherwise
+ * this position remains the same.
+ *
+ * @param tElement
+ * @return
+ */
+ public Object tagIsValidForContext(TagElement tElement)
+ {
+ // Check the current content model, if one is available.
+ node cv = getCurrentContentModel();
+
+ if (cv != null)
+ return cv.show(tElement.getElement());
+
+ // Check exclusions and inclusions.
+ ListIterator iter = stack.listIterator(stack.size());
+ hTag t = null;
+ final int idx = tElement.getElement().index;
+
+ // Check only known tags.
+ if (idx >= 0)
+ {
+ BitSet inclusions = new BitSet();
+ while (iter.hasPrevious())
+ {
+ t = (hTag) iter.previous();
+ if (! t.forcibly_closed)
+ {
+ if (t.element.exclusions != null
+ && t.element.exclusions.get(idx))
+ return Boolean.FALSE;
+
+ if (t.element.inclusions != null)
+ inclusions.or(t.element.inclusions);
+ }
+ }
+ if (! inclusions.get(idx))
+ {
+ // If we need to insert something, and cannot do this, but
+ // it is allowed to insert the paragraph here, insert the
+ // paragraph.
+ Element P = dtd.getElement(HTML_401F.P);
+ if (inclusions.get(P.index))
+ return P;
+ else
+ return Boolean.FALSE;
+ }
+ }
+ return Boolean.TRUE;
+ }
+
+ /**
+ * Validate tag without storing in into the tag stack. This is called
+ * for the empty tags and results the subsequent calls to the openTag
+ * and closeTag.
+ */
+ public void validateTag(TagElement tElement, htmlAttributeSet parameters)
+ {
+ openTag(tElement, parameters);
+ closeTag(tElement);
+ }
+
+ /**
+ * Check for mandatory elements, subsequent to the last tag:
+ * @param tElement The element that will be inserted next.
+ */
+ protected void checkContentModel(TagElement tElement, boolean first)
+ {
+ if (stack.isEmpty())
+ return;
+
+ hTag last = (hTag) stack.getLast();
+ if (last.validationTrace == null)
+ return;
+
+ Object r = last.validationTrace.show(tElement.getElement());
+ if (r == Boolean.FALSE)
+ s_error("The <" + last.element + "> does not match the content model " +
+ last.validationTrace
+ );
+ else if (r instanceof Element) // The content model recommends insertion of this element
+ {
+ if (!first)
+ closeTag(last.tgElement);
+ handleSupposedStartTag((Element) r);
+ openTag(new TagElement((Element) r), null);
+ }
+ }
+
+ /**
+ * The method is called when the tag must be closed because
+ * it does not allow the subsequent elements inside its context
+ * or the end of stream has been reached. The parser is only
+ * informed if the element being closed does not require the
+ * end tag (the "omitEnd" flag is set).
+ * The closing message must be passed to the parser mechanism
+ * before passing message about the opening the next tag.
+ *
+ * @param element The tag being fictionally (forcibly) closed.
+ */
+ protected abstract void handleSupposedEndTag(Element element);
+
+ /**
+ * The method is called when the validator decides to open the
+ * tag on its own initiative. This may happen if the content model
+ * includes the element with the optional (supposed) start tag.
+ *
+ * @param element The tag being opened.
+ */
+ protected abstract void handleSupposedStartTag(Element element);
+
+ /**
+ * Handles the error message. This method must be overridden to pass
+ * the message where required.
+ * @param msg The message text.
+ */
+ protected abstract void s_error(String msg);
+
+ /**
+ * Validate the parameters, report the error if the given parameter is
+ * not in the parameter set, valid for the given attribute. The information
+ * about the valid parameter set is taken from the Element, enclosed
+ * inside the tag. The method does not validate the default parameters.
+ * @param tag The tag
+ * @param parameters The parameters of this tag.
+ */
+ protected void validateParameters(TagElement tag, htmlAttributeSet parameters)
+ {
+ if (parameters == null ||
+ parameters == htmlAttributeSet.EMPTY_HTML_ATTRIBUTE_SET ||
+ parameters == SimpleAttributeSet.EMPTY
+ )
+ return;
+
+ Enumeration enumeration = parameters.getAttributeNames();
+
+ while (enumeration.hasMoreElements())
+ {
+ validateAttribute(tag, parameters, enumeration);
+ }
+
+ // Check for missing required values.
+ AttributeList a = tag.getElement().getAttributes();
+
+ while (a != null)
+ {
+ if (a.getModifier() == DTDConstants.REQUIRED)
+ if (parameters.getAttribute(a.getName()) == null)
+ {
+ s_error("Missing required attribute '" + a.getName() + "' for <" +
+ tag.getHTMLTag() + ">"
+ );
+ }
+ a = a.next;
+ }
+ }
+
+ private node getCurrentContentModel()
+ {
+ if (!stack.isEmpty())
+ {
+ hTag last = (hTag) stack.getLast();
+ return last.validationTrace;
+ }
+ else
+ return null;
+ }
+
+ private void closeLast()
+ {
+ handleSupposedEndTag(((hTag) stack.getLast()).element);
+ stack.removeLast();
+ }
+
+ private void openFictionalTag(Element e)
+ {
+ handleSupposedStartTag(e);
+ stack.add(new hTag(new TagElement(e, true)));
+ if (!e.omitStart())
+ s_error("<" + e + "> is expected (supposing it)");
+ }
+
+ private void validateAttribute(TagElement tag, htmlAttributeSet parameters,
+ Enumeration enumeration
+ )
+ {
+ Object foundAttribute;
+ AttributeList dtdAttribute;
+ foundAttribute = enumeration.nextElement();
+ dtdAttribute = tag.getElement().getAttribute(foundAttribute.toString());
+ if (dtdAttribute == null)
+ {
+ StringBuffer valid =
+ new StringBuffer("The tag <" + tag.getHTMLTag() +
+ "> cannot contain the attribute '" + foundAttribute +
+ "'. The valid attributes for this tag are: "
+ );
+
+ AttributeList a = tag.getElement().getAttributes();
+
+ while (a != null)
+ {
+ valid.append(a.name.toUpperCase());
+ valid.append(' ');
+ a = a.next;
+ }
+ s_error(valid.toString());
+ }
+
+ else
+ {
+ String value = parameters.getAttribute(foundAttribute).toString();
+
+ if (dtdAttribute.type == DTDConstants.NUMBER)
+ validateNumberAttribute(tag, foundAttribute, value);
+
+ if (dtdAttribute.type == DTDConstants.NAME ||
+ dtdAttribute.type == DTDConstants.ID
+ )
+ validateNameOrIdAttribute(tag, foundAttribute, value);
+
+ if (dtdAttribute.values != null)
+ validateAttributeWithValueList(tag, foundAttribute, dtdAttribute,
+ value
+ );
+ }
+ }
+
+ private void validateAttributeWithValueList(TagElement tag,
+ Object foundAttribute,
+ AttributeList dtdAttribute,
+ String value
+ )
+ {
+ if (!dtdAttribute.values.contains(value.toLowerCase()) &&
+ !dtdAttribute.values.contains(value.toUpperCase())
+ )
+ {
+ StringBuffer valid;
+ if (dtdAttribute.values.size() == 1)
+ valid =
+ new StringBuffer("The attribute '" + foundAttribute +
+ "' of the tag <" + tag.getHTMLTag() +
+ "> cannot have the value '" + value +
+ "'. The only valid value is "
+ );
+ else
+ valid =
+ new StringBuffer("The attribute '" + foundAttribute +
+ "' of the tag <" + tag.getHTMLTag() +
+ "> cannot have the value '" + value + "'. The " +
+ dtdAttribute.values.size() +
+ " valid values are: "
+ );
+
+ Enumeration vv = dtdAttribute.values.elements();
+ while (vv.hasMoreElements())
+ {
+ valid.append('"');
+ valid.append(vv.nextElement());
+ valid.append("\" ");
+ }
+ s_error(valid.toString());
+ }
+ }
+
+ private void validateNameOrIdAttribute(TagElement tag, Object foundAttribute,
+ String value
+ )
+ {
+ boolean ok = true;
+
+ if (!Character.isLetter(value.charAt(0)))
+ ok = false;
+
+ char c;
+ for (int i = 0; i < value.length(); i++)
+ {
+ c = value.charAt(i);
+ if (!(
+ Character.isLetter(c) || Character.isDigit(c) ||
+ "".indexOf(c) >= 0
+ )
+ )
+ ok = false;
+ }
+ if (!ok)
+ s_error("The '" + foundAttribute + "' attribute of the tag <" +
+ tag.getHTMLTag() + "> must start from letter and consist of " +
+ "letters, digits, hypens, colons, underscores and periods. " +
+ "It cannot be '" + value + "'"
+ );
+ }
+
+ private void validateNumberAttribute(TagElement tag, Object foundAttribute,
+ String value
+ )
+ {
+ try
+ {
+ Integer.parseInt(value);
+ }
+ catch (NumberFormatException ex)
+ {
+ s_error("The '" + foundAttribute + "' attribute of the tag <" +
+ tag.getHTMLTag() + "> must be a valid number and not '" +
+ value + "'"
+ );
+ }
+ }
+}
Added: llvm-gcc-4.2/trunk/libjava/classpath/gnu/javax/swing/text/html/parser/models/PCDATAonly_model.java
URL: http://llvm.org/viewvc/llvm-project/llvm-gcc-4.2/trunk/libjava/classpath/gnu/javax/swing/text/html/parser/models/PCDATAonly_model.java?rev=43913&view=auto
==============================================================================
--- llvm-gcc-4.2/trunk/libjava/classpath/gnu/javax/swing/text/html/parser/models/PCDATAonly_model.java (added)
+++ llvm-gcc-4.2/trunk/libjava/classpath/gnu/javax/swing/text/html/parser/models/PCDATAonly_model.java Thu Nov 8 16:56:19 2007
@@ -0,0 +1,62 @@
+/* PCDATAonly_model.java --
+ Copyright (C) 2005 Free Software Foundation, Inc.
+
+This file is part of GNU Classpath.
+
+GNU Classpath is free software; you can redistribute it and/or modify
+it under the terms of the GNU General Public License as published by
+the Free Software Foundation; either version 2, or (at your option)
+any later version.
+
+GNU Classpath is distributed in the hope that it will be useful, but
+WITHOUT ANY WARRANTY; without even the implied warranty of
+MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+General Public License for more details.
+
+You should have received a copy of the GNU General Public License
+along with GNU Classpath; see the file COPYING. If not, write to the
+Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA
+02110-1301 USA.
+
+Linking this library statically or dynamically with other modules is
+making a combined work based on this library. Thus, the terms and
+conditions of the GNU General Public License cover the whole
+combination.
+
+As a special exception, the copyright holders of this library give you
+permission to link this library with independent modules to produce an
+executable, regardless of the license terms of these independent
+modules, and to copy and distribute the resulting executable under
+terms of your choice, provided that you also meet, for each linked
+independent module, the terms and conditions of the license of that
+module. An independent module is a module which is not derived from
+or based on this library. If you modify this library, you may extend
+this exception to your version of the library, but you are not
+obligated to do so. If you do not wish to do so, delete this
+exception statement from your version. */
+
+
+package gnu.javax.swing.text.html.parser.models;
+
+import java.io.Serializable;
+
+/**
+ * The model, allowing only PCDATA in it (like for element OPTION).
+ * @author Audrius Meskauskas, Lithuania (AudriusA at Bioinformatics.org)
+ */
+public class PCDATAonly_model
+ extends node
+ implements Serializable
+{
+ private static final long serialVersionUID = 1;
+
+ public PCDATAonly_model()
+ {
+ super((char) 0, (char) 0, null);
+ }
+
+ public Object show(Object x)
+ {
+ return x.toString().equalsIgnoreCase("#pcdata") ? Boolean.TRUE : Boolean.FALSE;
+ }
+}
Added: llvm-gcc-4.2/trunk/libjava/classpath/gnu/javax/swing/text/html/parser/models/TableRowContentModel.java
URL: http://llvm.org/viewvc/llvm-project/llvm-gcc-4.2/trunk/libjava/classpath/gnu/javax/swing/text/html/parser/models/TableRowContentModel.java?rev=43913&view=auto
==============================================================================
--- llvm-gcc-4.2/trunk/libjava/classpath/gnu/javax/swing/text/html/parser/models/TableRowContentModel.java (added)
+++ llvm-gcc-4.2/trunk/libjava/classpath/gnu/javax/swing/text/html/parser/models/TableRowContentModel.java Thu Nov 8 16:56:19 2007
@@ -0,0 +1,77 @@
+/* TableRowContentModel.java --
+ Copyright (C) 2005 Free Software Foundation, Inc.
+
+This file is part of GNU Classpath.
+
+GNU Classpath is free software; you can redistribute it and/or modify
+it under the terms of the GNU General Public License as published by
+the Free Software Foundation; either version 2, or (at your option)
+any later version.
+
+GNU Classpath is distributed in the hope that it will be useful, but
+WITHOUT ANY WARRANTY; without even the implied warranty of
+MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+General Public License for more details.
+
+You should have received a copy of the GNU General Public License
+along with GNU Classpath; see the file COPYING. If not, write to the
+Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA
+02110-1301 USA.
+
+Linking this library statically or dynamically with other modules is
+making a combined work based on this library. Thus, the terms and
+conditions of the GNU General Public License cover the whole
+combination.
+
+As a special exception, the copyright holders of this library give you
+permission to link this library with independent modules to produce an
+executable, regardless of the license terms of these independent
+modules, and to copy and distribute the resulting executable under
+terms of your choice, provided that you also meet, for each linked
+independent module, the terms and conditions of the license of that
+module. An independent module is a module which is not derived from
+or based on this library. If you modify this library, you may extend
+this exception to your version of the library, but you are not
+obligated to do so. If you do not wish to do so, delete this
+exception statement from your version. */
+
+
+package gnu.javax.swing.text.html.parser.models;
+
+import java.io.Serializable;
+
+import javax.swing.text.html.parser.DTD;
+import javax.swing.text.html.parser.Element;
+
+/**
+ * Table row content model.
+ * @author Audrius Meskauskas, Lithuania (AudriusA at Bioinformatics.org)
+ */
+public class TableRowContentModel
+ extends node
+ implements Serializable
+{
+ private static final long serialVersionUID = 1;
+ final Element TD;
+
+ public TableRowContentModel(DTD dtd)
+ {
+ super((char) 0, (char) 0, null);
+ TD = dtd.getElement("TD");
+ }
+
+ public Object show(Object x)
+ {
+ // Always accept TD and TH
+ String s = x.toString();
+ if (s.equalsIgnoreCase("TD") || s.equalsIgnoreCase("TH"))
+ return Boolean.TRUE;
+
+ // Suggest closing in response to TR:
+ if (s.equalsIgnoreCase("TR"))
+ return Boolean.FALSE;
+
+ // Recommend TD for other cases:
+ return TD;
+ }
+}
Added: llvm-gcc-4.2/trunk/libjava/classpath/gnu/javax/swing/text/html/parser/models/list.java
URL: http://llvm.org/viewvc/llvm-project/llvm-gcc-4.2/trunk/libjava/classpath/gnu/javax/swing/text/html/parser/models/list.java?rev=43913&view=auto
==============================================================================
--- llvm-gcc-4.2/trunk/libjava/classpath/gnu/javax/swing/text/html/parser/models/list.java (added)
+++ llvm-gcc-4.2/trunk/libjava/classpath/gnu/javax/swing/text/html/parser/models/list.java Thu Nov 8 16:56:19 2007
@@ -0,0 +1,382 @@
+/* list.java --
+ Copyright (C) 2005 Free Software Foundation, Inc.
+
+This file is part of GNU Classpath.
+
+GNU Classpath is free software; you can redistribute it and/or modify
+it under the terms of the GNU General Public License as published by
+the Free Software Foundation; either version 2, or (at your option)
+any later version.
+
+GNU Classpath is distributed in the hope that it will be useful, but
+WITHOUT ANY WARRANTY; without even the implied warranty of
+MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+General Public License for more details.
+
+You should have received a copy of the GNU General Public License
+along with GNU Classpath; see the file COPYING. If not, write to the
+Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA
+02110-1301 USA.
+
+Linking this library statically or dynamically with other modules is
+making a combined work based on this library. Thus, the terms and
+conditions of the GNU General Public License cover the whole
+combination.
+
+As a special exception, the copyright holders of this library give you
+permission to link this library with independent modules to produce an
+executable, regardless of the license terms of these independent
+modules, and to copy and distribute the resulting executable under
+terms of your choice, provided that you also meet, for each linked
+independent module, the terms and conditions of the license of that
+module. An independent module is a module which is not derived from
+or based on this library. If you modify this library, you may extend
+this exception to your version of the library, but you are not
+obligated to do so. If you do not wish to do so, delete this
+exception statement from your version. */
+
+
+package gnu.javax.swing.text.html.parser.models;
+
+import java.io.Serializable;
+
+/**
+ * Part of the internal representation of the content model.
+ * @author Audrius Meskauskas, Lithuania (AudriusA at Bioinformatics.org)
+ */
+public class list
+ extends node
+ implements Serializable
+{
+ private static final long serialVersionUID = 1;
+
+ /**
+ * Setting to true means that the list nodes must always be connected
+ * by the same operation. This is far safer and clearer, but not
+ * required by default standard.
+ */
+ public static boolean CLEAR;
+
+ /**
+ * A list of nodes.
+ */
+ public final node[] nodes;
+
+ /**
+ * Creates a new model list that is a member of some enclosing list.
+ * @param binary_operator An operator with that this list is connected
+ * with other members of the enclosing list.
+ * @param unary_operator The unary operator for this list.
+ * @param a_nodes The nodes inside this list.
+ */
+ public list(char binary_operator, char unary_operator, node[] a_nodes)
+ {
+ super(binary_operator, unary_operator, a_nodes);
+ nodes = a_nodes;
+ }
+
+ /**
+ * Creates a new model list. Assigns the previous field.
+ * @param a_nodes The nodes for this list.
+ * @throws an error if the node elements are connected by the
+ * different operations. This is not supported, use grouping.
+ */
+ public list(node[] a_nodes)
+ throws Error
+ {
+ this(',', (char) 0, a_nodes);
+
+ int operation = nodes [ 0 ].binary;
+
+ for (int i = 0; i < nodes.length; i++)
+ {
+ if (CLEAR && nodes [ i ].binary != operation)
+ throw new Error("List members can only be connected by " +
+ "the same operation, use grouping"
+ );
+
+ if (i > 0)
+ nodes [ i ].previous = nodes [ i - 1 ];
+ }
+ }
+
+ /**
+ * Returns true if all members in the list are closed.
+ */
+ public boolean isClosed()
+ {
+ if (super.isClosed())
+ return true;
+ for (int i = 0; i < nodes.length; i++)
+ {
+ if (!nodes [ i ].isClosed())
+ return false;
+ }
+ return true;
+ }
+
+ /**
+ * Find the token that could match as the next token in
+ * the token list.
+ *
+ * @return Such token object or null if none is found.
+ */
+ public Object findFreeNode()
+ {
+ Object fn;
+ for (int j = 0; j < nodes.length; j++)
+ {
+ if (!nodes [ j ].isClosed())
+ {
+ fn = nodes [ j ].findFreeNode();
+ if (fn != null)
+ return fn;
+ }
+ }
+ return null;
+ }
+
+ /**
+ * Tries to match this list agains the given token sequence.
+ * @param tokens the sequence of the tokens to match.
+ * @return true if the valid match is found.
+ */
+ public boolean matches(Object[] tokens)
+ {
+ reset();
+
+ Object x;
+ boolean m;
+ boolean matched = false;
+
+ for (int i = 0; i < tokens.length; i++)
+ {
+ matched = false;
+ x = tokens [ i ];
+
+ nodescan:
+ for (int j = 0; j < nodes.length; j++)
+ {
+ if (!nodes [ j ].isClosed())
+ {
+ m = nodes [ j ].performMatch(x);
+
+ if (m)
+ {
+ matched = true;
+ break nodescan;
+ }
+ }
+ }
+ if (!matched)
+ return false;
+ }
+
+ boolean valid = true;
+
+ for (int i = 0; i < nodes.length; i++)
+ {
+ if (!nodes [ i ].valid())
+ valid = false;
+ }
+
+ return valid;
+ }
+
+ /**
+ * The list never closes, despite it is trated as closed
+ * if all members in the list are closed.
+ * @return false.
+ */
+ public boolean mustClose()
+ {
+ return false;
+ }
+
+ /**
+ * Perform a match operation for the single token
+ * against this list.
+ * @param token a token to match.
+ * @return true if the match is found.
+ */
+ public boolean performMatch(Object token)
+ {
+ boolean ok = false;
+ Matching:
+ for (int i = 0; i < nodes.length; i++)
+ {
+ ok = nodes [ i ].performMatch(token);
+
+ if (ok)
+ break Matching;
+ }
+
+ if (ok)
+ matches();
+
+ return ok;
+ }
+
+ /**
+ * Prepeares the list for the next matching operation.
+ */
+ public void reset()
+ {
+ super.reset();
+ for (int i = 0; i < nodes.length; i++)
+ nodes [ i ].reset();
+ }
+
+ /**
+ * Check if the provided token can match as a next token in the
+ * list. In the case of match, the list state changes, moving
+ * current position after the matched token. However if this method
+ * returns a suggested new token to insert before the provided one,
+ * the state of the list does not change.
+ * @return Boolean.TRUE if the match is found,
+ * Boolean.FALSE if the match is not possible and no token can be
+ * inserted to make the match valid. Otherwise, returns the
+ * token object that can be inserted before the last token in the
+ * list, probably (not for sure) making the match valid.
+ * If the object is an instance of Element or TagElement,
+ * it is first ensured that the object flag "omit start" is set.
+ */
+ public Object show(Object x)
+ {
+ boolean m;
+ boolean matched = false;
+
+ nodescan:
+ for (int j = 0; j < nodes.length; j++)
+ {
+ if (!nodes [ j ].isClosed())
+ {
+ m = nodes [ j ].performMatch(x);
+
+ if (m)
+ {
+ matched = true;
+ break nodescan;
+ }
+ else
+ {
+ // For comma operation, only first not closed
+ // node must be tested for a match.
+ // unless it allows matching zero times.
+ if (binary == ',' &&
+ !(nodes [ j ].unary == '?' || nodes [ j ].unary == '*')
+ )
+ break nodescan;
+ }
+ }
+ }
+
+ if (!matched)
+ {
+ // Find and return that would be matched.
+ Object freeNode = findFreeNode();
+ if (freeNode == null)
+ return Boolean.FALSE;
+ else
+ return freeNode;
+ }
+
+ for (int i = 0; i < nodes.length; i++)
+ if (!nodes [ i ].validPreliminary())
+ {
+ return Boolean.FALSE;
+ }
+
+ return Boolean.TRUE;
+ }
+
+ /**
+ * Returns a string representation of the list.
+ * @return String representation, similar to BNF expression.
+ */
+ public String toString()
+ {
+ StringBuffer b = new StringBuffer();
+ b.append(" ( ");
+ for (int i = 0; i < nodes.length; i++)
+ {
+ if (i > 0)
+ b.append(" " + (char) nodes [ i ].binary + " ");
+ b.append(nodes [ i ]);
+ }
+
+ b.append(" )");
+ if (unary != 0)
+ b.append((char) unary);
+ else
+ b.append(' ');
+ return b.toString();
+ }
+
+ /**
+ * Returns true if all memebers in the list are valid.
+ */
+ public boolean valid()
+ {
+ for (int i = 0; i < nodes.length; i++)
+ {
+ if (!nodes [ i ].valid())
+ return false;
+ }
+ return true;
+ }
+
+ /**
+ * Returns true if all memebers in the list are either valid
+ * or unvisited. The unvisited members can become valid after
+ * more tokens will be shown.
+ */
+ public boolean validPreliminary()
+ {
+ if (silenceAllowed())
+ {
+ boolean everVisited = false;
+ for (int i = 0; i < nodes.length; i++)
+ {
+ if (nodes [ i ].visits > 0)
+ {
+ everVisited = true;
+ break;
+ }
+ }
+ if (!everVisited)
+ return true;
+ }
+
+ for (int i = 0; i < nodes.length; i++)
+ {
+ if (!nodes [ i ].validPreliminary())
+ return false;
+ }
+ return true;
+ }
+
+ /**
+ * Closes all members in the list.
+ */
+ protected void close()
+ {
+ super.close();
+ for (int i = 0; i < nodes.length; i++)
+ {
+ nodes [ i ].close();
+ }
+ }
+
+ /**
+ * Compare given token with the token of this node.
+ * If the token represents a <code>list</code>, the call may be
+ * delegeted to the child subnodes.
+ * @param a_token A token to compare.
+ * @return True if the token matches the token of this node.
+ */
+ protected boolean compare(Object a_token)
+ {
+ return performMatch(a_token);
+ }
+}
Added: llvm-gcc-4.2/trunk/libjava/classpath/gnu/javax/swing/text/html/parser/models/noTagModel.java
URL: http://llvm.org/viewvc/llvm-project/llvm-gcc-4.2/trunk/libjava/classpath/gnu/javax/swing/text/html/parser/models/noTagModel.java?rev=43913&view=auto
==============================================================================
--- llvm-gcc-4.2/trunk/libjava/classpath/gnu/javax/swing/text/html/parser/models/noTagModel.java (added)
+++ llvm-gcc-4.2/trunk/libjava/classpath/gnu/javax/swing/text/html/parser/models/noTagModel.java Thu Nov 8 16:56:19 2007
@@ -0,0 +1,75 @@
+/* noTagModel.java --
+ Copyright (C) 2005 Free Software Foundation, Inc.
+
+This file is part of GNU Classpath.
+
+GNU Classpath is free software; you can redistribute it and/or modify
+it under the terms of the GNU General Public License as published by
+the Free Software Foundation; either version 2, or (at your option)
+any later version.
+
+GNU Classpath is distributed in the hope that it will be useful, but
+WITHOUT ANY WARRANTY; without even the implied warranty of
+MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+General Public License for more details.
+
+You should have received a copy of the GNU General Public License
+along with GNU Classpath; see the file COPYING. If not, write to the
+Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA
+02110-1301 USA.
+
+Linking this library statically or dynamically with other modules is
+making a combined work based on this library. Thus, the terms and
+conditions of the GNU General Public License cover the whole
+combination.
+
+As a special exception, the copyright holders of this library give you
+permission to link this library with independent modules to produce an
+executable, regardless of the license terms of these independent
+modules, and to copy and distribute the resulting executable under
+terms of your choice, provided that you also meet, for each linked
+independent module, the terms and conditions of the license of that
+module. An independent module is a module which is not derived from
+or based on this library. If you modify this library, you may extend
+this exception to your version of the library, but you are not
+obligated to do so. If you do not wish to do so, delete this
+exception statement from your version. */
+
+
+package gnu.javax.swing.text.html.parser.models;
+
+import java.io.Serializable;
+
+/**
+ * Disallows a single given tag at the current content level only.
+ * <p>@author Audrius Meskauskas, Lithuania (AudriusA at Bioinformatics.org)</p>
+ */
+public class noTagModel
+ extends node
+ implements Serializable
+{
+ private static final long serialVersionUID = 1;
+ final String[] no;
+
+ public noTagModel(String[] noTag)
+ {
+ super((char) 0, (char) 0, null);
+ no = noTag;
+ }
+
+ public noTagModel(String noTag)
+ {
+ super((char) 0, (char) 0, null);
+ no = new String[] { noTag };
+ }
+
+ public Object show(Object x)
+ {
+ for (int i = 0; i < no.length; i++)
+ {
+ if (x.toString().equalsIgnoreCase(no [ i ]))
+ return Boolean.FALSE;
+ }
+ return Boolean.TRUE;
+ }
+}
Added: llvm-gcc-4.2/trunk/libjava/classpath/gnu/javax/swing/text/html/parser/models/node.java
URL: http://llvm.org/viewvc/llvm-project/llvm-gcc-4.2/trunk/libjava/classpath/gnu/javax/swing/text/html/parser/models/node.java?rev=43913&view=auto
==============================================================================
--- llvm-gcc-4.2/trunk/libjava/classpath/gnu/javax/swing/text/html/parser/models/node.java (added)
+++ llvm-gcc-4.2/trunk/libjava/classpath/gnu/javax/swing/text/html/parser/models/node.java Thu Nov 8 16:56:19 2007
@@ -0,0 +1,337 @@
+/* node.java --
+ Copyright (C) 2005 Free Software Foundation, Inc.
+
+This file is part of GNU Classpath.
+
+GNU Classpath is free software; you can redistribute it and/or modify
+it under the terms of the GNU General Public License as published by
+the Free Software Foundation; either version 2, or (at your option)
+any later version.
+
+GNU Classpath is distributed in the hope that it will be useful, but
+WITHOUT ANY WARRANTY; without even the implied warranty of
+MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+General Public License for more details.
+
+You should have received a copy of the GNU General Public License
+along with GNU Classpath; see the file COPYING. If not, write to the
+Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA
+02110-1301 USA.
+
+Linking this library statically or dynamically with other modules is
+making a combined work based on this library. Thus, the terms and
+conditions of the GNU General Public License cover the whole
+combination.
+
+As a special exception, the copyright holders of this library give you
+permission to link this library with independent modules to produce an
+executable, regardless of the license terms of these independent
+modules, and to copy and distribute the resulting executable under
+terms of your choice, provided that you also meet, for each linked
+independent module, the terms and conditions of the license of that
+module. An independent module is a module which is not derived from
+or based on this library. If you modify this library, you may extend
+this exception to your version of the library, but you are not
+obligated to do so. If you do not wish to do so, delete this
+exception statement from your version. */
+
+
+package gnu.javax.swing.text.html.parser.models;
+
+import java.io.Serializable;
+
+/**
+ * Part of the internal representation of the content model.
+ * @author Audrius Meskauskas, Lithuania (AudriusA at Bioinformatics.org)
+ */
+public class node
+ implements Serializable
+{
+ private static final long serialVersionUID = 1;
+
+ /**
+ * The token to match (can be instance of list).
+ */
+ public Object token;
+
+ /**
+ * True for the node that cannot be visited again.
+ */
+ public boolean _closed;
+
+ /**
+ * The binary operation for this node.
+ */
+ public char binary;
+
+ /**
+ * The unary opeation for this node.
+ */
+ public char unary;
+
+ /**
+ * The number of times the node already was visited.
+ */
+ public int visits;
+
+ /**
+ * The previous node in content model (used for closing nodes).
+ */
+ public node previous;
+
+ /**
+ * Creates a new node.
+ * @param binary_operator The operator, connecting all nodes in the list.
+ * The nodes, connected by the different operators, must be arranged into
+ * the different lists.
+ * @param unary_operator The unary operator for this node or zero if
+ * no such was specified.
+ * @param token The token to match. This can be either a string or
+ * the new instance of the list.
+ * @param a_previous The previous node in the list, null for the first
+ * node. This is used for propagating the closing operation for the
+ * comma delimited list.
+ */
+ public node(char binary_operator, char unary_operator, Object a_token)
+ {
+ if (a_token != null)
+ if (a_token.getClass().equals(node.class))
+ throw new Error("Creating node in node is redundant and ineffective.");
+
+ binary = binary_operator;
+ unary = unary_operator;
+ token = a_token;
+ }
+
+ /**
+ * Checks if this node is in the closed state.
+ * @return True if the node is closed.
+ */
+ public boolean isClosed()
+ {
+ return _closed;
+ }
+
+ /**
+ * Check if closing this node means closing the previous node.
+ */
+ public boolean closePrevious()
+ {
+ return binary == ',';
+ }
+
+ /**
+ * Return the token object if it could match as a next token in
+ * a token list of null if it could not.
+ * @return
+ */
+ public Object findFreeNode()
+ {
+ boolean ok;
+ if (isClosed() || silenceAllowed())
+ return null;
+
+ // Try if the node would stay valid after a one more visit.
+ visits++;
+ ok = valid();
+ visits--;
+
+ if (ok)
+ {
+ if (token instanceof node)
+ return ((node) token).findFreeNode();
+ else
+ return token;
+ }
+ else
+ return null;
+ }
+
+ /**
+ * Check if the current situation is such that the node must be closed
+ * now.
+ */
+ public boolean mustClose()
+ {
+ switch (unary)
+ {
+ case 0 :
+ return true;
+
+ case '*' :
+ return false;
+
+ case '+' :
+ return false;
+
+ case '?' :
+ return visits <= 1;
+
+ default :
+ throw new Error("Invalid unary operation " + unary + " ( '" +
+ (char) unary + "' )"
+ );
+ }
+ }
+
+ /**
+ * Do the match operation with the given token. This sets various
+ * flags.
+ * @param token The token to match.
+ * @return true if the the token matches node, false if it does not match
+ * or if the node is closed.
+ */
+ public boolean performMatch(Object a_token)
+ {
+ if (isClosed())
+ return false;
+
+ boolean matches = compare(a_token);
+ if (matches)
+ matches();
+
+ return matches;
+ }
+
+ /**
+ * Prepares the node for matching against a new list of tokens.
+ */
+ public void reset()
+ {
+ _closed = false;
+ visits = 0;
+ }
+
+ /**
+ * Check if the provided token can match this node.
+ * In the case of match, the node state changes, moving
+ * current position after the matched token. However if this method
+ * returns a suggested new token to insert before the provided one,
+ * the state of the list does not change.
+ * @return Boolean.TRUE if the match is found,
+ * Boolean.FALSE if the match is not possible and no token can be
+ * inserted to make the match valid. Otherwise, returns the
+ * token object that can be inserted before the last token in the
+ * list, probably (not for sure) making the match valid.
+ */
+ public Object show(Object x)
+ {
+ if (compare(x))
+ return performMatch(x) ? Boolean.TRUE : Boolean.FALSE;
+
+ Object recommended = findFreeNode();
+ return recommended != null ? recommended : Boolean.FALSE;
+ }
+
+ /**
+ * Check if it would be a valid case if this node is visited zero times.
+ * Nodes with unary operator * or ? need not be matched to make a
+ * model valid.
+ */
+ public boolean silenceAllowed()
+ {
+ return unary == '?' || unary == '*';
+ }
+
+ /**
+ * Returns a string representation of the list.
+ * @return String representation, similar to BNF expression.
+ */
+ public String toString()
+ {
+ StringBuffer b = new StringBuffer();
+
+ b.append(token);
+ if (unary != 0)
+ b.append((char) unary);
+ else
+ b.append('\'');
+
+ return b.toString();
+ }
+
+ /**
+ * Check if the node state is valid.
+ */
+ public boolean valid()
+ {
+ switch (unary)
+ {
+ case 0 :
+ if (binary == '|')
+ return true;
+ else
+ return visits == 1;
+
+ case '*' :
+ return true;
+
+ case '+' :
+ return visits > 0;
+
+ case '?' :
+ return visits <= 1;
+
+ default :
+ throw new Error("Invalid unary operation " + unary + " ( '" +
+ (char) unary + "' )"
+ );
+ }
+ }
+
+ public boolean validPreliminary()
+ {
+ return visits == 0 || valid();
+ }
+
+ /**
+ * Closes this node and, if closePrevious() returs true, calls close() for
+ * the previous node.
+ */
+ protected void close()
+ {
+ _closed = true;
+ if (previous != null && closePrevious())
+ previous.close();
+ }
+
+ /**
+ * Compare the provided token object with the token object of this node.
+ */
+ protected boolean compare(Object a_token)
+ {
+ if (token instanceof Object[])
+ throw new Error("Invalid token object, probably the 'list' " +
+ "should be used. "
+ );
+
+ if (token instanceof node[])
+ throw new Error("Do not use 'node' for the array of nodes, use 'list'. ");
+
+ if (token instanceof node)
+ {
+ return ((node) token).performMatch(a_token);
+ }
+
+ boolean rt = false;
+
+ if (token == a_token)
+ rt = true;
+ if (token.equals(a_token))
+ rt = true;
+ if (token.toString().equalsIgnoreCase(a_token.toString()))
+ rt = true;
+
+ return rt;
+ }
+
+ /**
+ * Fire the changes that must happen then the token matches this node.
+ */
+ protected void matches()
+ {
+ visits++;
+ if (mustClose())
+ close();
+ }
+}
Added: llvm-gcc-4.2/trunk/libjava/classpath/gnu/javax/swing/text/html/parser/models/package.html
URL: http://llvm.org/viewvc/llvm-project/llvm-gcc-4.2/trunk/libjava/classpath/gnu/javax/swing/text/html/parser/models/package.html?rev=43913&view=auto
==============================================================================
--- llvm-gcc-4.2/trunk/libjava/classpath/gnu/javax/swing/text/html/parser/models/package.html (added)
+++ llvm-gcc-4.2/trunk/libjava/classpath/gnu/javax/swing/text/html/parser/models/package.html Thu Nov 8 16:56:19 2007
@@ -0,0 +1,53 @@
+<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 3.2 Final//EN">
+<!-- package.html - describes classes in javax.swing.text.html.parser package.
+ Copyright (C) 2002 Free Software Foundation, Inc.
+
+This file is part of GNU Classpath.
+
+GNU Classpath is free software; you can redistribute it and/or modify
+it under the terms of the GNU General Public License as published by
+the Free Software Foundation; either version 2, or (at your option)
+any later version.
+
+GNU Classpath is distributed in the hope that it will be useful, but
+WITHOUT ANY WARRANTY; without even the implied warranty of
+MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+General Public License for more details.
+
+You should have received a copy of the GNU General Public License
+along with GNU Classpath; see the file COPYING. If not, write to the
+Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA
+02110-1301 USA.
+
+Linking this library statically or dynamically with other modules is
+making a combined work based on this library. Thus, the terms and
+conditions of the GNU General Public License cover the whole
+combination.
+
+As a special exception, the copyright holders of this library give you
+permission to link this library with independent modules to produce an
+executable, regardless of the license terms of these independent
+modules, and to copy and distribute the resulting executable under
+terms of your choice, provided that you also meet, for each linked
+independent module, the terms and conditions of the license of that
+module. An independent module is a module which is not derived from
+or based on this library. If you modify this library, you may extend
+this exception to your version of the library, but you are not
+obligated to do so. If you do not wish to do so, delete this
+exception statement from your version. -->
+
+<html>
+<head><title>GNU Classpath - gnu.javax.swing.text.html.parser.models</title></head>
+
+<body>
+<p>This package contains classes for working with content models. In this implementation, the
+standardized content model is pre-processed by <code>transformer</code> into an instance of
+<code>node</code>. Node holds a single element of the content model with the optional unary operation.
+The derived class <code>list</code> holds multiple nodes connected by the same binary operation.
+As the members of this <code>list</code> can also be lists itself, these structures support
+the most of required operations. Several cases when the model cannot be expressed using
+BNF syntax are handled providing specialised classes that are also derived from <code>node</code>.
+</p>
+ at author Audrius Meskauskas, Lithuania
+</body>
+</html>
Added: llvm-gcc-4.2/trunk/libjava/classpath/gnu/javax/swing/text/html/parser/models/transformer.java
URL: http://llvm.org/viewvc/llvm-project/llvm-gcc-4.2/trunk/libjava/classpath/gnu/javax/swing/text/html/parser/models/transformer.java?rev=43913&view=auto
==============================================================================
--- llvm-gcc-4.2/trunk/libjava/classpath/gnu/javax/swing/text/html/parser/models/transformer.java (added)
+++ llvm-gcc-4.2/trunk/libjava/classpath/gnu/javax/swing/text/html/parser/models/transformer.java Thu Nov 8 16:56:19 2007
@@ -0,0 +1,201 @@
+/* transformer.java -- Content model transforms.
+ Copyright (C) 2005 Free Software Foundation, Inc.
+
+This file is part of GNU Classpath.
+
+GNU Classpath is free software; you can redistribute it and/or modify
+it under the terms of the GNU General Public License as published by
+the Free Software Foundation; either version 2, or (at your option)
+any later version.
+
+GNU Classpath is distributed in the hope that it will be useful, but
+WITHOUT ANY WARRANTY; without even the implied warranty of
+MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+General Public License for more details.
+
+You should have received a copy of the GNU General Public License
+along with GNU Classpath; see the file COPYING. If not, write to the
+Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA
+02110-1301 USA.
+
+Linking this library statically or dynamically with other modules is
+making a combined work based on this library. Thus, the terms and
+conditions of the GNU General Public License cover the whole
+combination.
+
+As a special exception, the copyright holders of this library give you
+permission to link this library with independent modules to produce an
+executable, regardless of the license terms of these independent
+modules, and to copy and distribute the resulting executable under
+terms of your choice, provided that you also meet, for each linked
+independent module, the terms and conditions of the license of that
+module. An independent module is a module which is not derived from
+or based on this library. If you modify this library, you may extend
+this exception to your version of the library, but you are not
+obligated to do so. If you do not wish to do so, delete this
+exception statement from your version. */
+
+
+package gnu.javax.swing.text.html.parser.models;
+
+import java.io.Serializable;
+
+import javax.swing.text.html.parser.ContentModel;
+import javax.swing.text.html.parser.DTD;
+
+/**
+ * Transforms the standard ContentModel tree into the internal representation,
+ * used in this implementation.
+ * @author Audrius Meskauskas, Lithuania (AudriusA at Bioinformatics.org)
+ */
+public class transformer
+ implements Serializable
+{
+ private static final long serialVersionUID = 1;
+
+ /**
+ * All binary operators.
+ */
+ protected static String binary = "&|,";
+
+ /**
+ * All unary operators.
+ */
+ protected static String unary = "+*?";
+
+ /**
+ * Measure length of the linked list of the content models.
+ * @param c The heading element of the linked list.
+ * @return the length of the list (0 for null 1 if c!=null and c.next==null,
+ * etc.
+ */
+ public static int measureChainLength(ContentModel c)
+ {
+ if (c == null)
+ return 0;
+ else
+ return measureChainLength(c.next) + 1;
+ }
+
+ /**
+ * Transform into internal representation without usind dtd.
+ * This should be used only for testing.
+ */
+ public static node transform(ContentModel c)
+ {
+ return transform(c, null);
+ }
+
+ /**
+ * Transform into internal representation.
+ * @param c a model to transform
+ * @return a transformed model
+ * @throws Error if the model structure contains errors.
+ */
+ public static node transform(ContentModel c, DTD dtd)
+ {
+ // Handle the special cases first.
+ if (c.content instanceof node)
+ return (node) c.content;
+
+ // Do the typical transform.
+ node n;
+
+ /* Case with the single token */
+ if (c.next == null)
+ {
+ n = optionalTransform(c, dtd);
+ }
+ else /* Case with the chain of the multiple tokens. */
+ {
+ node[] l = new node[ measureChainLength(c) ];
+ ContentModel m = c;
+ for (int i = 0; i < l.length; i++)
+ {
+ if (m.content instanceof ContentModel)
+ {
+ ContentModel nested = (ContentModel) m.content;
+ if (nested.next == null &&
+ !(nested.content instanceof ContentModel)
+ )
+ {
+ l [ i ] =
+ new node((char) m.type, (char) nested.type, nested.content);
+ }
+ else
+ {
+ l [ i ] = transform(nested, dtd);
+ }
+ }
+ else
+ l [ i ] = new node((char) 0, (char) 0, m.content);
+ addtype(l [ i ], (char) m.type);
+ m = m.next;
+ }
+
+ if (isBinary(c.type))
+ for (int i = 0; i < l.length; i++)
+ {
+ l [ i ].binary = (char) c.type;
+ }
+
+ n = new list(l);
+ }
+
+ addtype(n, (char) c.type);
+
+ return n;
+ }
+
+ /**
+ * True for binary operator
+ * @param c a character to test
+ * @return true for [ ,&| ], false otherwise.
+ */
+ private static boolean isBinary(int c)
+ {
+ return binary.indexOf((char) c) >= 0;
+ }
+
+ /**
+ * True for unary operator.
+ * @param c a character to test
+ * @return true for [ +?* ], false otherwise.
+ */
+ private static boolean isUnary(int c)
+ {
+ return unary.indexOf((char) c) >= 0;
+ }
+
+ /**
+ * Assign an operation type for the given node.
+ * @param n A node to set the operation to.
+ * @param type Either binary or unary operation, is assigned to the
+ * corresponding field of the node.
+ * @throws error if the operation type is not
+ * representing a valid unary or binary operation.
+ */
+ private static void addtype(node n, char type)
+ {
+ if (isBinary(type))
+ n.binary = type;
+
+ else if (isUnary(type))
+ n.unary = type;
+
+ else if (type != 0)
+ throw new Error("Invalid operation '" + (char) type + "'");
+ }
+
+ private static node optionalTransform(ContentModel c, DTD dtd)
+ {
+ node n;
+ if (c.content instanceof ContentModel)
+ n = transform((ContentModel) c.content, dtd);
+ else
+
+ /* A single token with the specified operation */
+ n = new node((char) 0, (char) 0, c.content);
+ return n;
+ }
+}
Added: llvm-gcc-4.2/trunk/libjava/classpath/gnu/javax/swing/text/html/parser/package.html
URL: http://llvm.org/viewvc/llvm-project/llvm-gcc-4.2/trunk/libjava/classpath/gnu/javax/swing/text/html/parser/package.html?rev=43913&view=auto
==============================================================================
--- llvm-gcc-4.2/trunk/libjava/classpath/gnu/javax/swing/text/html/parser/package.html (added)
+++ llvm-gcc-4.2/trunk/libjava/classpath/gnu/javax/swing/text/html/parser/package.html Thu Nov 8 16:56:19 2007
@@ -0,0 +1,51 @@
+<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 3.2 Final//EN">
+<!-- package.html - describes classes in javax.swing.text.html.parser package.
+ Copyright (C) 2002 Free Software Foundation, Inc.
+
+This file is part of GNU Classpath.
+
+GNU Classpath is free software; you can redistribute it and/or modify
+it under the terms of the GNU General Public License as published by
+the Free Software Foundation; either version 2, or (at your option)
+any later version.
+
+GNU Classpath is distributed in the hope that it will be useful, but
+WITHOUT ANY WARRANTY; without even the implied warranty of
+MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+General Public License for more details.
+
+You should have received a copy of the GNU General Public License
+along with GNU Classpath; see the file COPYING. If not, write to the
+Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA
+02110-1301 USA.
+
+Linking this library statically or dynamically with other modules is
+making a combined work based on this library. Thus, the terms and
+conditions of the GNU General Public License cover the whole
+combination.
+
+As a special exception, the copyright holders of this library give you
+permission to link this library with independent modules to produce an
+executable, regardless of the license terms of these independent
+modules, and to copy and distribute the resulting executable under
+terms of your choice, provided that you also meet, for each linked
+independent module, the terms and conditions of the license of that
+module. An independent module is a module which is not derived from
+or based on this library. If you modify this library, you may extend
+this exception to your version of the library, but you are not
+obligated to do so. If you do not wish to do so, delete this
+exception statement from your version. -->
+
+<html>
+<head><title>GNU Classpath - javax.swing.text.html.parser</title></head>
+
+<body>
+<p>Provides the error tolerant, DTD-driven HTML 4.01 parser.
+The parser that is used in web robots, html content analysers,
+web browsers, web editors and other related applications.
+It should compativle with the older HTML versions, supporting
+obsoleted HTML featues. This package also includes some
+supporting classes.</p>
+ at author Audrius Meskauskas, Lithuania
+</body>
+</html>
Added: llvm-gcc-4.2/trunk/libjava/classpath/gnu/javax/swing/text/html/parser/support/Parser.java
URL: http://llvm.org/viewvc/llvm-project/llvm-gcc-4.2/trunk/libjava/classpath/gnu/javax/swing/text/html/parser/support/Parser.java?rev=43913&view=auto
==============================================================================
--- llvm-gcc-4.2/trunk/libjava/classpath/gnu/javax/swing/text/html/parser/support/Parser.java (added)
+++ llvm-gcc-4.2/trunk/libjava/classpath/gnu/javax/swing/text/html/parser/support/Parser.java Thu Nov 8 16:56:19 2007
@@ -0,0 +1,1486 @@
+/* Parser.java -- HTML parser.
+ Copyright (C) 2005 Free Software Foundation, Inc.
+
+This file is part of GNU Classpath.
+
+GNU Classpath is free software; you can redistribute it and/or modify
+it under the terms of the GNU General Public License as published by
+the Free Software Foundation; either version 2, or (at your option)
+any later version.
+
+GNU Classpath is distributed in the hope that it will be useful, but
+WITHOUT ANY WARRANTY; without even the implied warranty of
+MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+General Public License for more details.
+
+You should have received a copy of the GNU General Public License
+along with GNU Classpath; see the file COPYING. If not, write to the
+Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA
+02110-1301 USA.
+
+Linking this library statically or dynamically with other modules is
+making a combined work based on this library. Thus, the terms and
+conditions of the GNU General Public License cover the whole
+combination.
+
+As a special exception, the copyright holders of this library give you
+permission to link this library with independent modules to produce an
+executable, regardless of the license terms of these independent
+modules, and to copy and distribute the resulting executable under
+terms of your choice, provided that you also meet, for each linked
+independent module, the terms and conditions of the license of that
+module. An independent module is a module which is not derived from
+or based on this library. If you modify this library, you may extend
+this exception to your version of the library, but you are not
+obligated to do so. If you do not wish to do so, delete this
+exception statement from your version. */
+
+
+package gnu.javax.swing.text.html.parser.support;
+
+import gnu.javax.swing.text.html.parser.htmlAttributeSet;
+import gnu.javax.swing.text.html.parser.htmlValidator;
+import gnu.javax.swing.text.html.parser.support.low.Constants;
+import gnu.javax.swing.text.html.parser.support.low.ParseException;
+import gnu.javax.swing.text.html.parser.support.low.ReaderTokenizer;
+import gnu.javax.swing.text.html.parser.support.low.Token;
+import gnu.javax.swing.text.html.parser.support.low.node;
+import gnu.javax.swing.text.html.parser.support.low.pattern;
+
+import java.io.IOException;
+import java.io.Reader;
+
+import java.util.Comparator;
+import java.util.Set;
+import java.util.TreeSet;
+import java.util.Vector;
+
+import javax.swing.text.ChangedCharSetException;
+import javax.swing.text.html.HTML;
+import javax.swing.text.html.parser.AttributeList;
+import javax.swing.text.html.parser.DTD;
+import javax.swing.text.html.parser.DTDConstants;
+import javax.swing.text.html.parser.Element;
+import javax.swing.text.html.parser.Entity;
+import javax.swing.text.html.parser.TagElement;
+
+/**
+ * <p>A simple error-tolerant HTML parser that uses a DTD document
+ * to access data on the possible tokens, arguments and syntax.</p>
+ * <p> The parser reads an HTML content from a Reader and calls various
+ * notifying methods (which should be overridden in a subclass)
+ * when tags or data are encountered.</p>
+ * <p>Some HTML elements need no opening or closing tags. The
+ * task of this parser is to invoke the tag handling methods also when
+ * the tags are not explicitly specified and must be supposed using
+ * information, stored in the DTD.
+ * For example, parsing the document
+ * <p><table><tr><td>a<td>b<td>c</tr> <br>
+ * will invoke exactly the handling methods exactly in the same order
+ * (and with the same parameters) as if parsing the document: <br>
+ * <em><html><head></head><body><table><
+ * tbody></em><tr><td>a<em></td></em><td>b<em>
+ * </td></em><td>c<em></td></tr></em><
+ * <em>/tbody></table></body></html></em></p>
+ * (supposed tags are given in italics). The parser also supports
+ * obsolete elements of HTML syntax.<p>
+ * </p>
+ * @author Audrius Meskauskas, Lithuania (AudriusA at Bioinformatics.org)
+ */
+public class Parser
+ extends ReaderTokenizer
+ implements DTDConstants
+{
+ /**
+ * The current html tag.
+ */
+ public Token hTag = new Token();
+
+ /**
+ * The document template description that will be used to parse the documents.
+ */
+ protected DTD dtd;
+
+ /**
+ * The value of this field determines whether or not the Parser will be
+ * strict in enforcing SGML compatibility. The default value is false,
+ * stating that the parser should do everything to parse and get at least
+ * some information even from the incorrectly written HTML input.
+ */
+ protected boolean strict;
+
+ /**
+ * This fields has positive values in preformatted tags.
+ */
+ protected int preformatted = 0;
+
+ /**
+ * The set of the document tags. This field is used for supporting
+ * markFirstTime().
+ */
+ private Set documentTags =
+ new TreeSet(new Comparator()
+ {
+ public int compare(Object a, Object b)
+ {
+ return ((String) a).compareToIgnoreCase((String) b);
+ }
+ }
+ );
+
+ /**
+ * The buffer to collect the incremental output like text or coment.
+ */
+ private StringBuffer buffer = new StringBuffer();
+
+ /**
+ * The buffer to store the document title.
+ */
+ private StringBuffer title = new StringBuffer();
+
+ /**
+ * The current token.
+ */
+ private Token t;
+
+ /**
+ * True means that the 'title' tag of this document has
+ * already been handled.
+ */
+ private boolean titleHandled;
+
+ /**
+ * True means that the 'title' tag is currently open and all
+ * text is also added to the title buffer.
+ */
+ private boolean titleOpen;
+
+ /**
+ * The attributes of the current HTML element.
+ * Package-private to avoid an accessor method.
+ */
+ htmlAttributeSet attributes =
+ htmlAttributeSet.EMPTY_HTML_ATTRIBUTE_SET;
+
+ /**
+ * The validator, controlling the forcible closing of the tags that
+ * (in accordance to dtd) are not allowed in the current context.
+ */
+ private htmlValidator validator;
+
+ /**
+ * Provides the default values for parameters in the case when these
+ * values are defined in the DTD.
+ */
+ private parameterDefaulter defaulter;
+
+ /**
+ * The text pre-processor for handling line ends and tabs.
+ */
+ private textPreProcessor textProcessor = new textPreProcessor();
+
+ /**
+ * Creates a new Parser that uses the given
+ * {@link javax.swing.text.html.parser.DTD }. The only standard way
+ * to get an instance of DTD is to construct it manually, filling in
+ * all required fields.
+ * @param a_dtd The DTD to use. The parser behaviour after passing null
+ * as an argument is not documented and may vary between implementations.
+ */
+ public Parser(DTD a_dtd)
+ {
+ if (a_dtd == null)
+ dtd = gnu.javax.swing.text.html.parser.HTML_401F.getInstance();
+ else
+ dtd = a_dtd;
+
+ defaulter = new parameterDefaulter(dtd);
+
+ validator =
+ new htmlValidator(dtd)
+ {
+ /**
+ * Handles the error message. This method must be overridden to pass
+ * the message where required.
+ * @param msg The message text.
+ */
+ protected void s_error(String msg)
+ {
+ error(msg);
+ }
+
+ /**
+ * The method is called when the tag validator decides to close the
+ * tag on its own initiative. After reaching the end of stream,
+ * The tag validator closes all unclosed elements that are required
+ * to have the end (closing) tag.
+ *
+ * @param element The tag being fictionally (forcibly) closed.
+ */
+ protected void handleSupposedEndTag(Element tElement)
+ {
+ // The tag is cloned as the original tElement is the
+ // element from the starting tag - may be accidently used
+ // somewhere else.
+ TagElement tag = makeTag(tElement, true);
+ _handleEndTag_remaining(tag);
+ }
+
+ /**
+ * The method is called when the the tag validator decides to open
+ * the new tag on its own initiative. The tags, opened in this
+ * way, are HTML, HEAD and BODY. The attribute set is temporary
+ * assigned to the empty one, the previous value is
+ * restored before return.
+ *
+ * @param element The tag being fictionally (forcibly) closed.
+ */
+ protected void handleSupposedStartTag(Element tElement)
+ {
+ TagElement tag = makeTag(tElement, true);
+ htmlAttributeSet were = attributes;
+ attributes = htmlAttributeSet.EMPTY_HTML_ATTRIBUTE_SET;
+ _handleStartTag(tag);
+ attributes = were;
+ }
+ };
+ }
+
+ /**
+ * Get the attributes of the current tag.
+ * @return The attribute set, representing the attributes of the current tag.
+ */
+ public htmlAttributeSet getAttributes()
+ {
+ return attributes;
+ }
+
+ /**
+ * Invokes the error handler. The default method in this implementation
+ * delegates the call to handleError, also providing the current line.
+ */
+ public void error(String msg)
+ {
+ error(msg, getTokenAhead());
+ }
+
+ public void error(String msg, Token atToken)
+ {
+ if (atToken != null)
+ handleError(atToken.where.beginLine,
+ msg + ": line " + atToken.where.beginLine +
+ ", absolute pos " + atToken.where.startPosition
+ );
+ else
+ handleError(0, msg);
+ }
+
+ /**
+ * Invokes the error handler. The default method in this implementation
+ * delegates the call to error (parm1+": '"+parm2+"'").
+ */
+ public void error(String msg, String invalid)
+ {
+ error(msg + ": '" + invalid + "'");
+ }
+
+ /**
+ * Invokes the error handler. The default method in this implementation
+ * delegates the call to error (parm1+" "+ parm2+" "+ parm3).
+ */
+ public void error(String parm1, String parm2, String parm3)
+ {
+ error(parm1 + " " + parm2 + " " + parm3);
+ }
+
+ /**
+ * Invokes the error handler. The default method in this implementation
+ * delegates the call to error (parm1+" "+ parm2+" "+ parm3+" "+ parm4).
+ */
+ public void error(String parm1, String parm2, String parm3, String parm4)
+ {
+ error(parm1 + " " + parm2 + " " + parm3 + " " + parm4);
+ }
+
+ public void flushAttributes()
+ {
+ }
+
+ /**
+ * Parse the HTML text, calling various methods in response to the
+ * occurence of the corresponding HTML constructions.
+ * @param reader The reader to read the source HTML from.
+ * @throws IOException If the reader throws one.
+ */
+ public synchronized void parse(Reader reader)
+ throws IOException
+ {
+ reset(reader);
+ restart();
+ try
+ {
+ parseDocument();
+ validator.closeAll();
+ }
+ catch (ParseException ex)
+ {
+ if (ex != null)
+ {
+ error("Unable to continue parsing the document", ex.getMessage());
+
+ Throwable cause = ex.getCause();
+ if (cause instanceof IOException)
+ throw (IOException) cause;
+ }
+ }
+ }
+
+ /**
+ * Parses DTD markup declaration. Currently returns null without action.
+ * @return null.
+ * @throws IOException
+ */
+ public String parseDTDMarkup()
+ throws IOException
+ {
+ return null;
+ }
+
+ /**
+ * Parse SGML insertion ( <! ... > ). When the
+ * the SGML insertion is found, this method is called, passing
+ * SGML in the string buffer as a parameter. The default method
+ * returns false without action and can be overridden to
+ * implement user - defined SGML support.
+ * <p>
+ * If you need more information about SGML insertions in HTML documents,
+ * the author suggests to read SGML tutorial on
+ * {@link http://www.w3.org/TR/WD-html40-970708/intro/sgmltut.html}.
+ * We also recommend Goldfarb C.F (1991) <i>The SGML Handbook</i>,
+ * Oxford University Press, 688 p, ISBN: 0198537379.
+ * </p>
+ * @param strBuff
+ * @return true if this is a valid DTD markup declaration.
+ * @throws IOException
+ */
+ public boolean parseMarkupDeclarations(StringBuffer strBuff)
+ throws IOException
+ {
+ return false;
+ }
+
+ /**
+ * Get the first line of the last parsed token.
+ */
+ protected int getCurrentLine()
+ {
+ return hTag.where.beginLine;
+ }
+
+ /**
+ * Read parseable character data, add to buffer.
+ * @param clearBuffer If true, buffer if filled by CDATA section,
+ * otherwise the section is appended to the existing content of the
+ * buffer.
+ *
+ * @throws ParseException
+ */
+ protected void CDATA(boolean clearBuffer)
+ throws ParseException
+ {
+ Token start = hTag = getTokenAhead();
+
+ if (clearBuffer)
+ buffer.setLength(0);
+
+ // Handle expected EOF.
+ if (start.kind == EOF)
+ return;
+
+ read:
+ while (true)
+ {
+ t = getTokenAhead();
+ if (t.kind == EOF)
+ {
+ error("unexpected eof", t);
+ break read;
+ }
+ else if (t.kind == BEGIN)
+ break read;
+ else if (t.kind == Constants.ENTITY)
+ {
+ resolveAndAppendEntity(t);
+ getNextToken();
+ }
+ else
+ {
+ append(t);
+ getNextToken();
+ }
+ }
+ hTag = new Token(start, getTokenAhead(0));
+ if (buffer.length() != 0)
+ _handleText();
+ }
+
+ /**
+ * Process Comment. This method skips till --> without
+ * taking SGML constructs into consideration. The supported SGML
+ * constructs are handled separately.
+ */
+ protected void Comment()
+ throws ParseException
+ {
+ buffer.setLength(0);
+
+ Token start = hTag = mustBe(BEGIN);
+ optional(WS);
+ mustBe(EXCLAMATION);
+ optional(WS);
+ mustBe(DOUBLE_DASH);
+
+ Token t;
+ Token last;
+
+ comment:
+ while (true)
+ {
+ t = getTokenAhead();
+ if (t.kind == EOF)
+ {
+ handleEOFInComment();
+ last = t;
+ break comment;
+ }
+ else if (COMMENT_END.matches(this))
+ {
+ mustBe(DOUBLE_DASH);
+ optional(WS);
+ last = mustBe(END);
+ break comment;
+ }
+ else if (COMMENT_TRIPLEDASH_END.matches(this))
+ {
+ mustBe(DOUBLE_DASH);
+ t = mustBe(NUMTOKEN);
+ if (t.getImage().equals("-"))
+ {
+ append(t);
+ last = mustBe(END);
+ break comment;
+ }
+ else
+ {
+ buffer.append("--");
+ append(t);
+ t = getTokenAhead();
+ }
+ }
+ else
+ /* The lllll-- can match as NUMTOKEN */
+ if ((t.getImage().endsWith("--")) &&
+ (
+ getTokenAhead(1).kind == END ||
+ (getTokenAhead(1).kind == WS && getTokenAhead(2).kind == END)
+ )
+ )
+ {
+ buffer.append(t.getImage().substring(0, t.getImage().length() - 2));
+
+ /* Skip the closing > that we have already checked. */
+ last = mustBe(t.kind);
+ break comment;
+ }
+ else
+ append(t);
+ mustBe(t.kind);
+ }
+ hTag = new Token(start, last);
+ handleComment();
+ }
+
+ /**
+ * Read a script. The text, returned without any changes,
+ * is terminated only by the closing tag SCRIPT.
+ */
+ protected void Script()
+ throws ParseException
+ {
+ Token name;
+
+ Token start = hTag = mustBe(BEGIN);
+ optional(WS);
+
+ name = mustBe(SCRIPT);
+
+ optional(WS);
+
+ restOfTag(false, name, start);
+
+ buffer.setLength(0);
+
+ script:
+ while (!SCRIPT_CLOSE.matches(this))
+ {
+ append(getNextToken());
+ }
+
+ consume(SCRIPT_CLOSE);
+
+ _handleText();
+
+ endTag(false);
+ _handleEndTag(makeTagElement(name.getImage(), false));
+ }
+
+ /**
+ * Process SGML insertion that is not a comment.
+ */
+ protected void Sgml()
+ throws ParseException
+ {
+ if (COMMENT_OPEN.matches(this))
+ Comment();
+ else // skip till ">"
+ {
+ Token start = hTag = mustBe(BEGIN);
+ optional(WS);
+ mustBe(EXCLAMATION);
+
+ buffer.setLength(0);
+ read:
+ while (true)
+ {
+ t = getNextToken();
+ if (t.kind == Constants.ENTITY)
+ {
+ resolveAndAppendEntity(t);
+ }
+ else if (t.kind == EOF)
+ {
+ error("unexpected eof", t);
+ break read;
+ }
+ else if (t.kind == END)
+ break read;
+ else
+ append(t);
+ }
+
+ try
+ {
+ parseMarkupDeclarations(buffer);
+ }
+ catch (IOException ex)
+ {
+ error("Unable to parse SGML insertion: '" + buffer + "'",
+ new Token(start, t)
+ );
+ }
+ }
+ }
+
+ /**
+ * Read a style definition. The text, returned without any changes,
+ * is terminated only by the closing tag STYLE.
+ */
+ protected void Style()
+ throws ParseException
+ {
+ Token name;
+
+ Token start = hTag = mustBe(BEGIN);
+ optional(WS);
+
+ name = mustBe(STYLE);
+
+ optional(WS);
+
+ restOfTag(false, name, start);
+
+ buffer.setLength(0);
+
+ style:
+ while (!STYLE_CLOSE.matches(this))
+ {
+ append(getNextToken());
+ }
+
+ consume(STYLE_CLOSE);
+
+ _handleText();
+
+ endTag(false);
+ _handleEndTag(makeTagElement(name.getImage(), false));
+ }
+
+ /**
+ * Read a html tag.
+ */
+ protected void Tag()
+ throws ParseException
+ {
+ mark(true);
+
+ boolean closing = false;
+ Token name;
+ Token start = hTag = mustBe(BEGIN);
+
+ optional(WS);
+ name = getNextToken();
+ optional(WS);
+
+ if (name.kind == SLASH)
+ {
+ closing = true;
+ name = getNextToken();
+ }
+
+ restOfTag(closing, name, start);
+ }
+
+ /**
+ * A hook, for operations, preceeding call to handleText.
+ * Handle text in a string buffer.
+ * In non - preformatted mode, all line breaks immediately following the
+ * start tag and immediately before an end tag is discarded,
+ * \r, \n and \t are replaced by spaces, multiple space are replaced
+ * by the single one and the result is moved into array,
+ * passing it to handleText().
+ */
+ protected void _handleText()
+ {
+ char[] text;
+
+ if (preformatted > 0)
+ text = textProcessor.preprocessPreformatted(buffer);
+ else
+ text = textProcessor.preprocess(buffer);
+
+ if (text != null && text.length > 0)
+ {
+ TagElement pcdata = new TagElement(dtd.getElement("#pcdata"));
+ attributes = htmlAttributeSet.EMPTY_HTML_ATTRIBUTE_SET;
+ _handleEmptyTag(pcdata);
+
+ handleText(text);
+ if (titleOpen)
+ title.append(text);
+ }
+ }
+
+ /**
+ * Add the image of this token to the buffer.
+ * @param t A token to append.
+ */
+ protected final void append(Token t)
+ {
+ if (t.kind != EOF)
+ t.appendTo(buffer);
+ }
+
+ /**
+ * Consume pattern that must match.
+ * @param p A pattern to consume.
+ */
+ protected final void consume(pattern p)
+ {
+ node n;
+ for (int i = 0; i < p.nodes.length; i++)
+ {
+ n = p.nodes [ i ];
+ if (n.optional)
+ optional(n.kind);
+ else
+ mustBe(n.kind);
+ }
+ }
+
+ /**
+ * The method is called when the HTML end (closing) tag is found or if
+ * the parser concludes that the one should be present in the
+ * current position. The method is called immediatly
+ * before calling the handleEndTag().
+ * @param omitted True if the tag is no actually present in the document,
+ * but is supposed by the parser (like </html> at the end of the
+ * document).
+ */
+ protected void endTag(boolean omitted)
+ {
+ }
+
+ /**
+ * Handle HTML comment. The default method returns without action.
+ * @param comment
+ */
+ protected void handleComment(char[] comment)
+ {
+ }
+
+ /**
+ * This is additionally called in when the HTML content terminates
+ * without closing the HTML comment. This can only happen if the
+ * HTML document contains errors (for example, the closing --;gt is
+ * missing.
+ */
+ protected void handleEOFInComment()
+ {
+ error("Unclosed comment");
+ }
+
+ /**
+ * Handle the tag with no content, like <br>. The method is
+ * called for the elements that, in accordance with the current DTD,
+ * has an empty content.
+ * @param The tag being handled.
+ * @throws javax.swing.text.ChangedCharSetException
+ */
+ protected void handleEmptyTag(TagElement tag)
+ throws javax.swing.text.ChangedCharSetException
+ {
+ }
+
+ /**
+ * The method is called when the HTML closing tag ((like </table>)
+ * is found or if the parser concludes that the one should be present
+ * in the current position.
+ * @param The tag
+ */
+ protected void handleEndTag(TagElement tag)
+ {
+ }
+
+ /* Handle error that has occured in the given line. */
+ protected void handleError(int line, String message)
+ {
+ }
+
+ /**
+ * The method is called when the HTML opening tag ((like <table>)
+ * is found or if the parser concludes that the one should be present
+ * in the current position.
+ * @param The tag
+ */
+ protected void handleStartTag(TagElement tag)
+ {
+ }
+
+ /**
+ * Handle the text section.
+ * <p> For non-preformatted section, the parser replaces
+ * \t, \r and \n by spaces and then multiple spaces
+ * by a single space. Additionaly, all whitespace around
+ * tags is discarded.
+ * </p>
+ * <p> For pre-formatted text (inside TEXAREA and PRE), the parser preserves
+ * all tabs and spaces, but removes <b>one</b> bounding \r, \n or \r\n,
+ * if it is present. Additionally, it replaces each occurence of \r or \r\n
+ * by a single \n.</p>
+ *
+ * @param text A section text.
+ */
+ protected void handleText(char[] text)
+ {
+ }
+
+ /**
+ * Handle HTML <title> tag. This method is invoked when
+ * both title starting and closing tags are already behind.
+ * The passed argument contains the concatenation of all
+ * title text sections.
+ * @param The title text.
+ */
+ protected void handleTitle(char[] title)
+ {
+ }
+
+ /**
+ * Constructs the tag from the given element. In this implementation,
+ * this is defined, but never called.
+ * @return the tag
+ */
+ protected TagElement makeTag(Element element)
+ {
+ return makeTag(element, false);
+ }
+
+ /**
+ * Constructs the tag from the given element.
+ * @param the tag base {@link javax.swing.text.html.parser.Element}
+ * @param isSupposed true if the tag is not actually present in the
+ * html input, but the parser supposes that it should to occur in
+ * the current location.
+ * @return the tag
+ */
+ protected TagElement makeTag(Element element, boolean isSupposed)
+ {
+ return new TagElement(element, isSupposed);
+ }
+
+ /**
+ * This is called when the tag, representing the given element,
+ * occurs first time in the document.
+ * @param element
+ */
+ protected void markFirstTime(Element element)
+ {
+ }
+
+ /**
+ * Consume the token that was checked before and hence MUST be present.
+ * @param kind The kind of token to consume.
+ */
+ protected Token mustBe(int kind)
+ {
+ if (getTokenAhead().kind == kind)
+ return getNextToken();
+ else
+ {
+ String ei = "";
+ if (kind < 1000)
+ ei = " ('" + (char) kind + "') ";
+ throw new AssertionError("The token of kind " + kind + ei +
+ " MUST be here,"
+ );
+ }
+ }
+
+ /**
+ * Handle attribute without value. The default method uses
+ * the only allowed attribute value from DTD.
+ * If the attribute is unknown or allows several values,
+ * the HTML.NULL_ATTRIBUTE_VALUE is used. The attribute with
+ * this value is added to the attribute set.
+ * @param element The name of element.
+ * @param attribute The name of attribute without value.
+ */
+ protected void noValueAttribute(String element, String attribute)
+ {
+ Object value = HTML.NULL_ATTRIBUTE_VALUE;
+
+ Element e = (Element) dtd.elementHash.get(element.toLowerCase());
+ if (e != null)
+ {
+ AttributeList attr = e.getAttribute(attribute);
+ if (attr != null)
+ {
+ Vector values = attr.values;
+ if (values != null && values.size() == 1)
+ value = values.get(0);
+ }
+ }
+ attributes.addAttribute(attribute, value);
+ }
+
+ /**
+ * Consume the optional token, if present.
+ * @param kind The kind of token to consume.
+ */
+ protected Token optional(int kind)
+ {
+ if (getTokenAhead().kind == kind)
+ return getNextToken();
+ else
+ return null;
+ }
+
+ /** Parse the html document. */
+ protected void parseDocument()
+ throws ParseException
+ {
+ while (getTokenAhead().kind != EOF)
+ {
+ advanced = false;
+ if (TAG.matches(this))
+ Tag();
+ else if (COMMENT_OPEN.matches(this))
+ Comment();
+ else if (STYLE_OPEN.matches(this))
+ Style();
+ else if (SCRIPT_OPEN.matches(this))
+ Script();
+ else if (SGML.matches(this))
+ Sgml();
+ else
+ CDATA(true);
+
+ // Surely HTML error, treat as a text.
+ if (!advanced)
+ {
+ Token wrong = getNextToken();
+ error("unexpected '" + wrong.getImage() + "'", wrong);
+ buffer.setLength(0);
+ buffer.append(wrong.getImage());
+ _handleText();
+ }
+ }
+ }
+
+ /**
+ * Read the element attributes, adding them into attribute set.
+ * @param element The element name (needed to access attribute
+ * information in dtd).
+ */
+ protected void readAttributes(String element)
+ {
+ Token name;
+ Token value;
+ Token next;
+ String attrValue;
+
+ attributes = new htmlAttributeSet();
+
+ optional(WS);
+
+ attributeReading:
+ while (getTokenAhead().kind == NUMTOKEN)
+ {
+ name = getNextToken();
+ optional(WS);
+
+ next = getTokenAhead();
+ if (next.kind == EQ)
+ {
+ mustBe(EQ);
+ optional(WS);
+
+ next = getNextToken();
+
+ switch (next.kind)
+ {
+ case QUOT:
+
+ // read "quoted" attribute.
+ buffer.setLength(0);
+ readTillTokenE(QUOT);
+ attrValue = buffer.toString();
+ break;
+
+ case AP:
+
+ // read 'quoted' attribute.
+ buffer.setLength(0);
+ readTillTokenE(AP);
+ attrValue = buffer.toString();
+ break;
+
+ // read unquoted attribute.
+ case NUMTOKEN:
+ value = next;
+ optional(WS);
+
+ // Check maybe the opening quote is missing.
+ next = getTokenAhead();
+ if (bQUOTING.get(next.kind))
+ {
+ hTag = next;
+ error("The value without opening quote is closed with '"
+ + next.getImage() + "'");
+ attrValue = value.getImage();
+ }
+ else if (next.kind == SLASH)
+ // The slash in this context is treated as the ordinary
+ // character, not as a token. The slash may be part of
+ // the unquoted URL.
+ {
+ StringBuffer image = new StringBuffer(value.getImage());
+ while (next.kind == NUMTOKEN || next.kind == SLASH)
+ {
+ image.append(getNextToken().getImage());
+ next = getTokenAhead();
+ }
+ attrValue = image.toString();
+ }
+ else
+ attrValue = value.getImage();
+ break;
+
+ case SLASH:
+ value = next;
+ optional(WS);
+
+ // Check maybe the opening quote is missing.
+ next = getTokenAhead();
+ if (bQUOTING.get(next.kind))
+ {
+ hTag = next;
+ error("The value without opening quote is closed with '"
+ + next.getImage() + "'");
+ attrValue = value.getImage();
+ }
+ else if (next.kind == NUMTOKEN || next.kind == SLASH)
+ // The slash in this context is treated as the ordinary
+ // character, not as a token. The slash may be part of
+ // the unquoted URL.
+ {
+ StringBuffer image = new StringBuffer(value.getImage());
+ while (next.kind == NUMTOKEN || next.kind == SLASH)
+ {
+ image.append(getNextToken().getImage());
+ next = getTokenAhead();
+ }
+ attrValue = image.toString();
+ }
+ else
+ attrValue = value.getImage();
+ break;
+ default:
+ break attributeReading;
+ }
+ attributes.addAttribute(name.getImage(), attrValue);
+ optional(WS);
+ }
+ else
+ // The '=' is missing: attribute without value.
+ {
+ noValueAttribute(element, name.getImage());
+ }
+ }
+ }
+
+ /**
+ * Return string, corresponding the given named entity. The name is passed
+ * with the preceeding &, but without the ending semicolon.
+ */
+ protected String resolveNamedEntity(final String a_tag)
+ {
+ // Discard &
+ if (!a_tag.startsWith("&"))
+ throw new AssertionError("Named entity " + a_tag +
+ " must start witn '&'."
+ );
+
+ String tag = a_tag.substring(1);
+
+ try
+ {
+ Entity entity = dtd.getEntity(tag);
+ if (entity != null)
+ return entity.getString();
+
+ entity = dtd.getEntity(tag.toLowerCase());
+
+ if (entity != null)
+ {
+ error("The name of this entity should be in lowercase", a_tag);
+ return entity.getString();
+ }
+ }
+ catch (IndexOutOfBoundsException ibx)
+ {
+ /* The error will be reported. */
+ }
+
+ error("Unknown named entity", a_tag);
+ return a_tag;
+ }
+
+ /**
+ * Return char, corresponding the given numeric entity.
+ * The name is passed with the preceeding &#, but without
+ * the ending semicolon.
+ */
+ protected char resolveNumericEntity(final String a_tag)
+ {
+ // Discard &#
+ if (!a_tag.startsWith("&#"))
+ throw new AssertionError("Numeric entity " + a_tag +
+ " must start witn '&#'."
+ );
+
+ String tag = a_tag.substring(2);
+
+ try
+ {
+ // Determine the encoding type:
+ char cx = tag.charAt(0);
+ if (cx == 'x' || cx == 'X') // Hexadecimal &#Xnnn;
+
+ return (char) Integer.parseInt(tag.substring(1), 16);
+
+ return (char) Integer.parseInt(tag);
+ }
+
+ /* The error will be reported. */
+ catch (NumberFormatException nex)
+ {
+ }
+ catch (IndexOutOfBoundsException ix)
+ {
+ }
+
+ error("Invalid numeric entity", a_tag);
+ return '?';
+ }
+
+ /**
+ * Reset all fields into the intial default state, preparing the
+ * parset for parsing the next document.
+ */
+ protected void restart()
+ {
+ documentTags.clear();
+ titleHandled = false;
+ titleOpen = false;
+ buffer.setLength(0);
+ title.setLength(0);
+ validator.restart();
+ }
+
+ /**
+ * The method is called when the HTML opening tag ((like <table>)
+ * is found or if the parser concludes that the one should be present
+ * in the current position. The method is called immediately before
+ * calling the handleStartTag.
+ * @param The tag
+ */
+ protected void startTag(TagElement tag)
+ throws ChangedCharSetException
+ {
+ }
+
+ /**
+ * Handle a complete element, when the tag content is already present in the
+ * buffer and both starting and heading tags behind. This is called
+ * in the case when the tag text must not be parsed for the nested
+ * elements (elements STYLE and SCRIPT).
+ */
+ private void _handleCompleteElement(TagElement tag)
+ {
+ _handleStartTag(tag);
+
+ // Suppress inclusion of the SCRIPT ans STYLE texts into the title.
+ HTML.Tag h = tag.getHTMLTag();
+ if (h == HTML.Tag.SCRIPT || h == HTML.Tag.STYLE)
+ {
+ boolean tmp = titleOpen;
+ titleOpen = false;
+ _handleText();
+ titleOpen = tmp;
+ }
+ else
+ _handleText();
+
+ _handleEndTag(tag);
+ }
+
+ /**
+ * A hooks for operations, preceeding call to handleEmptyTag().
+ * Handle the tag with no content, like <br>. As no any
+ * nested tags are expected, the tag validator is not involved.
+ * @param The tag being handled.
+ */
+ private void _handleEmptyTag(TagElement tag)
+ {
+ try
+ {
+ validator.validateTag(tag, attributes);
+ handleEmptyTag(tag);
+ }
+ catch (ChangedCharSetException ex)
+ {
+ error("Changed charset exception:", ex.getMessage());
+ }
+ }
+
+ /**
+ * A hooks for operations, preceeding call to handleEndTag().
+ * The method is called when the HTML closing tag
+ * is found. Calls handleTitle after closing the 'title' tag.
+ * @param The tag
+ */
+ private void _handleEndTag(TagElement tag)
+ {
+ validator.closeTag(tag);
+ _handleEndTag_remaining(tag);
+ }
+
+ /**
+ * Actions that are also required if the closing action was
+ * initiated by the tag validator.
+ * Package-private to avoid an accessor method.
+ */
+ void _handleEndTag_remaining(TagElement tag)
+ {
+ HTML.Tag h = tag.getHTMLTag();
+
+ handleEndTag(tag);
+ endTag(tag.fictional());
+
+ if (h.isPreformatted())
+ preformatted--;
+ if (preformatted < 0)
+ preformatted = 0;
+
+ if (h == HTML.Tag.TITLE)
+ {
+ titleOpen = false;
+ titleHandled = true;
+
+ char[] a = new char[ title.length() ];
+ title.getChars(0, a.length, a, 0);
+ handleTitle(a);
+ }
+ }
+
+ /**
+ * A hooks for operations, preceeding call to handleStartTag().
+ * The method is called when the HTML opening tag ((like <table>)
+ * is found.
+ * Package-private to avoid an accessor method.
+ * @param The tag
+ */
+ void _handleStartTag(TagElement tag)
+ {
+ validator.openTag(tag, attributes);
+ startingTag(tag);
+ handleStartTag(tag);
+
+ HTML.Tag h = tag.getHTMLTag();
+
+ if (h.isPreformatted())
+ preformatted++;
+
+ if (h == HTML.Tag.TITLE)
+ {
+ if (titleHandled)
+ error("Repetetive <TITLE> tag");
+ titleOpen = true;
+ titleHandled = false;
+ }
+ }
+
+ /**
+ * Resume parsing after heavy errors in HTML tag structure.
+ * @throws ParseException
+ */
+ private void forciblyCloseTheTag()
+ throws ParseException
+ {
+ int closeAt = 0;
+ buffer.setLength(0);
+
+ ahead:
+ for (int i = 1; i < 100; i++)
+ {
+ t = getTokenAhead(i - 1);
+ if (t.kind == EOF || t.kind == BEGIN)
+ break ahead;
+ if (t.kind == END)
+ {
+ /* Closing '>' found. */
+ closeAt = i;
+ break ahead;
+ }
+ }
+ if (closeAt > 0)
+ {
+ buffer.append("Ignoring '");
+ for (int i = 1; i <= closeAt; i++)
+ {
+ t = getNextToken();
+ append(t);
+ }
+ buffer.append('\'');
+ error(buffer.toString());
+ }
+ }
+
+ /**
+ * Handle comment in string buffer. You can avoid allocating a char
+ * array each time by processing your comment directly here.
+ */
+ private void handleComment()
+ {
+ char[] a = new char[ buffer.length() ];
+ buffer.getChars(0, a.length, a, 0);
+ handleComment(a);
+ }
+
+ private TagElement makeTagElement(String name, boolean isSupposed)
+ {
+ Element e = (Element) dtd.elementHash.get(name.toLowerCase());
+ if (e == null)
+ {
+ error("Unknown tag <" + name + ">");
+ e = dtd.getElement(name);
+ e.name = name.toUpperCase();
+ e.index = -1;
+ }
+
+ if (!documentTags.contains(e.name))
+ {
+ markFirstTime(e);
+ documentTags.add(e.name);
+ }
+
+ return makeTag(e, isSupposed);
+ }
+
+ /**
+ * Read till the given token, resolving entities. Consume the given
+ * token without adding it to buffer.
+ * @param till The token to read till
+ * @throws ParseException
+ */
+ private void readTillTokenE(int till)
+ throws ParseException
+ {
+ buffer.setLength(0);
+ read:
+ while (true)
+ {
+ t = getNextToken();
+ if (t.kind == Constants.ENTITY)
+ {
+ resolveAndAppendEntity(t);
+ }
+ else if (t.kind == EOF)
+ {
+ error("unexpected eof", t);
+ break read;
+ }
+ else if (t.kind == till)
+ break read;
+ else if (t.kind == WS)
+ {
+ // Processing whitespace in accordance with CDATA rules:
+ String s = t.getImage();
+ char c;
+ for (int i = 0; i < s.length(); i++)
+ {
+ c = s.charAt(i);
+ if (c == '\r')
+ buffer.append(' '); // CR replaced by space
+ else if (c == '\n')
+ ; // LF ignored
+ else if (c == '\t')
+ buffer.append(' '); // Tab replaced by space
+ else
+ buffer.append(c);
+ }
+ }
+ else
+ append(t);
+ }
+ }
+
+ /**
+ * Resolve the entity and append it to the end of buffer.
+ * @param entity
+ */
+ private void resolveAndAppendEntity(Token entity)
+ {
+ switch (entity.category)
+ {
+ case ENTITY_NAMED :
+ buffer.append(resolveNamedEntity(entity.getImage()));
+ break;
+
+ case ENTITY_NUMERIC :
+ buffer.append(resolveNumericEntity(entity.getImage()));
+ break;
+
+ default :
+ throw new AssertionError("Invalid entity category " +
+ entity.category
+ );
+ }
+ }
+
+ /**
+ * Handle the remaining of HTML tags. This is a common end for
+ * TAG, SCRIPT and STYLE.
+ * @param closing True for closing tags ( </TAG> ).
+ * @param name Name of element
+ * @param start Token where element has started
+ * @throws ParseException
+ */
+ private void restOfTag(boolean closing, Token name, Token start)
+ throws ParseException
+ {
+ boolean end = false;
+ Token next;
+
+ optional(WS);
+
+ readAttributes(name.getImage());
+
+ optional(WS);
+
+ next = getTokenAhead();
+ if (next.kind == END)
+ {
+ mustBe(END);
+ end = true;
+ }
+
+ hTag = new Token(start, next);
+
+ attributes.setResolveParent(defaulter.getDefaultParameters(name.getImage()));
+
+ if (!end)
+ {
+ // The tag body contains errors. If additionally the tag
+ // name is not valid, this construction is treated as text.
+ if (dtd.elementHash.get(name.getImage().toLowerCase()) == null &&
+ backupMode
+ )
+ {
+ error("Errors in tag body and unknown tag name. " +
+ "Treating the tag as a text."
+ );
+ reset();
+
+ hTag = mustBe(BEGIN);
+ buffer.setLength(0);
+ buffer.append(hTag.getImage());
+ CDATA(false);
+ return;
+ }
+ else
+ {
+ error("Forcibly closing invalid parameter list");
+ forciblyCloseTheTag();
+ }
+ }
+
+ if (closing)
+ {
+ endTag(false);
+ _handleEndTag(makeTagElement(name.getImage(), false));
+ }
+ else
+ {
+ TagElement te = makeTagElement(name.getImage(), false);
+ if (te.getElement().type == DTDConstants.EMPTY)
+ _handleEmptyTag(te);
+ else
+ _handleStartTag(te);
+ }
+ }
+
+ /**
+ * This should fire additional actions in response to the
+ * ChangedCharSetException. The current implementation
+ * does nothing.
+ * @param tag
+ */
+ private void startingTag(TagElement tag)
+ {
+ try
+ {
+ startTag(tag);
+ }
+ catch (ChangedCharSetException cax)
+ {
+ error("Invalid change of charset");
+ }
+ }
+
+ private void ws_error()
+ {
+ error("Whitespace here is not permitted");
+ }
+}
Added: llvm-gcc-4.2/trunk/libjava/classpath/gnu/javax/swing/text/html/parser/support/gnuStringIntMapper.java
URL: http://llvm.org/viewvc/llvm-project/llvm-gcc-4.2/trunk/libjava/classpath/gnu/javax/swing/text/html/parser/support/gnuStringIntMapper.java?rev=43913&view=auto
==============================================================================
--- llvm-gcc-4.2/trunk/libjava/classpath/gnu/javax/swing/text/html/parser/support/gnuStringIntMapper.java (added)
+++ llvm-gcc-4.2/trunk/libjava/classpath/gnu/javax/swing/text/html/parser/support/gnuStringIntMapper.java Thu Nov 8 16:56:19 2007
@@ -0,0 +1,112 @@
+/* gnuStringIntMapper.java --
+ Copyright (C) 2005 Free Software Foundation, Inc.
+
+This file is part of GNU Classpath.
+
+GNU Classpath is free software; you can redistribute it and/or modify
+it under the terms of the GNU General Public License as published by
+the Free Software Foundation; either version 2, or (at your option)
+any later version.
+
+GNU Classpath is distributed in the hope that it will be useful, but
+WITHOUT ANY WARRANTY; without even the implied warranty of
+MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+General Public License for more details.
+
+You should have received a copy of the GNU General Public License
+along with GNU Classpath; see the file COPYING. If not, write to the
+Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA
+02110-1301 USA.
+
+Linking this library statically or dynamically with other modules is
+making a combined work based on this library. Thus, the terms and
+conditions of the GNU General Public License cover the whole
+combination.
+
+As a special exception, the copyright holders of this library give you
+permission to link this library with independent modules to produce an
+executable, regardless of the license terms of these independent
+modules, and to copy and distribute the resulting executable under
+terms of your choice, provided that you also meet, for each linked
+independent module, the terms and conditions of the license of that
+module. An independent module is a module which is not derived from
+or based on this library. If you modify this library, you may extend
+this exception to your version of the library, but you are not
+obligated to do so. If you do not wish to do so, delete this
+exception statement from your version. */
+
+
+package gnu.javax.swing.text.html.parser.support;
+
+import java.util.HashMap;
+import java.util.Map;
+import java.util.TreeMap;
+
+/**
+ * A helper class, mapping between the strings and they unique integer
+ * identifiers.
+ * @author Audrius Meskauskas, Lithuania (AudriusA at Bioinformatics.org)
+ */
+public abstract class gnuStringIntMapper
+{
+ /**
+ * Maps argument integer values from DTDConstants into they string
+ * names. Initialized on demand.
+ */
+ private Map is_Map;
+
+ /**
+ * Maps argument string names into they integer values from DTDConstants.
+ * Initialized on demand.
+ */
+ private Map si_Map;
+
+ /**
+ * Get string from id or null if no such id is present in the mapper.
+ */
+ public final String get(int id)
+ {
+ if (is_Map == null)
+ createTheMap();
+
+ return (String) is_Map.get(new Integer(id));
+ }
+
+ /** Get id from string or 0 if no such string is present in the mapper. */
+ public final int get(String id)
+ {
+ if (si_Map == null)
+ createTheMap();
+
+ Integer i = (Integer) si_Map.get(id);
+
+ return i != null ? i.intValue() : 0;
+ }
+
+ /**
+ * Create the mapping table for this mapper by adding the required
+ * String/int pairs. The method is invoked
+ * only once for each instance, after the first invocation of the any
+ * form of the <code>get</code> method. Use <code>add</code> to
+ * create a map for a concrete instance.
+ */
+ protected abstract void create();
+
+ /**
+ * Add an id/string pair to this mapper. This is called from
+ * the method <code>create</code> only.
+ */
+ protected void add(String name, int id)
+ {
+ Integer i = new Integer(id);
+ si_Map.put(name, i);
+ is_Map.put(i, name);
+ }
+
+ private void createTheMap()
+ {
+ is_Map = new HashMap();
+ si_Map = new TreeMap();
+ create();
+ }
+}
Added: llvm-gcc-4.2/trunk/libjava/classpath/gnu/javax/swing/text/html/parser/support/low/Buffer.java
URL: http://llvm.org/viewvc/llvm-project/llvm-gcc-4.2/trunk/libjava/classpath/gnu/javax/swing/text/html/parser/support/low/Buffer.java?rev=43913&view=auto
==============================================================================
--- llvm-gcc-4.2/trunk/libjava/classpath/gnu/javax/swing/text/html/parser/support/low/Buffer.java (added)
+++ llvm-gcc-4.2/trunk/libjava/classpath/gnu/javax/swing/text/html/parser/support/low/Buffer.java Thu Nov 8 16:56:19 2007
@@ -0,0 +1,238 @@
+/* Buffer.java --
+ Copyright (C) 2005 Free Software Foundation, Inc.
+
+This file is part of GNU Classpath.
+
+GNU Classpath is free software; you can redistribute it and/or modify
+it under the terms of the GNU General Public License as published by
+the Free Software Foundation; either version 2, or (at your option)
+any later version.
+
+GNU Classpath is distributed in the hope that it will be useful, but
+WITHOUT ANY WARRANTY; without even the implied warranty of
+MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+General Public License for more details.
+
+You should have received a copy of the GNU General Public License
+along with GNU Classpath; see the file COPYING. If not, write to the
+Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA
+02110-1301 USA.
+
+Linking this library statically or dynamically with other modules is
+making a combined work based on this library. Thus, the terms and
+conditions of the GNU General Public License cover the whole
+combination.
+
+As a special exception, the copyright holders of this library give you
+permission to link this library with independent modules to produce an
+executable, regardless of the license terms of these independent
+modules, and to copy and distribute the resulting executable under
+terms of your choice, provided that you also meet, for each linked
+independent module, the terms and conditions of the license of that
+module. An independent module is a module which is not derived from
+or based on this library. If you modify this library, you may extend
+this exception to your version of the library, but you are not
+obligated to do so. If you do not wish to do so, delete this
+exception statement from your version. */
+
+
+package gnu.javax.swing.text.html.parser.support.low;
+
+/**
+ * A string buffer that additionally holds line and absolute postion
+ * information.
+ * @author Audrius Meskauskas, Lithuania (AudriusA at Bioinformatics.org)
+ */
+public class Buffer
+{
+ public static int INITIAL_SIZE = 2048;
+
+ /**
+ * True if the \n symbol has been seen.
+ */
+ public boolean n_seen;
+
+ /**
+ * True if the \r symbol has been seen.
+ */
+ public boolean r_seen;
+ char[] chr = new char[ INITIAL_SIZE ];
+ int[] line = new int[ INITIAL_SIZE ];
+ int[] position = new int[ INITIAL_SIZE ];
+
+ /**
+ * Current line.
+ */
+ int current_line = 0;
+
+ /**
+ * Point to the next free position.
+ */
+ int length;
+
+ public Buffer()
+ {
+ }
+
+ public Buffer(String content)
+ {
+ for (int i = 0; i < content.length(); i++)
+ {
+ append(content.charAt(i), i);
+ }
+ }
+
+ /**
+ * Get the characters into array.
+ * @param srcBegin From, inclusive
+ * @param srcEnd To, exclusive.
+ * @param dst Into
+ * @param dstBegin Offset.
+ */
+ public void getChars(int srcBegin, int srcEnd, char[] dst, int dstBegin)
+ {
+ System.arraycopy(chr, srcBegin, dst, dstBegin, (srcEnd - srcBegin));
+ }
+
+ /**
+ * Return the sequence, used to separate lines in the document.
+ * @return one of \n, \r or \r\n.
+ */
+ public String getEndOfLineSequence()
+ {
+ if (r_seen && n_seen)
+ return "\r\n";
+ else if (r_seen)
+ return "\r";
+ else
+
+ // This also is returned for single-line document.
+ return "\n";
+ }
+
+ /**
+ * Truncate.
+ * @param n The length to truncate till.
+ */
+ public void setLength(int n)
+ {
+ length = n;
+ }
+
+ /**
+ * Get location information for the given region.
+ * @param from Region start, inclusive.
+ * @param to Region end, exclusive.
+ * @return The location, covering the region.
+ */
+ public Location getLocation(int from, int to)
+ {
+ Location l = new Location();
+ l.beginLine = line [ from ];
+ l.endLine = line [ to - 1 ];
+
+ l.startPosition = position [ from ];
+ l.endPosition = position [ to - 1 ] + 1;
+
+ return l;
+ }
+
+ /**
+ * Add the character.
+ * @param c The character.
+ * @param pos The character position in the stream (the line number
+ * is handled internally in the buffer).
+ */
+ public void append(char c, int pos)
+ {
+ if (length >= chr.length)
+ expand();
+ chr [ length ] = c;
+ position [ length ] = pos;
+
+ if (c == '\n')
+ {
+ if (!r_seen)
+ current_line++;
+ n_seen = true;
+ }
+ else if (c == '\r')
+ {
+ current_line++;
+ r_seen = true;
+ }
+
+ line [ length ] = current_line;
+
+ length++;
+ }
+
+ /**
+ * Return char at the given positon.
+ */
+ public char charAt(int i)
+ {
+ return chr [ i ];
+ }
+
+ /**
+ * Delete the range
+ * @param from Start position, inclusive.
+ * @param to End position, exclusive.
+ */
+ public void delete(int from, int to)
+ {
+ int len = to - from;
+ if (len < 1)
+ throw new AssertionError("Deleting " + from + " till " + to);
+
+ int tail = length - to;
+
+ System.arraycopy(chr, to, chr, from, tail);
+ System.arraycopy(position, to, position, from, tail);
+ System.arraycopy(line, to, line, from, tail);
+ length = length - len;
+ }
+
+ /**
+ * Double the buffer size.
+ */
+ public void expand()
+ {
+ int nSize = 2 * chr.length;
+
+ char[] nchr = new char[ nSize ];
+ int[] nposition = new int[ nSize ];
+ int[] nline = new int[ nSize ];
+
+ System.arraycopy(chr, 0, nchr, 0, chr.length);
+ System.arraycopy(position, 0, nposition, 0, position.length);
+ System.arraycopy(line, 0, nline, 0, line.length);
+
+ chr = nchr;
+ position = nposition;
+ line = nline;
+ }
+
+ /**
+ * Return length of the occupied part of the buffer.
+ */
+ public int length()
+ {
+ return length;
+ }
+
+ /**
+ * Prepare for parsing the new document.
+ */
+ public void reset()
+ {
+ setLength(0);
+ r_seen = n_seen = false;
+ }
+
+ public String toString()
+ {
+ return new String(chr, 0, length);
+ }
+}
Added: llvm-gcc-4.2/trunk/libjava/classpath/gnu/javax/swing/text/html/parser/support/low/Constants.java
URL: http://llvm.org/viewvc/llvm-project/llvm-gcc-4.2/trunk/libjava/classpath/gnu/javax/swing/text/html/parser/support/low/Constants.java?rev=43913&view=auto
==============================================================================
--- llvm-gcc-4.2/trunk/libjava/classpath/gnu/javax/swing/text/html/parser/support/low/Constants.java (added)
+++ llvm-gcc-4.2/trunk/libjava/classpath/gnu/javax/swing/text/html/parser/support/low/Constants.java Thu Nov 8 16:56:19 2007
@@ -0,0 +1,422 @@
+/* Constants.java --
+ Copyright (C) 2005 Free Software Foundation, Inc.
+
+This file is part of GNU Classpath.
+
+GNU Classpath is free software; you can redistribute it and/or modify
+it under the terms of the GNU General Public License as published by
+the Free Software Foundation; either version 2, or (at your option)
+any later version.
+
+GNU Classpath is distributed in the hope that it will be useful, but
+WITHOUT ANY WARRANTY; without even the implied warranty of
+MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+General Public License for more details.
+
+You should have received a copy of the GNU General Public License
+along with GNU Classpath; see the file COPYING. If not, write to the
+Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA
+02110-1301 USA.
+
+Linking this library statically or dynamically with other modules is
+making a combined work based on this library. Thus, the terms and
+conditions of the GNU General Public License cover the whole
+combination.
+
+As a special exception, the copyright holders of this library give you
+permission to link this library with independent modules to produce an
+executable, regardless of the license terms of these independent
+modules, and to copy and distribute the resulting executable under
+terms of your choice, provided that you also meet, for each linked
+independent module, the terms and conditions of the license of that
+module. An independent module is a module which is not derived from
+or based on this library. If you modify this library, you may extend
+this exception to your version of the library, but you are not
+obligated to do so. If you do not wish to do so, delete this
+exception statement from your version. */
+
+
+package gnu.javax.swing.text.html.parser.support.low;
+
+import java.util.BitSet;
+
+/**
+ * The parser constants and operations, directly related to the parser
+ * constants.
+ * @author Audrius Meskauskas, Lithuania (AudriusA at Bioinformatics.org)
+ */
+public class Constants
+{
+ /* Single character tokens are reflected into they ASCII codes. */
+
+ /**
+ * Start of HTML token.
+ */
+ public static final int BEGIN = '<';
+
+ /**
+ * End of HTML token.
+ */
+ public static final int END = '>';
+
+ /**
+ * Exclamation (indicates SGML or comment).
+ */
+ public static final int EXCLAMATION = '!';
+
+ /**
+ * Slash (indicates closing tag).
+ */
+ public static final int SLASH = '/';
+
+ /**
+ * Equals sign.
+ */
+ public static final int EQ = '=';
+
+ /**
+ * Quoting sign.
+ */
+ public static final int AP = '\'';
+
+ /**
+ * Quoting sign.
+ */
+ public static final int QUOT = '"';
+
+ /* The numbers of other tokens start outside the ascii space. */
+ /* String tokens */
+
+ /**
+ * Double dash (--)
+ */
+ public static final int DOUBLE_DASH = 1000;
+
+ /**
+ * The STYLE tag (needs special handling).
+ */
+ public static final int STYLE = 1001;
+
+ /**
+ * The SCRIPT tag (needs special handling).
+ */
+ public static final int SCRIPT = 1002;
+
+ /* Pattern tokens */
+
+ /**
+ * HTML whitespace.
+ */
+ public static final int WS = 1003;
+
+ /**
+ * Named or numeric entity,
+ */
+ public static final int ENTITY = 1004;
+
+ /**
+ * Sequence of valid name characters (can start from digit).
+ */
+ public static final int NUMTOKEN = 1005;
+
+ /* Complex tokens */
+
+ /**
+ * Comment opening sequence.
+ */
+ public static final pattern COMMENT_OPEN =
+ new pattern(new node[]
+ {
+ new node(BEGIN), new node(WS, true), new node(EXCLAMATION),
+ new node(WS, true), new node(DOUBLE_DASH),
+ }
+ );
+
+ /**
+ * Comment closing sequence
+ */
+ public static final pattern COMMENT_END =
+ new pattern(new node[]
+ {
+ new node(DOUBLE_DASH), new node(WS, true), new node(END)
+ }
+ );
+
+ /**
+ * Special case ---> (also is treated as end of comment).
+ */
+ public static final pattern COMMENT_TRIPLEDASH_END =
+ new pattern(new node[]
+ {
+ new node(DOUBLE_DASH), new node(NUMTOKEN), new node(END)
+ }
+ );
+
+ /**
+ * STYLE element heading pattern.
+ */
+ public static final pattern STYLE_OPEN =
+ new pattern(new node[] { new node(BEGIN), new node(WS, true), new node(STYLE) });
+
+ /**
+ * SCRIPT element heading pattern.
+ */
+ public static final pattern SCRIPT_OPEN =
+ new pattern(new node[] { new node(BEGIN), new node(WS, true), new node(SCRIPT) });
+
+ /**
+ * SGML element heading pattern.
+ */
+ public static final pattern SGML =
+ new pattern(new node[]
+ {
+ new node(BEGIN), new node(WS, true), new node(EXCLAMATION)
+ }
+ );
+
+ /**
+ * SCRIPT element closing pattern.
+ */
+ public static final pattern SCRIPT_CLOSE =
+ new pattern(new node[]
+ {
+ new node(BEGIN), new node(WS, true), new node(SLASH),
+ new node(WS, true), new node(SCRIPT), new node(WS, true),
+ new node(END)
+ }
+ );
+
+ /**
+ * STYLE element closing pattern.
+ */
+ public static final pattern STYLE_CLOSE =
+ new pattern(new node[]
+ {
+ new node(BEGIN), new node(WS, true), new node(SLASH),
+ new node(WS, true), new node(STYLE), new node(WS, true),
+ new node(END)
+ }
+ );
+
+ /**
+ * Ordinary HTML tag heading pattern.
+ */
+ public static final pattern TAG =
+ new pattern(new node[]
+ {
+ new node(BEGIN), new node(WS, true), new node(SLASH, true),
+ new node(WS, true), new node(NUMTOKEN)
+ }
+ );
+
+ /* Special tokens */
+
+ /**
+ * All other tokens.
+ */
+ public static final int OTHER = 1999;
+
+ /**
+ * The UNICODE "end of text" control code
+ */
+ static final char ETX = 3;
+
+ /**
+ * End of file.
+ */
+ public static final int EOF = ETX;
+
+ /* Character categories */
+
+ /**
+ * All single char tokens.
+ */
+ public static final BitSet bSINGLE_CHAR_TOKEN = new BitSet();
+
+ /**
+ * Non letters and non numbers, allowed in HTML names.
+ */
+ public static final BitSet bSPECIAL = new BitSet();
+
+ /**
+ * All letters, used in HTML names.
+ */
+ public static final BitSet bLETTER = new BitSet();
+
+ /**
+ * Digits.
+ */
+ public static final BitSet bDIGIT = new BitSet();
+
+ /**
+ * Both line breaks.
+ */
+ public static final BitSet bLINEBREAK = new BitSet();
+
+ /**
+ * All whitespace.
+ */
+ public static final BitSet bWHITESPACE = new BitSet();
+
+ /**
+ * Both quoting characters.
+ */
+ public static final BitSet bQUOTING = new BitSet();
+
+ /**
+ * Valid name characters.
+ */
+ public static final BitSet bNAME = new BitSet();
+
+ /* Entity subcategories */
+
+ /**
+ * Named entity.
+ */
+ public static final int ENTITY_NAMED = 1;
+
+ /**
+ * Numeric entity.
+ */
+ public static final int ENTITY_NUMERIC = 2;
+
+ static
+ {
+ bQUOTING.set(AP);
+ bQUOTING.set(QUOT);
+
+ bSINGLE_CHAR_TOKEN.set(BEGIN);
+ bSINGLE_CHAR_TOKEN.set(END);
+ bSINGLE_CHAR_TOKEN.set(EXCLAMATION);
+ bSINGLE_CHAR_TOKEN.set(SLASH);
+ bSINGLE_CHAR_TOKEN.set(EQ);
+ bSINGLE_CHAR_TOKEN.set(EOF);
+
+ bSINGLE_CHAR_TOKEN.or(bQUOTING);
+
+ bLINEBREAK.set('\r');
+ bLINEBREAK.set('\n');
+
+ bWHITESPACE.set(' ');
+ bWHITESPACE.set('\t');
+ bWHITESPACE.set(0xC);
+ bWHITESPACE.or(bLINEBREAK);
+
+ for (char i = '0'; i <= '9'; i++)
+ {
+ bDIGIT.set(i);
+ }
+
+ for (char i = 'a'; i <= 'z'; i++)
+ {
+ bLETTER.set(i);
+ }
+
+ for (char i = 'A'; i <= 'Z'; i++)
+ {
+ bLETTER.set(i);
+ }
+
+ bSPECIAL.set('-');
+ bSPECIAL.set('_');
+ bSPECIAL.set(':');
+ bSPECIAL.set('.');
+
+ bNAME.or(bLETTER);
+ bNAME.or(bDIGIT);
+ bNAME.or(bSPECIAL);
+ }
+
+ /**
+ * Verifies if one of the tokens matches the end of string
+ * buffer. The last character in the string buffer is the
+ * "future character", some tokens needs to verify it the
+ * token does not continue "towards the future". If the token
+ * matches, it matches till "pre-last" character in the buffer.
+ * @param b
+ * @return
+ */
+ public Token endMatches(Buffer b)
+ {
+ if (b.length() < 2)
+ return null;
+
+ int p = b.length() - 2;
+
+ if (b.length() > 2 && b.charAt(p) == '-' && b.charAt(p - 1) == '-')
+ return new Token(DOUBLE_DASH, "--", b.getLocation(p - 1, p + 1));
+
+ char last = b.charAt(p);
+
+ if (bSINGLE_CHAR_TOKEN.get(last))
+ return new Token(last, last, b.getLocation(p, p + 1));
+
+ char future = b.charAt(p + 1);
+
+ // Check for numtokens, script and style:
+ if (bNAME.get(last) && !bNAME.get(future))
+ {
+ // Scan the history up:
+ int u = p - 1;
+ while (u >= 0 && bNAME.get(b.charAt(u)))
+ u--;
+ u++;
+
+ char[] token = new char[ p - u + 1 ];
+
+ // Found a numtoken
+ b.getChars(u, p + 1, token, 0);
+
+ // Verify for the built-in tokens:
+ String e = new String(token);
+
+ // found the entity reference
+ if (u > 0 && b.charAt(u - 1) == '&')
+ {
+ // The subsequent semicolon may be the part of the token
+ // as well. The semicolon must be ignored. This must be
+ // handled elsewhere.
+ return new Token(ENTITY, ENTITY_NAMED, "&" + e,
+ b.getLocation(u - 1, p + 1)
+ );
+ }
+
+ // found the numeric entity reference
+ if (u > 1 && b.charAt(u - 1) == '#' && b.charAt(u - 2) == '&')
+ {
+ // The subsequent semicolon may be the part of the token
+ // as well. The semicolon must be ignored. This must be
+ // handled elsewhere.
+ return new Token(ENTITY, ENTITY_NUMERIC, "&#" + e,
+ b.getLocation(u - 2, p + 2)
+ );
+ }
+
+ Location le = b.getLocation(u, p + 1);
+
+ if (e.equalsIgnoreCase("SCRIPT"))
+ return new Token(SCRIPT, e, le);
+ else if (e.equalsIgnoreCase("STYLE"))
+ return new Token(STYLE, e, le);
+ else
+ return new Token(NUMTOKEN, e, le);
+ }
+
+ // Check for whitespace
+ if (bWHITESPACE.get(last) && !bWHITESPACE.get(future))
+ {
+ // Scan the history up:
+ int u = p - 1;
+ while (u >= 0 && bWHITESPACE.get(b.charAt(u)))
+ u--;
+ u++;
+
+ char[] token = new char[ p - u + 1 ];
+ b.getChars(u, p + 1, token, 0);
+
+ return new Token(WS, new String(token), b.getLocation(u, p + 1));
+ }
+
+ return null;
+ }
+}
Added: llvm-gcc-4.2/trunk/libjava/classpath/gnu/javax/swing/text/html/parser/support/low/Location.java
URL: http://llvm.org/viewvc/llvm-project/llvm-gcc-4.2/trunk/libjava/classpath/gnu/javax/swing/text/html/parser/support/low/Location.java?rev=43913&view=auto
==============================================================================
--- llvm-gcc-4.2/trunk/libjava/classpath/gnu/javax/swing/text/html/parser/support/low/Location.java (added)
+++ llvm-gcc-4.2/trunk/libjava/classpath/gnu/javax/swing/text/html/parser/support/low/Location.java Thu Nov 8 16:56:19 2007
@@ -0,0 +1,83 @@
+/* Location.java --
+ Copyright (C) 2005 Free Software Foundation, Inc.
+
+This file is part of GNU Classpath.
+
+GNU Classpath is free software; you can redistribute it and/or modify
+it under the terms of the GNU General Public License as published by
+the Free Software Foundation; either version 2, or (at your option)
+any later version.
+
+GNU Classpath is distributed in the hope that it will be useful, but
+WITHOUT ANY WARRANTY; without even the implied warranty of
+MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+General Public License for more details.
+
+You should have received a copy of the GNU General Public License
+along with GNU Classpath; see the file COPYING. If not, write to the
+Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA
+02110-1301 USA.
+
+Linking this library statically or dynamically with other modules is
+making a combined work based on this library. Thus, the terms and
+conditions of the GNU General Public License cover the whole
+combination.
+
+As a special exception, the copyright holders of this library give you
+permission to link this library with independent modules to produce an
+executable, regardless of the license terms of these independent
+modules, and to copy and distribute the resulting executable under
+terms of your choice, provided that you also meet, for each linked
+independent module, the terms and conditions of the license of that
+module. An independent module is a module which is not derived from
+or based on this library. If you modify this library, you may extend
+this exception to your version of the library, but you are not
+obligated to do so. If you do not wish to do so, delete this
+exception statement from your version. */
+
+
+package gnu.javax.swing.text.html.parser.support.low;
+
+/**
+ * Defines a region in the text: its bounding positions and the line number.
+ * @author Audrius Meskauskas, Lithuania (AudriusA at Bioinformatics.org)
+ */
+public class Location
+{
+ /**
+ * The line number, where the token starts.
+ */
+ public int beginLine;
+
+ /**
+ * The line, where the token ends.
+ */
+ public int endLine;
+
+ /**
+ * The absolute token end position in the input stream,
+ * exclusive.
+ */
+ public int endPosition;
+
+ /**
+ * The absolute token start position in the input stream,
+ * inclusive.
+ */
+ public int startPosition;
+
+ public Location()
+ {
+ }
+
+ /**
+ * Special case, used to mark EOF.
+ * @param p The total stream length.
+ */
+ public Location(int p)
+ {
+ startPosition = p;
+ endPosition = p + 1;
+ beginLine = endLine = -1;
+ }
+}
Added: llvm-gcc-4.2/trunk/libjava/classpath/gnu/javax/swing/text/html/parser/support/low/ParseException.java
URL: http://llvm.org/viewvc/llvm-project/llvm-gcc-4.2/trunk/libjava/classpath/gnu/javax/swing/text/html/parser/support/low/ParseException.java?rev=43913&view=auto
==============================================================================
--- llvm-gcc-4.2/trunk/libjava/classpath/gnu/javax/swing/text/html/parser/support/low/ParseException.java (added)
+++ llvm-gcc-4.2/trunk/libjava/classpath/gnu/javax/swing/text/html/parser/support/low/ParseException.java Thu Nov 8 16:56:19 2007
@@ -0,0 +1,51 @@
+/* ParseException.java --
+ Copyright (C) 2005 Free Software Foundation, Inc.
+
+This file is part of GNU Classpath.
+
+GNU Classpath is free software; you can redistribute it and/or modify
+it under the terms of the GNU General Public License as published by
+the Free Software Foundation; either version 2, or (at your option)
+any later version.
+
+GNU Classpath is distributed in the hope that it will be useful, but
+WITHOUT ANY WARRANTY; without even the implied warranty of
+MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+General Public License for more details.
+
+You should have received a copy of the GNU General Public License
+along with GNU Classpath; see the file COPYING. If not, write to the
+Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA
+02110-1301 USA.
+
+Linking this library statically or dynamically with other modules is
+making a combined work based on this library. Thus, the terms and
+conditions of the GNU General Public License cover the whole
+combination.
+
+As a special exception, the copyright holders of this library give you
+permission to link this library with independent modules to produce an
+executable, regardless of the license terms of these independent
+modules, and to copy and distribute the resulting executable under
+terms of your choice, provided that you also meet, for each linked
+independent module, the terms and conditions of the license of that
+module. An independent module is a module which is not derived from
+or based on this library. If you modify this library, you may extend
+this exception to your version of the library, but you are not
+obligated to do so. If you do not wish to do so, delete this
+exception statement from your version. */
+
+
+package gnu.javax.swing.text.html.parser.support.low;
+
+/**
+ * This can be thrown from various parsing methods.
+ */
+public class ParseException
+ extends RuntimeException
+{
+ public ParseException(String s, Throwable cause)
+ {
+ super(s, cause);
+ }
+}
Added: llvm-gcc-4.2/trunk/libjava/classpath/gnu/javax/swing/text/html/parser/support/low/Queue.java
URL: http://llvm.org/viewvc/llvm-project/llvm-gcc-4.2/trunk/libjava/classpath/gnu/javax/swing/text/html/parser/support/low/Queue.java?rev=43913&view=auto
==============================================================================
--- llvm-gcc-4.2/trunk/libjava/classpath/gnu/javax/swing/text/html/parser/support/low/Queue.java (added)
+++ llvm-gcc-4.2/trunk/libjava/classpath/gnu/javax/swing/text/html/parser/support/low/Queue.java Thu Nov 8 16:56:19 2007
@@ -0,0 +1,142 @@
+/* Queue.java -- a token queue.
+ Copyright (C) 2005 Free Software Foundation, Inc.
+
+This file is part of GNU Classpath.
+
+GNU Classpath is free software; you can redistribute it and/or modify
+it under the terms of the GNU General Public License as published by
+the Free Software Foundation; either version 2, or (at your option)
+any later version.
+
+GNU Classpath is distributed in the hope that it will be useful, but
+WITHOUT ANY WARRANTY; without even the implied warranty of
+MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+General Public License for more details.
+
+You should have received a copy of the GNU General Public License
+along with GNU Classpath; see the file COPYING. If not, write to the
+Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA
+02110-1301 USA.
+
+Linking this library statically or dynamically with other modules is
+making a combined work based on this library. Thus, the terms and
+conditions of the GNU General Public License cover the whole
+combination.
+
+As a special exception, the copyright holders of this library give you
+permission to link this library with independent modules to produce an
+executable, regardless of the license terms of these independent
+modules, and to copy and distribute the resulting executable under
+terms of your choice, provided that you also meet, for each linked
+independent module, the terms and conditions of the license of that
+module. An independent module is a module which is not derived from
+or based on this library. If you modify this library, you may extend
+this exception to your version of the library, but you are not
+obligated to do so. If you do not wish to do so, delete this
+exception statement from your version. */
+
+
+package gnu.javax.swing.text.html.parser.support.low;
+
+import java.util.Arrays;
+
+/**
+ * A token queue.
+ * @author Audrius Meskauskas, Lithuania (AudriusA at Bioinformatics.org)
+ */
+public class Queue
+{
+ Token[] m = new Token[ 64 ];
+ int a = 0;
+ int b = 0;
+
+ /**
+ * True for the empty queue.
+ */
+ public boolean isEmpty()
+ {
+ return size() == 0;
+ }
+
+ /**
+ * Add this trace to the end of the queue.
+ */
+ public void add(Token u)
+ {
+ if (a < m.length)
+ {
+ m [ a ] = u;
+ a++;
+ }
+ else // The end of array has been reached.
+ {
+ if (b > 0) // If some elements were deleted from the start of the queue, shift.
+ {
+ int d = b;
+ System.arraycopy(m, b, m, 0, a - b);
+ b = b - d;
+ a = a - d;
+ m [ a ] = u;
+ a++;
+ }
+ else // Enlarge the queue, doubling the size.
+ {
+ int n = m.length * 2;
+ Token[] nm = new Token[ 2 * n ];
+ System.arraycopy(m, 0, nm, 0, m.length);
+ Arrays.fill(m, null);
+
+ nm [ a ] = u;
+ m = nm;
+ a++;
+ }
+ }
+ }
+
+ /**
+ * Clear the queue.
+ */
+ public void clear()
+ {
+ a = b = 0;
+ Arrays.fill(m, null);
+ }
+
+ /**
+ * Read the value ahead. 0 is the value that will be returned with
+ * the following next. This method does not remove values from the
+ * queue. To test if there is enough tokens in the queue, size() must
+ * be checked before calling this method.
+ */
+ public Token get(int ahead)
+ {
+ int p = b + ahead;
+ if (p < a)
+ return m [ p ];
+ else
+ throw new ArrayIndexOutOfBoundsException("Not enough tokens");
+ }
+
+ /**
+ * Read the oldest value from the queue and remove this value from
+ * the queue.
+ */
+ public Token next()
+ {
+ if (a == b)
+ throw new ArrayIndexOutOfBoundsException("queue empty");
+
+ Token r = m [ b ];
+ m [ b ] = null;
+ b++;
+ return r;
+ }
+
+ /**
+ * Size of the queue.
+ */
+ public int size()
+ {
+ return a - b;
+ }
+}
Added: llvm-gcc-4.2/trunk/libjava/classpath/gnu/javax/swing/text/html/parser/support/low/ReaderTokenizer.java
URL: http://llvm.org/viewvc/llvm-project/llvm-gcc-4.2/trunk/libjava/classpath/gnu/javax/swing/text/html/parser/support/low/ReaderTokenizer.java?rev=43913&view=auto
==============================================================================
--- llvm-gcc-4.2/trunk/libjava/classpath/gnu/javax/swing/text/html/parser/support/low/ReaderTokenizer.java (added)
+++ llvm-gcc-4.2/trunk/libjava/classpath/gnu/javax/swing/text/html/parser/support/low/ReaderTokenizer.java Thu Nov 8 16:56:19 2007
@@ -0,0 +1,374 @@
+/* ReaderTokenizer.java -- splits the input char sequence int tokens.
+ Copyright (C) 2005 Free Software Foundation, Inc.
+
+This file is part of GNU Classpath.
+
+GNU Classpath is free software; you can redistribute it and/or modify
+it under the terms of the GNU General Public License as published by
+the Free Software Foundation; either version 2, or (at your option)
+any later version.
+
+GNU Classpath is distributed in the hope that it will be useful, but
+WITHOUT ANY WARRANTY; without even the implied warranty of
+MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+General Public License for more details.
+
+You should have received a copy of the GNU General Public License
+along with GNU Classpath; see the file COPYING. If not, write to the
+Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA
+02110-1301 USA.
+
+Linking this library statically or dynamically with other modules is
+making a combined work based on this library. Thus, the terms and
+conditions of the GNU General Public License cover the whole
+combination.
+
+As a special exception, the copyright holders of this library give you
+permission to link this library with independent modules to produce an
+executable, regardless of the license terms of these independent
+modules, and to copy and distribute the resulting executable under
+terms of your choice, provided that you also meet, for each linked
+independent module, the terms and conditions of the license of that
+module. An independent module is a module which is not derived from
+or based on this library. If you modify this library, you may extend
+this exception to your version of the library, but you are not
+obligated to do so. If you do not wish to do so, delete this
+exception statement from your version. */
+
+
+package gnu.javax.swing.text.html.parser.support.low;
+
+import java.io.IOException;
+import java.io.Reader;
+
+/**
+ * Reader splits the input char sequence into tokens.
+ * @author Audrius Meskauskas, Lithuania (AudriusA at Bioinformatics.org)
+ */
+public class ReaderTokenizer
+ extends Constants
+{
+ /**
+ * This is set to true each time the getNextToken is called.
+ * Used in preventing loops when all patterns refuse to accept
+ * the invalid input.
+ */
+ protected boolean advanced;
+
+ /**
+ * If true, the returned tokens are also placed in the backup
+ * queue.
+ */
+ protected boolean backupMode;
+
+ /**
+ * The buffer to read document into.
+ */
+ Buffer buffer = new Buffer();
+
+ /**
+ * The queue for supporting mark().
+ */
+ Queue backup = new Queue();
+
+ /**
+ * The queue of found tokens.
+ */
+ Queue queue = new Queue();
+
+ /**
+ * The reader to read the document from.
+ */
+ Reader reader;
+
+ /**
+ * Array of char tokens
+ */
+ char[] charTokens;
+
+ /**
+ * Array of string tokens.
+ */
+ String[] stringTokens;
+
+ /**
+ * The current reader position.
+ */
+ int readerPosition = -1;
+
+ /**
+ * Creates a new ReaderTokenizer. The reset(...) method must be
+ * subsequently called to set the reader.
+ */
+ public ReaderTokenizer()
+ {
+ }
+
+ /**
+ * Return the sequence, used to separate lines in the document.
+ * @return one of \n, \r or \r\n.
+ */
+ public String getEndOfLineSequence()
+ {
+ return buffer.getEndOfLineSequence();
+ }
+
+ /**
+ * Get the next token.
+ * @return
+ */
+ public Token getNextToken()
+ {
+ Token rt;
+ advanced = true;
+ try
+ {
+ if (queue.isEmpty())
+ read(1);
+
+ if (!queue.isEmpty())
+ rt = queue.next();
+ else
+ rt = new Token(EOF, new Location(readerPosition));
+ }
+ catch (IOException ex)
+ {
+ throw new ParseException("IO Exception", ex);
+ }
+ if (backupMode)
+ backup.add(rt);
+ return rt;
+ }
+
+ /**
+ * Get a token, lying the given number of tokens
+ * ahead. getToken(0) will return the same token,
+ * what would be returned by getNextToken().
+ * getToken(..) does change the current position
+ * in the input stream. If the end of stream is
+ * reached, the EOF token is always returned.
+ */
+ public Token getTokenAhead(int ahead)
+ {
+ try
+ {
+ read(ahead - queue.size() + 1);
+ return queue.size() >= ahead ? queue.get(ahead) : eofToken();
+ }
+ catch (IOException ex)
+ {
+ throw new ParseException("IO Exception", ex);
+ }
+ }
+
+ /**
+ * Get a token, bein immediatley ahead.
+ * If the end of stream is
+ * reached, the EOF token is always returned.
+ * The method is equivalent calling getTokenAhead(0).
+ */
+ public Token getTokenAhead()
+ {
+ try
+ {
+ if (queue.isEmpty())
+ read(1);
+ if (!queue.isEmpty())
+ return queue.get(0);
+ else
+ return eofToken();
+ }
+ catch (IOException ex)
+ {
+ throw new ParseException("IO Exception", ex);
+ }
+ }
+
+ /**
+ * Invokes the error handler.
+ */
+ public void error(String msg, Token at)
+ {
+ System.out.println(msg);
+ }
+
+ /**
+ * Turns the backup mode on or off.
+ * It is possible to return where the mark(true) was last called
+ * by calling reset().
+ * @param mode True if it is required to save tokens, making
+ * returning to the current point possible.
+ */
+ public void mark(boolean mode)
+ {
+ backup.clear();
+ backupMode = mode;
+ }
+
+ /**
+ * Prepare for new parsing from the given stream.
+ * @param a_reader A reader to parse from.
+ */
+ public void reset(Reader a_reader)
+ {
+ reader = a_reader;
+ readerPosition = -1;
+ buffer.reset();
+ queue.clear();
+ }
+
+ /**
+ * Reset the internal cursor to the position where the mark()
+ * was last time called. Switches the backup mode off.
+ */
+ public void reset()
+ {
+ if (!backupMode)
+ throw new AssertionError("Call mark(true) before using reset()!");
+ backupMode = false;
+
+ // That is now in the queue, will be appended to the end of backup.
+ while (!queue.isEmpty())
+ backup.add(queue.next());
+
+ Queue t = queue;
+ queue = backup;
+ backup = t;
+ backup.clear();
+ }
+
+ /**
+ * Read the given number of the tokens. Add the needed number of EOF
+ * tokens if there are no more data in the stream.
+ * @param amount The number of additional tokens to read.
+ */
+ void read(int numberOfTokens)
+ throws IOException
+ {
+ if (numberOfTokens <= 0)
+ return;
+
+ reading:
+ for (int i = 0; i < numberOfTokens; i++)
+ readToken();
+ }
+
+ /**
+ * Read next token from the reader, add it to the queue
+ */
+ void readToken()
+ throws IOException
+ {
+ Token t;
+ int ch;
+
+ enlarging:
+ while (true)
+ {
+ t = tokenMatches();
+ if (t != null)
+ break enlarging;
+ else
+ {
+ ch = reader.read();
+ readerPosition++;
+ if (ch == ETX)
+ ch = ' ';
+ if (ch < 0)
+ {
+ if (buffer.length() == 0)
+ {
+ queue.add(eofToken());
+ return;
+ }
+ else
+ {
+ if (buffer.charAt(buffer.length() - 1) != ETX)
+ buffer.append(ETX, readerPosition++);
+ else
+ {
+ // Discard terminating ETX
+ buffer.setLength(buffer.length() - 1);
+ if (buffer.length() > 0)
+ {
+ t = new Token(OTHER, buffer.toString(),
+ buffer.getLocation(0, buffer.length())
+ );
+ queue.add(t);
+ buffer.setLength(0);
+ }
+ return;
+ }
+ }
+ }
+ else
+ buffer.append((char) ch, readerPosition);
+ }
+ }
+ }
+
+ /**
+ * Check if the end of buffer matches one of the tokens. If it does,
+ * return this token and remove the token sequence from the end of
+ * buffer.
+ * @return The matching token.
+ */
+ Token tokenMatches()
+ {
+ Token rt = endMatches(buffer);
+ if (rt != null) // Remove the matched image
+ {
+ // Consume future character if it was an entity and the future
+ // character is semicolon.
+ if (rt.kind == ENTITY)
+ {
+ if (buffer.charAt(buffer.length() - 1) == ';')
+ buffer.setLength(buffer.length() - rt.getImage().length() - 1);
+ else
+ {
+ error("Missing closing semicolon for entity '" + rt.getImage() +
+ "'", rt
+ );
+ consumeBuffer(rt);
+ }
+ }
+ else
+ {
+ consumeBuffer(rt);
+ }
+ }
+
+ // If the buffer is not empty, some sequence does not match any tokens.
+ // Add it to the queue as "OTHER".
+ if (rt != null)
+ {
+ if (buffer.length() > 1)
+ {
+ String rest = buffer.toString();
+ rest = rest.substring(0, rest.length() - 1);
+
+ Token other =
+ new Token(OTHER, rest, buffer.getLocation(0, buffer.length));
+ queue.add(other);
+ consumeBuffer(other);
+ }
+ queue.add(rt);
+ }
+ return rt;
+ }
+
+ private void consumeBuffer(Token rt)
+ {
+ buffer.delete(buffer.length() - rt.getImage().length() - 1,
+ buffer.length() - 1
+ );
+ }
+
+ /**
+ * Create EOF token.
+ */
+ private Token eofToken()
+ {
+ return new Token(EOF, "#", new Location(readerPosition));
+ }
+}
Added: llvm-gcc-4.2/trunk/libjava/classpath/gnu/javax/swing/text/html/parser/support/low/Token.java
URL: http://llvm.org/viewvc/llvm-project/llvm-gcc-4.2/trunk/libjava/classpath/gnu/javax/swing/text/html/parser/support/low/Token.java?rev=43913&view=auto
==============================================================================
--- llvm-gcc-4.2/trunk/libjava/classpath/gnu/javax/swing/text/html/parser/support/low/Token.java (added)
+++ llvm-gcc-4.2/trunk/libjava/classpath/gnu/javax/swing/text/html/parser/support/low/Token.java Thu Nov 8 16:56:19 2007
@@ -0,0 +1,169 @@
+/* Token.java --
+ Copyright (C) 2005 Free Software Foundation, Inc.
+
+This file is part of GNU Classpath.
+
+GNU Classpath is free software; you can redistribute it and/or modify
+it under the terms of the GNU General Public License as published by
+the Free Software Foundation; either version 2, or (at your option)
+any later version.
+
+GNU Classpath is distributed in the hope that it will be useful, but
+WITHOUT ANY WARRANTY; without even the implied warranty of
+MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+General Public License for more details.
+
+You should have received a copy of the GNU General Public License
+along with GNU Classpath; see the file COPYING. If not, write to the
+Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA
+02110-1301 USA.
+
+Linking this library statically or dynamically with other modules is
+making a combined work based on this library. Thus, the terms and
+conditions of the GNU General Public License cover the whole
+combination.
+
+As a special exception, the copyright holders of this library give you
+permission to link this library with independent modules to produce an
+executable, regardless of the license terms of these independent
+modules, and to copy and distribute the resulting executable under
+terms of your choice, provided that you also meet, for each linked
+independent module, the terms and conditions of the license of that
+module. An independent module is a module which is not derived from
+or based on this library. If you modify this library, you may extend
+this exception to your version of the library, but you are not
+obligated to do so. If you do not wish to do so, delete this
+exception statement from your version. */
+
+
+package gnu.javax.swing.text.html.parser.support.low;
+
+/**
+ * A token.
+ * @author Audrius Meskauskas, Lithuania (AudriusA at Bioinformatics.org)
+ */
+public class Token
+{
+ /**
+ * The place of this token in the document.
+ */
+ public Location where;
+
+ /**
+ * The additional category of token.
+ */
+ public int category;
+
+ /**
+ * An integer that describes the kind of this token.
+ */
+ public int kind;
+
+ /**
+ * The string image of the token, null if the char image must be used.
+ */
+ private String stringImage;
+
+ /**
+ * The char image of the token.
+ */
+ private char charImage;
+
+ /**
+ * Creates a new token with fields, initialized to the default values.
+ */
+ public Token()
+ {
+ }
+
+ /**
+ * Creates a new token of the given kind.
+ */
+ public Token(int _kind, Location _where)
+ {
+ kind = _kind;
+ where = _where;
+ }
+
+ /**
+ * Creates a new token of the given kind and given single char image.
+ */
+ public Token(int _kind, char _image, Location _where)
+ {
+ kind = _kind;
+ charImage = _image;
+ where = _where;
+ }
+
+ /**
+ * Creates a new token of the given kind and given string image.
+ */
+ public Token(int _kind, String _image, Location _where)
+ {
+ kind = _kind;
+ stringImage = _image;
+ where = _where;
+ }
+
+ /**
+ * Creates a new token of the given kind, category and given string image.
+ */
+ public Token(int _kind, int _category, String _image, Location _where)
+ {
+ kind = _kind;
+ category = _category;
+ stringImage = _image;
+ where = _where;
+ }
+
+ /**
+ * Creates a new token, where location fields are set as for token,
+ * spanning over two provided tokens and any tokens between them.
+ * The image field is initialized to null, the kind field is set to -1.
+ */
+ public Token(Token fromInclusive, Token toInclusive)
+ {
+ where = new Location();
+ where.beginLine = fromInclusive.where.beginLine;
+ where.startPosition = fromInclusive.where.startPosition;
+
+ where.endLine = toInclusive.where.endLine;
+ where.endPosition = toInclusive.where.endPosition;
+ }
+
+ public String getImage()
+ {
+ if (kind == 3)
+ return "#";
+ if (stringImage == null)
+ {
+ if (charImage == 0)
+ return null;
+ stringImage = new String(new char[] { charImage });
+ }
+ return stringImage;
+ }
+
+ /**
+ * Append the token image to the given string buffer.
+ * This may be more effective that buffer.append(this.getImage()).
+ * @param buffer A buffer to append.
+ */
+ public void appendTo(StringBuffer buffer)
+ {
+ if (charImage == 0)
+ buffer.append(getImage());
+ else
+ buffer.append(charImage);
+ }
+
+ /**
+ * Returns the string image or, if null, the bounding positions.
+ */
+ public String toString()
+ {
+ return getImage() != null ? kind + "'" + getImage()
+ : "<line " + where.beginLine + ", abs pos " + where.startPosition +
+ ".." + where.endPosition + ">";
+ }
+}
Added: llvm-gcc-4.2/trunk/libjava/classpath/gnu/javax/swing/text/html/parser/support/low/node.java
URL: http://llvm.org/viewvc/llvm-project/llvm-gcc-4.2/trunk/libjava/classpath/gnu/javax/swing/text/html/parser/support/low/node.java?rev=43913&view=auto
==============================================================================
--- llvm-gcc-4.2/trunk/libjava/classpath/gnu/javax/swing/text/html/parser/support/low/node.java (added)
+++ llvm-gcc-4.2/trunk/libjava/classpath/gnu/javax/swing/text/html/parser/support/low/node.java Thu Nov 8 16:56:19 2007
@@ -0,0 +1,78 @@
+/* node.java --
+ Copyright (C) 2005 Free Software Foundation, Inc.
+
+This file is part of GNU Classpath.
+
+GNU Classpath is free software; you can redistribute it and/or modify
+it under the terms of the GNU General Public License as published by
+the Free Software Foundation; either version 2, or (at your option)
+any later version.
+
+GNU Classpath is distributed in the hope that it will be useful, but
+WITHOUT ANY WARRANTY; without even the implied warranty of
+MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+General Public License for more details.
+
+You should have received a copy of the GNU General Public License
+along with GNU Classpath; see the file COPYING. If not, write to the
+Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA
+02110-1301 USA.
+
+Linking this library statically or dynamically with other modules is
+making a combined work based on this library. Thus, the terms and
+conditions of the GNU General Public License cover the whole
+combination.
+
+As a special exception, the copyright holders of this library give you
+permission to link this library with independent modules to produce an
+executable, regardless of the license terms of these independent
+modules, and to copy and distribute the resulting executable under
+terms of your choice, provided that you also meet, for each linked
+independent module, the terms and conditions of the license of that
+module. An independent module is a module which is not derived from
+or based on this library. If you modify this library, you may extend
+this exception to your version of the library, but you are not
+obligated to do so. If you do not wish to do so, delete this
+exception statement from your version. */
+
+
+package gnu.javax.swing.text.html.parser.support.low;
+
+/**
+ * A text level content model node. The only required unary operations
+ * here are "appears" and "optionally appears" ('?').
+ * <p>@author Audrius Meskauskas, Lithuania (AudriusA at Bioinformatics.org)</p>
+ */
+public class node
+{
+ /**
+ * True for node that is optional for the given position.
+ */
+ public boolean optional;
+
+ /**
+ * The kind of the token to match.
+ */
+ public int kind;
+
+ /**
+ * Creates the new node for matching a given kind of the token.
+ * @param kind The kind of the token to match.
+ * @param modifier The modifier (*?+).
+ */
+ public node(int kind, boolean _optional)
+ {
+ this.kind = kind;
+ optional = _optional;
+ }
+
+ /**
+ * Creates the node, indicating that token must match exactluy one time.
+ * @param kind The kind of token to match.
+ */
+ public node(int kind)
+ {
+ this.kind = kind;
+ optional = false;
+ }
+}
Added: llvm-gcc-4.2/trunk/libjava/classpath/gnu/javax/swing/text/html/parser/support/low/package.html
URL: http://llvm.org/viewvc/llvm-project/llvm-gcc-4.2/trunk/libjava/classpath/gnu/javax/swing/text/html/parser/support/low/package.html?rev=43913&view=auto
==============================================================================
--- llvm-gcc-4.2/trunk/libjava/classpath/gnu/javax/swing/text/html/parser/support/low/package.html (added)
+++ llvm-gcc-4.2/trunk/libjava/classpath/gnu/javax/swing/text/html/parser/support/low/package.html Thu Nov 8 16:56:19 2007
@@ -0,0 +1,47 @@
+<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 3.2 Final//EN">
+<!-- package.html - describes classes in javax.swing.text.html.parser package.
+ Copyright (C) 2002 Free Software Foundation, Inc.
+
+This file is part of GNU Classpath.
+
+GNU Classpath is free software; you can redistribute it and/or modify
+it under the terms of the GNU General Public License as published by
+the Free Software Foundation; either version 2, or (at your option)
+any later version.
+
+GNU Classpath is distributed in the hope that it will be useful, but
+WITHOUT ANY WARRANTY; without even the implied warranty of
+MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+General Public License for more details.
+
+You should have received a copy of the GNU General Public License
+along with GNU Classpath; see the file COPYING. If not, write to the
+Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA
+02110-1301 USA.
+
+Linking this library statically or dynamically with other modules is
+making a combined work based on this library. Thus, the terms and
+conditions of the GNU General Public License cover the whole
+combination.
+
+As a special exception, the copyright holders of this library give you
+permission to link this library with independent modules to produce an
+executable, regardless of the license terms of these independent
+modules, and to copy and distribute the resulting executable under
+terms of your choice, provided that you also meet, for each linked
+independent module, the terms and conditions of the license of that
+module. An independent module is a module which is not derived from
+or based on this library. If you modify this library, you may extend
+this exception to your version of the library, but you are not
+obligated to do so. If you do not wish to do so, delete this
+exception statement from your version. -->
+
+<html>
+<head><title>GNU Classpath - gnu.javax.swing.text.html.parser.support.low</title></head>
+
+<body>
+<p>This package contains classes that are directly used to process
+the text input: adapted stream tokenizer, specialized buffer and text-level content models .</p>
+ at author Audrius Meskauskas, Lithuania
+</body>
+</html>
Added: llvm-gcc-4.2/trunk/libjava/classpath/gnu/javax/swing/text/html/parser/support/low/pattern.java
URL: http://llvm.org/viewvc/llvm-project/llvm-gcc-4.2/trunk/libjava/classpath/gnu/javax/swing/text/html/parser/support/low/pattern.java?rev=43913&view=auto
==============================================================================
--- llvm-gcc-4.2/trunk/libjava/classpath/gnu/javax/swing/text/html/parser/support/low/pattern.java (added)
+++ llvm-gcc-4.2/trunk/libjava/classpath/gnu/javax/swing/text/html/parser/support/low/pattern.java Thu Nov 8 16:56:19 2007
@@ -0,0 +1,105 @@
+/* pattern.java --
+ Copyright (C) 2005 Free Software Foundation, Inc.
+
+This file is part of GNU Classpath.
+
+GNU Classpath is free software; you can redistribute it and/or modify
+it under the terms of the GNU General Public License as published by
+the Free Software Foundation; either version 2, or (at your option)
+any later version.
+
+GNU Classpath is distributed in the hope that it will be useful, but
+WITHOUT ANY WARRANTY; without even the implied warranty of
+MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+General Public License for more details.
+
+You should have received a copy of the GNU General Public License
+along with GNU Classpath; see the file COPYING. If not, write to the
+Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA
+02110-1301 USA.
+
+Linking this library statically or dynamically with other modules is
+making a combined work based on this library. Thus, the terms and
+conditions of the GNU General Public License cover the whole
+combination.
+
+As a special exception, the copyright holders of this library give you
+permission to link this library with independent modules to produce an
+executable, regardless of the license terms of these independent
+modules, and to copy and distribute the resulting executable under
+terms of your choice, provided that you also meet, for each linked
+independent module, the terms and conditions of the license of that
+module. An independent module is a module which is not derived from
+or based on this library. If you modify this library, you may extend
+this exception to your version of the library, but you are not
+obligated to do so. If you do not wish to do so, delete this
+exception statement from your version. */
+
+
+package gnu.javax.swing.text.html.parser.support.low;
+
+
+/**
+ * The simple pattern, consisting from the sequence of tokens that
+ * may have the unary modifier '?'. Choices and grouping
+ * are not required here.
+ * @author Audrius Meskauskas, Lithuania (AudriusA at Bioinformatics.org)
+ */
+public class pattern
+{
+ /**
+ * The nodes of this pattern.
+ */
+ public final node[] nodes;
+
+ /**
+ * Create a pattern, containing the given list of nodes.
+ * @param a_nodes
+ */
+ public pattern(node[] a_nodes)
+ {
+ nodes = a_nodes;
+ }
+
+ /**
+ * Checks if the pattern can match the tokens in this
+ * tokenizer. Does not change the state of tokenizer.
+ * @param stream The tokenizer to read data from
+ * @return True if the pattern sequence matches the
+ * beginning of the tokenizer content.
+ */
+ public boolean matches(ReaderTokenizer stream)
+ {
+ try
+ {
+ int pt = 0;
+ int pn = 0;
+ Token t;
+ node n;
+
+ while (pn < nodes.length)
+ {
+ n = nodes [ pn ];
+ t = stream.getTokenAhead(pt);
+
+ if (t.kind == n.kind)
+ {
+ pn++;
+ pt++;
+ }
+ else
+ {
+ if (!n.optional)
+ return false;
+ else
+ pn++;
+ }
+ }
+ return true;
+ }
+ catch (Exception ex)
+ {
+ throw new ParseException("Exception", ex);
+ }
+ }
+}
Added: llvm-gcc-4.2/trunk/libjava/classpath/gnu/javax/swing/text/html/parser/support/package.html
URL: http://llvm.org/viewvc/llvm-project/llvm-gcc-4.2/trunk/libjava/classpath/gnu/javax/swing/text/html/parser/support/package.html?rev=43913&view=auto
==============================================================================
--- llvm-gcc-4.2/trunk/libjava/classpath/gnu/javax/swing/text/html/parser/support/package.html (added)
+++ llvm-gcc-4.2/trunk/libjava/classpath/gnu/javax/swing/text/html/parser/support/package.html Thu Nov 8 16:56:19 2007
@@ -0,0 +1,47 @@
+<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 3.2 Final//EN">
+<!-- package.html - describes classes in javax.swing.text.html.parser package.
+ Copyright (C) 2002 Free Software Foundation, Inc.
+
+This file is part of GNU Classpath.
+
+GNU Classpath is free software; you can redistribute it and/or modify
+it under the terms of the GNU General Public License as published by
+the Free Software Foundation; either version 2, or (at your option)
+any later version.
+
+GNU Classpath is distributed in the hope that it will be useful, but
+WITHOUT ANY WARRANTY; without even the implied warranty of
+MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+General Public License for more details.
+
+You should have received a copy of the GNU General Public License
+along with GNU Classpath; see the file COPYING. If not, write to the
+Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA
+02110-1301 USA.
+
+Linking this library statically or dynamically with other modules is
+making a combined work based on this library. Thus, the terms and
+conditions of the GNU General Public License cover the whole
+combination.
+
+As a special exception, the copyright holders of this library give you
+permission to link this library with independent modules to produce an
+executable, regardless of the license terms of these independent
+modules, and to copy and distribute the resulting executable under
+terms of your choice, provided that you also meet, for each linked
+independent module, the terms and conditions of the license of that
+module. An independent module is a module which is not derived from
+or based on this library. If you modify this library, you may extend
+this exception to your version of the library, but you are not
+obligated to do so. If you do not wish to do so, delete this
+exception statement from your version. -->
+
+<html>
+<head><title>GNU Classpath - gnu.javax.swing.text.html.parser.support</title></head>
+
+<body>
+<p>This package provides various specialised classes, needed by HTML parser.
+</p>
+ at author Audrius Meskauskas, Lithuania
+</body>
+</html>
Added: llvm-gcc-4.2/trunk/libjava/classpath/gnu/javax/swing/text/html/parser/support/parameterDefaulter.java
URL: http://llvm.org/viewvc/llvm-project/llvm-gcc-4.2/trunk/libjava/classpath/gnu/javax/swing/text/html/parser/support/parameterDefaulter.java?rev=43913&view=auto
==============================================================================
--- llvm-gcc-4.2/trunk/libjava/classpath/gnu/javax/swing/text/html/parser/support/parameterDefaulter.java (added)
+++ llvm-gcc-4.2/trunk/libjava/classpath/gnu/javax/swing/text/html/parser/support/parameterDefaulter.java Thu Nov 8 16:56:19 2007
@@ -0,0 +1,106 @@
+/* parameterDefaulter.java --
+ Copyright (C) 2005 Free Software Foundation, Inc.
+
+This file is part of GNU Classpath.
+
+GNU Classpath is free software; you can redistribute it and/or modify
+it under the terms of the GNU General Public License as published by
+the Free Software Foundation; either version 2, or (at your option)
+any later version.
+
+GNU Classpath is distributed in the hope that it will be useful, but
+WITHOUT ANY WARRANTY; without even the implied warranty of
+MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+General Public License for more details.
+
+You should have received a copy of the GNU General Public License
+along with GNU Classpath; see the file COPYING. If not, write to the
+Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA
+02110-1301 USA.
+
+Linking this library statically or dynamically with other modules is
+making a combined work based on this library. Thus, the terms and
+conditions of the GNU General Public License cover the whole
+combination.
+
+As a special exception, the copyright holders of this library give you
+permission to link this library with independent modules to produce an
+executable, regardless of the license terms of these independent
+modules, and to copy and distribute the resulting executable under
+terms of your choice, provided that you also meet, for each linked
+independent module, the terms and conditions of the license of that
+module. An independent module is a module which is not derived from
+or based on this library. If you modify this library, you may extend
+this exception to your version of the library, but you are not
+obligated to do so. If you do not wish to do so, delete this
+exception statement from your version. */
+
+
+package gnu.javax.swing.text.html.parser.support;
+
+import gnu.javax.swing.text.html.parser.htmlAttributeSet;
+
+import java.util.Hashtable;
+
+import javax.swing.text.html.parser.AttributeList;
+import javax.swing.text.html.parser.DTD;
+import javax.swing.text.html.parser.Element;
+
+/**
+ * Returns an attribute set, containing default
+ * parameters for the given element. Caches sets of default
+ * parameters.
+ * @author Audrius Meskauskas, Lithuania (AudriusA at Bioinformatics.org)
+ */
+public class parameterDefaulter
+{
+ public final DTD dtd;
+ Hashtable sets = new Hashtable();
+
+ /**
+ * Create a parameterDefaulter that looks for the default attribute
+ * values in the given DTD.
+ * @param a_dtd
+ */
+ public parameterDefaulter(DTD a_dtd)
+ {
+ dtd = a_dtd;
+ }
+
+ /**
+ * Get the default parameter set for the given element.
+ * @param element The element name (case insensitive).
+ * @return the default attrbute set.
+ */
+ public htmlAttributeSet getDefaultParameters(String element)
+ {
+ String key = element.toLowerCase();
+ htmlAttributeSet atts = (htmlAttributeSet) sets.get(key);
+
+ if (atts == null)
+ {
+ htmlAttributeSet set = new htmlAttributeSet();
+ Element e = (Element) dtd.elementHash.get(element.toLowerCase());
+
+ if (e != null)
+ {
+ AttributeList a = e.getAttributes();
+
+ while (a != null)
+ {
+ if (a.value != null)
+ set.addAttribute(a.name, a.value);
+ a = a.next;
+ }
+ }
+
+ if (set.getAttributeCount() > 0)
+ sets.put(key, set);
+ else
+ sets.put(key, htmlAttributeSet.EMPTY_HTML_ATTRIBUTE_SET);
+
+ atts = set;
+ }
+ return atts;
+ }
+}
Added: llvm-gcc-4.2/trunk/libjava/classpath/gnu/javax/swing/text/html/parser/support/textPreProcessor.java
URL: http://llvm.org/viewvc/llvm-project/llvm-gcc-4.2/trunk/libjava/classpath/gnu/javax/swing/text/html/parser/support/textPreProcessor.java?rev=43913&view=auto
==============================================================================
--- llvm-gcc-4.2/trunk/libjava/classpath/gnu/javax/swing/text/html/parser/support/textPreProcessor.java (added)
+++ llvm-gcc-4.2/trunk/libjava/classpath/gnu/javax/swing/text/html/parser/support/textPreProcessor.java Thu Nov 8 16:56:19 2007
@@ -0,0 +1,193 @@
+/* textPreProcessor.java --
+ Copyright (C) 2005 Free Software Foundation, Inc.
+
+This file is part of GNU Classpath.
+
+GNU Classpath is free software; you can redistribute it and/or modify
+it under the terms of the GNU General Public License as published by
+the Free Software Foundation; either version 2, or (at your option)
+any later version.
+
+GNU Classpath is distributed in the hope that it will be useful, but
+WITHOUT ANY WARRANTY; without even the implied warranty of
+MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+General Public License for more details.
+
+You should have received a copy of the GNU General Public License
+along with GNU Classpath; see the file COPYING. If not, write to the
+Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA
+02110-1301 USA.
+
+Linking this library statically or dynamically with other modules is
+making a combined work based on this library. Thus, the terms and
+conditions of the GNU General Public License cover the whole
+combination.
+
+As a special exception, the copyright holders of this library give you
+permission to link this library with independent modules to produce an
+executable, regardless of the license terms of these independent
+modules, and to copy and distribute the resulting executable under
+terms of your choice, provided that you also meet, for each linked
+independent module, the terms and conditions of the license of that
+module. An independent module is a module which is not derived from
+or based on this library. If you modify this library, you may extend
+this exception to your version of the library, but you are not
+obligated to do so. If you do not wish to do so, delete this
+exception statement from your version. */
+
+
+package gnu.javax.swing.text.html.parser.support;
+
+import gnu.javax.swing.text.html.parser.support.low.Constants;
+
+/**
+ * Pre - processes text in text parts of the html document.
+ * Not thread - safe.
+ * @author Audrius Meskauskas, Lithuania (AudriusA at Bioinformatics.org)
+ */
+public class textPreProcessor
+{
+ /**
+ * Pre - process non-preformatted text.
+ * \t, \r and \n mutate into spaces, then multiple spaces mutate
+ * into single one, all whitespace around tags is consumed.
+ * The content of the passed buffer is destroyed.
+ * @param text A text to pre-process.
+ */
+ public char[] preprocess(StringBuffer a_text)
+ {
+ if (a_text.length() == 0)
+ return null;
+
+ char[] text = toCharArray(a_text);
+
+ int a = 0;
+ int b = text.length - 1;
+
+ try
+ {
+ while (Constants.bWHITESPACE.get(text [ a ]))
+ a++;
+ while (Constants.bWHITESPACE.get(text [ b ]))
+ b--;
+ }
+ catch (ArrayIndexOutOfBoundsException sx)
+ {
+ // A text fragment, consisting from line breaks only.
+ return null;
+ }
+
+ a_text.setLength(0);
+
+ boolean spacesWere = false;
+ boolean spaceNow;
+ char c;
+
+ chars:
+ for (int i = a; i <= b; i++)
+ {
+ c = text [ i ];
+ spaceNow = Constants.bWHITESPACE.get(c);
+ if (spacesWere && spaceNow)
+ continue chars;
+ if (spaceNow)
+ a_text.append(' ');
+ else
+ a_text.append(c);
+ spacesWere = spaceNow;
+ }
+
+ if (a_text.length() == text.length)
+ {
+ a_text.getChars(0, a_text.length(), text, 0);
+ return text;
+ }
+ else
+ return toCharArray(a_text);
+ }
+
+ /**
+ * Pre - process pre-formatted text.
+ * Heading/closing spaces and tabs preserved.
+ * ONE bounding \r, \n or \r\n is removed.
+ * \r or \r\n mutate into \n. Tabs are
+ * preserved.
+ * The content of the passed buffer is destroyed.
+ * @param text
+ * @return
+ */
+ public char[] preprocessPreformatted(StringBuffer a_text)
+ {
+ if (a_text.length() == 0)
+ return null;
+
+ char[] text = toCharArray(a_text);
+
+ int a = 0;
+ int n = text.length - 1;
+ int b = n;
+
+ if (text [ 0 ] == '\n')
+ a++;
+ else
+ {
+ if (text [ 0 ] == '\r')
+ {
+ a++;
+ if (text.length > 1 && text [ 1 ] == '\n')
+ a++;
+ }
+ }
+
+ if (text [ n ] == '\r')
+ b--;
+ else
+ {
+ if (text [ n ] == '\n')
+ {
+ b--;
+ if (n > 0 && text [ n - 1 ] == '\r')
+ b--;
+ }
+ }
+
+ a_text.setLength(0);
+
+ if (a > b)
+ return null;
+
+ char c;
+
+ for (int i = a; i <= b; i++)
+ {
+ c = text [ i ];
+ if (c == '\r')
+ {
+ if (i == b || text [ i + 1 ] != '\n')
+ a_text.append('\n');
+ }
+ else
+ a_text.append(c);
+ }
+
+ if (a_text.length() == text.length)
+ {
+ a_text.getChars(0, a_text.length(), text, 0);
+ return text;
+ }
+ else
+ return toCharArray(a_text);
+ }
+
+ /**
+ * Return array of chars, present in the given buffer.
+ * @param a_text The buffer
+ * @return
+ */
+ private static char[] toCharArray(StringBuffer a_text)
+ {
+ char[] text = new char[ a_text.length() ];
+ a_text.getChars(0, text.length, text, 0);
+ return text;
+ }
+}
Added: llvm-gcc-4.2/trunk/libjava/classpath/gnu/javax/swing/tree/GnuPath.java
URL: http://llvm.org/viewvc/llvm-project/llvm-gcc-4.2/trunk/libjava/classpath/gnu/javax/swing/tree/GnuPath.java?rev=43913&view=auto
==============================================================================
--- llvm-gcc-4.2/trunk/libjava/classpath/gnu/javax/swing/tree/GnuPath.java (added)
+++ llvm-gcc-4.2/trunk/libjava/classpath/gnu/javax/swing/tree/GnuPath.java Thu Nov 8 16:56:19 2007
@@ -0,0 +1,65 @@
+/* GnuPath.java -- The extended version of TreePath
+ Copyright (C) 2006 Free Software Foundation, Inc.
+
+This file is part of GNU Classpath.
+
+GNU Classpath is free software; you can redistribute it and/or modify
+it under the terms of the GNU General Public License as published by
+the Free Software Foundation; either version 2, or (at your option)
+any later version.
+
+GNU Classpath is distributed in the hope that it will be useful, but
+WITHOUT ANY WARRANTY; without even the implied warranty of
+MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+General Public License for more details.
+
+You should have received a copy of the GNU General Public License
+along with GNU Classpath; see the file COPYING. If not, write to the
+Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA
+02110-1301 USA.
+
+Linking this library statically or dynamically with other modules is
+making a combined work based on this library. Thus, the terms and
+conditions of the GNU General Public License cover the whole
+combination.
+
+As a special exception, the copyright holders of this library give you
+permission to link this library with independent modules to produce an
+executable, regardless of the license terms of these independent
+modules, and to copy and distribute the resulting executable under
+terms of your choice, provided that you also meet, for each linked
+independent module, the terms and conditions of the license of that
+module. An independent module is a module which is not derived from
+or based on this library. If you modify this library, you may extend
+this exception to your version of the library, but you are not
+obligated to do so. If you do not wish to do so, delete this
+exception statement from your version. */
+
+
+package gnu.javax.swing.tree;
+
+import javax.swing.tree.TreePath;
+
+/**
+ * The tree path with additional data. Needed for the optimized tree drawing.
+ * Returned by layout caches.
+ *
+ * @author Audrius Meskauskas
+ */
+public class GnuPath extends TreePath
+{
+ /**
+ * The flag, marking the last visible child.
+ */
+ public boolean isLastChild;
+
+ /**
+ * Create a new path, specifying flag if this path is the path to the
+ * last visible child (needed for optimized tree drawing).
+ */
+ public GnuPath(Object[] path, boolean lastChild)
+ {
+ super(path);
+ isLastChild = lastChild;
+ }
+}
Added: llvm-gcc-4.2/trunk/libjava/classpath/gnu/test/Fail.java
URL: http://llvm.org/viewvc/llvm-project/llvm-gcc-4.2/trunk/libjava/classpath/gnu/test/Fail.java?rev=43913&view=auto
==============================================================================
--- llvm-gcc-4.2/trunk/libjava/classpath/gnu/test/Fail.java (added)
+++ llvm-gcc-4.2/trunk/libjava/classpath/gnu/test/Fail.java Thu Nov 8 16:56:19 2007
@@ -0,0 +1,57 @@
+/* Fail.java -- Result code returned when test failed but was expected to
+ Copyright (c) 1998 Free Software Foundation, Inc.
+
+This file is part of GNU Classpath.
+
+GNU Classpath is free software; you can redistribute it and/or modify
+it under the terms of the GNU General Public License as published by
+the Free Software Foundation; either version 2, or (at your option)
+any later version.
+
+GNU Classpath is distributed in the hope that it will be useful, but
+WITHOUT ANY WARRANTY; without even the implied warranty of
+MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+General Public License for more details.
+
+You should have received a copy of the GNU General Public License
+along with GNU Classpath; see the file COPYING. If not, write to the
+Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA
+02110-1301 USA.
+
+Linking this library statically or dynamically with other modules is
+making a combined work based on this library. Thus, the terms and
+conditions of the GNU General Public License cover the whole
+combination.
+
+As a special exception, the copyright holders of this library give you
+permission to link this library with independent modules to produce an
+executable, regardless of the license terms of these independent
+modules, and to copy and distribute the resulting executable under
+terms of your choice, provided that you also meet, for each linked
+independent module, the terms and conditions of the license of that
+module. An independent module is a module which is not derived from
+or based on this library. If you modify this library, you may extend
+this exception to your version of the library, but you are not
+obligated to do so. If you do not wish to do so, delete this
+exception statement from your version. */
+
+package gnu.test;
+
+/**
+ * Test failed but was expected to pass.
+ */
+public class Fail extends Result
+{
+ /**
+ * Constructs a Fail result code with additional information.
+ */
+ public Fail(String msg) {
+ super("FAIL", msg);
+ }
+ /**
+ * Constructs a Fail result code.
+ */
+ public Fail() {
+ this("");
+ }
+}
Added: llvm-gcc-4.2/trunk/libjava/classpath/gnu/test/Makefile.am
URL: http://llvm.org/viewvc/llvm-project/llvm-gcc-4.2/trunk/libjava/classpath/gnu/test/Makefile.am?rev=43913&view=auto
==============================================================================
--- llvm-gcc-4.2/trunk/libjava/classpath/gnu/test/Makefile.am (added)
+++ llvm-gcc-4.2/trunk/libjava/classpath/gnu/test/Makefile.am Thu Nov 8 16:56:19 2007
@@ -0,0 +1,5 @@
+## Input file for automake to generate the Makefile.in used by configure
+
+##gnutestdir = $(datadir)/gnu/test/
+
+##gnutest_JAVA = Fail.java Test.java Untested.java Pass.java Unresolved.java XFail.java Result.java Unsupported.java XPass.java
Added: llvm-gcc-4.2/trunk/libjava/classpath/gnu/test/Pass.java
URL: http://llvm.org/viewvc/llvm-project/llvm-gcc-4.2/trunk/libjava/classpath/gnu/test/Pass.java?rev=43913&view=auto
==============================================================================
--- llvm-gcc-4.2/trunk/libjava/classpath/gnu/test/Pass.java (added)
+++ llvm-gcc-4.2/trunk/libjava/classpath/gnu/test/Pass.java Thu Nov 8 16:56:19 2007
@@ -0,0 +1,57 @@
+/* Pass.java -- Result code returned when test passed and was excepted to
+ Copyright (c) 1998 Free Software Foundation, Inc.
+
+This file is part of GNU Classpath.
+
+GNU Classpath is free software; you can redistribute it and/or modify
+it under the terms of the GNU General Public License as published by
+the Free Software Foundation; either version 2, or (at your option)
+any later version.
+
+GNU Classpath is distributed in the hope that it will be useful, but
+WITHOUT ANY WARRANTY; without even the implied warranty of
+MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+General Public License for more details.
+
+You should have received a copy of the GNU General Public License
+along with GNU Classpath; see the file COPYING. If not, write to the
+Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA
+02110-1301 USA.
+
+Linking this library statically or dynamically with other modules is
+making a combined work based on this library. Thus, the terms and
+conditions of the GNU General Public License cover the whole
+combination.
+
+As a special exception, the copyright holders of this library give you
+permission to link this library with independent modules to produce an
+executable, regardless of the license terms of these independent
+modules, and to copy and distribute the resulting executable under
+terms of your choice, provided that you also meet, for each linked
+independent module, the terms and conditions of the license of that
+module. An independent module is a module which is not derived from
+or based on this library. If you modify this library, you may extend
+this exception to your version of the library, but you are not
+obligated to do so. If you do not wish to do so, delete this
+exception statement from your version. */
+
+package gnu.test;
+
+/**
+ * Test passed and was excepted to pass.
+ */
+public class Pass extends Result
+{
+ /**
+ * Constructs a Pass result code with additional information.
+ */
+ public Pass(String msg) {
+ super("PASS", msg);
+ }
+ /**
+ * Constructs a Pass result code.
+ */
+ public Pass() {
+ this("");
+ }
+}
Added: llvm-gcc-4.2/trunk/libjava/classpath/gnu/test/Result.java
URL: http://llvm.org/viewvc/llvm-project/llvm-gcc-4.2/trunk/libjava/classpath/gnu/test/Result.java?rev=43913&view=auto
==============================================================================
--- llvm-gcc-4.2/trunk/libjava/classpath/gnu/test/Result.java (added)
+++ llvm-gcc-4.2/trunk/libjava/classpath/gnu/test/Result.java Thu Nov 8 16:56:19 2007
@@ -0,0 +1,85 @@
+/* Result.java -- Abstract base class for all Result types.
+ Copyright (c) 1998 Free Software Foundation, Inc.
+
+This file is part of GNU Classpath.
+
+GNU Classpath is free software; you can redistribute it and/or modify
+it under the terms of the GNU General Public License as published by
+the Free Software Foundation; either version 2, or (at your option)
+any later version.
+
+GNU Classpath is distributed in the hope that it will be useful, but
+WITHOUT ANY WARRANTY; without even the implied warranty of
+MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+General Public License for more details.
+
+You should have received a copy of the GNU General Public License
+along with GNU Classpath; see the file COPYING. If not, write to the
+Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA
+02110-1301 USA.
+
+Linking this library statically or dynamically with other modules is
+making a combined work based on this library. Thus, the terms and
+conditions of the GNU General Public License cover the whole
+combination.
+
+As a special exception, the copyright holders of this library give you
+permission to link this library with independent modules to produce an
+executable, regardless of the license terms of these independent
+modules, and to copy and distribute the resulting executable under
+terms of your choice, provided that you also meet, for each linked
+independent module, the terms and conditions of the license of that
+module. An independent module is a module which is not derived from
+or based on this library. If you modify this library, you may extend
+this exception to your version of the library, but you are not
+obligated to do so. If you do not wish to do so, delete this
+exception statement from your version. */
+
+package gnu.test;
+
+/**
+ * Class which all usable Result objects extend.
+ */
+public abstract class Result
+{
+ String name, msg;
+
+ /**
+ * Create a result of a given type, with a given message.
+ *
+ * @param name name of type
+ * @param msg message
+ */
+ public Result(String name, String msg) {
+ this.name = name;
+ this.msg = msg;
+ }
+
+ /**
+ * Create a result of a given type.
+ *
+ * @param name name of type
+ */
+ public Result(String name) {
+ this(name, "");
+ }
+
+ /**
+ * Returns the name of the type.
+ */
+ public String getName() {
+ return name;
+ }
+
+ /**
+ * Returns the message associated with this instance of Result, or
+ * the empty string if no message exists.
+ */
+ public String getMsg() {
+ return (msg != null) ? msg : "";
+ }
+
+ public String toString() {
+ return getName() + ":" + getMsg();
+ }
+}
Added: llvm-gcc-4.2/trunk/libjava/classpath/gnu/test/Test.java
URL: http://llvm.org/viewvc/llvm-project/llvm-gcc-4.2/trunk/libjava/classpath/gnu/test/Test.java?rev=43913&view=auto
==============================================================================
--- llvm-gcc-4.2/trunk/libjava/classpath/gnu/test/Test.java (added)
+++ llvm-gcc-4.2/trunk/libjava/classpath/gnu/test/Test.java Thu Nov 8 16:56:19 2007
@@ -0,0 +1,57 @@
+/* Test.java -- Interface representing a single test.
+ Copyright (c) 1998 Free Software Foundation, Inc.
+
+This file is part of GNU Classpath.
+
+GNU Classpath is free software; you can redistribute it and/or modify
+it under the terms of the GNU General Public License as published by
+the Free Software Foundation; either version 2, or (at your option)
+any later version.
+
+GNU Classpath is distributed in the hope that it will be useful, but
+WITHOUT ANY WARRANTY; without even the implied warranty of
+MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+General Public License for more details.
+
+You should have received a copy of the GNU General Public License
+along with GNU Classpath; see the file COPYING. If not, write to the
+Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA
+02110-1301 USA.
+
+Linking this library statically or dynamically with other modules is
+making a combined work based on this library. Thus, the terms and
+conditions of the GNU General Public License cover the whole
+combination.
+
+As a special exception, the copyright holders of this library give you
+permission to link this library with independent modules to produce an
+executable, regardless of the license terms of these independent
+modules, and to copy and distribute the resulting executable under
+terms of your choice, provided that you also meet, for each linked
+independent module, the terms and conditions of the license of that
+module. An independent module is a module which is not derived from
+or based on this library. If you modify this library, you may extend
+this exception to your version of the library, but you are not
+obligated to do so. If you do not wish to do so, delete this
+exception statement from your version. */
+
+package gnu.test;
+
+/**
+ * Interface which all GNU Classpath tests must implement.
+ * The method <code>test</code> is invoked once for each test.
+ */
+public interface Test
+{
+ /**
+ * Returns the name of the test.
+ */
+ public String getName();
+
+ /**
+ * Performs a test.
+ *
+ * @return result from running the test
+ */
+ public Result test();
+}
Added: llvm-gcc-4.2/trunk/libjava/classpath/gnu/test/Unresolved.java
URL: http://llvm.org/viewvc/llvm-project/llvm-gcc-4.2/trunk/libjava/classpath/gnu/test/Unresolved.java?rev=43913&view=auto
==============================================================================
--- llvm-gcc-4.2/trunk/libjava/classpath/gnu/test/Unresolved.java (added)
+++ llvm-gcc-4.2/trunk/libjava/classpath/gnu/test/Unresolved.java Thu Nov 8 16:56:19 2007
@@ -0,0 +1,57 @@
+/* Unresolved.java - Result code returned when test gives indeterminate results.
+ Copyright (c) 1998 Free Software Foundation, Inc.
+
+This file is part of GNU Classpath.
+
+GNU Classpath is free software; you can redistribute it and/or modify
+it under the terms of the GNU General Public License as published by
+the Free Software Foundation; either version 2, or (at your option)
+any later version.
+
+GNU Classpath is distributed in the hope that it will be useful, but
+WITHOUT ANY WARRANTY; without even the implied warranty of
+MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+General Public License for more details.
+
+You should have received a copy of the GNU General Public License
+along with GNU Classpath; see the file COPYING. If not, write to the
+Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA
+02110-1301 USA.
+
+Linking this library statically or dynamically with other modules is
+making a combined work based on this library. Thus, the terms and
+conditions of the GNU General Public License cover the whole
+combination.
+
+As a special exception, the copyright holders of this library give you
+permission to link this library with independent modules to produce an
+executable, regardless of the license terms of these independent
+modules, and to copy and distribute the resulting executable under
+terms of your choice, provided that you also meet, for each linked
+independent module, the terms and conditions of the license of that
+module. An independent module is a module which is not derived from
+or based on this library. If you modify this library, you may extend
+this exception to your version of the library, but you are not
+obligated to do so. If you do not wish to do so, delete this
+exception statement from your version. */
+
+package gnu.test;
+
+/**
+ * Test produced indeterminate results.
+ */
+public class Unresolved extends Result
+{
+ /**
+ * Constructs an Unresolved result code with additional information.
+ */
+ public Unresolved(String msg) {
+ super("UNRESOLVED", msg);
+ }
+ /**
+ * Constructs an Unresolved result code.
+ */
+ public Unresolved() {
+ this("");
+ }
+}
Added: llvm-gcc-4.2/trunk/libjava/classpath/gnu/test/Unsupported.java
URL: http://llvm.org/viewvc/llvm-project/llvm-gcc-4.2/trunk/libjava/classpath/gnu/test/Unsupported.java?rev=43913&view=auto
==============================================================================
--- llvm-gcc-4.2/trunk/libjava/classpath/gnu/test/Unsupported.java (added)
+++ llvm-gcc-4.2/trunk/libjava/classpath/gnu/test/Unsupported.java Thu Nov 8 16:56:19 2007
@@ -0,0 +1,59 @@
+/* Unsupported.java -- Result code returned when test does not have the
+ Copyright (c) 1998 Free Software Foundation, Inc.
+
+This file is part of GNU Classpath.
+
+GNU Classpath is free software; you can redistribute it and/or modify
+it under the terms of the GNU General Public License as published by
+the Free Software Foundation; either version 2, or (at your option)
+any later version.
+
+GNU Classpath is distributed in the hope that it will be useful, but
+WITHOUT ANY WARRANTY; without even the implied warranty of
+MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+General Public License for more details.
+
+You should have received a copy of the GNU General Public License
+along with GNU Classpath; see the file COPYING. If not, write to the
+Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA
+02110-1301 USA.
+
+Linking this library statically or dynamically with other modules is
+making a combined work based on this library. Thus, the terms and
+conditions of the GNU General Public License cover the whole
+combination.
+
+As a special exception, the copyright holders of this library give you
+permission to link this library with independent modules to produce an
+executable, regardless of the license terms of these independent
+modules, and to copy and distribute the resulting executable under
+terms of your choice, provided that you also meet, for each linked
+independent module, the terms and conditions of the license of that
+module. An independent module is a module which is not derived from
+or based on this library. If you modify this library, you may extend
+this exception to your version of the library, but you are not
+obligated to do so. If you do not wish to do so, delete this
+exception statement from your version. */
+
+package gnu.test;
+
+/**
+ * Test does not have the required support to run. For example,
+ * Unsupported could be returned when a needed resource
+ * (ie. multicasting) is not available.
+ */
+public class Unsupported extends Result
+{
+ /**
+ * Constructs an Unsupported result code with additional information.
+ */
+ public Unsupported(String msg) {
+ super("UNSUPPORTED", msg);
+ }
+ /**
+ * Constructs an Unsupported result code.
+ */
+ public Unsupported() {
+ this("");
+ }
+}
Added: llvm-gcc-4.2/trunk/libjava/classpath/gnu/test/Untested.java
URL: http://llvm.org/viewvc/llvm-project/llvm-gcc-4.2/trunk/libjava/classpath/gnu/test/Untested.java?rev=43913&view=auto
==============================================================================
--- llvm-gcc-4.2/trunk/libjava/classpath/gnu/test/Untested.java (added)
+++ llvm-gcc-4.2/trunk/libjava/classpath/gnu/test/Untested.java Thu Nov 8 16:56:19 2007
@@ -0,0 +1,57 @@
+/* Untested.java -- Result code returned when test was not run -- placeholder.
+ Copyright (c) 1998 Free Software Foundation, Inc.
+
+This file is part of GNU Classpath.
+
+GNU Classpath is free software; you can redistribute it and/or modify
+it under the terms of the GNU General Public License as published by
+the Free Software Foundation; either version 2, or (at your option)
+any later version.
+
+GNU Classpath is distributed in the hope that it will be useful, but
+WITHOUT ANY WARRANTY; without even the implied warranty of
+MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+General Public License for more details.
+
+You should have received a copy of the GNU General Public License
+along with GNU Classpath; see the file COPYING. If not, write to the
+Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA
+02110-1301 USA.
+
+Linking this library statically or dynamically with other modules is
+making a combined work based on this library. Thus, the terms and
+conditions of the GNU General Public License cover the whole
+combination.
+
+As a special exception, the copyright holders of this library give you
+permission to link this library with independent modules to produce an
+executable, regardless of the license terms of these independent
+modules, and to copy and distribute the resulting executable under
+terms of your choice, provided that you also meet, for each linked
+independent module, the terms and conditions of the license of that
+module. An independent module is a module which is not derived from
+or based on this library. If you modify this library, you may extend
+this exception to your version of the library, but you are not
+obligated to do so. If you do not wish to do so, delete this
+exception statement from your version. */
+
+package gnu.test;
+
+/**
+ * Test was not run -- a placeholder.
+ */
+public class Untested extends Result
+{
+ /**
+ * Constructs an Untested result code with additional information.
+ */
+ public Untested(String msg) {
+ super("UNTESTED", msg);
+ }
+ /**
+ * Constructs an Untested result code.
+ */
+ public Untested() {
+ this("");
+ }
+}
Added: llvm-gcc-4.2/trunk/libjava/classpath/gnu/test/XFail.java
URL: http://llvm.org/viewvc/llvm-project/llvm-gcc-4.2/trunk/libjava/classpath/gnu/test/XFail.java?rev=43913&view=auto
==============================================================================
--- llvm-gcc-4.2/trunk/libjava/classpath/gnu/test/XFail.java (added)
+++ llvm-gcc-4.2/trunk/libjava/classpath/gnu/test/XFail.java Thu Nov 8 16:56:19 2007
@@ -0,0 +1,57 @@
+/* XFail.java - Result code returned when test failed and was expected to fail.
+ Copyright (c) 1998 Free Software Foundation, Inc.
+
+This file is part of GNU Classpath.
+
+GNU Classpath is free software; you can redistribute it and/or modify
+it under the terms of the GNU General Public License as published by
+the Free Software Foundation; either version 2, or (at your option)
+any later version.
+
+GNU Classpath is distributed in the hope that it will be useful, but
+WITHOUT ANY WARRANTY; without even the implied warranty of
+MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+General Public License for more details.
+
+You should have received a copy of the GNU General Public License
+along with GNU Classpath; see the file COPYING. If not, write to the
+Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA
+02110-1301 USA.
+
+Linking this library statically or dynamically with other modules is
+making a combined work based on this library. Thus, the terms and
+conditions of the GNU General Public License cover the whole
+combination.
+
+As a special exception, the copyright holders of this library give you
+permission to link this library with independent modules to produce an
+executable, regardless of the license terms of these independent
+modules, and to copy and distribute the resulting executable under
+terms of your choice, provided that you also meet, for each linked
+independent module, the terms and conditions of the license of that
+module. An independent module is a module which is not derived from
+or based on this library. If you modify this library, you may extend
+this exception to your version of the library, but you are not
+obligated to do so. If you do not wish to do so, delete this
+exception statement from your version. */
+
+package gnu.test;
+
+/**
+ * Test failed and was expected to fail.
+ */
+public class XFail extends Result
+{
+ /**
+ * Constructs an XFail result code with additional information.
+ */
+ public XFail(String msg) {
+ super("XFAIL", msg);
+ }
+ /**
+ * Constructs an XFail result code.
+ */
+ public XFail() {
+ this("");
+ }
+}
Added: llvm-gcc-4.2/trunk/libjava/classpath/gnu/test/XPass.java
URL: http://llvm.org/viewvc/llvm-project/llvm-gcc-4.2/trunk/libjava/classpath/gnu/test/XPass.java?rev=43913&view=auto
==============================================================================
--- llvm-gcc-4.2/trunk/libjava/classpath/gnu/test/XPass.java (added)
+++ llvm-gcc-4.2/trunk/libjava/classpath/gnu/test/XPass.java Thu Nov 8 16:56:19 2007
@@ -0,0 +1,56 @@
+/* XPass.java - Result code returned when test passed but was expected to fail.
+ Copyright (c) 1998 Free Software Foundation, Inc.
+This file is part of GNU Classpath.
+
+GNU Classpath is free software; you can redistribute it and/or modify
+it under the terms of the GNU General Public License as published by
+the Free Software Foundation; either version 2, or (at your option)
+any later version.
+
+GNU Classpath is distributed in the hope that it will be useful, but
+WITHOUT ANY WARRANTY; without even the implied warranty of
+MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+General Public License for more details.
+
+You should have received a copy of the GNU General Public License
+along with GNU Classpath; see the file COPYING. If not, write to the
+Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA
+02110-1301 USA.
+
+Linking this library statically or dynamically with other modules is
+making a combined work based on this library. Thus, the terms and
+conditions of the GNU General Public License cover the whole
+combination.
+
+As a special exception, the copyright holders of this library give you
+permission to link this library with independent modules to produce an
+executable, regardless of the license terms of these independent
+modules, and to copy and distribute the resulting executable under
+terms of your choice, provided that you also meet, for each linked
+independent module, the terms and conditions of the license of that
+module. An independent module is a module which is not derived from
+or based on this library. If you modify this library, you may extend
+this exception to your version of the library, but you are not
+obligated to do so. If you do not wish to do so, delete this
+exception statement from your version. */
+
+package gnu.test;
+
+/**
+ * Test passed but was expected to fail.
+ */
+public class XPass extends Result
+{
+ /**
+ * Constructs an XPass result code with additional information.
+ */
+ public XPass(String msg) {
+ super("XPASS", msg);
+ }
+ /**
+ * Constructs an XPass result code.
+ */
+ public XPass() {
+ this("");
+ }
+}
Added: llvm-gcc-4.2/trunk/libjava/classpath/gnu/xml/aelfred2/JAXPFactory.java
URL: http://llvm.org/viewvc/llvm-project/llvm-gcc-4.2/trunk/libjava/classpath/gnu/xml/aelfred2/JAXPFactory.java?rev=43913&view=auto
==============================================================================
--- llvm-gcc-4.2/trunk/libjava/classpath/gnu/xml/aelfred2/JAXPFactory.java (added)
+++ llvm-gcc-4.2/trunk/libjava/classpath/gnu/xml/aelfred2/JAXPFactory.java Thu Nov 8 16:56:19 2007
@@ -0,0 +1,231 @@
+/* JAXPFactory.java --
+ Copyright (C) 2001 Free Software Foundation, Inc.
+
+This file is part of GNU Classpath.
+
+GNU Classpath is free software; you can redistribute it and/or modify
+it under the terms of the GNU General Public License as published by
+the Free Software Foundation; either version 2, or (at your option)
+any later version.
+
+GNU Classpath is distributed in the hope that it will be useful, but
+WITHOUT ANY WARRANTY; without even the implied warranty of
+MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+General Public License for more details.
+
+You should have received a copy of the GNU General Public License
+along with GNU Classpath; see the file COPYING. If not, write to the
+Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA
+02110-1301 USA.
+
+Linking this library statically or dynamically with other modules is
+making a combined work based on this library. Thus, the terms and
+conditions of the GNU General Public License cover the whole
+combination.
+
+As a special exception, the copyright holders of this library give you
+permission to link this library with independent modules to produce an
+executable, regardless of the license terms of these independent
+modules, and to copy and distribute the resulting executable under
+terms of your choice, provided that you also meet, for each linked
+independent module, the terms and conditions of the license of that
+module. An independent module is a module which is not derived from
+or based on this library. If you modify this library, you may extend
+this exception to your version of the library, but you are not
+obligated to do so. If you do not wish to do so, delete this
+exception statement from your version. */
+
+package gnu.xml.aelfred2;
+
+import java.util.Enumeration;
+import java.util.Hashtable;
+
+import org.xml.sax.Parser;
+import org.xml.sax.XMLReader;
+import org.xml.sax.SAXException;
+import org.xml.sax.SAXNotRecognizedException;
+import org.xml.sax.SAXNotSupportedException;
+import org.xml.sax.helpers.XMLReaderAdapter;
+
+import javax.xml.parsers.ParserConfigurationException;
+import javax.xml.parsers.SAXParser;
+import javax.xml.parsers.SAXParserFactory;
+
+
+/**
+ * Configurable factory to create an Ælfred2 JAXP parser; required
+ * to bootstrap using JAXP. You should use SAX2 directly where possible,
+ * rather than through JAXP, since that gives you better control.
+ * This class would normally be configured as a platform default factory.
+ *
+ * @author David Brownell
+ */
+public final class JAXPFactory
+ extends SAXParserFactory
+{
+
+ private Hashtable flags = new Hashtable();
+
+ /**
+ * Constructs a factory which normally returns a non-validating
+ * parser.
+ */
+ public JAXPFactory()
+ {
+ }
+
+ public SAXParser newSAXParser()
+ throws ParserConfigurationException, SAXException
+ {
+ JaxpParser jaxp = new JaxpParser();
+ Enumeration e = flags.keys();
+ XMLReader parser = jaxp.getXMLReader();
+
+ parser.setFeature(SAXDriver.FEATURE + "namespaces",
+ isNamespaceAware());
+ parser.setFeature(SAXDriver.FEATURE + "validation",
+ isValidating());
+ // that makes SAX2 feature flags trump JAXP
+
+ while (e.hasMoreElements())
+ {
+ String uri = (String) e.nextElement();
+ Boolean value = (Boolean) flags.get(uri);
+ parser.setFeature(uri, value.booleanValue());
+ }
+
+ return jaxp;
+ }
+
+ // yes, this "feature transfer" mechanism doesn't play well
+
+ public void setFeature(String name, boolean value)
+ throws ParserConfigurationException, SAXNotRecognizedException,
+ SAXNotSupportedException
+ {
+ try
+ {
+ // force "early" detection of errors where possible
+ // (flags can't necessarily be set before parsing)
+ new JaxpParser().getXMLReader().setFeature(name, value);
+
+ flags.put(name, Boolean.valueOf(value));
+ }
+ catch (SAXNotRecognizedException e)
+ {
+ throw new SAXNotRecognizedException(name);
+ }
+ catch (SAXNotSupportedException e)
+ {
+ throw new SAXNotSupportedException(name);
+ }
+ catch (Exception e)
+ {
+ throw new ParserConfigurationException(e.getClass().getName()
+ + ": "
+ + e.getMessage());
+ }
+ }
+
+ public boolean getFeature(String name)
+ throws ParserConfigurationException, SAXNotRecognizedException,
+ SAXNotSupportedException
+ {
+ Boolean value = (Boolean) flags.get(name);
+
+ if (value != null)
+ {
+ return value.booleanValue();
+ }
+ else
+ {
+ try
+ {
+ return new JaxpParser().getXMLReader().getFeature(name);
+ }
+ catch (SAXNotRecognizedException e)
+ {
+ throw new SAXNotRecognizedException(name);
+ }
+ catch (SAXNotSupportedException e)
+ {
+ throw new SAXNotSupportedException(name);
+ }
+ catch (SAXException e)
+ {
+ throw new ParserConfigurationException(e.getClass().getName()
+ + ": "
+ + e.getMessage());
+ }
+ }
+ }
+
+ private static class JaxpParser
+ extends SAXParser
+ {
+
+ private XmlReader ae2 = new XmlReader();
+ private XMLReaderAdapter parser = null;
+
+ JaxpParser()
+ {
+ }
+
+ public void setProperty(String id, Object value)
+ throws SAXNotRecognizedException, SAXNotSupportedException
+ {
+ ae2.setProperty(id, value);
+ }
+
+ public Object getProperty(String id)
+ throws SAXNotRecognizedException, SAXNotSupportedException
+ {
+ return ae2.getProperty(id);
+ }
+
+ public Parser getParser()
+ throws SAXException
+ {
+ if (parser == null)
+ {
+ parser = new XMLReaderAdapter(ae2);
+ }
+ return parser;
+ }
+
+ public XMLReader getXMLReader ()
+ throws SAXException
+ {
+ return ae2;
+ }
+
+ public boolean isNamespaceAware()
+ {
+ try
+ {
+ return ae2.getFeature(SAXDriver.FEATURE + "namespaces");
+ }
+ catch (Exception e)
+ {
+ throw new Error();
+ }
+ }
+
+ public boolean isValidating()
+ {
+ try
+ {
+ return ae2.getFeature(SAXDriver.FEATURE + "validation");
+ }
+ catch (Exception e)
+ {
+ throw new Error();
+ }
+ }
+
+ // TODO isXIncludeAware()
+
+ }
+
+}
+
Added: llvm-gcc-4.2/trunk/libjava/classpath/gnu/xml/aelfred2/SAXDriver.java
URL: http://llvm.org/viewvc/llvm-project/llvm-gcc-4.2/trunk/libjava/classpath/gnu/xml/aelfred2/SAXDriver.java?rev=43913&view=auto
==============================================================================
--- llvm-gcc-4.2/trunk/libjava/classpath/gnu/xml/aelfred2/SAXDriver.java (added)
+++ llvm-gcc-4.2/trunk/libjava/classpath/gnu/xml/aelfred2/SAXDriver.java Thu Nov 8 16:56:19 2007
@@ -0,0 +1,1609 @@
+/* SAXDriver.java --
+ Copyright (C) 1999,2000,2001,2004 Free Software Foundation, Inc.
+
+This file is part of GNU Classpath.
+
+GNU Classpath is free software; you can redistribute it and/or modify
+it under the terms of the GNU General Public License as published by
+the Free Software Foundation; either version 2, or (at your option)
+any later version.
+
+GNU Classpath is distributed in the hope that it will be useful, but
+WITHOUT ANY WARRANTY; without even the implied warranty of
+MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+General Public License for more details.
+
+You should have received a copy of the GNU General Public License
+along with GNU Classpath; see the file COPYING. If not, write to the
+Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA
+02110-1301 USA.
+
+Linking this library statically or dynamically with other modules is
+making a combined work based on this library. Thus, the terms and
+conditions of the GNU General Public License cover the whole
+combination.
+
+As a special exception, the copyright holders of this library give you
+permission to link this library with independent modules to produce an
+executable, regardless of the license terms of these independent
+modules, and to copy and distribute the resulting executable under
+terms of your choice, provided that you also meet, for each linked
+independent module, the terms and conditions of the license of that
+module. An independent module is a module which is not derived from
+or based on this library. If you modify this library, you may extend
+this exception to your version of the library, but you are not
+obligated to do so. If you do not wish to do so, delete this
+exception statement from your version.
+
+Portions derived from code which carried the following notice:
+
+ Copyright (c) 1997, 1998 by Microstar Software Ltd.
+
+ AElfred is free for both commercial and non-commercial use and
+ redistribution, provided that Microstar's copyright and disclaimer are
+ retained intact. You are free to modify AElfred for your own use and
+ to redistribute AElfred with your modifications, provided that the
+ modifications are clearly documented.
+
+ This program is distributed in the hope that it will be useful, but
+ WITHOUT ANY WARRANTY; without even the implied warranty of
+ merchantability or fitness for a particular purpose. Please use it AT
+ YOUR OWN RISK.
+*/
+
+package gnu.xml.aelfred2;
+
+import java.io.*;
+
+import java.net.MalformedURLException;
+import java.net.URL;
+import java.util.Locale;
+import java.util.Stack;
+
+import java.util.ArrayList;
+import java.util.Collections;
+import java.util.Enumeration;
+import java.util.Iterator;
+import java.util.List;
+
+import org.xml.sax.*;
+import org.xml.sax.ext.*;
+import org.xml.sax.helpers.NamespaceSupport;
+
+
+/**
+ * An enhanced SAX2 version of Microstar's Ælfred XML parser.
+ * The enhancements primarily relate to significant improvements in
+ * conformance to the XML specification, and SAX2 support. Performance
+ * has been improved. See the package level documentation for more
+ * information.
+ *
+ * <table border="1" width='100%' cellpadding='3' cellspacing='0'>
+ * <tr bgcolor='#ccccff'>
+ * <th><font size='+1'>Name</font></th>
+ * <th><font size='+1'>Notes</font></th></tr>
+ *
+ * <tr><td colspan=2><center><em>Features ... URL prefix is
+ * <b>http://xml.org/sax/features/</b></em></center></td></tr>
+ *
+ * <tr><td>(URL)/external-general-entities</td>
+ * <td>Value defaults to <em>true</em></td></tr>
+ * <tr><td>(URL)/external-parameter-entities</td>
+ * <td>Value defaults to <em>true</em></td></tr>
+ * <tr><td>(URL)/is-standalone</td>
+ * <td>(PRELIMINARY) Returns true iff the document's parsing
+ * has started (some non-error event after <em>startDocument()</em>
+ * was reported) and the document's standalone flag is set.</td></tr>
+ * <tr><td>(URL)/namespace-prefixes</td>
+ * <td>Value defaults to <em>false</em> (but XML 1.0 names are
+ * always reported)</td></tr>
+ * <tr><td>(URL)/lexical-handler/parameter-entities</td>
+ * <td>Value is fixed at <em>true</em></td></tr>
+ * <tr><td>(URL)/namespaces</td>
+ * <td>Value defaults to <em>true</em></td></tr>
+ * <tr><td>(URL)/resolve-dtd-uris</td>
+ * <td>(PRELIMINARY) Value defaults to <em>true</em></td></tr>
+ * <tr><td>(URL)/string-interning</td>
+ * <td>Value is fixed at <em>true</em></td></tr>
+ * <tr><td>(URL)/use-attributes2</td>
+ * <td>(PRELIMINARY) Value is fixed at <em>true</em></td></tr>
+ * <tr><td>(URL)/use-entity-resolver2</td>
+ * <td>(PRELIMINARY) Value defaults to <em>true</em></td></tr>
+ * <tr><td>(URL)/validation</td>
+ * <td>Value is fixed at <em>false</em></td></tr>
+ *
+ * <tr><td colspan=2><center><em>Handler Properties ... URL prefix is
+ * <b>http://xml.org/sax/properties/</b></em></center></td></tr>
+ *
+ * <tr><td>(URL)/declaration-handler</td>
+ * <td>A declaration handler may be provided. </td></tr>
+ * <tr><td>(URL)/lexical-handler</td>
+ * <td>A lexical handler may be provided. </td></tr>
+ * </table>
+ *
+ * <p>This parser currently implements the SAX1 Parser API, but
+ * it may not continue to do so in the future.
+ *
+ * @author Written by David Megginson (version 1.2a from Microstar)
+ * @author Updated by David Brownell <dbrownell at users.sourceforge.net>
+ * @see org.xml.sax.Parser
+ */
+final public class SAXDriver
+ implements Locator, Attributes2, XMLReader, Parser, AttributeList
+{
+
+ private final DefaultHandler2 base = new DefaultHandler2();
+ private XmlParser parser;
+
+ private EntityResolver entityResolver = base;
+ private EntityResolver2 resolver2 = null;
+ private ContentHandler contentHandler = base;
+ private DTDHandler dtdHandler = base;
+ private ErrorHandler errorHandler = base;
+ private DeclHandler declHandler = base;
+ private LexicalHandler lexicalHandler = base;
+
+ private String elementName;
+ private Stack entityStack;
+
+ // one vector (of object/struct): faster, smaller
+ private List attributesList;
+
+ private boolean namespaces = true;
+ private boolean xmlNames = false;
+ private boolean extGE = true;
+ private boolean extPE = true;
+ private boolean resolveAll = true;
+ private boolean useResolver2 = true;
+
+ // package private to allow (read-only) access in XmlParser
+ boolean stringInterning = true;
+
+ private int attributeCount;
+ private boolean attributes;
+ private String[] nsTemp;
+ private NamespaceSupport prefixStack;
+
+ //
+ // Constructor.
+ //
+
+ /**
+ * Constructs a SAX Parser.
+ */
+ public SAXDriver()
+ {
+ reset();
+ }
+
+ private void reset()
+ {
+ elementName = null;
+ entityStack = new Stack();
+ attributesList = Collections.synchronizedList(new ArrayList());
+ attributeCount = 0;
+ attributes = false;
+ nsTemp = new String[3];
+ prefixStack = null;
+ }
+
+
+ //
+ // Implementation of org.xml.sax.Parser.
+ //
+
+ /**
+ * <b>SAX1</b>: Sets the locale used for diagnostics; currently,
+ * only locales using the English language are supported.
+ * @param locale The locale for which diagnostics will be generated
+ */
+ public void setLocale(Locale locale)
+ throws SAXException
+ {
+ if ("en".equals(locale.getLanguage()))
+ {
+ return;
+ }
+ throw new SAXException ("AElfred2 only supports English locales.");
+ }
+
+ /**
+ * <b>SAX2</b>: Returns the object used when resolving external
+ * entities during parsing (both general and parameter entities).
+ */
+ public EntityResolver getEntityResolver()
+ {
+ return (entityResolver == base) ? null : entityResolver;
+ }
+
+ /**
+ * <b>SAX1, SAX2</b>: Set the entity resolver for this parser.
+ * @param handler The object to receive entity events.
+ */
+ public void setEntityResolver(EntityResolver resolver)
+ {
+ if (resolver instanceof EntityResolver2)
+ {
+ resolver2 = (EntityResolver2) resolver;
+ }
+ else
+ {
+ resolver2 = null;
+ }
+ if (resolver == null)
+ {
+ resolver = base;
+ }
+ entityResolver = resolver;
+ }
+
+ /**
+ * <b>SAX2</b>: Returns the object used to process declarations related
+ * to notations and unparsed entities.
+ */
+ public DTDHandler getDTDHandler()
+ {
+ return (dtdHandler == base) ? null : dtdHandler;
+ }
+
+ /**
+ * <b>SAX1, SAX2</b>: Set the DTD handler for this parser.
+ * @param handler The object to receive DTD events.
+ */
+ public void setDTDHandler(DTDHandler handler)
+ {
+ if (handler == null)
+ {
+ handler = base;
+ }
+ this.dtdHandler = handler;
+ }
+
+
+ /**
+ * <b>SAX1</b>: Set the document handler for this parser. If a
+ * content handler was set, this document handler will supplant it.
+ * The parser is set to report all XML 1.0 names rather than to
+ * filter out "xmlns" attributes (the "namespace-prefixes" feature
+ * is set to true).
+ *
+ * @deprecated SAX2 programs should use the XMLReader interface
+ * and a ContentHandler.
+ *
+ * @param handler The object to receive document events.
+ */
+ public void setDocumentHandler(DocumentHandler handler)
+ {
+ contentHandler = new Adapter(handler);
+ xmlNames = true;
+ }
+
+ /**
+ * <b>SAX2</b>: Returns the object used to report the logical
+ * content of an XML document.
+ */
+ public ContentHandler getContentHandler()
+ {
+ return (contentHandler == base) ? null : contentHandler;
+ }
+
+ /**
+ * <b>SAX2</b>: Assigns the object used to report the logical
+ * content of an XML document. If a document handler was set,
+ * this content handler will supplant it (but XML 1.0 style name
+ * reporting may remain enabled).
+ */
+ public void setContentHandler(ContentHandler handler)
+ {
+ if (handler == null)
+ {
+ handler = base;
+ }
+ contentHandler = handler;
+ }
+
+ /**
+ * <b>SAX1, SAX2</b>: Set the error handler for this parser.
+ * @param handler The object to receive error events.
+ */
+ public void setErrorHandler(ErrorHandler handler)
+ {
+ if (handler == null)
+ {
+ handler = base;
+ }
+ this.errorHandler = handler;
+ }
+
+ /**
+ * <b>SAX2</b>: Returns the object used to receive callbacks for XML
+ * errors of all levels (fatal, nonfatal, warning); this is never null;
+ */
+ public ErrorHandler getErrorHandler()
+ {
+ return (errorHandler == base) ? null : errorHandler;
+ }
+
+ /**
+ * <b>SAX1, SAX2</b>: Auxiliary API to parse an XML document, used mostly
+ * when no URI is available.
+ * If you want anything useful to happen, you should set
+ * at least one type of handler.
+ * @param source The XML input source. Don't set 'encoding' unless
+ * you know for a fact that it's correct.
+ * @see #setEntityResolver
+ * @see #setDTDHandler
+ * @see #setContentHandler
+ * @see #setErrorHandler
+ * @exception SAXException The handlers may throw any SAXException,
+ * and the parser normally throws SAXParseException objects.
+ * @exception IOException IOExceptions are normally through through
+ * the parser if there are problems reading the source document.
+ */
+ public void parse(InputSource source)
+ throws SAXException, IOException
+ {
+ synchronized (base)
+ {
+ parser = new XmlParser();
+ if (namespaces)
+ {
+ prefixStack = new NamespaceSupport();
+ }
+ else if (!xmlNames)
+ {
+ throw new IllegalStateException();
+ }
+ parser.setHandler(this);
+
+ try
+ {
+ Reader r = source.getCharacterStream();
+ InputStream in = source.getByteStream();
+
+ parser.doParse(source.getSystemId(),
+ source.getPublicId(),
+ r,
+ in,
+ source.getEncoding());
+ }
+ catch (SAXException e)
+ {
+ throw e;
+ }
+ catch (IOException e)
+ {
+ throw e;
+ }
+ catch (RuntimeException e)
+ {
+ throw e;
+ }
+ catch (Exception e)
+ {
+ throw new SAXParseException(e.getMessage(), this, e);
+ }
+ finally
+ {
+ contentHandler.endDocument();
+ reset();
+ }
+ }
+ }
+
+ /**
+ * <b>SAX1, SAX2</b>: Preferred API to parse an XML document, using a
+ * system identifier (URI).
+ */
+ public void parse(String systemId)
+ throws SAXException, IOException
+ {
+ parse(new InputSource(systemId));
+ }
+
+ //
+ // Implementation of SAX2 "XMLReader" interface
+ //
+ static final String FEATURE = "http://xml.org/sax/features/";
+ static final String PROPERTY = "http://xml.org/sax/properties/";
+
+ /**
+ * <b>SAX2</b>: Tells the value of the specified feature flag.
+ *
+ * @exception SAXNotRecognizedException thrown if the feature flag
+ * is neither built in, nor yet assigned.
+ */
+ public boolean getFeature(String featureId)
+ throws SAXNotRecognizedException, SAXNotSupportedException
+ {
+ if ((FEATURE + "validation").equals(featureId))
+ {
+ return false;
+ }
+
+ // external entities (both types) are optionally included
+ if ((FEATURE + "external-general-entities").equals(featureId))
+ {
+ return extGE;
+ }
+ if ((FEATURE + "external-parameter-entities").equals(featureId))
+ {
+ return extPE;
+ }
+
+ // element/attribute names are as written in document; no mangling
+ if ((FEATURE + "namespace-prefixes").equals(featureId))
+ {
+ return xmlNames;
+ }
+
+ // report element/attribute namespaces?
+ if ((FEATURE + "namespaces").equals(featureId))
+ {
+ return namespaces;
+ }
+
+ // all PEs and GEs are reported
+ if ((FEATURE + "lexical-handler/parameter-entities").equals(featureId))
+ {
+ return true;
+ }
+
+ // default is true
+ if ((FEATURE + "string-interning").equals(featureId))
+ {
+ return stringInterning;
+ }
+
+ // EXTENSIONS 1.1
+
+ // always returns isSpecified info
+ if ((FEATURE + "use-attributes2").equals(featureId))
+ {
+ return true;
+ }
+
+ // meaningful between startDocument/endDocument
+ if ((FEATURE + "is-standalone").equals(featureId))
+ {
+ if (parser == null)
+ {
+ throw new SAXNotSupportedException(featureId);
+ }
+ return parser.isStandalone();
+ }
+
+ // optionally don't absolutize URIs in declarations
+ if ((FEATURE + "resolve-dtd-uris").equals(featureId))
+ {
+ return resolveAll;
+ }
+
+ // optionally use resolver2 interface methods, if possible
+ if ((FEATURE + "use-entity-resolver2").equals(featureId))
+ {
+ return useResolver2;
+ }
+
+ throw new SAXNotRecognizedException(featureId);
+ }
+
+ // package private
+ DeclHandler getDeclHandler()
+ {
+ return declHandler;
+ }
+
+ // package private
+ boolean resolveURIs()
+ {
+ return resolveAll;
+ }
+
+ /**
+ * <b>SAX2</b>: Returns the specified property.
+ *
+ * @exception SAXNotRecognizedException thrown if the property value
+ * is neither built in, nor yet stored.
+ */
+ public Object getProperty(String propertyId)
+ throws SAXNotRecognizedException
+ {
+ if ((PROPERTY + "declaration-handler").equals(propertyId))
+ {
+ return (declHandler == base) ? null : declHandler;
+ }
+
+ if ((PROPERTY + "lexical-handler").equals(propertyId))
+ {
+ return (lexicalHandler == base) ? null : lexicalHandler;
+ }
+
+ // unknown properties
+ throw new SAXNotRecognizedException(propertyId);
+ }
+
+ /**
+ * <b>SAX2</b>: Sets the state of feature flags in this parser. Some
+ * built-in feature flags are mutable.
+ */
+ public void setFeature(String featureId, boolean value)
+ throws SAXNotRecognizedException, SAXNotSupportedException
+ {
+ boolean state;
+
+ // Features with a defined value, we just change it if we can.
+ state = getFeature (featureId);
+
+ if (state == value)
+ {
+ return;
+ }
+ if (parser != null)
+ {
+ throw new SAXNotSupportedException("not while parsing");
+ }
+
+ if ((FEATURE + "namespace-prefixes").equals(featureId))
+ {
+ // in this implementation, this only affects xmlns reporting
+ xmlNames = value;
+ // forcibly prevent illegal parser state
+ if (!xmlNames)
+ {
+ namespaces = true;
+ }
+ return;
+ }
+
+ if ((FEATURE + "namespaces").equals(featureId))
+ {
+ namespaces = value;
+ // forcibly prevent illegal parser state
+ if (!namespaces)
+ {
+ xmlNames = true;
+ }
+ return;
+ }
+
+ if ((FEATURE + "external-general-entities").equals(featureId))
+ {
+ extGE = value;
+ return;
+ }
+ if ((FEATURE + "external-parameter-entities").equals(featureId))
+ {
+ extPE = value;
+ return;
+ }
+ if ((FEATURE + "resolve-dtd-uris").equals(featureId))
+ {
+ resolveAll = value;
+ return;
+ }
+
+ if ((FEATURE + "use-entity-resolver2").equals(featureId))
+ {
+ useResolver2 = value;
+ return;
+ }
+
+ throw new SAXNotRecognizedException(featureId);
+ }
+
+ /**
+ * <b>SAX2</b>: Assigns the specified property. Like SAX1 handlers,
+ * these may be changed at any time.
+ */
+ public void setProperty(String propertyId, Object value)
+ throws SAXNotRecognizedException, SAXNotSupportedException
+ {
+ // see if the property is recognized
+ getProperty(propertyId);
+
+ // Properties with a defined value, we just change it if we can.
+
+ if ((PROPERTY + "declaration-handler").equals(propertyId))
+ {
+ if (value == null)
+ {
+ declHandler = base;
+ }
+ else if (!(value instanceof DeclHandler))
+ {
+ throw new SAXNotSupportedException(propertyId);
+ }
+ else
+ {
+ declHandler = (DeclHandler) value;
+ }
+ return ;
+ }
+
+ if ((PROPERTY + "lexical-handler").equals(propertyId))
+ {
+ if (value == null)
+ {
+ lexicalHandler = base;
+ }
+ else if (!(value instanceof LexicalHandler))
+ {
+ throw new SAXNotSupportedException(propertyId);
+ }
+ else
+ {
+ lexicalHandler = (LexicalHandler) value;
+ }
+ return;
+ }
+
+ throw new SAXNotSupportedException(propertyId);
+ }
+
+ //
+ // This is where the driver receives XmlParser callbacks and translates
+ // them into SAX callbacks. Some more callbacks have been added for
+ // SAX2 support.
+ //
+
+ void startDocument()
+ throws SAXException
+ {
+ contentHandler.setDocumentLocator(this);
+ contentHandler.startDocument();
+ attributesList.clear();
+ }
+
+ void skippedEntity(String name)
+ throws SAXException
+ {
+ contentHandler.skippedEntity(name);
+ }
+
+ InputSource getExternalSubset(String name, String baseURI)
+ throws SAXException, IOException
+ {
+ if (resolver2 == null || !useResolver2 || !extPE)
+ {
+ return null;
+ }
+ return resolver2.getExternalSubset(name, baseURI);
+ }
+
+ InputSource resolveEntity(boolean isPE, String name,
+ InputSource in, String baseURI)
+ throws SAXException, IOException
+ {
+ InputSource source;
+
+ // external entities might be skipped
+ if (isPE && !extPE)
+ {
+ return null;
+ }
+ if (!isPE && !extGE)
+ {
+ return null;
+ }
+
+ // ... or not
+ lexicalHandler.startEntity(name);
+ if (resolver2 != null && useResolver2)
+ {
+ source = resolver2.resolveEntity(name, in.getPublicId(),
+ baseURI, in.getSystemId());
+ if (source == null)
+ {
+ in.setSystemId(absolutize(baseURI,
+ in.getSystemId(), false));
+ source = in;
+ }
+ }
+ else
+ {
+ in.setSystemId(absolutize(baseURI,
+ in.getSystemId(),
+ entityResolver != base));
+ source = entityResolver.resolveEntity(in.getPublicId(),
+ in.getSystemId());
+ if (source == null)
+ {
+ source = in;
+ }
+ }
+ startExternalEntity(name, source.getSystemId(), true);
+ return source;
+ }
+
+ // absolutize a system ID relative to the specified base URI
+ // (temporarily) package-visible for external entity decls
+ String absolutize(String baseURI, String systemId, boolean nice)
+ throws MalformedURLException, SAXException
+ {
+ // FIXME normalize system IDs -- when?
+ // - Convert to UTF-8
+ // - Map reserved and non-ASCII characters to %HH
+
+ try
+ {
+ if (baseURI == null)
+ {
+ if (XmlParser.uriWarnings)
+ {
+ warn ("No base URI; hope this SYSTEM id is absolute: "
+ + systemId);
+ }
+ return new URL(systemId).toString();
+ }
+ else
+ {
+ return new URL(new URL(baseURI), systemId).toString();
+ }
+ }
+ catch (MalformedURLException e)
+ {
+ // Let unknown URI schemes pass through unless we need
+ // the JVM to map them to i/o streams for us...
+ if (!nice)
+ {
+ throw e;
+ }
+
+ // sometimes sysids for notations or unparsed entities
+ // aren't really URIs...
+ warn("Can't absolutize SYSTEM id: " + e.getMessage());
+ return systemId;
+ }
+ }
+
+ void startExternalEntity(String name, String systemId, boolean stackOnly)
+ throws SAXException
+ {
+ // The following warning was deleted because the application has the
+ // option of not setting systemId. Sun's JAXP or Xerces seems to
+ // ignore this case.
+ /*
+ if (systemId == null)
+ warn ("URI was not reported to parser for entity " + name);
+ */
+ if (!stackOnly) // spliced [dtd] needs startEntity
+ {
+ lexicalHandler.startEntity(name);
+ }
+ entityStack.push(systemId);
+ }
+
+ void endExternalEntity(String name)
+ throws SAXException
+ {
+ if (!"[document]".equals(name))
+ {
+ lexicalHandler.endEntity(name);
+ }
+ entityStack.pop();
+ }
+
+ void startInternalEntity(String name)
+ throws SAXException
+ {
+ lexicalHandler.startEntity(name);
+ }
+
+ void endInternalEntity(String name)
+ throws SAXException
+ {
+ lexicalHandler.endEntity(name);
+ }
+
+ void doctypeDecl(String name, String publicId, String systemId)
+ throws SAXException
+ {
+ lexicalHandler.startDTD(name, publicId, systemId);
+
+ // ... the "name" is a declaration and should be given
+ // to the DeclHandler (but sax2 doesn't).
+
+ // the IDs for the external subset are lexical details,
+ // as are the contents of the internal subset; but sax2
+ // doesn't provide the internal subset "pre-parse"
+ }
+
+ void notationDecl(String name, String publicId, String systemId,
+ String baseUri)
+ throws SAXException
+ {
+ try
+ {
+ dtdHandler.notationDecl(name, publicId,
+ (resolveAll && systemId != null)
+ ? absolutize(baseUri, systemId, true)
+ : systemId);
+ }
+ catch (IOException e)
+ {
+ // "can't happen"
+ throw new SAXParseException(e.getMessage(), this, e);
+ }
+ }
+
+ void unparsedEntityDecl(String name, String publicId, String systemId,
+ String baseUri, String notation)
+ throws SAXException
+ {
+ try
+ {
+ dtdHandler.unparsedEntityDecl(name, publicId,
+ resolveAll
+ ? absolutize(baseUri, systemId, true)
+ : systemId,
+ notation);
+ }
+ catch (IOException e)
+ {
+ // "can't happen"
+ throw new SAXParseException(e.getMessage(), this, e);
+ }
+ }
+
+ void endDoctype()
+ throws SAXException
+ {
+ lexicalHandler.endDTD();
+ }
+
+ private void declarePrefix(String prefix, String uri)
+ throws SAXException
+ {
+ int index = uri.indexOf(':');
+
+ // many versions of nwalsh docbook stylesheets
+ // have bogus URLs; so this can't be an error...
+ if (index < 1 && uri.length() != 0)
+ {
+ warn("relative URI for namespace: " + uri);
+ }
+
+ // FIXME: char [0] must be ascii alpha; chars [1..index]
+ // must be ascii alphanumeric or in "+-." [RFC 2396]
+
+ //Namespace Constraints
+ //name for xml prefix must be http://www.w3.org/XML/1998/namespace
+ boolean prefixEquality = prefix.equals("xml");
+ boolean uriEquality = uri.equals("http://www.w3.org/XML/1998/namespace");
+ if ((prefixEquality || uriEquality) && !(prefixEquality && uriEquality))
+ {
+ fatal("xml is by definition bound to the namespace name " +
+ "http://www.w3.org/XML/1998/namespace");
+ }
+
+ //xmlns prefix declaration is illegal but xml prefix declaration is llegal...
+ if (prefixEquality && uriEquality)
+ {
+ return;
+ }
+
+ //name for xmlns prefix must be http://www.w3.org/2000/xmlns/
+ prefixEquality = prefix.equals("xmlns");
+ uriEquality = uri.equals("http://www.w3.org/2000/xmlns/");
+ if ((prefixEquality || uriEquality) && !(prefixEquality && uriEquality))
+ {
+ fatal("http://www.w3.org/2000/xmlns/ is by definition bound" +
+ " to prefix xmlns");
+ }
+
+ //even if the uri is http://www.w3.org/2000/xmlns/
+ // it is illegal to declare it
+ if (prefixEquality && uriEquality)
+ {
+ fatal ("declaring the xmlns prefix is illegal");
+ }
+
+ uri = uri.intern();
+ prefixStack.declarePrefix(prefix, uri);
+ contentHandler.startPrefixMapping(prefix, uri);
+ }
+
+ void attribute(String qname, String value, boolean isSpecified)
+ throws SAXException
+ {
+ if (!attributes)
+ {
+ attributes = true;
+ if (namespaces)
+ {
+ prefixStack.pushContext();
+ }
+ }
+
+ // process namespace decls immediately;
+ // then maybe forget this as an attribute
+ if (namespaces)
+ {
+ int index;
+
+ // default NS declaration?
+ if (stringInterning)
+ {
+ if ("xmlns" == qname)
+ {
+ declarePrefix("", value);
+ if (!xmlNames)
+ {
+ return;
+ }
+ }
+ // NS prefix declaration?
+ else if ((index = qname.indexOf(':')) == 5
+ && qname.startsWith("xmlns"))
+ {
+ String prefix = qname.substring(6);
+
+ if (prefix.equals(""))
+ {
+ fatal("missing prefix " +
+ "in namespace declaration attribute");
+ }
+ if (value.length() == 0)
+ {
+ verror("missing URI in namespace declaration attribute: "
+ + qname);
+ }
+ else
+ {
+ declarePrefix(prefix, value);
+ }
+ if (!xmlNames)
+ {
+ return;
+ }
+ }
+ }
+ else
+ {
+ if ("xmlns".equals(qname))
+ {
+ declarePrefix("", value);
+ if (!xmlNames)
+ {
+ return;
+ }
+ }
+ // NS prefix declaration?
+ else if ((index = qname.indexOf(':')) == 5
+ && qname.startsWith("xmlns"))
+ {
+ String prefix = qname.substring(6);
+
+ if (value.length() == 0)
+ {
+ verror("missing URI in namespace decl attribute: "
+ + qname);
+ }
+ else
+ {
+ declarePrefix(prefix, value);
+ }
+ if (!xmlNames)
+ {
+ return;
+ }
+ }
+ }
+ }
+ // remember this attribute ...
+ attributeCount++;
+
+ // attribute type comes from querying parser's DTD records
+ attributesList.add(new Attribute(qname, value, isSpecified));
+
+ }
+
+ void startElement(String elname)
+ throws SAXException
+ {
+ ContentHandler handler = contentHandler;
+
+ //
+ // NOTE: this implementation of namespace support adds something
+ // like six percent to parsing CPU time, in a large (~50 MB)
+ // document that doesn't use namespaces at all. (Measured by PC
+ // sampling, with a bug where endElement processing was omitted.)
+ // [Measurement referred to older implementation, older JVM ...]
+ //
+ // It ought to become notably faster in such cases. Most
+ // costs are the prefix stack calling Hashtable.get() (2%),
+ // String.hashCode() (1.5%) and about 1.3% each for pushing
+ // the context, and two chunks of name processing.
+ //
+
+ if (!attributes)
+ {
+ if (namespaces)
+ {
+ prefixStack.pushContext();
+ }
+ }
+ else if (namespaces)
+ {
+
+ // now we can patch up namespace refs; we saw all the
+ // declarations, so now we'll do the Right Thing
+ Iterator itt = attributesList.iterator();
+ while (itt.hasNext())
+ {
+ Attribute attribute = (Attribute) itt.next();
+ String qname = attribute.name;
+ int index;
+
+ // default NS declaration?
+ if (stringInterning)
+ {
+ if ("xmlns" == qname)
+ {
+ continue;
+ }
+ }
+ else
+ {
+ if ("xmlns".equals(qname))
+ {
+ continue;
+ }
+ }
+ //Illegal in the new Namespaces Draft
+ //should it be only in 1.1 docs??
+ if (qname.equals (":"))
+ {
+ fatal("namespace names consisting of a single colon " +
+ "character are invalid");
+ }
+ index = qname.indexOf(':');
+
+ // NS prefix declaration?
+ if (index == 5 && qname.startsWith("xmlns"))
+ {
+ continue;
+ }
+
+ // it's not a NS decl; patch namespace info items
+ if (prefixStack.processName(qname, nsTemp, true) == null)
+ {
+ fatal("undeclared attribute prefix in: " + qname);
+ }
+ else
+ {
+ attribute.nameSpace = nsTemp[0];
+ attribute.localName = nsTemp[1];
+ }
+ }
+ }
+
+ // save element name so attribute callbacks work
+ elementName = elname;
+ if (namespaces)
+ {
+ if (prefixStack.processName(elname, nsTemp, false) == null)
+ {
+ fatal("undeclared element prefix in: " + elname);
+ nsTemp[0] = nsTemp[1] = "";
+ }
+ handler.startElement(nsTemp[0], nsTemp[1], elname, this);
+ }
+ else
+ {
+ handler.startElement("", "", elname, this);
+ }
+ // elementName = null;
+
+ // elements with no attributes are pretty common!
+ if (attributes)
+ {
+ attributesList.clear();
+ attributeCount = 0;
+ attributes = false;
+ }
+ }
+
+ void endElement(String elname)
+ throws SAXException
+ {
+ ContentHandler handler = contentHandler;
+
+ if (!namespaces)
+ {
+ handler.endElement("", "", elname);
+ return;
+ }
+ prefixStack.processName(elname, nsTemp, false);
+ handler.endElement(nsTemp[0], nsTemp[1], elname);
+
+ Enumeration prefixes = prefixStack.getDeclaredPrefixes();
+
+ while (prefixes.hasMoreElements())
+ {
+ handler.endPrefixMapping((String) prefixes.nextElement());
+ }
+ prefixStack.popContext();
+ }
+
+ void startCDATA()
+ throws SAXException
+ {
+ lexicalHandler.startCDATA();
+ }
+
+ void charData(char[] ch, int start, int length)
+ throws SAXException
+ {
+ contentHandler.characters(ch, start, length);
+ }
+
+ void endCDATA()
+ throws SAXException
+ {
+ lexicalHandler.endCDATA();
+ }
+
+ void ignorableWhitespace(char[] ch, int start, int length)
+ throws SAXException
+ {
+ contentHandler.ignorableWhitespace(ch, start, length);
+ }
+
+ void processingInstruction(String target, String data)
+ throws SAXException
+ {
+ contentHandler.processingInstruction(target, data);
+ }
+
+ void comment(char[] ch, int start, int length)
+ throws SAXException
+ {
+ if (lexicalHandler != base)
+ {
+ lexicalHandler.comment(ch, start, length);
+ }
+ }
+
+ void fatal(String message)
+ throws SAXException
+ {
+ SAXParseException fatal;
+
+ fatal = new SAXParseException(message, this);
+ errorHandler.fatalError(fatal);
+
+ // Even if the application can continue ... we can't!
+ throw fatal;
+ }
+
+ // We can safely report a few validity errors that
+ // make layered SAX2 DTD validation more conformant
+ void verror(String message)
+ throws SAXException
+ {
+ SAXParseException err;
+
+ err = new SAXParseException(message, this);
+ errorHandler.error(err);
+ }
+
+ void warn(String message)
+ throws SAXException
+ {
+ SAXParseException err;
+
+ err = new SAXParseException(message, this);
+ errorHandler.warning(err);
+ }
+
+ //
+ // Implementation of org.xml.sax.Attributes.
+ //
+
+ /**
+ * <b>SAX1 AttributeList, SAX2 Attributes</b> method
+ * (don't invoke on parser);
+ */
+ public int getLength()
+ {
+ return attributesList.size();
+ }
+
+ /**
+ * <b>SAX2 Attributes</b> method (don't invoke on parser);
+ */
+ public String getURI(int index)
+ {
+ if (index < 0 || index >= attributesList.size())
+ {
+ return null;
+ }
+ return ((Attribute) attributesList.get(index)).nameSpace;
+ }
+
+ /**
+ * <b>SAX2 Attributes</b> method (don't invoke on parser);
+ */
+ public String getLocalName(int index)
+ {
+ if (index < 0 || index >= attributesList.size())
+ {
+ return null;
+ }
+ Attribute attr = (Attribute) attributesList.get(index);
+ // FIXME attr.localName is sometimes null, why?
+ if (namespaces && attr.localName == null)
+ {
+ // XXX fix this here for now
+ int ci = attr.name.indexOf(':');
+ attr.localName = (ci == -1) ? attr.name :
+ attr.name.substring(ci + 1);
+ }
+ return (attr.localName == null) ? "" : attr.localName;
+ }
+
+ /**
+ * <b>SAX2 Attributes</b> method (don't invoke on parser);
+ */
+ public String getQName(int index)
+ {
+ if (index < 0 || index >= attributesList.size())
+ {
+ return null;
+ }
+ Attribute attr = (Attribute) attributesList.get(index);
+ return (attr.name == null) ? "" : attr.name;
+ }
+
+ /**
+ * <b>SAX1 AttributeList</b> method (don't invoke on parser);
+ */
+ public String getName(int index)
+ {
+ return getQName(index);
+ }
+
+ /**
+ * <b>SAX1 AttributeList, SAX2 Attributes</b> method
+ * (don't invoke on parser);
+ */
+ public String getType(int index)
+ {
+ if (index < 0 || index >= attributesList.size())
+ {
+ return null;
+ }
+ String type = parser.getAttributeType(elementName, getQName(index));
+ if (type == null)
+ {
+ return "CDATA";
+ }
+ // ... use DeclHandler.attributeDecl to see enumerations
+ if (type == "ENUMERATION")
+ {
+ return "NMTOKEN";
+ }
+ return type;
+ }
+
+ /**
+ * <b>SAX1 AttributeList, SAX2 Attributes</b> method
+ * (don't invoke on parser);
+ */
+ public String getValue(int index)
+ {
+ if (index < 0 || index >= attributesList.size())
+ {
+ return null;
+ }
+ return ((Attribute) attributesList.get(index)).value;
+ }
+
+ /**
+ * <b>SAX2 Attributes</b> method (don't invoke on parser);
+ */
+ public int getIndex(String uri, String local)
+ {
+ int length = getLength();
+
+ for (int i = 0; i < length; i++)
+ {
+ if (!getURI(i).equals(uri))
+ {
+ continue;
+ }
+ if (getLocalName(i).equals(local))
+ {
+ return i;
+ }
+ }
+ return -1;
+ }
+
+ /**
+ * <b>SAX2 Attributes</b> method (don't invoke on parser);
+ */
+ public int getIndex(String xmlName)
+ {
+ int length = getLength();
+
+ for (int i = 0; i < length; i++)
+ {
+ if (getQName(i).equals(xmlName))
+ {
+ return i;
+ }
+ }
+ return -1;
+ }
+
+ /**
+ * <b>SAX2 Attributes</b> method (don't invoke on parser);
+ */
+ public String getType(String uri, String local)
+ {
+ int index = getIndex(uri, local);
+
+ if (index < 0)
+ {
+ return null;
+ }
+ return getType(index);
+ }
+
+ /**
+ * <b>SAX1 AttributeList, SAX2 Attributes</b> method
+ * (don't invoke on parser);
+ */
+ public String getType(String xmlName)
+ {
+ int index = getIndex(xmlName);
+
+ if (index < 0)
+ {
+ return null;
+ }
+ return getType(index);
+ }
+
+ /**
+ * <b>SAX Attributes</b> method (don't invoke on parser);
+ */
+ public String getValue(String uri, String local)
+ {
+ int index = getIndex(uri, local);
+
+ if (index < 0)
+ {
+ return null;
+ }
+ return getValue(index);
+ }
+
+ /**
+ * <b>SAX1 AttributeList, SAX2 Attributes</b> method
+ * (don't invoke on parser);
+ */
+ public String getValue(String xmlName)
+ {
+ int index = getIndex(xmlName);
+
+ if (index < 0)
+ {
+ return null;
+ }
+ return getValue(index);
+ }
+
+ //
+ // Implementation of org.xml.sax.ext.Attributes2
+ //
+
+ /** @return false unless the attribute was declared in the DTD.
+ * @throws java.lang.ArrayIndexOutOfBoundsException
+ * When the supplied index does not identify an attribute.
+ */
+ public boolean isDeclared(int index)
+ {
+ if (index < 0 || index >= attributeCount)
+ {
+ throw new ArrayIndexOutOfBoundsException();
+ }
+ String type = parser.getAttributeType(elementName, getQName(index));
+ return (type != null);
+ }
+
+ /** @return false unless the attribute was declared in the DTD.
+ * @throws java.lang.IllegalArgumentException
+ * When the supplied names do not identify an attribute.
+ */
+ public boolean isDeclared(String qName)
+ {
+ int index = getIndex(qName);
+ if (index < 0)
+ {
+ throw new IllegalArgumentException();
+ }
+ String type = parser.getAttributeType(elementName, qName);
+ return (type != null);
+ }
+
+ /** @return false unless the attribute was declared in the DTD.
+ * @throws java.lang.IllegalArgumentException
+ * When the supplied names do not identify an attribute.
+ */
+ public boolean isDeclared(String uri, String localName)
+ {
+ int index = getIndex(uri, localName);
+ return isDeclared(index);
+ }
+
+ /**
+ * <b>SAX-ext Attributes2</b> method (don't invoke on parser);
+ */
+ public boolean isSpecified(int index)
+ {
+ return ((Attribute) attributesList.get(index)).specified;
+ }
+
+ /**
+ * <b>SAX-ext Attributes2</b> method (don't invoke on parser);
+ */
+ public boolean isSpecified(String uri, String local)
+ {
+ int index = getIndex (uri, local);
+ return isSpecified(index);
+ }
+
+ /**
+ * <b>SAX-ext Attributes2</b> method (don't invoke on parser);
+ */
+ public boolean isSpecified(String xmlName)
+ {
+ int index = getIndex (xmlName);
+ return isSpecified(index);
+ }
+
+ //
+ // Implementation of org.xml.sax.Locator.
+ //
+
+ /**
+ * <b>SAX Locator</b> method (don't invoke on parser);
+ */
+ public String getPublicId()
+ {
+ return null; // FIXME track public IDs too
+ }
+
+ /**
+ * <b>SAX Locator</b> method (don't invoke on parser);
+ */
+ public String getSystemId()
+ {
+ if (entityStack.empty())
+ {
+ return null;
+ }
+ else
+ {
+ return (String) entityStack.peek();
+ }
+ }
+
+ /**
+ * <b>SAX Locator</b> method (don't invoke on parser);
+ */
+ public int getLineNumber()
+ {
+ return parser.getLineNumber();
+ }
+
+ /**
+ * <b>SAX Locator</b> method (don't invoke on parser);
+ */
+ public int getColumnNumber()
+ {
+ return parser.getColumnNumber();
+ }
+
+ // adapter between SAX2 content handler and SAX1 document handler callbacks
+ private static class Adapter
+ implements ContentHandler
+ {
+
+ private DocumentHandler docHandler;
+
+ Adapter(DocumentHandler dh)
+ {
+ docHandler = dh;
+ }
+
+ public void setDocumentLocator(Locator l)
+ {
+ docHandler.setDocumentLocator(l);
+ }
+
+ public void startDocument()
+ throws SAXException
+ {
+ docHandler.startDocument();
+ }
+
+ public void processingInstruction(String target, String data)
+ throws SAXException
+ {
+ docHandler.processingInstruction(target, data);
+ }
+
+ public void startPrefixMapping(String prefix, String uri)
+ {
+ /* ignored */
+ }
+
+ public void startElement(String namespace,
+ String local,
+ String name,
+ Attributes attrs)
+ throws SAXException
+ {
+ docHandler.startElement(name, (AttributeList) attrs);
+ }
+
+ public void characters(char[] buf, int offset, int len)
+ throws SAXException
+ {
+ docHandler.characters(buf, offset, len);
+ }
+
+ public void ignorableWhitespace(char[] buf, int offset, int len)
+ throws SAXException
+ {
+ docHandler.ignorableWhitespace(buf, offset, len);
+ }
+
+ public void skippedEntity(String name)
+ {
+ /* ignored */
+ }
+
+ public void endElement(String u, String l, String name)
+ throws SAXException
+ {
+ docHandler.endElement(name);
+ }
+
+ public void endPrefixMapping(String prefix)
+ {
+ /* ignored */
+ }
+
+ public void endDocument()
+ throws SAXException
+ {
+ docHandler.endDocument();
+ }
+ }
+
+ private static class Attribute
+ {
+
+ String name;
+ String value;
+ String nameSpace;
+ String localName;
+ boolean specified;
+
+ Attribute(String name, String value, boolean specified)
+ {
+ this.name = name;
+ this.value = value;
+ this.nameSpace = "";
+ this.specified = specified;
+ }
+
+ }
+
+}
Added: llvm-gcc-4.2/trunk/libjava/classpath/gnu/xml/aelfred2/XmlParser.java
URL: http://llvm.org/viewvc/llvm-project/llvm-gcc-4.2/trunk/libjava/classpath/gnu/xml/aelfred2/XmlParser.java?rev=43913&view=auto
==============================================================================
--- llvm-gcc-4.2/trunk/libjava/classpath/gnu/xml/aelfred2/XmlParser.java (added)
+++ llvm-gcc-4.2/trunk/libjava/classpath/gnu/xml/aelfred2/XmlParser.java Thu Nov 8 16:56:19 2007
@@ -0,0 +1,5833 @@
+/* XmlParser.java --
+ Copyright (C) 1999,2000,2001 Free Software Foundation, Inc.
+
+This file is part of GNU Classpath.
+
+GNU Classpath is free software; you can redistribute it and/or modify
+it under the terms of the GNU General Public License as published by
+the Free Software Foundation; either version 2, or (at your option)
+any later version.
+
+GNU Classpath is distributed in the hope that it will be useful, but
+WITHOUT ANY WARRANTY; without even the implied warranty of
+MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+General Public License for more details.
+
+You should have received a copy of the GNU General Public License
+along with GNU Classpath; see the file COPYING. If not, write to the
+Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA
+02110-1301 USA.
+
+Linking this library statically or dynamically with other modules is
+making a combined work based on this library. Thus, the terms and
+conditions of the GNU General Public License cover the whole
+combination.
+
+As a special exception, the copyright holders of this library give you
+permission to link this library with independent modules to produce an
+executable, regardless of the license terms of these independent
+modules, and to copy and distribute the resulting executable under
+terms of your choice, provided that you also meet, for each linked
+independent module, the terms and conditions of the license of that
+module. An independent module is a module which is not derived from
+or based on this library. If you modify this library, you may extend
+this exception to your version of the library, but you are not
+obligated to do so. If you do not wish to do so, delete this
+exception statement from your version.
+
+Partly derived from code which carried the following notice:
+
+ Copyright (c) 1997, 1998 by Microstar Software Ltd.
+
+ AElfred is free for both commercial and non-commercial use and
+ redistribution, provided that Microstar's copyright and disclaimer are
+ retained intact. You are free to modify AElfred for your own use and
+ to redistribute AElfred with your modifications, provided that the
+ modifications are clearly documented.
+
+ This program is distributed in the hope that it will be useful, but
+ WITHOUT ANY WARRANTY; without even the implied warranty of
+ merchantability or fitness for a particular purpose. Please use it AT
+ YOUR OWN RISK.
+*/
+
+package gnu.xml.aelfred2;
+
+import gnu.java.security.action.GetPropertyAction;
+
+import java.io.BufferedInputStream;
+import java.io.CharConversionException;
+import java.io.EOFException;
+import java.io.InputStream;
+import java.io.InputStreamReader;
+import java.io.IOException;
+import java.io.Reader;
+import java.io.UnsupportedEncodingException;
+import java.net.URL;
+import java.net.URLConnection;
+import java.security.AccessController;
+
+import java.util.Iterator;
+import java.util.HashMap;
+import java.util.LinkedList;
+
+import org.xml.sax.InputSource;
+import org.xml.sax.SAXException;
+
+
+/**
+ * Parse XML documents and return parse events through call-backs.
+ * Use the <code>SAXDriver</code> class as your entry point, as all
+ * internal parser interfaces are subject to change.
+ *
+ * @author Written by David Megginson <dmeggins at microstar.com>
+ * (version 1.2a with bugfixes)
+ * @author Updated by David Brownell <dbrownell at users.sourceforge.net>
+ * @see SAXDriver
+ */
+final class XmlParser
+{
+
+ // avoid slow per-character readCh()
+ private final static boolean USE_CHEATS = true;
+
+ ////////////////////////////////////////////////////////////////////////
+ // Constants.
+ ////////////////////////////////////////////////////////////////////////
+
+ //
+ // Constants for element content type.
+ //
+
+ /**
+ * Constant: an element has not been declared.
+ * @see #getElementContentType
+ */
+ public final static int CONTENT_UNDECLARED = 0;
+
+ /**
+ * Constant: the element has a content model of ANY.
+ * @see #getElementContentType
+ */
+ public final static int CONTENT_ANY = 1;
+
+ /**
+ * Constant: the element has declared content of EMPTY.
+ * @see #getElementContentType
+ */
+ public final static int CONTENT_EMPTY = 2;
+
+ /**
+ * Constant: the element has mixed content.
+ * @see #getElementContentType
+ */
+ public final static int CONTENT_MIXED = 3;
+
+ /**
+ * Constant: the element has element content.
+ * @see #getElementContentType
+ */
+ public final static int CONTENT_ELEMENTS = 4;
+
+
+ //
+ // Constants for the entity type.
+ //
+
+ /**
+ * Constant: the entity has not been declared.
+ * @see #getEntityType
+ */
+ public final static int ENTITY_UNDECLARED = 0;
+
+ /**
+ * Constant: the entity is internal.
+ * @see #getEntityType
+ */
+ public final static int ENTITY_INTERNAL = 1;
+
+ /**
+ * Constant: the entity is external, non-parsable data.
+ * @see #getEntityType
+ */
+ public final static int ENTITY_NDATA = 2;
+
+ /**
+ * Constant: the entity is external XML data.
+ * @see #getEntityType
+ */
+ public final static int ENTITY_TEXT = 3;
+
+ //
+ // Attribute type constants are interned literal strings.
+ //
+
+ //
+ // Constants for supported encodings. "external" is just a flag.
+ //
+ private final static int ENCODING_EXTERNAL = 0;
+ private final static int ENCODING_UTF_8 = 1;
+ private final static int ENCODING_ISO_8859_1 = 2;
+ private final static int ENCODING_UCS_2_12 = 3;
+ private final static int ENCODING_UCS_2_21 = 4;
+ private final static int ENCODING_UCS_4_1234 = 5;
+ private final static int ENCODING_UCS_4_4321 = 6;
+ private final static int ENCODING_UCS_4_2143 = 7;
+ private final static int ENCODING_UCS_4_3412 = 8;
+ private final static int ENCODING_ASCII = 9;
+
+ //
+ // Constants for attribute default value.
+ //
+
+ /**
+ * Constant: the attribute is not declared.
+ * @see #getAttributeDefaultValueType
+ */
+ public final static int ATTRIBUTE_DEFAULT_UNDECLARED = 30;
+
+ /**
+ * Constant: the attribute has a literal default value specified.
+ * @see #getAttributeDefaultValueType
+ * @see #getAttributeDefaultValue
+ */
+ public final static int ATTRIBUTE_DEFAULT_SPECIFIED = 31;
+
+ /**
+ * Constant: the attribute was declared #IMPLIED.
+ * @see #getAttributeDefaultValueType
+ */
+ public final static int ATTRIBUTE_DEFAULT_IMPLIED = 32;
+
+ /**
+ * Constant: the attribute was declared #REQUIRED.
+ * @see #getAttributeDefaultValueType
+ */
+ public final static int ATTRIBUTE_DEFAULT_REQUIRED = 33;
+
+ /**
+ * Constant: the attribute was declared #FIXED.
+ * @see #getAttributeDefaultValueType
+ * @see #getAttributeDefaultValue
+ */
+ public final static int ATTRIBUTE_DEFAULT_FIXED = 34;
+
+ //
+ // Constants for input.
+ //
+ private final static int INPUT_NONE = 0;
+ private final static int INPUT_INTERNAL = 1;
+ private final static int INPUT_STREAM = 3;
+ private final static int INPUT_READER = 5;
+
+ //
+ // Flags for reading literals.
+ //
+ // expand general entity refs (attribute values in dtd and content)
+ private final static int LIT_ENTITY_REF = 2;
+ // normalize this value (space chars) (attributes, public ids)
+ private final static int LIT_NORMALIZE = 4;
+ // literal is an attribute value
+ private final static int LIT_ATTRIBUTE = 8;
+ // don't expand parameter entities
+ private final static int LIT_DISABLE_PE = 16;
+ // don't expand [or parse] character refs
+ private final static int LIT_DISABLE_CREF = 32;
+ // don't parse general entity refs
+ private final static int LIT_DISABLE_EREF = 64;
+ // literal is a public ID value
+ private final static int LIT_PUBID = 256;
+
+ //
+ // Flags affecting PE handling in DTDs (if expandPE is true).
+ // PEs expand with space padding, except inside literals.
+ //
+ private final static int CONTEXT_NORMAL = 0;
+ private final static int CONTEXT_LITERAL = 1;
+
+ // Emit warnings for relative URIs with no base URI.
+ static boolean uriWarnings;
+ static
+ {
+ String key = "gnu.xml.aelfred2.XmlParser.uriWarnings";
+ GetPropertyAction a = new GetPropertyAction(key);
+ uriWarnings = "true".equals(AccessController.doPrivileged(a));
+ }
+
+ //
+ // The current XML handler interface.
+ //
+ private SAXDriver handler;
+
+ //
+ // I/O information.
+ //
+ private Reader reader; // current reader
+ private InputStream is; // current input stream
+ private int line; // current line number
+ private int column; // current column number
+ private int sourceType; // type of input source
+ private LinkedList inputStack; // stack of input soruces
+ private URLConnection externalEntity; // current external entity
+ private int encoding; // current character encoding
+ private int currentByteCount; // bytes read from current source
+ private InputSource scratch; // temporary
+
+ //
+ // Buffers for decoded but unparsed character input.
+ //
+ private char[] readBuffer;
+ private int readBufferPos;
+ private int readBufferLength;
+ private int readBufferOverflow; // overflow from last data chunk.
+
+ //
+ // Buffer for undecoded raw byte input.
+ //
+ private final static int READ_BUFFER_MAX = 16384;
+ private byte[] rawReadBuffer;
+
+
+ //
+ // Buffer for attribute values, char refs, DTD stuff.
+ //
+ private static int DATA_BUFFER_INITIAL = 4096;
+ private char[] dataBuffer;
+ private int dataBufferPos;
+
+ //
+ // Buffer for parsed names.
+ //
+ private static int NAME_BUFFER_INITIAL = 1024;
+ private char[] nameBuffer;
+ private int nameBufferPos;
+
+ //
+ // Save any standalone flag
+ //
+ private boolean docIsStandalone;
+
+ //
+ // Hashtables for DTD information on elements, entities, and notations.
+ // Populated until we start ignoring decls (because of skipping a PE)
+ //
+ private HashMap elementInfo;
+ private HashMap entityInfo;
+ private HashMap notationInfo;
+ private boolean skippedPE;
+
+ //
+ // Element type currently in force.
+ //
+ private String currentElement;
+ private int currentElementContent;
+
+ //
+ // Stack of entity names, to detect recursion.
+ //
+ private LinkedList entityStack;
+
+ //
+ // PE expansion is enabled in most chunks of the DTD, not all.
+ // When it's enabled, literals are treated differently.
+ //
+ private boolean inLiteral;
+ private boolean expandPE;
+ private boolean peIsError;
+
+ //
+ // can't report entity expansion inside two constructs:
+ // - attribute expansions (internal entities only)
+ // - markup declarations (parameter entities only)
+ //
+ private boolean doReport;
+
+ //
+ // Symbol table, for caching interned names.
+ //
+ // These show up wherever XML names or nmtokens are used: naming elements,
+ // attributes, PIs, notations, entities, and enumerated attribute values.
+ //
+ // NOTE: This hashtable doesn't grow. The default size is intended to be
+ // rather large for most documents. Example: one snapshot of the DocBook
+ // XML 4.1 DTD used only about 350 such names. As a rule, only pathological
+ // documents (ones that don't reuse names) should ever see much collision.
+ //
+ // Be sure that SYMBOL_TABLE_LENGTH always stays prime, for best hashing.
+ // "2039" keeps the hash table size at about two memory pages on typical
+ // 32 bit hardware.
+ //
+ private final static int SYMBOL_TABLE_LENGTH = 2039;
+
+ private Object[][] symbolTable;
+
+ //
+ // Hash table of attributes found in current start tag.
+ //
+ private String[] tagAttributes;
+ private int tagAttributePos;
+
+ //
+ // Utility flag: have we noticed a CR while reading the last
+ // data chunk? If so, we will have to go back and normalise
+ // CR or CR/LF line ends.
+ //
+ private boolean sawCR;
+
+ //
+ // Utility flag: are we in CDATA? If so, whitespace isn't ignorable.
+ //
+ private boolean inCDATA;
+
+ //
+ // Xml version.
+ //
+ private static final int XML_10 = 0;
+ private static final int XML_11 = 1;
+ private int xmlVersion = XML_10;
+
+ //////////////////////////////////////////////////////////////////////
+ // Constructors.
+ ////////////////////////////////////////////////////////////////////////
+
+ /**
+ * Construct a new parser with no associated handler.
+ * @see #setHandler
+ * @see #parse
+ */
+ // package private
+ XmlParser()
+ {
+ }
+
+ /**
+ * Set the handler that will receive parsing events.
+ * @param handler The handler to receive callback events.
+ * @see #parse
+ */
+ // package private
+ void setHandler(SAXDriver handler)
+ {
+ this.handler = handler;
+ }
+
+ /**
+ * Parse an XML document from the character stream, byte stream, or URI
+ * that you provide (in that order of preference). Any URI that you
+ * supply will become the base URI for resolving relative URI, and may
+ * be used to acquire a reader or byte stream.
+ *
+ * <p> Only one thread at a time may use this parser; since it is
+ * private to this package, post-parse cleanup is done by the caller,
+ * which MUST NOT REUSE the parser (just null it).
+ *
+ * @param systemId Absolute URI of the document; should never be null,
+ * but may be so iff a reader <em>or</em> a stream is provided.
+ * @param publicId The public identifier of the document, or null.
+ * @param reader A character stream; must be null if stream isn't.
+ * @param stream A byte input stream; must be null if reader isn't.
+ * @param encoding The suggested encoding, or null if unknown.
+ * @exception java.lang.Exception Basically SAXException or IOException
+ */
+ // package private
+ void doParse(String systemId, String publicId, Reader reader,
+ InputStream stream, String encoding)
+ throws Exception
+ {
+ if (handler == null)
+ {
+ throw new IllegalStateException("no callback handler");
+ }
+
+ initializeVariables();
+
+ // predeclare the built-in entities here (replacement texts)
+ // we don't need to intern(), since we're guaranteed literals
+ // are always (globally) interned.
+ setInternalEntity("amp", "&");
+ setInternalEntity("lt", "<");
+ setInternalEntity("gt", ">");
+ setInternalEntity("apos", "'");
+ setInternalEntity("quot", """);
+
+ try
+ {
+ // pushURL first to ensure locator is correct in startDocument
+ // ... it might report an IO or encoding exception.
+ handler.startDocument();
+ pushURL(false, "[document]",
+ // default baseURI: null
+ new ExternalIdentifiers(publicId, systemId, null),
+ reader, stream, encoding, false);
+
+ parseDocument();
+ }
+ catch (EOFException e)
+ {
+ //empty input
+ error("empty document, with no root element.");
+ }
+ finally
+ {
+ if (reader != null)
+ {
+ try
+ {
+ reader.close();
+ }
+ catch (IOException e)
+ {
+ /* ignore */
+ }
+ }
+ if (stream != null)
+ {
+ try
+ {
+ stream.close();
+ }
+ catch (IOException e)
+ {
+ /* ignore */
+ }
+ }
+ if (is != null)
+ {
+ try
+ {
+ is.close();
+ }
+ catch (IOException e)
+ {
+ /* ignore */
+ }
+ }
+ scratch = null;
+ }
+ }
+
+ //////////////////////////////////////////////////////////////////////
+ // Error reporting.
+ //////////////////////////////////////////////////////////////////////
+
+ /**
+ * Report an error.
+ * @param message The error message.
+ * @param textFound The text that caused the error (or null).
+ * @see SAXDriver#error
+ * @see #line
+ */
+ private void error(String message, String textFound, String textExpected)
+ throws SAXException
+ {
+ if (textFound != null)
+ {
+ message = message + " (found \"" + textFound + "\")";
+ }
+ if (textExpected != null)
+ {
+ message = message + " (expected \"" + textExpected + "\")";
+ }
+ handler.fatal(message);
+
+ // "can't happen"
+ throw new SAXException(message);
+ }
+
+ /**
+ * Report a serious error.
+ * @param message The error message.
+ * @param textFound The text that caused the error (or null).
+ */
+ private void error(String message, char textFound, String textExpected)
+ throws SAXException
+ {
+ error(message, new Character(textFound).toString(), textExpected);
+ }
+
+ /**
+ * Report typical case fatal errors.
+ */
+ private void error(String message)
+ throws SAXException
+ {
+ handler.fatal(message);
+ }
+
+ //////////////////////////////////////////////////////////////////////
+ // Major syntactic productions.
+ //////////////////////////////////////////////////////////////////////
+
+ /**
+ * Parse an XML document.
+ * <pre>
+ * [1] document ::= prolog element Misc*
+ * </pre>
+ * <p>This is the top-level parsing function for a single XML
+ * document. As a minimum, a well-formed document must have
+ * a document element, and a valid document must have a prolog
+ * (one with doctype) as well.
+ */
+ private void parseDocument()
+ throws Exception
+ {
+ try
+ { // added by MHK
+ boolean sawDTD = parseProlog();
+ require('<');
+ parseElement(!sawDTD);
+ }
+ catch (EOFException ee)
+ { // added by MHK
+ error("premature end of file", "[EOF]", null);
+ }
+
+ try
+ {
+ parseMisc(); //skip all white, PIs, and comments
+ char c = readCh(); //if this doesn't throw an exception...
+ error("unexpected characters after document end", c, null);
+ }
+ catch (EOFException e)
+ {
+ return;
+ }
+ }
+
+ static final char[] startDelimComment = { '<', '!', '-', '-' };
+ static final char[] endDelimComment = { '-', '-' };
+
+ /**
+ * Skip a comment.
+ * <pre>
+ * [15] Comment ::= '<!--' ((Char - '-') | ('-' (Char - '-')))* "-->"
+ * </pre>
+ * <p> (The <code><!--</code> has already been read.)
+ */
+ private void parseComment()
+ throws Exception
+ {
+ char c;
+ boolean saved = expandPE;
+
+ expandPE = false;
+ parseUntil(endDelimComment);
+ require('>');
+ expandPE = saved;
+ handler.comment(dataBuffer, 0, dataBufferPos);
+ dataBufferPos = 0;
+ }
+
+ static final char[] startDelimPI = { '<', '?' };
+ static final char[] endDelimPI = { '?', '>' };
+
+ /**
+ * Parse a processing instruction and do a call-back.
+ * <pre>
+ * [16] PI ::= '<?' PITarget
+ * (S (Char* - (Char* '?>' Char*)))?
+ * '?>'
+ * [17] PITarget ::= Name - ( ('X'|'x') ('M'|m') ('L'|l') )
+ * </pre>
+ * <p> (The <code><?</code> has already been read.)
+ */
+ private void parsePI()
+ throws SAXException, IOException
+ {
+ String name;
+ boolean saved = expandPE;
+
+ expandPE = false;
+ name = readNmtoken(true);
+ //NE08
+ if (name.indexOf(':') >= 0)
+ {
+ error("Illegal character(':') in processing instruction name ",
+ name, null);
+ }
+ if ("xml".equalsIgnoreCase(name))
+ {
+ error("Illegal processing instruction target", name, null);
+ }
+ if (!tryRead(endDelimPI))
+ {
+ requireWhitespace();
+ parseUntil(endDelimPI);
+ }
+ expandPE = saved;
+ handler.processingInstruction(name, dataBufferToString());
+ }
+
+ static final char[] endDelimCDATA = { ']', ']', '>' };
+
+ private boolean isDirtyCurrentElement;
+
+ /**
+ * Parse a CDATA section.
+ * <pre>
+ * [18] CDSect ::= CDStart CData CDEnd
+ * [19] CDStart ::= '<![CDATA['
+ * [20] CData ::= (Char* - (Char* ']]>' Char*))
+ * [21] CDEnd ::= ']]>'
+ * </pre>
+ * <p> (The '<![CDATA[' has already been read.)
+ */
+ private void parseCDSect()
+ throws Exception
+ {
+ parseUntil(endDelimCDATA);
+ dataBufferFlush();
+ }
+
+ /**
+ * Parse the prolog of an XML document.
+ * <pre>
+ * [22] prolog ::= XMLDecl? Misc* (Doctypedecl Misc*)?
+ * </pre>
+ * <p>We do not look for the XML declaration here, because it was
+ * handled by pushURL ().
+ * @see pushURL
+ * @return true if a DTD was read.
+ */
+ private boolean parseProlog()
+ throws Exception
+ {
+ parseMisc();
+
+ if (tryRead("<!DOCTYPE"))
+ {
+ parseDoctypedecl();
+ parseMisc();
+ return true;
+ }
+ return false;
+ }
+
+ private void checkLegalVersion(String version)
+ throws SAXException
+ {
+ int len = version.length();
+ for (int i = 0; i < len; i++)
+ {
+ char c = version.charAt(i);
+ if ('0' <= c && c <= '9')
+ {
+ continue;
+ }
+ if (c == '_' || c == '.' || c == ':' || c == '-')
+ {
+ continue;
+ }
+ if ('a' <= c && c <= 'z')
+ {
+ continue;
+ }
+ if ('A' <= c && c <= 'Z')
+ {
+ continue;
+ }
+ error ("illegal character in version", version, "1.0");
+ }
+ }
+
+ /**
+ * Parse the XML declaration.
+ * <pre>
+ * [23] XMLDecl ::= '<?xml' VersionInfo EncodingDecl? SDDecl? S? '?>'
+ * [24] VersionInfo ::= S 'version' Eq
+ * ("'" VersionNum "'" | '"' VersionNum '"' )
+ * [26] VersionNum ::= ([a-zA-Z0-9_.:] | '-')*
+ * [32] SDDecl ::= S 'standalone' Eq
+ * ( "'"" ('yes' | 'no') "'"" | '"' ("yes" | "no") '"' )
+ * [80] EncodingDecl ::= S 'encoding' Eq
+ * ( "'" EncName "'" | "'" EncName "'" )
+ * [81] EncName ::= [A-Za-z] ([A-Za-z0-9._] | '-')*
+ * </pre>
+ * <p> (The <code><?xml</code> and whitespace have already been read.)
+ * @return the encoding in the declaration, uppercased; or null
+ * @see #parseTextDecl
+ * @see #setupDecoding
+ */
+ private String parseXMLDecl(boolean ignoreEncoding)
+ throws SAXException, IOException
+ {
+ String version;
+ String encodingName = null;
+ String standalone = null;
+ int flags = LIT_DISABLE_CREF | LIT_DISABLE_PE | LIT_DISABLE_EREF;
+ String inputEncoding = null;
+
+ switch (this.encoding)
+ {
+ case ENCODING_EXTERNAL:
+ case ENCODING_UTF_8:
+ inputEncoding = "UTF-8";
+ break;
+ case ENCODING_ISO_8859_1:
+ inputEncoding = "ISO-8859-1";
+ break;
+ case ENCODING_UCS_2_12:
+ inputEncoding = "UTF-16BE";
+ break;
+ case ENCODING_UCS_2_21:
+ inputEncoding = "UTF-16LE";
+ break;
+ }
+
+ // Read the version.
+ require("version");
+ parseEq();
+ checkLegalVersion(version = readLiteral(flags));
+ if (!version.equals("1.0"))
+ {
+ if (version.equals("1.1"))
+ {
+ handler.warn("expected XML version 1.0, not: " + version);
+ xmlVersion = XML_11;
+ }
+ else
+ {
+ error("illegal XML version", version, "1.0 or 1.1");
+ }
+ }
+ else
+ {
+ xmlVersion = XML_10;
+ }
+ // Try reading an encoding declaration.
+ boolean white = tryWhitespace();
+
+ if (tryRead("encoding"))
+ {
+ if (!white)
+ {
+ error("whitespace required before 'encoding='");
+ }
+ parseEq();
+ encodingName = readLiteral(flags);
+ if (!ignoreEncoding)
+ {
+ setupDecoding(encodingName);
+ }
+ }
+
+ // Try reading a standalone declaration
+ if (encodingName != null)
+ {
+ white = tryWhitespace();
+ }
+ if (tryRead("standalone"))
+ {
+ if (!white)
+ {
+ error("whitespace required before 'standalone='");
+ }
+ parseEq();
+ standalone = readLiteral(flags);
+ if ("yes".equals(standalone))
+ {
+ docIsStandalone = true;
+ }
+ else if (!"no".equals(standalone))
+ {
+ error("standalone flag must be 'yes' or 'no'");
+ }
+ }
+
+ skipWhitespace();
+ require("?>");
+
+ if (inputEncoding == null)
+ {
+ inputEncoding = encodingName;
+ }
+ return encodingName;
+ }
+
+ /**
+ * Parse a text declaration.
+ * <pre>
+ * [79] TextDecl ::= '<?xml' VersionInfo? EncodingDecl S? '?>'
+ * [80] EncodingDecl ::= S 'encoding' Eq
+ * ( '"' EncName '"' | "'" EncName "'" )
+ * [81] EncName ::= [A-Za-z] ([A-Za-z0-9._] | '-')*
+ * </pre>
+ * <p> (The <code><?xml</code>' and whitespace have already been read.)
+ * @return the encoding in the declaration, uppercased; or null
+ * @see #parseXMLDecl
+ * @see #setupDecoding
+ */
+ private String parseTextDecl(boolean ignoreEncoding)
+ throws SAXException, IOException
+ {
+ String encodingName = null;
+ int flags = LIT_DISABLE_CREF | LIT_DISABLE_PE | LIT_DISABLE_EREF;
+
+ // Read an optional version.
+ if (tryRead ("version"))
+ {
+ String version;
+ parseEq();
+ checkLegalVersion(version = readLiteral(flags));
+
+ if (version.equals("1.1"))
+ {
+ if (xmlVersion == XML_10)
+ {
+ error("external subset has later version number.", "1.0",
+ version);
+ }
+ handler.warn("expected XML version 1.0, not: " + version);
+ xmlVersion = XML_11;
+ }
+ else if (!version.equals("1.0"))
+ {
+ error("illegal XML version", version, "1.0 or 1.1");
+ }
+ requireWhitespace();
+ }
+
+ // Read the encoding.
+ require("encoding");
+ parseEq();
+ encodingName = readLiteral(flags);
+ if (!ignoreEncoding)
+ {
+ setupDecoding(encodingName);
+ }
+ skipWhitespace();
+ require("?>");
+
+ return encodingName;
+ }
+
+ /**
+ * Sets up internal state so that we can decode an entity using the
+ * specified encoding. This is used when we start to read an entity
+ * and we have been given knowledge of its encoding before we start to
+ * read any data (e.g. from a SAX input source or from a MIME type).
+ *
+ * <p> It is also used after autodetection, at which point only very
+ * limited adjustments to the encoding may be used (switching between
+ * related builtin decoders).
+ *
+ * @param encodingName The name of the encoding specified by the user.
+ * @exception IOException if the encoding isn't supported either
+ * internally to this parser, or by the hosting JVM.
+ * @see #parseXMLDecl
+ * @see #parseTextDecl
+ */
+ private void setupDecoding(String encodingName)
+ throws SAXException, IOException
+ {
+ encodingName = encodingName.toUpperCase();
+
+ // ENCODING_EXTERNAL indicates an encoding that wasn't
+ // autodetected ... we can use builtin decoders, or
+ // ones from the JVM (InputStreamReader).
+
+ // Otherwise we can only tweak what was autodetected, and
+ // only for single byte (ASCII derived) builtin encodings.
+
+ // ASCII-derived encodings
+ if (encoding == ENCODING_UTF_8 || encoding == ENCODING_EXTERNAL)
+ {
+ if (encodingName.equals("ISO-8859-1")
+ || encodingName.equals("8859_1")
+ || encodingName.equals("ISO8859_1"))
+ {
+ encoding = ENCODING_ISO_8859_1;
+ return;
+ }
+ else if (encodingName.equals("US-ASCII")
+ || encodingName.equals("ASCII"))
+ {
+ encoding = ENCODING_ASCII;
+ return;
+ }
+ else if (encodingName.equals("UTF-8")
+ || encodingName.equals("UTF8"))
+ {
+ encoding = ENCODING_UTF_8;
+ return;
+ }
+ else if (encoding != ENCODING_EXTERNAL)
+ {
+ // used to start with a new reader ...
+ throw new UnsupportedEncodingException(encodingName);
+ }
+ // else fallthrough ...
+ // it's ASCII-ish and something other than a builtin
+ }
+
+ // Unicode and such
+ if (encoding == ENCODING_UCS_2_12 || encoding == ENCODING_UCS_2_21)
+ {
+ if (!(encodingName.equals("ISO-10646-UCS-2")
+ || encodingName.equals("UTF-16")
+ || encodingName.equals("UTF-16BE")
+ || encodingName.equals("UTF-16LE")))
+ {
+ error("unsupported Unicode encoding", encodingName, "UTF-16");
+ }
+ return;
+ }
+
+ // four byte encodings
+ if (encoding == ENCODING_UCS_4_1234
+ || encoding == ENCODING_UCS_4_4321
+ || encoding == ENCODING_UCS_4_2143
+ || encoding == ENCODING_UCS_4_3412)
+ {
+ // Strictly: "UCS-4" == "UTF-32BE"; also, "UTF-32LE" exists
+ if (!encodingName.equals("ISO-10646-UCS-4"))
+ {
+ error("unsupported 32-bit encoding", encodingName,
+ "ISO-10646-UCS-4");
+ }
+ return;
+ }
+
+ // assert encoding == ENCODING_EXTERNAL
+ // if (encoding != ENCODING_EXTERNAL)
+ // throw new RuntimeException ("encoding = " + encoding);
+
+ if (encodingName.equals("UTF-16BE"))
+ {
+ encoding = ENCODING_UCS_2_12;
+ return;
+ }
+ if (encodingName.equals("UTF-16LE"))
+ {
+ encoding = ENCODING_UCS_2_21;
+ return;
+ }
+
+ // We couldn't use the builtin decoders at all. But we can try to
+ // create a reader, since we haven't messed up buffering. Tweak
+ // the encoding name if necessary.
+
+ if (encodingName.equals("UTF-16")
+ || encodingName.equals("ISO-10646-UCS-2"))
+ {
+ encodingName = "Unicode";
+ }
+ // Ignoring all the EBCDIC aliases here
+
+ reader = new InputStreamReader(is, encodingName);
+ sourceType = INPUT_READER;
+ }
+
+ /**
+ * Parse miscellaneous markup outside the document element and DOCTYPE
+ * declaration.
+ * <pre>
+ * [27] Misc ::= Comment | PI | S
+ * </pre>
+ */
+ private void parseMisc()
+ throws Exception
+ {
+ while (true)
+ {
+ skipWhitespace();
+ if (tryRead(startDelimPI))
+ {
+ parsePI();
+ }
+ else if (tryRead(startDelimComment))
+ {
+ parseComment();
+ }
+ else
+ {
+ return;
+ }
+ }
+ }
+
+ /**
+ * Parse a document type declaration.
+ * <pre>
+ * [28] doctypedecl ::= '<!DOCTYPE' S Name (S ExternalID)? S?
+ * ('[' (markupdecl | PEReference | S)* ']' S?)? '>'
+ * </pre>
+ * <p> (The <code><!DOCTYPE</code> has already been read.)
+ */
+ private void parseDoctypedecl()
+ throws Exception
+ {
+ String rootName;
+ ExternalIdentifiers ids;
+
+ // Read the document type name.
+ requireWhitespace();
+ rootName = readNmtoken(true);
+
+ // Read the External subset's IDs
+ skipWhitespace();
+ ids = readExternalIds(false, true);
+
+ // report (a) declaration of name, (b) lexical info (ids)
+ handler.doctypeDecl(rootName, ids.publicId, ids.systemId);
+
+ // Internal subset is parsed first, if present
+ skipWhitespace();
+ if (tryRead('['))
+ {
+
+ // loop until the subset ends
+ while (true)
+ {
+ doReport = expandPE = true;
+ skipWhitespace();
+ doReport = expandPE = false;
+ if (tryRead(']'))
+ {
+ break; // end of subset
+ }
+ else
+ {
+ // WFC, PEs in internal subset (only between decls)
+ peIsError = expandPE = true;
+ parseMarkupdecl();
+ peIsError = expandPE = false;
+ }
+ }
+ }
+ skipWhitespace();
+ require('>');
+
+ // Read the external subset, if any
+ InputSource subset;
+
+ if (ids.systemId == null)
+ {
+ subset = handler.getExternalSubset(rootName,
+ handler.getSystemId());
+ }
+ else
+ {
+ subset = null;
+ }
+ if (ids.systemId != null || subset != null)
+ {
+ pushString(null, ">");
+
+ // NOTE: [dtd] is so we say what SAX2 expects,
+ // though it's misleading (subset, not entire dtd)
+ if (ids.systemId != null)
+ {
+ pushURL(true, "[dtd]", ids, null, null, null, true);
+ }
+ else
+ {
+ handler.warn("modifying document by adding external subset");
+ pushURL(true, "[dtd]",
+ new ExternalIdentifiers(subset.getPublicId(),
+ subset.getSystemId(),
+ null),
+ subset.getCharacterStream(),
+ subset.getByteStream(),
+ subset.getEncoding(),
+ false);
+ }
+
+ // Loop until we end up back at '>'
+ while (true)
+ {
+ doReport = expandPE = true;
+ skipWhitespace();
+ doReport = expandPE = false;
+ if (tryRead('>'))
+ {
+ break;
+ }
+ else
+ {
+ expandPE = true;
+ parseMarkupdecl();
+ expandPE = false;
+ }
+ }
+
+ // the ">" string isn't popped yet
+ if (inputStack.size() != 1)
+ {
+ error("external subset has unmatched '>'");
+ }
+ }
+
+ // done dtd
+ handler.endDoctype();
+ expandPE = false;
+ doReport = true;
+ }
+
+ /**
+ * Parse a markup declaration in the internal or external DTD subset.
+ * <pre>
+ * [29] markupdecl ::= elementdecl | Attlistdecl | EntityDecl
+ * | NotationDecl | PI | Comment
+ * [30] extSubsetDecl ::= (markupdecl | conditionalSect
+ * | PEReference | S) *
+ * </pre>
+ * <p> Reading toplevel PE references is handled as a lexical issue
+ * by the caller, as is whitespace.
+ */
+ private void parseMarkupdecl()
+ throws Exception
+ {
+ char[] saved = null;
+ boolean savedPE = expandPE;
+
+ // prevent "<%foo;" and ensures saved entity is right
+ require('<');
+ unread('<');
+ expandPE = false;
+
+ if (tryRead("<!ELEMENT"))
+ {
+ saved = readBuffer;
+ expandPE = savedPE;
+ parseElementDecl();
+ }
+ else if (tryRead("<!ATTLIST"))
+ {
+ saved = readBuffer;
+ expandPE = savedPE;
+ parseAttlistDecl();
+ }
+ else if (tryRead("<!ENTITY"))
+ {
+ saved = readBuffer;
+ expandPE = savedPE;
+ parseEntityDecl();
+ }
+ else if (tryRead("<!NOTATION"))
+ {
+ saved = readBuffer;
+ expandPE = savedPE;
+ parseNotationDecl();
+ }
+ else if (tryRead(startDelimPI))
+ {
+ saved = readBuffer;
+ expandPE = savedPE;
+ parsePI();
+ }
+ else if (tryRead(startDelimComment))
+ {
+ saved = readBuffer;
+ expandPE = savedPE;
+ parseComment();
+ }
+ else if (tryRead("<!["))
+ {
+ saved = readBuffer;
+ expandPE = savedPE;
+ if (inputStack.size() > 0)
+ {
+ parseConditionalSect(saved);
+ }
+ else
+ {
+ error("conditional sections illegal in internal subset");
+ }
+ }
+ else
+ {
+ error("expected markup declaration");
+ }
+
+ // VC: Proper Decl/PE Nesting
+ if (readBuffer != saved)
+ {
+ handler.verror("Illegal Declaration/PE nesting");
+ }
+ }
+
+ /**
+ * Parse an element, with its tags.
+ * <pre>
+ * [39] element ::= EmptyElementTag | STag content ETag
+ * [40] STag ::= '<' Name (S Attribute)* S? '>'
+ * [44] EmptyElementTag ::= '<' Name (S Attribute)* S? '/>'
+ * </pre>
+ * <p> (The '<' has already been read.)
+ * <p>NOTE: this method actually chains onto parseContent (), if necessary,
+ * and parseContent () will take care of calling parseETag ().
+ */
+ private void parseElement(boolean maybeGetSubset)
+ throws Exception
+ {
+ String gi;
+ char c;
+ int oldElementContent = currentElementContent;
+ String oldElement = currentElement;
+ ElementDecl element;
+
+ // This is the (global) counter for the
+ // array of specified attributes.
+ tagAttributePos = 0;
+
+ // Read the element type name.
+ gi = readNmtoken(true);
+
+ // If we saw no DTD, and this is the document root element,
+ // let the application modify the input stream by providing one.
+ if (maybeGetSubset)
+ {
+ InputSource subset = handler.getExternalSubset(gi,
+ handler.getSystemId());
+ if (subset != null)
+ {
+ String publicId = subset.getPublicId();
+ String systemId = subset.getSystemId();
+
+ handler.warn("modifying document by adding DTD");
+ handler.doctypeDecl(gi, publicId, systemId);
+ pushString(null, ">");
+
+ // NOTE: [dtd] is so we say what SAX2 expects,
+ // though it's misleading (subset, not entire dtd)
+ pushURL(true, "[dtd]",
+ new ExternalIdentifiers(publicId, systemId, null),
+ subset.getCharacterStream(),
+ subset.getByteStream(),
+ subset.getEncoding(),
+ false);
+
+ // Loop until we end up back at '>'
+ while (true)
+ {
+ doReport = expandPE = true;
+ skipWhitespace();
+ doReport = expandPE = false;
+ if (tryRead('>'))
+ {
+ break;
+ }
+ else
+ {
+ expandPE = true;
+ parseMarkupdecl();
+ expandPE = false;
+ }
+ }
+
+ // the ">" string isn't popped yet
+ if (inputStack.size() != 1)
+ {
+ error("external subset has unmatched '>'");
+ }
+
+ handler.endDoctype();
+ }
+ }
+
+ // Determine the current content type.
+ currentElement = gi;
+ element = (ElementDecl) elementInfo.get(gi);
+ currentElementContent = getContentType(element, CONTENT_ANY);
+
+ // Read the attributes, if any.
+ // After this loop, "c" is the closing delimiter.
+ boolean white = tryWhitespace();
+ c = readCh();
+ while (c != '/' && c != '>')
+ {
+ unread(c);
+ if (!white)
+ {
+ error("need whitespace between attributes");
+ }
+ parseAttribute(gi);
+ white = tryWhitespace();
+ c = readCh();
+ }
+
+ // Supply any defaulted attributes.
+ Iterator atts = declaredAttributes(element);
+ if (atts != null)
+ {
+ String aname;
+loop:
+ while (atts.hasNext())
+ {
+ aname = (String) atts.next();
+ // See if it was specified.
+ for (int i = 0; i < tagAttributePos; i++)
+ {
+ if (tagAttributes[i] == aname)
+ {
+ continue loop;
+ }
+ }
+ // ... or has a default
+ String value = getAttributeDefaultValue(gi, aname);
+
+ if (value == null)
+ {
+ continue;
+ }
+ handler.attribute(aname, value, false);
+ }
+ }
+
+ // Figure out if this is a start tag
+ // or an empty element, and dispatch an
+ // event accordingly.
+ switch (c)
+ {
+ case '>':
+ handler.startElement(gi);
+ parseContent();
+ break;
+ case '/':
+ require('>');
+ handler.startElement(gi);
+ handler.endElement(gi);
+ break;
+ }
+
+ // Restore the previous state.
+ currentElement = oldElement;
+ currentElementContent = oldElementContent;
+ }
+
+ /**
+ * Parse an attribute assignment.
+ * <pre>
+ * [41] Attribute ::= Name Eq AttValue
+ * </pre>
+ * @param name The name of the attribute's element.
+ * @see SAXDriver#attribute
+ */
+ private void parseAttribute(String name)
+ throws Exception
+ {
+ String aname;
+ String type;
+ String value;
+ int flags = LIT_ATTRIBUTE | LIT_ENTITY_REF;
+
+ // Read the attribute name.
+ aname = readNmtoken(true);
+ type = getAttributeType(name, aname);
+
+ // Parse '='
+ parseEq();
+
+ // Read the value, normalizing whitespace
+ // unless it is CDATA.
+ if (handler.stringInterning)
+ {
+ if (type == "CDATA" || type == null)
+ {
+ value = readLiteral(flags);
+ }
+ else
+ {
+ value = readLiteral(flags | LIT_NORMALIZE);
+ }
+ }
+ else
+ {
+ if (type == null || type.equals("CDATA"))
+ {
+ value = readLiteral(flags);
+ }
+ else
+ {
+ value = readLiteral(flags | LIT_NORMALIZE);
+ }
+ }
+
+ // WFC: no duplicate attributes
+ for (int i = 0; i < tagAttributePos; i++)
+ {
+ if (aname.equals(tagAttributes [i]))
+ {
+ error("duplicate attribute", aname, null);
+ }
+ }
+
+ // Inform the handler about the
+ // attribute.
+ handler.attribute(aname, value, true);
+ dataBufferPos = 0;
+
+ // Note that the attribute has been
+ // specified.
+ if (tagAttributePos == tagAttributes.length)
+ {
+ String newAttrib[] = new String[tagAttributes.length * 2];
+ System.arraycopy(tagAttributes, 0, newAttrib, 0, tagAttributePos);
+ tagAttributes = newAttrib;
+ }
+ tagAttributes[tagAttributePos++] = aname;
+ }
+
+ /**
+ * Parse an equals sign surrounded by optional whitespace.
+ * <pre>
+ * [25] Eq ::= S? '=' S?
+ * </pre>
+ */
+ private void parseEq()
+ throws SAXException, IOException
+ {
+ skipWhitespace();
+ require('=');
+ skipWhitespace();
+ }
+
+ /**
+ * Parse an end tag.
+ * <pre>
+ * [42] ETag ::= '</' Name S? '>'
+ * </pre>
+ * <p>NOTE: parseContent () chains to here, we already read the
+ * "</".
+ */
+ private void parseETag()
+ throws Exception
+ {
+ require(currentElement);
+ skipWhitespace();
+ require('>');
+ handler.endElement(currentElement);
+ // not re-reporting any SAXException re bogus end tags,
+ // even though that diagnostic might be clearer ...
+ }
+
+ /**
+ * Parse the content of an element.
+ * <pre>
+ * [43] content ::= (element | CharData | Reference
+ * | CDSect | PI | Comment)*
+ * [67] Reference ::= EntityRef | CharRef
+ * </pre>
+ * <p> NOTE: consumes ETtag.
+ */
+ private void parseContent()
+ throws Exception
+ {
+ char c;
+
+ while (true)
+ {
+ // consume characters (or ignorable whitspace) until delimiter
+ parseCharData();
+
+ // Handle delimiters
+ c = readCh();
+ switch (c)
+ {
+ case '&': // Found "&"
+ c = readCh();
+ if (c == '#')
+ {
+ parseCharRef();
+ }
+ else
+ {
+ unread(c);
+ parseEntityRef(true);
+ }
+ isDirtyCurrentElement = true;
+ break;
+
+ case '<': // Found "<"
+ dataBufferFlush();
+ c = readCh();
+ switch (c)
+ {
+ case '!': // Found "<!"
+ c = readCh();
+ switch (c)
+ {
+ case '-': // Found "<!-"
+ require('-');
+ isDirtyCurrentElement = false;
+ parseComment();
+ break;
+ case '[': // Found "<!["
+ isDirtyCurrentElement = false;
+ require("CDATA[");
+ handler.startCDATA();
+ inCDATA = true;
+ parseCDSect();
+ inCDATA = false;
+ handler.endCDATA();
+ break;
+ default:
+ error("expected comment or CDATA section", c, null);
+ break;
+ }
+ break;
+
+ case '?': // Found "<?"
+ isDirtyCurrentElement = false;
+ parsePI();
+ break;
+
+ case '/': // Found "</"
+ isDirtyCurrentElement = false;
+ parseETag();
+ return;
+
+ default: // Found "<" followed by something else
+ isDirtyCurrentElement = false;
+ unread(c);
+ parseElement(false);
+ break;
+ }
+ }
+ }
+ }
+
+ /**
+ * Parse an element type declaration.
+ * <pre>
+ * [45] elementdecl ::= '<!ELEMENT' S Name S contentspec S? '>'
+ * </pre>
+ * <p> NOTE: the '<!ELEMENT' has already been read.
+ */
+ private void parseElementDecl()
+ throws Exception
+ {
+ String name;
+
+ requireWhitespace();
+ // Read the element type name.
+ name = readNmtoken(true);
+
+ requireWhitespace();
+ // Read the content model.
+ parseContentspec(name);
+
+ skipWhitespace();
+ require('>');
+ }
+
+ /**
+ * Content specification.
+ * <pre>
+ * [46] contentspec ::= 'EMPTY' | 'ANY' | Mixed | elements
+ * </pre>
+ */
+ private void parseContentspec(String name)
+ throws Exception
+ {
+ // FIXME: move elementDecl() into setElement(), pass EMTPY/ANY ...
+ if (tryRead("EMPTY"))
+ {
+ setElement(name, CONTENT_EMPTY, null, null);
+ if (!skippedPE)
+ {
+ handler.getDeclHandler().elementDecl(name, "EMPTY");
+ }
+ return;
+ }
+ else if (tryRead("ANY"))
+ {
+ setElement(name, CONTENT_ANY, null, null);
+ if (!skippedPE)
+ {
+ handler.getDeclHandler().elementDecl(name, "ANY");
+ }
+ return;
+ }
+ else
+ {
+ String model;
+ char[] saved;
+
+ require('(');
+ saved = readBuffer;
+ dataBufferAppend('(');
+ skipWhitespace();
+ if (tryRead("#PCDATA"))
+ {
+ dataBufferAppend("#PCDATA");
+ parseMixed(saved);
+ model = dataBufferToString();
+ setElement(name, CONTENT_MIXED, model, null);
+ }
+ else
+ {
+ parseElements(saved);
+ model = dataBufferToString();
+ setElement(name, CONTENT_ELEMENTS, model, null);
+ }
+ if (!skippedPE)
+ {
+ handler.getDeclHandler().elementDecl(name, model);
+ }
+ }
+ }
+
+ /**
+ * Parse an element-content model.
+ * <pre>
+ * [47] elements ::= (choice | seq) ('?' | '*' | '+')?
+ * [49] choice ::= '(' S? cp (S? '|' S? cp)+ S? ')'
+ * [50] seq ::= '(' S? cp (S? ',' S? cp)* S? ')'
+ * </pre>
+ *
+ * <p> NOTE: the opening '(' and S have already been read.
+ *
+ * @param saved Buffer for entity that should have the terminal ')'
+ */
+ private void parseElements(char[] saved)
+ throws Exception
+ {
+ char c;
+ char sep;
+
+ // Parse the first content particle
+ skipWhitespace();
+ parseCp();
+
+ // Check for end or for a separator.
+ skipWhitespace();
+ c = readCh();
+ switch (c)
+ {
+ case ')':
+ // VC: Proper Group/PE Nesting
+ if (readBuffer != saved)
+ {
+ handler.verror("Illegal Group/PE nesting");
+ }
+
+ dataBufferAppend(')');
+ c = readCh();
+ switch (c)
+ {
+ case '*':
+ case '+':
+ case '?':
+ dataBufferAppend(c);
+ break;
+ default:
+ unread(c);
+ }
+ return;
+ case ',': // Register the separator.
+ case '|':
+ sep = c;
+ dataBufferAppend(c);
+ break;
+ default:
+ error("bad separator in content model", c, null);
+ return;
+ }
+
+ // Parse the rest of the content model.
+ while (true)
+ {
+ skipWhitespace();
+ parseCp();
+ skipWhitespace();
+ c = readCh();
+ if (c == ')')
+ {
+ // VC: Proper Group/PE Nesting
+ if (readBuffer != saved)
+ {
+ handler.verror("Illegal Group/PE nesting");
+ }
+
+ dataBufferAppend(')');
+ break;
+ }
+ else if (c != sep)
+ {
+ error("bad separator in content model", c, null);
+ return;
+ }
+ else
+ {
+ dataBufferAppend(c);
+ }
+ }
+
+ // Check for the occurrence indicator.
+ c = readCh();
+ switch (c)
+ {
+ case '?':
+ case '*':
+ case '+':
+ dataBufferAppend(c);
+ return;
+ default:
+ unread(c);
+ return;
+ }
+ }
+
+ /**
+ * Parse a content particle.
+ * <pre>
+ * [48] cp ::= (Name | choice | seq) ('?' | '*' | '+')?
+ * </pre>
+ */
+ private void parseCp()
+ throws Exception
+ {
+ if (tryRead('('))
+ {
+ dataBufferAppend('(');
+ parseElements(readBuffer);
+ }
+ else
+ {
+ dataBufferAppend(readNmtoken(true));
+ char c = readCh();
+ switch (c)
+ {
+ case '?':
+ case '*':
+ case '+':
+ dataBufferAppend(c);
+ break;
+ default:
+ unread(c);
+ break;
+ }
+ }
+ }
+
+ /**
+ * Parse mixed content.
+ * <pre>
+ * [51] Mixed ::= '(' S? ( '#PCDATA' (S? '|' S? Name)*) S? ')*'
+ * | '(' S? ('#PCDATA') S? ')'
+ * </pre>
+ *
+ * @param saved Buffer for entity that should have the terminal ')'
+ */
+ private void parseMixed(char[] saved)
+ throws Exception
+ {
+ // Check for PCDATA alone.
+ skipWhitespace();
+ if (tryRead(')'))
+ {
+ // VC: Proper Group/PE Nesting
+ if (readBuffer != saved)
+ {
+ handler.verror("Illegal Group/PE nesting");
+ }
+
+ dataBufferAppend(")*");
+ tryRead('*');
+ return;
+ }
+
+ // Parse mixed content.
+ skipWhitespace();
+ while (!tryRead(")"))
+ {
+ require('|');
+ dataBufferAppend('|');
+ skipWhitespace();
+ dataBufferAppend(readNmtoken(true));
+ skipWhitespace();
+ }
+
+ // VC: Proper Group/PE Nesting
+ if (readBuffer != saved)
+ {
+ handler.verror("Illegal Group/PE nesting");
+ }
+
+ require('*');
+ dataBufferAppend(")*");
+ }
+
+ /**
+ * Parse an attribute list declaration.
+ * <pre>
+ * [52] AttlistDecl ::= '<!ATTLIST' S Name AttDef* S? '>'
+ * </pre>
+ * <p>NOTE: the '<!ATTLIST' has already been read.
+ */
+ private void parseAttlistDecl()
+ throws Exception
+ {
+ String elementName;
+
+ requireWhitespace();
+ elementName = readNmtoken(true);
+ boolean white = tryWhitespace();
+ while (!tryRead('>'))
+ {
+ if (!white)
+ {
+ error("whitespace required before attribute definition");
+ }
+ parseAttDef(elementName);
+ white = tryWhitespace();
+ }
+ }
+
+ /**
+ * Parse a single attribute definition.
+ * <pre>
+ * [53] AttDef ::= S Name S AttType S DefaultDecl
+ * </pre>
+ */
+ private void parseAttDef(String elementName)
+ throws Exception
+ {
+ String name;
+ String type;
+ String enumer = null;
+
+ // Read the attribute name.
+ name = readNmtoken(true);
+
+ // Read the attribute type.
+ requireWhitespace();
+ type = readAttType();
+
+ // Get the string of enumerated values if necessary.
+ if (handler.stringInterning)
+ {
+ if ("ENUMERATION" == type || "NOTATION" == type)
+ {
+ enumer = dataBufferToString();
+ }
+ }
+ else
+ {
+ if ("ENUMERATION".equals(type) || "NOTATION".equals(type))
+ {
+ enumer = dataBufferToString();
+ }
+ }
+
+ // Read the default value.
+ requireWhitespace();
+ parseDefault(elementName, name, type, enumer);
+ }
+
+ /**
+ * Parse the attribute type.
+ * <pre>
+ * [54] AttType ::= StringType | TokenizedType | EnumeratedType
+ * [55] StringType ::= 'CDATA'
+ * [56] TokenizedType ::= 'ID' | 'IDREF' | 'IDREFS' | 'ENTITY'
+ * | 'ENTITIES' | 'NMTOKEN' | 'NMTOKENS'
+ * [57] EnumeratedType ::= NotationType | Enumeration
+ * </pre>
+ */
+ private String readAttType()
+ throws Exception
+ {
+ if (tryRead('('))
+ {
+ parseEnumeration(false);
+ return "ENUMERATION";
+ }
+ else
+ {
+ String typeString = readNmtoken(true);
+ if (handler.stringInterning)
+ {
+ if ("NOTATION" == typeString)
+ {
+ parseNotationType();
+ return typeString;
+ }
+ else if ("CDATA" == typeString
+ || "ID" == typeString
+ || "IDREF" == typeString
+ || "IDREFS" == typeString
+ || "ENTITY" == typeString
+ || "ENTITIES" == typeString
+ || "NMTOKEN" == typeString
+ || "NMTOKENS" == typeString)
+ {
+ return typeString;
+ }
+ }
+ else
+ {
+ if ("NOTATION".equals(typeString))
+ {
+ parseNotationType();
+ return typeString;
+ }
+ else if ("CDATA".equals(typeString)
+ || "ID".equals(typeString)
+ || "IDREF".equals(typeString)
+ || "IDREFS".equals(typeString)
+ || "ENTITY".equals(typeString)
+ || "ENTITIES".equals(typeString)
+ || "NMTOKEN".equals(typeString)
+ || "NMTOKENS".equals(typeString))
+ {
+ return typeString;
+ }
+ }
+ error("illegal attribute type", typeString, null);
+ return null;
+ }
+ }
+
+ /**
+ * Parse an enumeration.
+ * <pre>
+ * [59] Enumeration ::= '(' S? Nmtoken (S? '|' S? Nmtoken)* S? ')'
+ * </pre>
+ * <p>NOTE: the '(' has already been read.
+ */
+ private void parseEnumeration(boolean isNames)
+ throws Exception
+ {
+ dataBufferAppend('(');
+
+ // Read the first token.
+ skipWhitespace();
+ dataBufferAppend(readNmtoken(isNames));
+ // Read the remaining tokens.
+ skipWhitespace();
+ while (!tryRead(')'))
+ {
+ require('|');
+ dataBufferAppend('|');
+ skipWhitespace();
+ dataBufferAppend(readNmtoken (isNames));
+ skipWhitespace();
+ }
+ dataBufferAppend(')');
+ }
+
+ /**
+ * Parse a notation type for an attribute.
+ * <pre>
+ * [58] NotationType ::= 'NOTATION' S '(' S? NameNtoks
+ * (S? '|' S? name)* S? ')'
+ * </pre>
+ * <p>NOTE: the 'NOTATION' has already been read
+ */
+ private void parseNotationType()
+ throws Exception
+ {
+ requireWhitespace();
+ require('(');
+
+ parseEnumeration(true);
+ }
+
+ /**
+ * Parse the default value for an attribute.
+ * <pre>
+ * [60] DefaultDecl ::= '#REQUIRED' | '#IMPLIED'
+ * | (('#FIXED' S)? AttValue)
+ * </pre>
+ */
+ private void parseDefault(String elementName, String name,
+ String type, String enumer)
+ throws Exception
+ {
+ int valueType = ATTRIBUTE_DEFAULT_SPECIFIED;
+ String value = null;
+ int flags = LIT_ATTRIBUTE;
+ boolean saved = expandPE;
+ String defaultType = null;
+
+ // LIT_ATTRIBUTE forces '<' checks now (ASAP) and turns whitespace
+ // chars to spaces (doesn't matter when that's done if it doesn't
+ // interfere with char refs expanding to whitespace).
+
+ if (!skippedPE)
+ {
+ flags |= LIT_ENTITY_REF;
+ if (handler.stringInterning)
+ {
+ if ("CDATA" != type)
+ {
+ flags |= LIT_NORMALIZE;
+ }
+ }
+ else
+ {
+ if (!"CDATA".equals(type))
+ {
+ flags |= LIT_NORMALIZE;
+ }
+ }
+ }
+
+ expandPE = false;
+ if (tryRead('#'))
+ {
+ if (tryRead("FIXED"))
+ {
+ defaultType = "#FIXED";
+ valueType = ATTRIBUTE_DEFAULT_FIXED;
+ requireWhitespace();
+ value = readLiteral(flags);
+ }
+ else if (tryRead("REQUIRED"))
+ {
+ defaultType = "#REQUIRED";
+ valueType = ATTRIBUTE_DEFAULT_REQUIRED;
+ }
+ else if (tryRead("IMPLIED"))
+ {
+ defaultType = "#IMPLIED";
+ valueType = ATTRIBUTE_DEFAULT_IMPLIED;
+ }
+ else
+ {
+ error("illegal keyword for attribute default value");
+ }
+ }
+ else
+ {
+ value = readLiteral(flags);
+ }
+ expandPE = saved;
+ setAttribute(elementName, name, type, enumer, value, valueType);
+ if (handler.stringInterning)
+ {
+ if ("ENUMERATION" == type)
+ {
+ type = enumer;
+ }
+ else if ("NOTATION" == type)
+ {
+ type = "NOTATION " + enumer;
+ }
+ }
+ else
+ {
+ if ("ENUMERATION".equals(type))
+ {
+ type = enumer;
+ }
+ else if ("NOTATION".equals(type))
+ {
+ type = "NOTATION " + enumer;
+ }
+ }
+ if (!skippedPE)
+ {
+ handler.getDeclHandler().attributeDecl(elementName, name, type,
+ defaultType, value);
+ }
+ }
+
+ /**
+ * Parse a conditional section.
+ * <pre>
+ * [61] conditionalSect ::= includeSect || ignoreSect
+ * [62] includeSect ::= '<![' S? 'INCLUDE' S? '['
+ * extSubsetDecl ']]>'
+ * [63] ignoreSect ::= '<![' S? 'IGNORE' S? '['
+ * ignoreSectContents* ']]>'
+ * [64] ignoreSectContents ::= Ignore
+ * ('<![' ignoreSectContents* ']]>' Ignore )*
+ * [65] Ignore ::= Char* - (Char* ( '<![' | ']]>') Char* )
+ * </pre>
+ * <p> NOTE: the '>![' has already been read.
+ */
+ private void parseConditionalSect(char[] saved)
+ throws Exception
+ {
+ skipWhitespace();
+ if (tryRead("INCLUDE"))
+ {
+ skipWhitespace();
+ require('[');
+ // VC: Proper Conditional Section/PE Nesting
+ if (readBuffer != saved)
+ {
+ handler.verror("Illegal Conditional Section/PE nesting");
+ }
+ skipWhitespace();
+ while (!tryRead("]]>"))
+ {
+ parseMarkupdecl();
+ skipWhitespace();
+ }
+ }
+ else if (tryRead("IGNORE"))
+ {
+ skipWhitespace();
+ require('[');
+ // VC: Proper Conditional Section/PE Nesting
+ if (readBuffer != saved)
+ {
+ handler.verror("Illegal Conditional Section/PE nesting");
+ }
+ int nesting = 1;
+ char c;
+ expandPE = false;
+ for (int nest = 1; nest > 0; )
+ {
+ c = readCh();
+ switch (c)
+ {
+ case '<':
+ if (tryRead("!["))
+ {
+ nest++;
+ }
+ break;
+ case ']':
+ if (tryRead("]>"))
+ {
+ nest--;
+ }
+ }
+ }
+ expandPE = true;
+ }
+ else
+ {
+ error("conditional section must begin with INCLUDE or IGNORE");
+ }
+ }
+
+ private void parseCharRef()
+ throws SAXException, IOException
+ {
+ parseCharRef(true /* do flushDataBuffer by default */);
+ }
+
+ /**
+ * Try to read a character reference without consuming data from buffer.
+ * <pre>
+ * [66] CharRef ::= '&#' [0-9]+ ';' | '&#x' [0-9a-fA-F]+ ';'
+ * </pre>
+ * <p>NOTE: the '&#' has already been read.
+ */
+ private void tryReadCharRef()
+ throws SAXException, IOException
+ {
+ int value = 0;
+ char c;
+
+ if (tryRead('x'))
+ {
+loop1:
+ while (true)
+ {
+ c = readCh();
+ if (c == ';')
+ {
+ break loop1;
+ }
+ else
+ {
+ int n = Character.digit(c, 16);
+ if (n == -1)
+ {
+ error("illegal character in character reference", c, null);
+ break loop1;
+ }
+ value *= 16;
+ value += n;
+ }
+ }
+ }
+ else
+ {
+loop2:
+ while (true)
+ {
+ c = readCh();
+ if (c == ';')
+ {
+ break loop2;
+ }
+ else
+ {
+ int n = Character.digit(c, 10);
+ if (n == -1)
+ {
+ error("illegal character in character reference", c, null);
+ break loop2;
+ }
+ value *= 10;
+ value += n;
+ }
+ }
+ }
+
+ // check for character refs being legal XML
+ if ((value < 0x0020
+ && ! (value == '\n' || value == '\t' || value == '\r'))
+ || (value >= 0xD800 && value <= 0xDFFF)
+ || value == 0xFFFE || value == 0xFFFF
+ || value > 0x0010ffff)
+ {
+ error("illegal XML character reference U+"
+ + Integer.toHexString(value));
+ }
+
+ // Check for surrogates: 00000000 0000xxxx yyyyyyyy zzzzzzzz
+ // (1101|10xx|xxyy|yyyy + 1101|11yy|zzzz|zzzz:
+ if (value > 0x0010ffff)
+ {
+ // too big for surrogate
+ error("character reference " + value + " is too large for UTF-16",
+ new Integer(value).toString(), null);
+ }
+
+ }
+
+ /**
+ * Read and interpret a character reference.
+ * <pre>
+ * [66] CharRef ::= '&#' [0-9]+ ';' | '&#x' [0-9a-fA-F]+ ';'
+ * </pre>
+ * <p>NOTE: the '&#' has already been read.
+ */
+ private void parseCharRef(boolean doFlush)
+ throws SAXException, IOException
+ {
+ int value = 0;
+ char c;
+
+ if (tryRead('x'))
+ {
+loop1:
+ while (true)
+ {
+ c = readCh();
+ if (c == ';')
+ {
+ break loop1;
+ }
+ else
+ {
+ int n = Character.digit(c, 16);
+ if (n == -1)
+ {
+ error("illegal character in character reference", c, null);
+ break loop1;
+ }
+ value *= 16;
+ value += n;
+ }
+ }
+ }
+ else
+ {
+loop2:
+ while (true)
+ {
+ c = readCh();
+ if (c == ';')
+ {
+ break loop2;
+ }
+ else
+ {
+ int n = Character.digit(c, 10);
+ if (n == -1)
+ {
+ error("illegal character in character reference", c, null);
+ break loop2;
+ }
+ value *= 10;
+ value += c - '0';
+ }
+ }
+ }
+
+ // check for character refs being legal XML
+ if ((value < 0x0020
+ && ! (value == '\n' || value == '\t' || value == '\r'))
+ || (value >= 0xD800 && value <= 0xDFFF)
+ || value == 0xFFFE || value == 0xFFFF
+ || value > 0x0010ffff)
+ {
+ error("illegal XML character reference U+"
+ + Integer.toHexString(value));
+ }
+
+ // Check for surrogates: 00000000 0000xxxx yyyyyyyy zzzzzzzz
+ // (1101|10xx|xxyy|yyyy + 1101|11yy|zzzz|zzzz:
+ if (value <= 0x0000ffff)
+ {
+ // no surrogates needed
+ dataBufferAppend((char) value);
+ }
+ else if (value <= 0x0010ffff)
+ {
+ value -= 0x10000;
+ // > 16 bits, surrogate needed
+ dataBufferAppend((char) (0xd800 | (value >> 10)));
+ dataBufferAppend((char) (0xdc00 | (value & 0x0003ff)));
+ }
+ else
+ {
+ // too big for surrogate
+ error("character reference " + value + " is too large for UTF-16",
+ new Integer(value).toString(), null);
+ }
+ if (doFlush)
+ {
+ dataBufferFlush();
+ }
+ }
+
+ /**
+ * Parse and expand an entity reference.
+ * <pre>
+ * [68] EntityRef ::= '&' Name ';'
+ * </pre>
+ * <p>NOTE: the '&' has already been read.
+ * @param externalAllowed External entities are allowed here.
+ */
+ private void parseEntityRef(boolean externalAllowed)
+ throws SAXException, IOException
+ {
+ String name;
+
+ name = readNmtoken(true);
+ require(';');
+ switch (getEntityType(name))
+ {
+ case ENTITY_UNDECLARED:
+ // NOTE: XML REC describes amazingly convoluted handling for
+ // this case. Nothing as meaningful as being a WFness error
+ // unless the processor might _legitimately_ not have seen a
+ // declaration ... which is what this implements.
+ String message;
+
+ message = "reference to undeclared general entity " + name;
+ if (skippedPE && !docIsStandalone)
+ {
+ handler.verror(message);
+ // we don't know this entity, and it might be external...
+ if (externalAllowed)
+ {
+ handler.skippedEntity(name);
+ }
+ }
+ else
+ {
+ error(message);
+ }
+ break;
+ case ENTITY_INTERNAL:
+ pushString(name, getEntityValue(name));
+
+ //workaround for possible input pop before marking
+ //the buffer reading position
+ char t = readCh();
+ unread(t);
+ int bufferPosMark = readBufferPos;
+
+ int end = readBufferPos + getEntityValue(name).length();
+ for (int k = readBufferPos; k < end; k++)
+ {
+ t = readCh();
+ if (t == '&')
+ {
+ t = readCh();
+ if (t == '#')
+ {
+ //try to match a character ref
+ tryReadCharRef();
+
+ //everything has been read
+ if (readBufferPos >= end)
+ {
+ break;
+ }
+ k = readBufferPos;
+ continue;
+ }
+ else if (Character.isLetter(t))
+ {
+ //looks like an entity ref
+ unread(t);
+ readNmtoken(true);
+ require(';');
+
+ //everything has been read
+ if (readBufferPos >= end)
+ {
+ break;
+ }
+ k = readBufferPos;
+ continue;
+ }
+ error(" malformed entity reference");
+ }
+
+ }
+ readBufferPos = bufferPosMark;
+ break;
+ case ENTITY_TEXT:
+ if (externalAllowed)
+ {
+ pushURL(false, name, getEntityIds(name),
+ null, null, null, true);
+ }
+ else
+ {
+ error("reference to external entity in attribute value.",
+ name, null);
+ }
+ break;
+ case ENTITY_NDATA:
+ if (externalAllowed)
+ {
+ error("unparsed entity reference in content", name, null);
+ }
+ else
+ {
+ error("reference to external entity in attribute value.",
+ name, null);
+ }
+ break;
+ default:
+ throw new RuntimeException();
+ }
+ }
+
+ /**
+ * Parse and expand a parameter entity reference.
+ * <pre>
+ * [69] PEReference ::= '%' Name ';'
+ * </pre>
+ * <p>NOTE: the '%' has already been read.
+ */
+ private void parsePEReference()
+ throws SAXException, IOException
+ {
+ String name;
+
+ name = "%" + readNmtoken(true);
+ require(';');
+ switch (getEntityType(name))
+ {
+ case ENTITY_UNDECLARED:
+ // VC: Entity Declared
+ handler.verror("reference to undeclared parameter entity " + name);
+
+ // we should disable handling of all subsequent declarations
+ // unless this is a standalone document (info discarded)
+ break;
+ case ENTITY_INTERNAL:
+ if (inLiteral)
+ {
+ pushString(name, getEntityValue(name));
+ }
+ else
+ {
+ pushString(name, ' ' + getEntityValue(name) + ' ');
+ }
+ break;
+ case ENTITY_TEXT:
+ if (!inLiteral)
+ {
+ pushString(null, " ");
+ }
+ pushURL(true, name, getEntityIds(name), null, null, null, true);
+ if (!inLiteral)
+ {
+ pushString(null, " ");
+ }
+ break;
+ }
+ }
+
+ /**
+ * Parse an entity declaration.
+ * <pre>
+ * [70] EntityDecl ::= GEDecl | PEDecl
+ * [71] GEDecl ::= '<!ENTITY' S Name S EntityDef S? '>'
+ * [72] PEDecl ::= '<!ENTITY' S '%' S Name S PEDef S? '>'
+ * [73] EntityDef ::= EntityValue | (ExternalID NDataDecl?)
+ * [74] PEDef ::= EntityValue | ExternalID
+ * [75] ExternalID ::= 'SYSTEM' S SystemLiteral
+ * | 'PUBLIC' S PubidLiteral S SystemLiteral
+ * [76] NDataDecl ::= S 'NDATA' S Name
+ * </pre>
+ * <p>NOTE: the '<!ENTITY' has already been read.
+ */
+ private void parseEntityDecl()
+ throws Exception
+ {
+ boolean peFlag = false;
+ int flags = 0;
+
+ // Check for a parameter entity.
+ expandPE = false;
+ requireWhitespace();
+ if (tryRead('%'))
+ {
+ peFlag = true;
+ requireWhitespace();
+ }
+ expandPE = true;
+
+ // Read the entity name, and prepend
+ // '%' if necessary.
+ String name = readNmtoken(true);
+ //NE08
+ if (name.indexOf(':') >= 0)
+ {
+ error("Illegal character(':') in entity name ", name, null);
+ }
+ if (peFlag)
+ {
+ name = "%" + name;
+ }
+
+ // Read the entity value.
+ requireWhitespace();
+ char c = readCh();
+ unread (c);
+ if (c == '"' || c == '\'')
+ {
+ // Internal entity ... replacement text has expanded refs
+ // to characters and PEs, but not to general entities
+ String value = readLiteral(flags);
+ setInternalEntity(name, value);
+ }
+ else
+ {
+ // Read the external IDs
+ ExternalIdentifiers ids = readExternalIds(false, false);
+
+ // Check for NDATA declaration.
+ boolean white = tryWhitespace();
+ if (!peFlag && tryRead("NDATA"))
+ {
+ if (!white)
+ {
+ error("whitespace required before NDATA");
+ }
+ requireWhitespace();
+ String notationName = readNmtoken(true);
+ if (!skippedPE)
+ {
+ setExternalEntity(name, ENTITY_NDATA, ids, notationName);
+ handler.unparsedEntityDecl(name, ids.publicId, ids.systemId,
+ ids.baseUri, notationName);
+ }
+ }
+ else if (!skippedPE)
+ {
+ setExternalEntity(name, ENTITY_TEXT, ids, null);
+ handler.getDeclHandler()
+ .externalEntityDecl(name, ids.publicId,
+ handler.resolveURIs()
+ // FIXME: ASSUMES not skipped
+ // "false" forces error on bad URI
+ ? handler.absolutize(ids.baseUri,
+ ids.systemId,
+ false)
+ : ids.systemId);
+ }
+ }
+
+ // Finish the declaration.
+ skipWhitespace();
+ require('>');
+ }
+
+ /**
+ * Parse a notation declaration.
+ * <pre>
+ * [82] NotationDecl ::= '<!NOTATION' S Name S
+ * (ExternalID | PublicID) S? '>'
+ * [83] PublicID ::= 'PUBLIC' S PubidLiteral
+ * </pre>
+ * <P>NOTE: the '<!NOTATION' has already been read.
+ */
+ private void parseNotationDecl()
+ throws Exception
+ {
+ String nname;
+ ExternalIdentifiers ids;
+
+ requireWhitespace();
+ nname = readNmtoken(true);
+ //NE08
+ if (nname.indexOf(':') >= 0)
+ {
+ error("Illegal character(':') in notation name ", nname, null);
+ }
+ requireWhitespace();
+
+ // Read the external identifiers.
+ ids = readExternalIds(true, false);
+
+ // Register the notation.
+ setNotation(nname, ids);
+
+ skipWhitespace();
+ require('>');
+ }
+
+ /**
+ * Parse character data.
+ * <pre>
+ * [14] CharData ::= [^<&]* - ([^<&]* ']]>' [^<&]*)
+ * </pre>
+ */
+ private void parseCharData()
+ throws Exception
+ {
+ char c;
+ int state = 0;
+ boolean pureWhite = false;
+
+ // assert (dataBufferPos == 0);
+
+ // are we expecting pure whitespace? it might be dirty...
+ if ((currentElementContent == CONTENT_ELEMENTS) && !isDirtyCurrentElement)
+ {
+ pureWhite = true;
+ }
+
+ // always report right out of readBuffer
+ // to minimize (pointless) buffer copies
+ while (true)
+ {
+ int lineAugment = 0;
+ int columnAugment = 0;
+ int i;
+
+loop:
+ for (i = readBufferPos; i < readBufferLength; i++)
+ {
+ switch (c = readBuffer[i])
+ {
+ case '\n':
+ lineAugment++;
+ columnAugment = 0;
+ // pureWhite unmodified
+ break;
+ case '\r': // should not happen!!
+ case '\t':
+ case ' ':
+ // pureWhite unmodified
+ columnAugment++;
+ break;
+ case '&':
+ case '<':
+ columnAugment++;
+ // pureWhite unmodified
+ // CLEAN end of text sequence
+ state = 1;
+ break loop;
+ case ']':
+ // that's not a whitespace char, and
+ // can not terminate pure whitespace either
+ pureWhite = false;
+ if ((i + 2) < readBufferLength)
+ {
+ if (readBuffer [i + 1] == ']'
+ && readBuffer [i + 2] == '>')
+ {
+ // ERROR end of text sequence
+ state = 2;
+ break loop;
+ }
+ }
+ else
+ {
+ // FIXME missing two end-of-buffer cases
+ }
+ columnAugment++;
+ break;
+ default:
+ if ((c < 0x0020 || c > 0xFFFD)
+ || ((c >= 0x007f) && (c <= 0x009f) && (c != 0x0085)
+ && xmlVersion == XML_11))
+ {
+ error("illegal XML character U+"
+ + Integer.toHexString(c));
+ }
+ // that's not a whitespace char
+ pureWhite = false;
+ columnAugment++;
+ }
+ }
+
+ // report text thus far
+ if (lineAugment > 0)
+ {
+ line += lineAugment;
+ column = columnAugment;
+ }
+ else
+ {
+ column += columnAugment;
+ }
+
+ // report characters/whitspace
+ int length = i - readBufferPos;
+
+ if (length != 0)
+ {
+ if (pureWhite)
+ {
+ handler.ignorableWhitespace(readBuffer,
+ readBufferPos, length);
+ }
+ else
+ {
+ handler.charData(readBuffer, readBufferPos, length);
+ }
+ readBufferPos = i;
+ }
+
+ if (state != 0)
+ {
+ break;
+ }
+
+ // fill next buffer from this entity, or
+ // pop stack and continue with previous entity
+ unread(readCh());
+ }
+ if (!pureWhite)
+ {
+ isDirtyCurrentElement = true;
+ }
+ // finish, maybe with error
+ if (state != 1) // finish, no error
+ {
+ error("character data may not contain ']]>'");
+ }
+ }
+
+ //////////////////////////////////////////////////////////////////////
+ // High-level reading and scanning methods.
+ //////////////////////////////////////////////////////////////////////
+
+ /**
+ * Require whitespace characters.
+ */
+ private void requireWhitespace()
+ throws SAXException, IOException
+ {
+ char c = readCh();
+ if (isWhitespace(c))
+ {
+ skipWhitespace();
+ }
+ else
+ {
+ error("whitespace required", c, null);
+ }
+ }
+
+ /**
+ * Skip whitespace characters.
+ * <pre>
+ * [3] S ::= (#x20 | #x9 | #xd | #xa)+
+ * </pre>
+ */
+ private void skipWhitespace()
+ throws SAXException, IOException
+ {
+ // Start with a little cheat. Most of
+ // the time, the white space will fall
+ // within the current read buffer; if
+ // not, then fall through.
+ if (USE_CHEATS)
+ {
+ int lineAugment = 0;
+ int columnAugment = 0;
+
+loop:
+ for (int i = readBufferPos; i < readBufferLength; i++)
+ {
+ switch (readBuffer[i])
+ {
+ case ' ':
+ case '\t':
+ case '\r':
+ columnAugment++;
+ break;
+ case '\n':
+ lineAugment++;
+ columnAugment = 0;
+ break;
+ case '%':
+ if (expandPE)
+ {
+ break loop;
+ }
+ // else fall through...
+ default:
+ readBufferPos = i;
+ if (lineAugment > 0)
+ {
+ line += lineAugment;
+ column = columnAugment;
+ }
+ else
+ {
+ column += columnAugment;
+ }
+ return;
+ }
+ }
+ }
+
+ // OK, do it the slow way.
+ char c = readCh ();
+ while (isWhitespace(c))
+ {
+ c = readCh();
+ }
+ unread(c);
+ }
+
+ /**
+ * Read a name or (when parsing an enumeration) name token.
+ * <pre>
+ * [5] Name ::= (Letter | '_' | ':') (NameChar)*
+ * [7] Nmtoken ::= (NameChar)+
+ * </pre>
+ */
+ private String readNmtoken(boolean isName)
+ throws SAXException, IOException
+ {
+ char c;
+
+ if (USE_CHEATS)
+ {
+loop:
+ for (int i = readBufferPos; i < readBufferLength; i++)
+ {
+ c = readBuffer[i];
+ switch (c)
+ {
+ case '%':
+ if (expandPE)
+ {
+ break loop;
+ }
+ // else fall through...
+
+ // What may legitimately come AFTER a name/nmtoken?
+ case '<': case '>': case '&':
+ case ',': case '|': case '*': case '+': case '?':
+ case ')':
+ case '=':
+ case '\'': case '"':
+ case '[':
+ case ' ': case '\t': case '\r': case '\n':
+ case ';':
+ case '/':
+ int start = readBufferPos;
+ if (i == start)
+ {
+ error("name expected", readBuffer[i], null);
+ }
+ readBufferPos = i;
+ return intern(readBuffer, start, i - start);
+
+ default:
+ // FIXME ... per IBM's OASIS test submission, these:
+ // ? U+06dd
+ // Combining U+309B
+ //these switches are kind of ugly but at least we won't
+ //have to go over the whole lits for each char
+ if (isName && i == readBufferPos)
+ {
+ char c2 = (char) (c & 0x00f0);
+ switch (c & 0xff00)
+ {
+ //starting with 01
+ case 0x0100:
+ switch (c2)
+ {
+ case 0x0030:
+ if (c == 0x0132 || c == 0x0133 || c == 0x013f)
+ {
+ error("Not a name start character, U+"
+ + Integer.toHexString(c));
+ }
+ break;
+ case 0x0040:
+ if (c == 0x0140 || c == 0x0149)
+ {
+ error("Not a name start character, U+"
+ + Integer.toHexString(c));
+ }
+ break;
+ case 0x00c0:
+ if (c == 0x01c4 || c == 0x01cc)
+ {
+ error("Not a name start character, U+"
+ + Integer.toHexString(c));
+ }
+ break;
+ case 0x00f0:
+ if (c == 0x01f1 || c == 0x01f3)
+ {
+ error("Not a name start character, U+"
+ + Integer.toHexString(c));
+ }
+ break;
+ case 0x00b0:
+ if (c == 0x01f1 || c == 0x01f3)
+ {
+ error("Not a name start character, U+"
+ + Integer.toHexString(c));
+ }
+ break;
+ default:
+ if (c == 0x017f)
+ {
+ error("Not a name start character, U+"
+ + Integer.toHexString(c));
+ }
+ }
+
+ break;
+ //starting with 11
+ case 0x1100:
+ switch (c2)
+ {
+ case 0x0000:
+ if (c == 0x1104 || c == 0x1108 ||
+ c == 0x110a || c == 0x110d)
+ {
+ error("Not a name start character, U+"
+ + Integer.toHexString(c));
+ }
+ break;
+ case 0x0030:
+ if (c == 0x113b || c == 0x113f)
+ {
+ error("Not a name start character, U+"
+ + Integer.toHexString(c));
+ }
+ break;
+ case 0x0040:
+ if (c == 0x1141 || c == 0x114d
+ || c == 0x114f )
+ {
+ error("Not a name start character, U+"
+ + Integer.toHexString(c));
+ }
+ break;
+ case 0x0050:
+ if (c == 0x1151 || c == 0x1156)
+ {
+ error("Not a name start character, U+"
+ + Integer.toHexString(c));
+ }
+ break;
+ case 0x0060:
+ if (c == 0x1162 || c == 0x1164
+ || c == 0x1166 || c == 0x116b
+ || c == 0x116f)
+ {
+ error("Not a name start character, U+"
+ + Integer.toHexString(c));
+ }
+ break;
+ case 0x00b0:
+ if (c == 0x11b6 || c == 0x11b9
+ || c == 0x11bb || c == 0x116f)
+ {
+ error("Not a name start character, U+"
+ + Integer.toHexString(c));
+ }
+ break;
+ default:
+ if (c == 0x1174 || c == 0x119f
+ || c == 0x11ac || c == 0x11c3
+ || c == 0x11f1)
+ {
+ error("Not a name start character, U+"
+ + Integer.toHexString(c));
+ }
+ }
+ break;
+ default:
+ if (c == 0x0e46 || c == 0x1011
+ || c == 0x212f || c == 0x0587
+ || c == 0x0230 )
+ {
+ error("Not a name start character, U+"
+ + Integer.toHexString(c));
+ }
+ }
+ }
+ // punt on exact tests from Appendix A; approximate
+ // them using the Unicode ID start/part rules
+ if (i == readBufferPos && isName)
+ {
+ if (!Character.isUnicodeIdentifierStart(c)
+ && c != ':' && c != '_')
+ {
+ error("Not a name start character, U+"
+ + Integer.toHexString(c));
+ }
+ }
+ else if (!Character.isUnicodeIdentifierPart(c)
+ && c != '-' && c != ':' && c != '_' && c != '.'
+ && !isExtender(c))
+ {
+ error("Not a name character, U+"
+ + Integer.toHexString(c));
+ }
+ }
+ }
+ }
+
+ nameBufferPos = 0;
+
+ // Read the first character.
+loop:
+ while (true)
+ {
+ c = readCh();
+ switch (c)
+ {
+ case '%':
+ case '<': case '>': case '&':
+ case ',': case '|': case '*': case '+': case '?':
+ case ')':
+ case '=':
+ case '\'': case '"':
+ case '[':
+ case ' ': case '\t': case '\n': case '\r':
+ case ';':
+ case '/':
+ unread(c);
+ if (nameBufferPos == 0)
+ {
+ error ("name expected");
+ }
+ // punt on exact tests from Appendix A, but approximate them
+ if (isName
+ && !Character.isUnicodeIdentifierStart(nameBuffer[0])
+ && ":_".indexOf(nameBuffer[0]) == -1)
+ {
+ error("Not a name start character, U+"
+ + Integer.toHexString(nameBuffer[0]));
+ }
+ String s = intern(nameBuffer, 0, nameBufferPos);
+ nameBufferPos = 0;
+ return s;
+ default:
+ // punt on exact tests from Appendix A, but approximate them
+
+ if ((nameBufferPos != 0 || !isName)
+ && !Character.isUnicodeIdentifierPart(c)
+ && ":-_.".indexOf(c) == -1
+ && !isExtender(c))
+ {
+ error("Not a name character, U+"
+ + Integer.toHexString(c));
+ }
+ if (nameBufferPos >= nameBuffer.length)
+ {
+ nameBuffer =
+ (char[]) extendArray(nameBuffer,
+ nameBuffer.length, nameBufferPos);
+ }
+ nameBuffer[nameBufferPos++] = c;
+ }
+ }
+ }
+
+ private static boolean isExtender(char c)
+ {
+ // [88] Extender ::= ...
+ return c == 0x00b7 || c == 0x02d0 || c == 0x02d1 || c == 0x0387
+ || c == 0x0640 || c == 0x0e46 || c == 0x0ec6 || c == 0x3005
+ || (c >= 0x3031 && c <= 0x3035)
+ || (c >= 0x309d && c <= 0x309e)
+ || (c >= 0x30fc && c <= 0x30fe);
+ }
+
+ /**
+ * Read a literal. With matching single or double quotes as
+ * delimiters (and not embedded!) this is used to parse:
+ * <pre>
+ * [9] EntityValue ::= ... ([^%&] | PEReference | Reference)* ...
+ * [10] AttValue ::= ... ([^<&] | Reference)* ...
+ * [11] SystemLiteral ::= ... (URLchar - "'")* ...
+ * [12] PubidLiteral ::= ... (PubidChar - "'")* ...
+ * </pre>
+ * as well as the quoted strings in XML and text declarations
+ * (for version, encoding, and standalone) which have their
+ * own constraints.
+ */
+ private String readLiteral(int flags)
+ throws SAXException, IOException
+ {
+ char delim, c;
+ int startLine = line;
+ boolean saved = expandPE;
+ boolean savedReport = doReport;
+
+ // Find the first delimiter.
+ delim = readCh();
+ if (delim != '"' && delim != '\'')
+ {
+ error("expected '\"' or \"'\"", delim, null);
+ return null;
+ }
+ inLiteral = true;
+ if ((flags & LIT_DISABLE_PE) != 0)
+ {
+ expandPE = false;
+ }
+ doReport = false;
+
+ // Each level of input source has its own buffer; remember
+ // ours, so we won't read the ending delimiter from any
+ // other input source, regardless of entity processing.
+ char[] ourBuf = readBuffer;
+
+ // Read the literal.
+ try
+ {
+ c = readCh();
+ boolean ampRead = false;
+loop:
+ while (! (c == delim && readBuffer == ourBuf))
+ {
+ switch (c)
+ {
+ // attributes and public ids are normalized
+ // in almost the same ways
+ case '\n':
+ case '\r':
+ if ((flags & (LIT_ATTRIBUTE | LIT_PUBID)) != 0)
+ {
+ c = ' ';
+ }
+ break;
+ case '\t':
+ if ((flags & LIT_ATTRIBUTE) != 0)
+ {
+ c = ' ';
+ }
+ break;
+ case '&':
+ c = readCh();
+ // Char refs are expanded immediately, except for
+ // all the cases where it's deferred.
+ if (c == '#')
+ {
+ if ((flags & LIT_DISABLE_CREF) != 0)
+ {
+ dataBufferAppend('&');
+ break;
+ }
+ parseCharRef(false /* Do not do flushDataBuffer */);
+
+ // exotic WFness risk: this is an entity literal,
+ // dataBuffer [dataBufferPos - 1] == '&', and
+ // following chars are a _partial_ entity/char ref
+
+ // It looks like an entity ref ...
+ }
+ else
+ {
+ unread(c);
+ // Expand it?
+ if ((flags & LIT_ENTITY_REF) > 0)
+ {
+ parseEntityRef(false);
+ if (String.valueOf(readBuffer).equals("&"))
+ {
+ ampRead = true;
+ }
+ //Is it just data?
+ }
+ else if ((flags & LIT_DISABLE_EREF) != 0)
+ {
+ dataBufferAppend('&');
+
+ // OK, it will be an entity ref -- expanded later.
+ }
+ else
+ {
+ String name = readNmtoken(true);
+ require(';');
+ dataBufferAppend('&');
+ dataBufferAppend(name);
+ dataBufferAppend(';');
+ }
+ }
+ c = readCh();
+ continue loop;
+
+ case '<':
+ // and why? Perhaps so "&foo;" expands the same
+ // inside and outside an attribute?
+ if ((flags & LIT_ATTRIBUTE) != 0)
+ {
+ error("attribute values may not contain '<'");
+ }
+ break;
+
+ // We don't worry about case '%' and PE refs, readCh does.
+
+ default:
+ break;
+ }
+ dataBufferAppend(c);
+ c = readCh();
+ }
+ }
+ catch (EOFException e)
+ {
+ error("end of input while looking for delimiter (started on line "
+ + startLine + ')', null, new Character(delim).toString());
+ }
+ inLiteral = false;
+ expandPE = saved;
+ doReport = savedReport;
+
+ // Normalise whitespace if necessary.
+ if ((flags & LIT_NORMALIZE) > 0)
+ {
+ dataBufferNormalize();
+ }
+
+ // Return the value.
+ return dataBufferToString();
+ }
+
+ /**
+ * Try reading external identifiers.
+ * A system identifier is not required for notations.
+ * @param inNotation Are we parsing a notation decl?
+ * @param isSubset Parsing external subset decl (may be omitted)?
+ * @return A three-member String array containing the identifiers,
+ * or nulls. Order: public, system, baseURI.
+ */
+ private ExternalIdentifiers readExternalIds(boolean inNotation,
+ boolean isSubset)
+ throws Exception
+ {
+ char c;
+ ExternalIdentifiers ids = new ExternalIdentifiers();
+ int flags = LIT_DISABLE_CREF | LIT_DISABLE_PE | LIT_DISABLE_EREF;
+
+ if (tryRead("PUBLIC"))
+ {
+ requireWhitespace();
+ ids.publicId = readLiteral(LIT_NORMALIZE | LIT_PUBID | flags);
+ if (inNotation)
+ {
+ skipWhitespace();
+ c = readCh();
+ unread(c);
+ if (c == '"' || c == '\'')
+ {
+ ids.systemId = readLiteral(flags);
+ }
+ }
+ else
+ {
+ requireWhitespace();
+ ids.systemId = readLiteral(flags);
+ }
+
+ for (int i = 0; i < ids.publicId.length(); i++)
+ {
+ c = ids.publicId.charAt(i);
+ if (c >= 'a' && c <= 'z')
+ {
+ continue;
+ }
+ if (c >= 'A' && c <= 'Z')
+ {
+ continue;
+ }
+ if (" \r\n0123456789-' ()+,./:=?;!*#@$_%".indexOf(c) != -1)
+ {
+ continue;
+ }
+ error("illegal PUBLIC id character U+"
+ + Integer.toHexString(c));
+ }
+ }
+ else if (tryRead("SYSTEM"))
+ {
+ requireWhitespace();
+ ids.systemId = readLiteral(flags);
+ }
+ else if (!isSubset)
+ {
+ error("missing SYSTEM or PUBLIC keyword");
+ }
+
+ if (ids.systemId != null)
+ {
+ if (ids.systemId.indexOf('#') != -1)
+ {
+ handler.verror("SYSTEM id has a URI fragment: " + ids.systemId);
+ }
+ ids.baseUri = handler.getSystemId();
+ if (ids.baseUri == null && uriWarnings)
+ {
+ handler.warn("No base URI; hope URI is absolute: "
+ + ids.systemId);
+ }
+ }
+
+ return ids;
+ }
+
+ /**
+ * Test if a character is whitespace.
+ * <pre>
+ * [3] S ::= (#x20 | #x9 | #xd | #xa)+
+ * </pre>
+ * @param c The character to test.
+ * @return true if the character is whitespace.
+ */
+ private final boolean isWhitespace(char c)
+ {
+ if (c > 0x20)
+ {
+ return false;
+ }
+ if (c == 0x20 || c == 0x0a || c == 0x09 || c == 0x0d)
+ {
+ return true;
+ }
+ return false; // illegal ...
+ }
+
+ //////////////////////////////////////////////////////////////////////
+ // Utility routines.
+ //////////////////////////////////////////////////////////////////////
+
+ /**
+ * Add a character to the data buffer.
+ */
+ private void dataBufferAppend(char c)
+ {
+ // Expand buffer if necessary.
+ if (dataBufferPos >= dataBuffer.length)
+ {
+ dataBuffer = (char[]) extendArray(dataBuffer,
+ dataBuffer.length, dataBufferPos);
+ }
+ dataBuffer[dataBufferPos++] = c;
+ }
+
+ /**
+ * Add a string to the data buffer.
+ */
+ private void dataBufferAppend(String s)
+ {
+ dataBufferAppend(s.toCharArray(), 0, s.length());
+ }
+
+ /**
+ * Append (part of) a character array to the data buffer.
+ */
+ private void dataBufferAppend(char[] ch, int start, int length)
+ {
+ dataBuffer = (char[]) extendArray(dataBuffer, dataBuffer.length,
+ dataBufferPos + length);
+
+ System.arraycopy(ch, start, dataBuffer, dataBufferPos, length);
+ dataBufferPos += length;
+ }
+
+ /**
+ * Normalise space characters in the data buffer.
+ */
+ private void dataBufferNormalize()
+ {
+ int i = 0;
+ int j = 0;
+ int end = dataBufferPos;
+
+ // Skip spaces at the start.
+ while (j < end && dataBuffer[j] == ' ')
+ {
+ j++;
+ }
+
+ // Skip whitespace at the end.
+ while (end > j && dataBuffer[end - 1] == ' ')
+ {
+ end --;
+ }
+
+ // Start copying to the left.
+ while (j < end)
+ {
+
+ char c = dataBuffer[j++];
+
+ // Normalise all other spaces to
+ // a single space.
+ if (c == ' ')
+ {
+ while (j < end && dataBuffer[j++] == ' ')
+ {
+ continue;
+ }
+ dataBuffer[i++] = ' ';
+ dataBuffer[i++] = dataBuffer[j - 1];
+ }
+ else
+ {
+ dataBuffer[i++] = c;
+ }
+ }
+
+ // The new length is <= the old one.
+ dataBufferPos = i;
+ }
+
+ /**
+ * Convert the data buffer to a string.
+ */
+ private String dataBufferToString()
+ {
+ String s = new String(dataBuffer, 0, dataBufferPos);
+ dataBufferPos = 0;
+ return s;
+ }
+
+ /**
+ * Flush the contents of the data buffer to the handler, as
+ * appropriate, and reset the buffer for new input.
+ */
+ private void dataBufferFlush()
+ throws SAXException
+ {
+ if (currentElementContent == CONTENT_ELEMENTS
+ && dataBufferPos > 0
+ && !inCDATA)
+ {
+ // We can't just trust the buffer to be whitespace, there
+ // are (error) cases when it isn't
+ for (int i = 0; i < dataBufferPos; i++)
+ {
+ if (!isWhitespace(dataBuffer[i]))
+ {
+ handler.charData(dataBuffer, 0, dataBufferPos);
+ dataBufferPos = 0;
+ }
+ }
+ if (dataBufferPos > 0)
+ {
+ handler.ignorableWhitespace(dataBuffer, 0, dataBufferPos);
+ dataBufferPos = 0;
+ }
+ }
+ else if (dataBufferPos > 0)
+ {
+ handler.charData(dataBuffer, 0, dataBufferPos);
+ dataBufferPos = 0;
+ }
+ }
+
+ /**
+ * Require a string to appear, or throw an exception.
+ * <p><em>Precondition:</em> Entity expansion is not required.
+ * <p><em>Precondition:</em> data buffer has no characters that
+ * will get sent to the application.
+ */
+ private void require(String delim)
+ throws SAXException, IOException
+ {
+ int length = delim.length();
+ char[] ch;
+
+ if (length < dataBuffer.length)
+ {
+ ch = dataBuffer;
+ delim.getChars(0, length, ch, 0);
+ }
+ else
+ {
+ ch = delim.toCharArray();
+ }
+
+ if (USE_CHEATS && length <= (readBufferLength - readBufferPos))
+ {
+ int offset = readBufferPos;
+
+ for (int i = 0; i < length; i++, offset++)
+ {
+ if (ch[i] != readBuffer[offset])
+ {
+ error ("required string", null, delim);
+ }
+ }
+ readBufferPos = offset;
+
+ }
+ else
+ {
+ for (int i = 0; i < length; i++)
+ {
+ require(ch[i]);
+ }
+ }
+ }
+
+ /**
+ * Require a character to appear, or throw an exception.
+ */
+ private void require(char delim)
+ throws SAXException, IOException
+ {
+ char c = readCh();
+
+ if (c != delim)
+ {
+ error("required character", c, new Character(delim).toString());
+ }
+ }
+
+ /**
+ * Create an interned string from a character array.
+ * Ælfred uses this method to create an interned version
+ * of all names and name tokens, so that it can test equality
+ * with <code>==</code> instead of <code>String.equals ()</code>.
+ *
+ * <p>This is much more efficient than constructing a non-interned
+ * string first, and then interning it.
+ *
+ * @param ch an array of characters for building the string.
+ * @param start the starting position in the array.
+ * @param length the number of characters to place in the string.
+ * @return an interned string.
+ * @see #intern (String)
+ * @see java.lang.String#intern
+ */
+ public String intern(char[] ch, int start, int length)
+ {
+ int index = 0;
+ int hash = 0;
+ Object[] bucket;
+
+ // Generate a hash code. This is a widely used string hash,
+ // often attributed to Brian Kernighan.
+ for (int i = start; i < start + length; i++)
+ {
+ hash = 31 * hash + ch[i];
+ }
+ hash = (hash & 0x7fffffff) % SYMBOL_TABLE_LENGTH;
+
+ // Get the bucket -- consists of {array,String} pairs
+ if ((bucket = symbolTable[hash]) == null)
+ {
+ // first string in this bucket
+ bucket = new Object[8];
+
+ // Search for a matching tuple, and
+ // return the string if we find one.
+ }
+ else
+ {
+ while (index < bucket.length)
+ {
+ char[] chFound = (char[]) bucket[index];
+
+ // Stop when we hit an empty entry.
+ if (chFound == null)
+ {
+ break;
+ }
+
+ // If they're the same length, check for a match.
+ if (chFound.length == length)
+ {
+ for (int i = 0; i < chFound.length; i++)
+ {
+ // continue search on failure
+ if (ch[start + i] != chFound[i])
+ {
+ break;
+ }
+ else if (i == length - 1)
+ {
+ // That's it, we have a match!
+ return (String) bucket[index + 1];
+ }
+ }
+ }
+ index += 2;
+ }
+ // Not found -- we'll have to add it.
+
+ // Do we have to grow the bucket?
+ bucket = (Object[]) extendArray(bucket, bucket.length, index);
+ }
+ symbolTable[hash] = bucket;
+
+ // OK, add it to the end of the bucket -- "local" interning.
+ // Intern "globally" to let applications share interning benefits.
+ // That is, "!=" and "==" work on our strings, not just equals().
+ String s = new String(ch, start, length).intern();
+ bucket[index] = s.toCharArray();
+ bucket[index + 1] = s;
+ return s;
+ }
+
+ /**
+ * Ensure the capacity of an array, allocating a new one if
+ * necessary. Usually extends only for name hash collisions.
+ */
+ private Object extendArray(Object array, int currentSize, int requiredSize)
+ {
+ if (requiredSize < currentSize)
+ {
+ return array;
+ }
+ else
+ {
+ Object newArray = null;
+ int newSize = currentSize * 2;
+
+ if (newSize <= requiredSize)
+ {
+ newSize = requiredSize + 1;
+ }
+
+ if (array instanceof char[])
+ {
+ newArray = new char[newSize];
+ }
+ else if (array instanceof Object[])
+ {
+ newArray = new Object[newSize];
+ }
+ else
+ {
+ throw new RuntimeException();
+ }
+
+ System.arraycopy(array, 0, newArray, 0, currentSize);
+ return newArray;
+ }
+ }
+
+ //////////////////////////////////////////////////////////////////////
+ // XML query routines.
+ //////////////////////////////////////////////////////////////////////
+
+ boolean isStandalone()
+ {
+ return docIsStandalone;
+ }
+
+ //
+ // Elements
+ //
+
+ private int getContentType(ElementDecl element, int defaultType)
+ {
+ int retval;
+
+ if (element == null)
+ {
+ return defaultType;
+ }
+ retval = element.contentType;
+ if (retval == CONTENT_UNDECLARED)
+ {
+ retval = defaultType;
+ }
+ return retval;
+ }
+
+ /**
+ * Look up the content type of an element.
+ * @param name The element type name.
+ * @return An integer constant representing the content type.
+ * @see #CONTENT_UNDECLARED
+ * @see #CONTENT_ANY
+ * @see #CONTENT_EMPTY
+ * @see #CONTENT_MIXED
+ * @see #CONTENT_ELEMENTS
+ */
+ public int getElementContentType(String name)
+ {
+ ElementDecl element = (ElementDecl) elementInfo.get(name);
+ return getContentType(element, CONTENT_UNDECLARED);
+ }
+
+ /**
+ * Register an element.
+ * Array format:
+ * [0] element type name
+ * [1] content model (mixed, elements only)
+ * [2] attribute hash table
+ */
+ private void setElement(String name, int contentType,
+ String contentModel, HashMap attributes)
+ throws SAXException
+ {
+ if (skippedPE)
+ {
+ return;
+ }
+
+ ElementDecl element = (ElementDecl) elementInfo.get(name);
+
+ // first <!ELEMENT ...> or <!ATTLIST ...> for this type?
+ if (element == null)
+ {
+ element = new ElementDecl();
+ element.contentType = contentType;
+ element.contentModel = contentModel;
+ element.attributes = attributes;
+ elementInfo.put(name, element);
+ return;
+ }
+
+ // <!ELEMENT ...> declaration?
+ if (contentType != CONTENT_UNDECLARED)
+ {
+ // ... following an associated <!ATTLIST ...>
+ if (element.contentType == CONTENT_UNDECLARED)
+ {
+ element.contentType = contentType;
+ element.contentModel = contentModel;
+ }
+ else
+ {
+ // VC: Unique Element Type Declaration
+ handler.verror("multiple declarations for element type: "
+ + name);
+ }
+ }
+
+ // first <!ATTLIST ...>, before <!ELEMENT ...> ?
+ else if (attributes != null)
+ {
+ element.attributes = attributes;
+ }
+ }
+
+ /**
+ * Look up the attribute hash table for an element.
+ * The hash table is the second item in the element array.
+ */
+ private HashMap getElementAttributes(String name)
+ {
+ ElementDecl element = (ElementDecl) elementInfo.get(name);
+ return (element == null) ? null : element.attributes;
+ }
+
+ //
+ // Attributes
+ //
+
+ /**
+ * Get the declared attributes for an element type.
+ * @param elname The name of the element type.
+ * @return An iterator over all the attributes declared for
+ * a specific element type. The results will be valid only
+ * after the DTD (if any) has been parsed.
+ * @see #getAttributeType
+ * @see #getAttributeEnumeration
+ * @see #getAttributeDefaultValueType
+ * @see #getAttributeDefaultValue
+ * @see #getAttributeExpandedValue
+ */
+ private Iterator declaredAttributes(ElementDecl element)
+ {
+ HashMap attlist;
+
+ if (element == null)
+ {
+ return null;
+ }
+ if ((attlist = element.attributes) == null)
+ {
+ return null;
+ }
+ return attlist.keySet().iterator();
+ }
+
+ /**
+ * Get the declared attributes for an element type.
+ * @param elname The name of the element type.
+ * @return An iterator over all the attributes declared for
+ * a specific element type. The results will be valid only
+ * after the DTD (if any) has been parsed.
+ * @see #getAttributeType
+ * @see #getAttributeEnumeration
+ * @see #getAttributeDefaultValueType
+ * @see #getAttributeDefaultValue
+ * @see #getAttributeExpandedValue
+ */
+ public Iterator declaredAttributes(String elname)
+ {
+ return declaredAttributes((ElementDecl) elementInfo.get(elname));
+ }
+
+ /**
+ * Retrieve the declared type of an attribute.
+ * @param name The name of the associated element.
+ * @param aname The name of the attribute.
+ * @return An interend string denoting the type, or null
+ * indicating an undeclared attribute.
+ */
+ public String getAttributeType(String name, String aname)
+ {
+ AttributeDecl attribute = getAttribute(name, aname);
+ return (attribute == null) ? null : attribute.type;
+ }
+
+ /**
+ * Retrieve the allowed values for an enumerated attribute type.
+ * @param name The name of the associated element.
+ * @param aname The name of the attribute.
+ * @return A string containing the token list.
+ */
+ public String getAttributeEnumeration(String name, String aname)
+ {
+ AttributeDecl attribute = getAttribute(name, aname);
+ // assert: attribute.enumeration is "ENUMERATION" or "NOTATION"
+ return (attribute == null) ? null : attribute.enumeration;
+ }
+
+ /**
+ * Retrieve the default value of a declared attribute.
+ * @param name The name of the associated element.
+ * @param aname The name of the attribute.
+ * @return The default value, or null if the attribute was
+ * #IMPLIED or simply undeclared and unspecified.
+ * @see #getAttributeExpandedValue
+ */
+ public String getAttributeDefaultValue(String name, String aname)
+ {
+ AttributeDecl attribute = getAttribute(name, aname);
+ return (attribute == null) ? null : attribute.value;
+ }
+
+ /*
+
+// FIXME: Leaving this in, until W3C finally resolves the confusion
+// between parts of the XML 2nd REC about when entity declararations
+// are guaranteed to be known. Current code matches what section 5.1
+// (conformance) describes, but some readings of the self-contradicting
+// text in 4.1 (the "Entity Declared" WFC and VC) seem to expect that
+// attribute expansion/normalization must be deferred in some cases
+// (just TRY to identify them!).
+
+ * Retrieve the expanded value of a declared attribute.
+ * <p>General entities (and char refs) will be expanded (once).
+ * @param name The name of the associated element.
+ * @param aname The name of the attribute.
+ * @return The expanded default value, or null if the attribute was
+ * #IMPLIED or simply undeclared
+ * @see #getAttributeDefaultValue
+ public String getAttributeExpandedValue (String name, String aname)
+ throws Exception
+ {
+ AttributeDecl attribute = getAttribute (name, aname);
+
+ if (attribute == null) {
+ return null;
+ } else if (attribute.defaultValue == null && attribute.value != null) {
+ // we MUST use the same buf for both quotes else the literal
+ // can't be properly terminated
+ char buf [] = new char [1];
+ int flags = LIT_ENTITY_REF | LIT_ATTRIBUTE;
+ String type = getAttributeType (name, aname);
+
+ if (type != "CDATA" && type != null)
+ flags |= LIT_NORMALIZE;
+ buf [0] = '"';
+ pushCharArray (null, buf, 0, 1);
+ pushString (null, attribute.value);
+ pushCharArray (null, buf, 0, 1);
+ attribute.defaultValue = readLiteral (flags);
+ }
+ return attribute.defaultValue;
+ }
+ */
+
+ /**
+ * Retrieve the default value mode of a declared attribute.
+ * @see #ATTRIBUTE_DEFAULT_SPECIFIED
+ * @see #ATTRIBUTE_DEFAULT_IMPLIED
+ * @see #ATTRIBUTE_DEFAULT_REQUIRED
+ * @see #ATTRIBUTE_DEFAULT_FIXED
+ */
+ public int getAttributeDefaultValueType(String name, String aname)
+ {
+ AttributeDecl attribute = getAttribute(name, aname);
+ return (attribute == null) ? ATTRIBUTE_DEFAULT_UNDECLARED :
+ attribute.valueType;
+ }
+
+ /**
+ * Register an attribute declaration for later retrieval.
+ * Format:
+ * - String type
+ * - String default value
+ * - int value type
+ * - enumeration
+ * - processed default value
+ */
+ private void setAttribute(String elName, String name, String type,
+ String enumeration, String value, int valueType)
+ throws Exception
+ {
+ HashMap attlist;
+
+ if (skippedPE)
+ {
+ return;
+ }
+
+ // Create a new hashtable if necessary.
+ attlist = getElementAttributes(elName);
+ if (attlist == null)
+ {
+ attlist = new HashMap();
+ }
+
+ // ignore multiple attribute declarations!
+ if (attlist.get(name) != null)
+ {
+ // warn ...
+ return;
+ }
+ else
+ {
+ AttributeDecl attribute = new AttributeDecl();
+ attribute.type = type;
+ attribute.value = value;
+ attribute.valueType = valueType;
+ attribute.enumeration = enumeration;
+ attlist.put(name, attribute);
+
+ // save; but don't overwrite any existing <!ELEMENT ...>
+ setElement(elName, CONTENT_UNDECLARED, null, attlist);
+ }
+ }
+
+ /**
+ * Retrieve the attribute declaration for the given element name and name.
+ */
+ private AttributeDecl getAttribute(String elName, String name)
+ {
+ HashMap attlist = getElementAttributes(elName);
+ return (attlist == null) ? null : (AttributeDecl) attlist.get(name);
+ }
+
+ //
+ // Entities
+ //
+
+ /**
+ * Find the type of an entity.
+ * @returns An integer constant representing the entity type.
+ * @see #ENTITY_UNDECLARED
+ * @see #ENTITY_INTERNAL
+ * @see #ENTITY_NDATA
+ * @see #ENTITY_TEXT
+ */
+ public int getEntityType(String ename)
+ {
+ EntityInfo entity = (EntityInfo) entityInfo.get(ename);
+ return (entity == null) ? ENTITY_UNDECLARED : entity.type;
+ }
+
+ /**
+ * Return an external entity's identifiers.
+ * @param ename The name of the external entity.
+ * @return The entity's public identifier, system identifier, and base URI.
+ * Null if the entity was not declared as an external entity.
+ * @see #getEntityType
+ */
+ public ExternalIdentifiers getEntityIds(String ename)
+ {
+ EntityInfo entity = (EntityInfo) entityInfo.get(ename);
+ return (entity == null) ? null : entity.ids;
+ }
+
+ /**
+ * Return an internal entity's replacement text.
+ * @param ename The name of the internal entity.
+ * @return The entity's replacement text, or null if
+ * the entity was not declared as an internal entity.
+ * @see #getEntityType
+ */
+ public String getEntityValue(String ename)
+ {
+ EntityInfo entity = (EntityInfo) entityInfo.get(ename);
+ return (entity == null) ? null : entity.value;
+ }
+
+ /**
+ * Register an entity declaration for later retrieval.
+ */
+ private void setInternalEntity(String eName, String value)
+ throws SAXException
+ {
+ if (skippedPE)
+ {
+ return;
+ }
+
+ if (entityInfo.get(eName) == null)
+ {
+ EntityInfo entity = new EntityInfo();
+ entity.type = ENTITY_INTERNAL;
+ entity.value = value;
+ entityInfo.put(eName, entity);
+ }
+ if (handler.stringInterning)
+ {
+ if ("lt" == eName || "gt" == eName || "quot" == eName
+ || "apos" == eName || "amp" == eName)
+ {
+ return;
+ }
+ }
+ else
+ {
+ if ("lt".equals(eName) || "gt".equals(eName) || "quot".equals(eName)
+ || "apos".equals(eName) || "amp".equals(eName))
+ {
+ return;
+ }
+ }
+ handler.getDeclHandler().internalEntityDecl(eName, value);
+ }
+
+ /**
+ * Register an external entity declaration for later retrieval.
+ */
+ private void setExternalEntity(String eName, int eClass,
+ ExternalIdentifiers ids, String nName)
+ {
+ if (entityInfo.get(eName) == null)
+ {
+ EntityInfo entity = new EntityInfo();
+ entity.type = eClass;
+ entity.ids = ids;
+ entity.notationName = nName;
+ entityInfo.put(eName, entity);
+ }
+ }
+
+ //
+ // Notations.
+ //
+
+ /**
+ * Report a notation declaration, checking for duplicates.
+ */
+ private void setNotation(String nname, ExternalIdentifiers ids)
+ throws SAXException
+ {
+ if (skippedPE)
+ {
+ return;
+ }
+
+ handler.notationDecl(nname, ids.publicId, ids.systemId, ids.baseUri);
+ if (notationInfo.get(nname) == null)
+ {
+ notationInfo.put(nname, nname);
+ }
+ else
+ {
+ // VC: Unique Notation Name
+ handler.verror("Duplicate notation name decl: " + nname);
+ }
+ }
+
+ //
+ // Location.
+ //
+
+ /**
+ * Return the current line number.
+ */
+ public int getLineNumber()
+ {
+ return line;
+ }
+
+ /**
+ * Return the current column number.
+ */
+ public int getColumnNumber()
+ {
+ return column;
+ }
+
+ //////////////////////////////////////////////////////////////////////
+ // High-level I/O.
+ //////////////////////////////////////////////////////////////////////
+
+ /**
+ * Read a single character from the readBuffer.
+ * <p>The readDataChunk () method maintains the buffer.
+ * <p>If we hit the end of an entity, try to pop the stack and
+ * keep going.
+ * <p> (This approach doesn't really enforce XML's rules about
+ * entity boundaries, but this is not currently a validating
+ * parser).
+ * <p>This routine also attempts to keep track of the current
+ * position in external entities, but it's not entirely accurate.
+ * @return The next available input character.
+ * @see #unread (char)
+ * @see #readDataChunk
+ * @see #readBuffer
+ * @see #line
+ * @return The next character from the current input source.
+ */
+ private char readCh()
+ throws SAXException, IOException
+ {
+ // As long as there's nothing in the
+ // read buffer, try reading more data
+ // (for an external entity) or popping
+ // the entity stack (for either).
+ while (readBufferPos >= readBufferLength)
+ {
+ switch (sourceType)
+ {
+ case INPUT_READER:
+ case INPUT_STREAM:
+ readDataChunk();
+ while (readBufferLength < 1)
+ {
+ popInput();
+ if (readBufferLength < 1)
+ {
+ readDataChunk();
+ }
+ }
+ break;
+
+ default:
+
+ popInput();
+ break;
+ }
+ }
+
+ char c = readBuffer[readBufferPos++];
+
+ if (c == '\n')
+ {
+ line++;
+ column = 0;
+ }
+ else
+ {
+ if (c == '<')
+ {
+ /* the most common return to parseContent () ... NOP */
+ }
+ else if (((c < 0x0020 && (c != '\t') && (c != '\r')) || c > 0xFFFD)
+ || ((c >= 0x007f) && (c <= 0x009f) && (c != 0x0085)
+ && xmlVersion == XML_11))
+ {
+ error("illegal XML character U+" + Integer.toHexString(c));
+ }
+
+ // If we're in the DTD and in a context where PEs get expanded,
+ // do so ... 1/14/2000 errata identify those contexts. There
+ // are also spots in the internal subset where PE refs are fatal
+ // errors, hence yet another flag.
+ else if (c == '%' && expandPE)
+ {
+ if (peIsError)
+ {
+ error("PE reference within decl in internal subset.");
+ }
+ parsePEReference();
+ return readCh();
+ }
+ column++;
+ }
+
+ return c;
+ }
+
+ /**
+ * Push a single character back onto the current input stream.
+ * <p>This method usually pushes the character back onto
+ * the readBuffer.
+ * <p>I don't think that this would ever be called with
+ * readBufferPos = 0, because the methods always reads a character
+ * before unreading it, but just in case, I've added a boundary
+ * condition.
+ * @param c The character to push back.
+ * @see #readCh
+ * @see #unread (char[])
+ * @see #readBuffer
+ */
+ private void unread(char c)
+ throws SAXException
+ {
+ // Normal condition.
+ if (c == '\n')
+ {
+ line--;
+ column = -1;
+ }
+ if (readBufferPos > 0)
+ {
+ readBuffer[--readBufferPos] = c;
+ }
+ else
+ {
+ pushString(null, new Character(c).toString());
+ }
+ }
+
+ /**
+ * Push a char array back onto the current input stream.
+ * <p>NOTE: you must <em>never</em> push back characters that you
+ * haven't actually read: use pushString () instead.
+ * @see #readCh
+ * @see #unread (char)
+ * @see #readBuffer
+ * @see #pushString
+ */
+ private void unread(char[] ch, int length)
+ throws SAXException
+ {
+ for (int i = 0; i < length; i++)
+ {
+ if (ch[i] == '\n')
+ {
+ line--;
+ column = -1;
+ }
+ }
+ if (length < readBufferPos)
+ {
+ readBufferPos -= length;
+ }
+ else
+ {
+ pushCharArray(null, ch, 0, length);
+ }
+ }
+
+ /**
+ * Push, or skip, a new external input source.
+ * The source will be some kind of parsed entity, such as a PE
+ * (including the external DTD subset) or content for the body.
+ *
+ * @param url The java.net.URL object for the entity.
+ * @see SAXDriver#resolveEntity
+ * @see #pushString
+ * @see #sourceType
+ * @see #pushInput
+ * @see #detectEncoding
+ * @see #sourceType
+ * @see #readBuffer
+ */
+ private void pushURL(boolean isPE,
+ String ename,
+ ExternalIdentifiers ids,
+ Reader reader,
+ InputStream stream,
+ String encoding,
+ boolean doResolve)
+ throws SAXException, IOException
+ {
+ boolean ignoreEncoding;
+ String systemId;
+ InputSource source;
+
+ if (!isPE)
+ {
+ dataBufferFlush();
+ }
+
+ scratch.setPublicId(ids.publicId);
+ scratch.setSystemId(ids.systemId);
+
+ // See if we should skip or substitute the entity.
+ // If we're not skipping, resolving reports startEntity()
+ // and updates the (handler's) stack of URIs.
+ if (doResolve)
+ {
+ // assert (stream == null && reader == null && encoding == null)
+ source = handler.resolveEntity(isPE, ename, scratch, ids.baseUri);
+ if (source == null)
+ {
+ handler.warn("skipping entity: " + ename);
+ handler.skippedEntity(ename);
+ if (isPE)
+ {
+ skippedPE = true;
+ }
+ return;
+ }
+
+ // we might be using alternate IDs/encoding
+ systemId = source.getSystemId();
+ // The following warning and setting systemId was deleted bcause
+ // the application has the option of not setting systemId
+ // provided that it has set the characte/byte stream.
+ /*
+ if (systemId == null) {
+ handler.warn ("missing system ID, using " + ids.systemId);
+ systemId = ids.systemId;
+ }
+ */
+ }
+ else
+ {
+ // "[document]", or "[dtd]" via getExternalSubset()
+ scratch.setCharacterStream(reader);
+ scratch.setByteStream(stream);
+ scratch.setEncoding(encoding);
+ source = scratch;
+ systemId = ids.systemId;
+ if (handler.stringInterning)
+ {
+ handler.startExternalEntity(ename, systemId,
+ "[document]" == ename);
+ }
+ else
+ {
+ handler.startExternalEntity(ename, systemId,
+ "[document]".equals(ename));
+ }
+ }
+
+ // we may have been given I/O streams directly
+ if (source.getCharacterStream() != null)
+ {
+ if (source.getByteStream() != null)
+ error("InputSource has two streams!");
+ reader = source.getCharacterStream();
+ }
+ else if (source.getByteStream() != null)
+ {
+ encoding = source.getEncoding();
+ if (encoding == null)
+ {
+ stream = source.getByteStream();
+ }
+ else
+ {
+ try
+ {
+ reader = new InputStreamReader(source.getByteStream(),
+ encoding);
+ }
+ catch (IOException e)
+ {
+ stream = source.getByteStream();
+ }
+ }
+ }
+ else if (systemId == null)
+ {
+ error("InputSource has no URI!");
+ }
+ scratch.setCharacterStream(null);
+ scratch.setByteStream(null);
+ scratch.setEncoding(null);
+
+ // Push the existing status.
+ pushInput(ename);
+
+ // Create a new read buffer.
+ // (Note the four-character margin)
+ readBuffer = new char[READ_BUFFER_MAX + 4];
+ readBufferPos = 0;
+ readBufferLength = 0;
+ readBufferOverflow = -1;
+ is = null;
+ line = 1;
+ column = 0;
+ currentByteCount = 0;
+
+ // If there's an explicit character stream, just
+ // ignore encoding declarations.
+ if (reader != null)
+ {
+ sourceType = INPUT_READER;
+ this.reader = reader;
+ tryEncodingDecl(true);
+ return;
+ }
+
+ // Else we handle the conversion, and need to ensure
+ // it's done right.
+ sourceType = INPUT_STREAM;
+ if (stream != null)
+ {
+ is = stream;
+ }
+ else
+ {
+ // We have to open our own stream to the URL.
+ URL url = new URL(systemId);
+
+ externalEntity = url.openConnection();
+ externalEntity.connect();
+ is = externalEntity.getInputStream();
+ }
+
+ // If we get to here, there must be
+ // an InputStream available.
+ if (!is.markSupported())
+ {
+ is = new BufferedInputStream(is);
+ }
+
+ // Get any external encoding label.
+ if (encoding == null && externalEntity != null)
+ {
+ // External labels can be untrustworthy; filesystems in
+ // particular often have the wrong default for content
+ // that wasn't locally originated. Those we autodetect.
+ if (!"file".equals(externalEntity.getURL().getProtocol()))
+ {
+ int temp;
+
+ // application/xml;charset=something;otherAttr=...
+ // ... with many variants on 'something'
+ encoding = externalEntity.getContentType();
+
+ // MHK code (fix for Saxon 5.5.1/007):
+ // protect against encoding==null
+ if (encoding == null)
+ {
+ temp = -1;
+ }
+ else
+ {
+ temp = encoding.indexOf("charset");
+ }
+
+ // RFC 2376 sez MIME text defaults to ASCII, but since the
+ // JDK will create a MIME type out of thin air, we always
+ // autodetect when there's no explicit charset attribute.
+ if (temp < 0)
+ {
+ encoding = null; // autodetect
+ }
+ else
+ {
+ // only this one attribute
+ if ((temp = encoding.indexOf(';')) > 0)
+ {
+ encoding = encoding.substring(0, temp);
+ }
+
+ if ((temp = encoding.indexOf('=', temp + 7)) > 0)
+ {
+ encoding = encoding.substring(temp + 1);
+
+ // attributes can have comment fields (RFC 822)
+ if ((temp = encoding.indexOf('(')) > 0)
+ {
+ encoding = encoding.substring(0, temp);
+ }
+ // ... and values may be quoted
+ if ((temp = encoding.indexOf('"')) > 0)
+ {
+ encoding =
+ encoding.substring(temp + 1,
+ encoding.indexOf('"', temp + 2));
+ }
+ encoding = encoding.trim();
+ }
+ else
+ {
+ handler.warn("ignoring illegal MIME attribute: "
+ + encoding);
+ encoding = null;
+ }
+ }
+ }
+ }
+
+ // if we got an external encoding label, use it ...
+ if (encoding != null)
+ {
+ this.encoding = ENCODING_EXTERNAL;
+ setupDecoding(encoding);
+ ignoreEncoding = true;
+
+ // ... else autodetect from first bytes.
+ }
+ else
+ {
+ detectEncoding();
+ ignoreEncoding = false;
+ }
+
+ // Read any XML or text declaration.
+ // If we autodetected, it may tell us the "real" encoding.
+ try
+ {
+ tryEncodingDecl(ignoreEncoding);
+ }
+ catch (UnsupportedEncodingException x)
+ {
+ encoding = x.getMessage();
+
+ // if we don't handle the declared encoding,
+ // try letting a JVM InputStreamReader do it
+ try
+ {
+ if (sourceType != INPUT_STREAM)
+ {
+ throw x;
+ }
+
+ is.reset();
+ readBufferPos = 0;
+ readBufferLength = 0;
+ readBufferOverflow = -1;
+ line = 1;
+ currentByteCount = column = 0;
+
+ sourceType = INPUT_READER;
+ this.reader = new InputStreamReader(is, encoding);
+ is = null;
+
+ tryEncodingDecl(true);
+
+ }
+ catch (IOException e)
+ {
+ error("unsupported text encoding",
+ encoding,
+ null);
+ }
+ }
+ }
+
+ /**
+ * Check for an encoding declaration. This is the second part of the
+ * XML encoding autodetection algorithm, relying on detectEncoding to
+ * get to the point that this part can read any encoding declaration
+ * in the document (using only US-ASCII characters).
+ *
+ * <p> Because this part starts to fill parser buffers with this data,
+ * it's tricky to setup a reader so that Java's built-in decoders can be
+ * used for the character encodings that aren't built in to this parser
+ * (such as EUC-JP, KOI8-R, Big5, etc).
+ *
+ * @return any encoding in the declaration, uppercased; or null
+ * @see detectEncoding
+ */
+ private String tryEncodingDecl(boolean ignoreEncoding)
+ throws SAXException, IOException
+ {
+ // Read the XML/text declaration.
+ if (tryRead("<?xml"))
+ {
+ if (tryWhitespace())
+ {
+ if (inputStack.size() > 0)
+ {
+ return parseTextDecl(ignoreEncoding);
+ }
+ else
+ {
+ return parseXMLDecl(ignoreEncoding);
+ }
+ }
+ else
+ {
+ // <?xml-stylesheet ...?> or similar
+ unread('l');
+ unread('m');
+ unread('x');
+ unread('?');
+ unread('<');
+ }
+ }
+ return null;
+ }
+
+ /**
+ * Attempt to detect the encoding of an entity.
+ * <p>The trick here (as suggested in the XML standard) is that
+ * any entity not in UTF-8, or in UCS-2 with a byte-order mark,
+ * <b>must</b> begin with an XML declaration or an encoding
+ * declaration; we simply have to look for "<?xml" in various
+ * encodings.
+ * <p>This method has no way to distinguish among 8-bit encodings.
+ * Instead, it sets up for UTF-8, then (possibly) revises its assumption
+ * later in setupDecoding (). Any ASCII-derived 8-bit encoding
+ * should work, but most will be rejected later by setupDecoding ().
+ * @see #tryEncoding (byte[], byte, byte, byte, byte)
+ * @see #tryEncoding (byte[], byte, byte)
+ * @see #setupDecoding
+ */
+ private void detectEncoding()
+ throws SAXException, IOException
+ {
+ byte[] signature = new byte[4];
+
+ // Read the first four bytes for
+ // autodetection.
+ is.mark(4);
+ is.read(signature);
+ is.reset();
+
+ //
+ // FIRST: four byte encodings (who uses these?)
+ //
+ if (tryEncoding(signature, (byte) 0x00, (byte) 0x00,
+ (byte) 0x00, (byte) 0x3c))
+ {
+ // UCS-4 must begin with "<?xml"
+ // 0x00 0x00 0x00 0x3c: UCS-4, big-endian (1234)
+ // "UTF-32BE"
+ encoding = ENCODING_UCS_4_1234;
+ }
+ else if (tryEncoding(signature, (byte) 0x3c, (byte) 0x00,
+ (byte) 0x00, (byte) 0x00))
+ {
+ // 0x3c 0x00 0x00 0x00: UCS-4, little-endian (4321)
+ // "UTF-32LE"
+ encoding = ENCODING_UCS_4_4321;
+ }
+ else if (tryEncoding(signature, (byte) 0x00, (byte) 0x00,
+ (byte) 0x3c, (byte) 0x00))
+ {
+ // 0x00 0x00 0x3c 0x00: UCS-4, unusual (2143)
+ encoding = ENCODING_UCS_4_2143;
+ }
+ else if (tryEncoding(signature, (byte) 0x00, (byte) 0x3c,
+ (byte) 0x00, (byte) 0x00))
+ {
+ // 0x00 0x3c 0x00 0x00: UCS-4, unusual (3421)
+ encoding = ENCODING_UCS_4_3412;
+
+ // 00 00 fe ff UCS_4_1234 (with BOM)
+ // ff fe 00 00 UCS_4_4321 (with BOM)
+ }
+
+ //
+ // SECOND: two byte encodings
+ // note ... with 1/14/2000 errata the XML spec identifies some
+ // more "broken UTF-16" autodetection cases, with no XML decl,
+ // which we don't handle here (that's legal too).
+ //
+ else if (tryEncoding(signature, (byte) 0xfe, (byte) 0xff))
+ {
+ // UCS-2 with a byte-order marker. (UTF-16)
+ // 0xfe 0xff: UCS-2, big-endian (12)
+ encoding = ENCODING_UCS_2_12;
+ is.read(); is.read();
+ }
+ else if (tryEncoding(signature, (byte) 0xff, (byte) 0xfe))
+ {
+ // UCS-2 with a byte-order marker. (UTF-16)
+ // 0xff 0xfe: UCS-2, little-endian (21)
+ encoding = ENCODING_UCS_2_21;
+ is.read(); is.read();
+ }
+ else if (tryEncoding(signature, (byte) 0x00, (byte) 0x3c,
+ (byte) 0x00, (byte) 0x3f))
+ {
+ // UTF-16BE (otherwise, malformed UTF-16)
+ // 0x00 0x3c 0x00 0x3f: UCS-2, big-endian, no byte-order mark
+ encoding = ENCODING_UCS_2_12;
+ error("no byte-order mark for UCS-2 entity");
+ }
+ else if (tryEncoding(signature, (byte) 0x3c, (byte) 0x00,
+ (byte) 0x3f, (byte) 0x00))
+ {
+ // UTF-16LE (otherwise, malformed UTF-16)
+ // 0x3c 0x00 0x3f 0x00: UCS-2, little-endian, no byte-order mark
+ encoding = ENCODING_UCS_2_21;
+ error("no byte-order mark for UCS-2 entity");
+ }
+
+ //
+ // THIRD: ASCII-derived encodings, fixed and variable lengths
+ //
+ else if (tryEncoding(signature, (byte) 0x3c, (byte) 0x3f,
+ (byte) 0x78, (byte) 0x6d))
+ {
+ // ASCII derived
+ // 0x3c 0x3f 0x78 0x6d: UTF-8 or other 8-bit markup (read ENCODING)
+ encoding = ENCODING_UTF_8;
+ prefetchASCIIEncodingDecl();
+ }
+ else if (signature[0] == (byte) 0xef
+ && signature[1] == (byte) 0xbb
+ && signature[2] == (byte) 0xbf)
+ {
+ // 0xef 0xbb 0xbf: UTF-8 BOM (not part of document text)
+ // this un-needed notion slipped into XML 2nd ed through a
+ // "non-normative" erratum; now required by MSFT and UDDI,
+ // and E22 made it normative.
+ encoding = ENCODING_UTF_8;
+ is.read(); is.read(); is.read();
+ }
+ else
+ {
+ // 4c 6f a7 94 ... we don't understand EBCDIC flavors
+ // ... but we COULD at least kick in some fixed code page
+
+ // (default) UTF-8 without encoding/XML declaration
+ encoding = ENCODING_UTF_8;
+ }
+ }
+
+ /**
+ * Check for a four-byte signature.
+ * <p>Utility routine for detectEncoding ().
+ * <p>Always looks for some part of "<?XML" in a specific encoding.
+ * @param sig The first four bytes read.
+ * @param b1 The first byte of the signature
+ * @param b2 The second byte of the signature
+ * @param b3 The third byte of the signature
+ * @param b4 The fourth byte of the signature
+ * @see #detectEncoding
+ */
+ private static boolean tryEncoding(byte[] sig, byte b1, byte b2,
+ byte b3, byte b4)
+ {
+ return (sig[0] == b1 && sig[1] == b2
+ && sig[2] == b3 && sig[3] == b4);
+ }
+
+ /**
+ * Check for a two-byte signature.
+ * <p>Looks for a UCS-2 byte-order mark.
+ * <p>Utility routine for detectEncoding ().
+ * @param sig The first four bytes read.
+ * @param b1 The first byte of the signature
+ * @param b2 The second byte of the signature
+ * @see #detectEncoding
+ */
+ private static boolean tryEncoding(byte[] sig, byte b1, byte b2)
+ {
+ return ((sig[0] == b1) && (sig[1] == b2));
+ }
+
+ /**
+ * This method pushes a string back onto input.
+ * <p>It is useful either as the expansion of an internal entity,
+ * or for backtracking during the parse.
+ * <p>Call pushCharArray () to do the actual work.
+ * @param s The string to push back onto input.
+ * @see #pushCharArray
+ */
+ private void pushString(String ename, String s)
+ throws SAXException
+ {
+ char[] ch = s.toCharArray();
+ pushCharArray(ename, ch, 0, ch.length);
+ }
+
+ /**
+ * Push a new internal input source.
+ * <p>This method is useful for expanding an internal entity,
+ * or for unreading a string of characters. It creates a new
+ * readBuffer containing the characters in the array, instead
+ * of characters converted from an input byte stream.
+ * @param ch The char array to push.
+ * @see #pushString
+ * @see #pushURL
+ * @see #readBuffer
+ * @see #sourceType
+ * @see #pushInput
+ */
+ private void pushCharArray(String ename, char[] ch, int start, int length)
+ throws SAXException
+ {
+ // Push the existing status
+ pushInput(ename);
+ if (ename != null && doReport)
+ {
+ dataBufferFlush();
+ handler.startInternalEntity(ename);
+ }
+ sourceType = INPUT_INTERNAL;
+ readBuffer = ch;
+ readBufferPos = start;
+ readBufferLength = length;
+ readBufferOverflow = -1;
+ }
+
+ /**
+ * Save the current input source onto the stack.
+ * <p>This method saves all of the global variables associated with
+ * the current input source, so that they can be restored when a new
+ * input source has finished. It also tests for entity recursion.
+ * <p>The method saves the following global variables onto a stack
+ * using a fixed-length array:
+ * <ol>
+ * <li>sourceType
+ * <li>externalEntity
+ * <li>readBuffer
+ * <li>readBufferPos
+ * <li>readBufferLength
+ * <li>line
+ * <li>encoding
+ * </ol>
+ * @param ename The name of the entity (if any) causing the new input.
+ * @see #popInput
+ * @see #sourceType
+ * @see #externalEntity
+ * @see #readBuffer
+ * @see #readBufferPos
+ * @see #readBufferLength
+ * @see #line
+ * @see #encoding
+ */
+ private void pushInput(String ename)
+ throws SAXException
+ {
+ // Check for entity recursion.
+ if (ename != null)
+ {
+ Iterator entities = entityStack.iterator();
+ while (entities.hasNext())
+ {
+ String e = (String) entities.next();
+ if (e != null && e == ename)
+ {
+ error("recursive reference to entity", ename, null);
+ }
+ }
+ }
+ entityStack.addLast(ename);
+
+ // Don't bother if there is no current input.
+ if (sourceType == INPUT_NONE)
+ {
+ return;
+ }
+
+ // Set up a snapshot of the current
+ // input source.
+ Input input = new Input();
+
+ input.sourceType = sourceType;
+ input.externalEntity = externalEntity;
+ input.readBuffer = readBuffer;
+ input.readBufferPos = readBufferPos;
+ input.readBufferLength = readBufferLength;
+ input.line = line;
+ input.encoding = encoding;
+ input.readBufferOverflow = readBufferOverflow;
+ input.is = is;
+ input.currentByteCount = currentByteCount;
+ input.column = column;
+ input.reader = reader;
+
+ // Push it onto the stack.
+ inputStack.addLast(input);
+ }
+
+ /**
+ * Restore a previous input source.
+ * <p>This method restores all of the global variables associated with
+ * the current input source.
+ * @exception java.io.EOFException
+ * If there are no more entries on the input stack.
+ * @see #pushInput
+ * @see #sourceType
+ * @see #externalEntity
+ * @see #readBuffer
+ * @see #readBufferPos
+ * @see #readBufferLength
+ * @see #line
+ * @see #encoding
+ */
+ private void popInput()
+ throws SAXException, IOException
+ {
+ String ename = (String) entityStack.removeLast();
+
+ if (ename != null && doReport)
+ {
+ dataBufferFlush();
+ }
+ switch (sourceType)
+ {
+ case INPUT_STREAM:
+ handler.endExternalEntity(ename);
+ is.close();
+ break;
+ case INPUT_READER:
+ handler.endExternalEntity(ename);
+ reader.close();
+ break;
+ case INPUT_INTERNAL:
+ if (ename != null && doReport)
+ {
+ handler.endInternalEntity(ename);
+ }
+ break;
+ }
+
+ // Throw an EOFException if there
+ // is nothing else to pop.
+ if (inputStack.isEmpty())
+ {
+ throw new EOFException("no more input");
+ }
+
+ Input input = (Input) inputStack.removeLast();
+
+ sourceType = input.sourceType;
+ externalEntity = input.externalEntity;
+ readBuffer = input.readBuffer;
+ readBufferPos = input.readBufferPos;
+ readBufferLength = input.readBufferLength;
+ line = input.line;
+ encoding = input.encoding;
+ readBufferOverflow = input.readBufferOverflow;
+ is = input.is;
+ currentByteCount = input.currentByteCount;
+ column = input.column;
+ reader = input.reader;
+ }
+
+ /**
+ * Return true if we can read the expected character.
+ * <p>Note that the character will be removed from the input stream
+ * on success, but will be put back on failure. Do not attempt to
+ * read the character again if the method succeeds.
+ * @param delim The character that should appear next. For a
+ * insensitive match, you must supply this in upper-case.
+ * @return true if the character was successfully read, or false if
+ * it was not.
+ * @see #tryRead (String)
+ */
+ private boolean tryRead(char delim)
+ throws SAXException, IOException
+ {
+ char c;
+
+ // Read the character
+ c = readCh();
+
+ // Test for a match, and push the character
+ // back if the match fails.
+ if (c == delim)
+ {
+ return true;
+ }
+ else
+ {
+ unread(c);
+ return false;
+ }
+ }
+
+ /**
+ * Return true if we can read the expected string.
+ * <p>This is simply a convenience method.
+ * <p>Note that the string will be removed from the input stream
+ * on success, but will be put back on failure. Do not attempt to
+ * read the string again if the method succeeds.
+ * <p>This method will push back a character rather than an
+ * array whenever possible (probably the majority of cases).
+ * @param delim The string that should appear next.
+ * @return true if the string was successfully read, or false if
+ * it was not.
+ * @see #tryRead (char)
+ */
+ private boolean tryRead(String delim)
+ throws SAXException, IOException
+ {
+ return tryRead(delim.toCharArray());
+ }
+
+ private boolean tryRead(char[] ch)
+ throws SAXException, IOException
+ {
+ char c;
+
+ // Compare the input, character-
+ // by character.
+
+ for (int i = 0; i < ch.length; i++)
+ {
+ c = readCh();
+ if (c != ch[i])
+ {
+ unread(c);
+ if (i != 0)
+ {
+ unread(ch, i);
+ }
+ return false;
+ }
+ }
+ return true;
+ }
+
+ /**
+ * Return true if we can read some whitespace.
+ * <p>This is simply a convenience method.
+ * <p>This method will push back a character rather than an
+ * array whenever possible (probably the majority of cases).
+ * @return true if whitespace was found.
+ */
+ private boolean tryWhitespace()
+ throws SAXException, IOException
+ {
+ char c;
+ c = readCh();
+ if (isWhitespace(c))
+ {
+ skipWhitespace();
+ return true;
+ }
+ else
+ {
+ unread(c);
+ return false;
+ }
+ }
+
+ /**
+ * Read all data until we find the specified string.
+ * This is useful for scanning CDATA sections and PIs.
+ * <p>This is inefficient right now, since it calls tryRead ()
+ * for every character.
+ * @param delim The string delimiter
+ * @see #tryRead (String, boolean)
+ * @see #readCh
+ */
+ private void parseUntil(String delim)
+ throws SAXException, IOException
+ {
+ parseUntil(delim.toCharArray());
+ }
+
+ private void parseUntil(char[] delim)
+ throws SAXException, IOException
+ {
+ char c;
+ int startLine = line;
+
+ try
+ {
+ while (!tryRead(delim))
+ {
+ c = readCh();
+ dataBufferAppend(c);
+ }
+ }
+ catch (EOFException e)
+ {
+ error("end of input while looking for delimiter "
+ + "(started on line " + startLine
+ + ')', null, new String(delim));
+ }
+ }
+
+ //////////////////////////////////////////////////////////////////////
+ // Low-level I/O.
+ //////////////////////////////////////////////////////////////////////
+
+ /**
+ * Prefetch US-ASCII XML/text decl from input stream into read buffer.
+ * Doesn't buffer more than absolutely needed, so that when an encoding
+ * decl says we need to create an InputStreamReader, we can discard our
+ * buffer and reset(). Caller knows the first chars of the decl exist
+ * in the input stream.
+ */
+ private void prefetchASCIIEncodingDecl()
+ throws SAXException, IOException
+ {
+ int ch;
+ readBufferPos = readBufferLength = 0;
+
+ is.mark(readBuffer.length);
+ while (true)
+ {
+ ch = is.read();
+ readBuffer[readBufferLength++] = (char) ch;
+ switch (ch)
+ {
+ case (int) '>':
+ return;
+ case -1:
+ error("file ends before end of XML or encoding declaration.",
+ null, "?>");
+ }
+ if (readBuffer.length == readBufferLength)
+ {
+ error("unfinished XML or encoding declaration");
+ }
+ }
+ }
+
+ /**
+ * Read a chunk of data from an external input source.
+ * <p>This is simply a front-end that fills the rawReadBuffer
+ * with bytes, then calls the appropriate encoding handler.
+ * @see #encoding
+ * @see #rawReadBuffer
+ * @see #readBuffer
+ * @see #filterCR
+ * @see #copyUtf8ReadBuffer
+ * @see #copyIso8859_1ReadBuffer
+ * @see #copyUcs_2ReadBuffer
+ * @see #copyUcs_4ReadBuffer
+ */
+ private void readDataChunk()
+ throws SAXException, IOException
+ {
+ int count;
+
+ // See if we have any overflow (filterCR sets for CR at end)
+ if (readBufferOverflow > -1)
+ {
+ readBuffer[0] = (char) readBufferOverflow;
+ readBufferOverflow = -1;
+ readBufferPos = 1;
+ sawCR = true;
+ }
+ else
+ {
+ readBufferPos = 0;
+ sawCR = false;
+ }
+
+ // input from a character stream.
+ if (sourceType == INPUT_READER)
+ {
+ count = reader.read(readBuffer,
+ readBufferPos, READ_BUFFER_MAX - readBufferPos);
+ if (count < 0)
+ {
+ readBufferLength = readBufferPos;
+ }
+ else
+ {
+ readBufferLength = readBufferPos + count;
+ }
+ if (readBufferLength > 0)
+ {
+ filterCR(count >= 0);
+ }
+ sawCR = false;
+ return;
+ }
+
+ // Read as many bytes as possible into the raw buffer.
+ count = is.read(rawReadBuffer, 0, READ_BUFFER_MAX);
+
+ // Dispatch to an encoding-specific reader method to populate
+ // the readBuffer. In most parser speed profiles, these routines
+ // show up at the top of the CPU usage chart.
+ if (count > 0)
+ {
+ switch (encoding)
+ {
+ // one byte builtins
+ case ENCODING_ASCII:
+ copyIso8859_1ReadBuffer(count, (char) 0x0080);
+ break;
+ case ENCODING_UTF_8:
+ copyUtf8ReadBuffer(count);
+ break;
+ case ENCODING_ISO_8859_1:
+ copyIso8859_1ReadBuffer(count, (char) 0);
+ break;
+
+ // two byte builtins
+ case ENCODING_UCS_2_12:
+ copyUcs2ReadBuffer(count, 8, 0);
+ break;
+ case ENCODING_UCS_2_21:
+ copyUcs2ReadBuffer(count, 0, 8);
+ break;
+
+ // four byte builtins
+ case ENCODING_UCS_4_1234:
+ copyUcs4ReadBuffer(count, 24, 16, 8, 0);
+ break;
+ case ENCODING_UCS_4_4321:
+ copyUcs4ReadBuffer(count, 0, 8, 16, 24);
+ break;
+ case ENCODING_UCS_4_2143:
+ copyUcs4ReadBuffer(count, 16, 24, 0, 8);
+ break;
+ case ENCODING_UCS_4_3412:
+ copyUcs4ReadBuffer(count, 8, 0, 24, 16);
+ break;
+ }
+ }
+ else
+ {
+ readBufferLength = readBufferPos;
+ }
+
+ readBufferPos = 0;
+
+ // Filter out all carriage returns if we've seen any
+ // (including any saved from a previous read)
+ if (sawCR)
+ {
+ filterCR(count >= 0);
+ sawCR = false;
+
+ // must actively report EOF, lest some CRs get lost.
+ if (readBufferLength == 0 && count >= 0)
+ {
+ readDataChunk();
+ }
+ }
+
+ if (count > 0)
+ {
+ currentByteCount += count;
+ }
+ }
+
+ /**
+ * Filter carriage returns in the read buffer.
+ * CRLF becomes LF; CR becomes LF.
+ * @param moreData true iff more data might come from the same source
+ * @see #readDataChunk
+ * @see #readBuffer
+ * @see #readBufferOverflow
+ */
+ private void filterCR(boolean moreData)
+ {
+ int i, j;
+
+ readBufferOverflow = -1;
+
+loop:
+ for (i = j = readBufferPos; j < readBufferLength; i++, j++)
+ {
+ switch (readBuffer[j])
+ {
+ case '\r':
+ if (j == readBufferLength - 1)
+ {
+ if (moreData)
+ {
+ readBufferOverflow = '\r';
+ readBufferLength--;
+ }
+ else // CR at end of buffer
+ {
+ readBuffer[i++] = '\n';
+ }
+ break loop;
+ }
+ else if (readBuffer[j + 1] == '\n')
+ {
+ j++;
+ }
+ readBuffer[i] = '\n';
+ break;
+
+ case '\n':
+ default:
+ readBuffer[i] = readBuffer[j];
+ break;
+ }
+ }
+ readBufferLength = i;
+ }
+
+ /**
+ * Convert a buffer of UTF-8-encoded bytes into UTF-16 characters.
+ * <p>When readDataChunk () calls this method, the raw bytes are in
+ * rawReadBuffer, and the final characters will appear in
+ * readBuffer.
+ * <p>Note that as of Unicode 3.1, good practice became a requirement,
+ * so that each Unicode character has exactly one UTF-8 representation.
+ * @param count The number of bytes to convert.
+ * @see #readDataChunk
+ * @see #rawReadBuffer
+ * @see #readBuffer
+ * @see #getNextUtf8Byte
+ */
+ private void copyUtf8ReadBuffer(int count)
+ throws SAXException, IOException
+ {
+ int i = 0;
+ int j = readBufferPos;
+ int b1;
+ char c = 0;
+
+ /*
+ // check once, so the runtime won't (if it's smart enough)
+ if (count < 0 || count > rawReadBuffer.length)
+ throw new ArrayIndexOutOfBoundsException (Integer.toString (count));
+ */
+
+ while (i < count)
+ {
+ b1 = rawReadBuffer[i++];
+
+ // Determine whether we are dealing
+ // with a one-, two-, three-, or four-
+ // byte sequence.
+ if (b1 < 0)
+ {
+ if ((b1 & 0xe0) == 0xc0)
+ {
+ // 2-byte sequence: 00000yyyyyxxxxxx = 110yyyyy 10xxxxxx
+ c = (char) (((b1 & 0x1f) << 6)
+ | getNextUtf8Byte(i++, count));
+ if (c < 0x0080)
+ {
+ encodingError("Illegal two byte UTF-8 sequence",
+ c, 0);
+ }
+
+ //Sec 2.11
+ // [1] the two-character sequence #xD #xA
+ // [2] the two-character sequence #xD #x85
+ if ((c == 0x0085 || c == 0x000a) && sawCR)
+ {
+ continue;
+ }
+
+ // Sec 2.11
+ // [3] the single character #x85
+
+ if (c == 0x0085 && xmlVersion == XML_11)
+ {
+ readBuffer[j++] = '\r';
+ }
+ }
+ else if ((b1 & 0xf0) == 0xe0)
+ {
+ // 3-byte sequence:
+ // zzzzyyyyyyxxxxxx = 1110zzzz 10yyyyyy 10xxxxxx
+ // most CJKV characters
+ c = (char) (((b1 & 0x0f) << 12) |
+ (getNextUtf8Byte(i++, count) << 6) |
+ getNextUtf8Byte(i++, count));
+ //sec 2.11
+ //[4] the single character #x2028
+ if (c == 0x2028 && xmlVersion == XML_11)
+ {
+ readBuffer[j++] = '\r';
+ sawCR = true;
+ continue;
+ }
+ if (c < 0x0800 || (c >= 0xd800 && c <= 0xdfff))
+ {
+ encodingError("Illegal three byte UTF-8 sequence",
+ c, 0);
+ }
+ }
+ else if ((b1 & 0xf8) == 0xf0)
+ {
+ // 4-byte sequence: 11101110wwwwzzzzyy + 110111yyyyxxxxxx
+ // = 11110uuu 10uuzzzz 10yyyyyy 10xxxxxx
+ // (uuuuu = wwww + 1)
+ // "Surrogate Pairs" ... from the "Astral Planes"
+ // Unicode 3.1 assigned the first characters there
+ int iso646 = b1 & 07;
+ iso646 = (iso646 << 6) + getNextUtf8Byte(i++, count);
+ iso646 = (iso646 << 6) + getNextUtf8Byte(i++, count);
+ iso646 = (iso646 << 6) + getNextUtf8Byte(i++, count);
+
+ if (iso646 <= 0xffff)
+ {
+ encodingError("Illegal four byte UTF-8 sequence",
+ iso646, 0);
+ }
+ else
+ {
+ if (iso646 > 0x0010ffff)
+ {
+ encodingError("UTF-8 value out of range for Unicode",
+ iso646, 0);
+ }
+ iso646 -= 0x010000;
+ readBuffer[j++] = (char) (0xd800 | (iso646 >> 10));
+ readBuffer[j++] = (char) (0xdc00 | (iso646 & 0x03ff));
+ continue;
+ }
+ }
+ else
+ {
+ // The five and six byte encodings aren't supported;
+ // they exceed the Unicode (and XML) range.
+ encodingError("unsupported five or six byte UTF-8 sequence",
+ 0xff & b1, i);
+ // NOTREACHED
+ c = 0;
+ }
+ }
+ else
+ {
+ // 1-byte sequence: 000000000xxxxxxx = 0xxxxxxx
+ // (US-ASCII character, "common" case, one branch to here)
+ c = (char) b1;
+ }
+ readBuffer[j++] = c;
+ if (c == '\r')
+ {
+ sawCR = true;
+ }
+ }
+ // How many characters have we read?
+ readBufferLength = j;
+ }
+
+ /**
+ * Return the next byte value in a UTF-8 sequence.
+ * If it is not possible to get a byte from the current
+ * entity, throw an exception.
+ * @param pos The current position in the rawReadBuffer.
+ * @param count The number of bytes in the rawReadBuffer
+ * @return The significant six bits of a non-initial byte in
+ * a UTF-8 sequence.
+ * @exception EOFException If the sequence is incomplete.
+ */
+ private int getNextUtf8Byte(int pos, int count)
+ throws SAXException, IOException
+ {
+ int val;
+
+ // Take a character from the buffer
+ // or from the actual input stream.
+ if (pos < count)
+ {
+ val = rawReadBuffer[pos];
+ }
+ else
+ {
+ val = is.read();
+ if (val == -1)
+ {
+ encodingError("unfinished multi-byte UTF-8 sequence at EOF",
+ -1, pos);
+ }
+ }
+
+ // Check for the correct bits at the start.
+ if ((val & 0xc0) != 0x80)
+ {
+ encodingError("bad continuation of multi-byte UTF-8 sequence",
+ val, pos + 1);
+ }
+
+ // Return the significant bits.
+ return (val & 0x3f);
+ }
+
+ /**
+ * Convert a buffer of US-ASCII or ISO-8859-1-encoded bytes into
+ * UTF-16 characters.
+ *
+ * <p>When readDataChunk () calls this method, the raw bytes are in
+ * rawReadBuffer, and the final characters will appear in
+ * readBuffer.
+ *
+ * @param count The number of bytes to convert.
+ * @param mask For ASCII conversion, 0x7f; else, 0xff.
+ * @see #readDataChunk
+ * @see #rawReadBuffer
+ * @see #readBuffer
+ */
+ private void copyIso8859_1ReadBuffer(int count, char mask)
+ throws IOException
+ {
+ int i, j;
+ for (i = 0, j = readBufferPos; i < count; i++, j++)
+ {
+ char c = (char) (rawReadBuffer[i] & 0xff);
+ if ((c & mask) != 0)
+ {
+ throw new CharConversionException("non-ASCII character U+"
+ + Integer.toHexString(c));
+ }
+ if (c == 0x0085 && xmlVersion == XML_11)
+ {
+ c = '\r';
+ }
+ readBuffer[j] = c;
+ if (c == '\r')
+ {
+ sawCR = true;
+ }
+ }
+ readBufferLength = j;
+ }
+
+ /**
+ * Convert a buffer of UCS-2-encoded bytes into UTF-16 characters
+ * (as used in Java string manipulation).
+ *
+ * <p>When readDataChunk () calls this method, the raw bytes are in
+ * rawReadBuffer, and the final characters will appear in
+ * readBuffer.
+ * @param count The number of bytes to convert.
+ * @param shift1 The number of bits to shift byte 1.
+ * @param shift2 The number of bits to shift byte 2
+ * @see #readDataChunk
+ * @see #rawReadBuffer
+ * @see #readBuffer
+ */
+ private void copyUcs2ReadBuffer(int count, int shift1, int shift2)
+ throws SAXException
+ {
+ int j = readBufferPos;
+
+ if (count > 0 && (count % 2) != 0)
+ {
+ encodingError("odd number of bytes in UCS-2 encoding", -1, count);
+ }
+ // The loops are faster with less internal brancing; hence two
+ if (shift1 == 0)
+ { // "UTF-16-LE"
+ for (int i = 0; i < count; i += 2)
+ {
+ char c = (char) (rawReadBuffer[i + 1] << 8);
+ c |= 0xff & rawReadBuffer[i];
+ readBuffer[j++] = c;
+ if (c == '\r')
+ {
+ sawCR = true;
+ }
+ }
+ }
+ else
+ { // "UTF-16-BE"
+ for (int i = 0; i < count; i += 2)
+ {
+ char c = (char) (rawReadBuffer[i] << 8);
+ c |= 0xff & rawReadBuffer[i + 1];
+ readBuffer[j++] = c;
+ if (c == '\r')
+ {
+ sawCR = true;
+ }
+ }
+ }
+ readBufferLength = j;
+ }
+
+ /**
+ * Convert a buffer of UCS-4-encoded bytes into UTF-16 characters.
+ *
+ * <p>When readDataChunk () calls this method, the raw bytes are in
+ * rawReadBuffer, and the final characters will appear in
+ * readBuffer.
+ * <p>Java has Unicode chars, and this routine uses surrogate pairs
+ * for ISO-10646 values between 0x00010000 and 0x000fffff. An
+ * exception is thrown if the ISO-10646 character has no Unicode
+ * representation.
+ *
+ * @param count The number of bytes to convert.
+ * @param shift1 The number of bits to shift byte 1.
+ * @param shift2 The number of bits to shift byte 2
+ * @param shift3 The number of bits to shift byte 2
+ * @param shift4 The number of bits to shift byte 2
+ * @see #readDataChunk
+ * @see #rawReadBuffer
+ * @see #readBuffer
+ */
+ private void copyUcs4ReadBuffer(int count, int shift1, int shift2,
+ int shift3, int shift4)
+ throws SAXException
+ {
+ int j = readBufferPos;
+
+ if (count > 0 && (count % 4) != 0)
+ {
+ encodingError("number of bytes in UCS-4 encoding " +
+ "not divisible by 4",
+ -1, count);
+ }
+ for (int i = 0; i < count; i += 4)
+ {
+ int value = (((rawReadBuffer [i] & 0xff) << shift1) |
+ ((rawReadBuffer [i + 1] & 0xff) << shift2) |
+ ((rawReadBuffer [i + 2] & 0xff) << shift3) |
+ ((rawReadBuffer [i + 3] & 0xff) << shift4));
+ if (value < 0x0000ffff)
+ {
+ readBuffer [j++] = (char) value;
+ if (value == (int) '\r')
+ {
+ sawCR = true;
+ }
+ }
+ else if (value < 0x0010ffff)
+ {
+ value -= 0x010000;
+ readBuffer[j++] = (char) (0xd8 | ((value >> 10) & 0x03ff));
+ readBuffer[j++] = (char) (0xdc | (value & 0x03ff));
+ }
+ else
+ {
+ encodingError("UCS-4 value out of range for Unicode",
+ value, i);
+ }
+ }
+ readBufferLength = j;
+ }
+
+ /**
+ * Report a character encoding error.
+ */
+ private void encodingError(String message, int value, int offset)
+ throws SAXException
+ {
+ if (value != -1)
+ {
+ message = message + " (character code: 0x" +
+ Integer.toHexString(value) + ')';
+ error(message);
+ }
+ }
+
+ //////////////////////////////////////////////////////////////////////
+ // Local Variables.
+ //////////////////////////////////////////////////////////////////////
+
+ /**
+ * Re-initialize the variables for each parse.
+ */
+ private void initializeVariables()
+ {
+ // First line
+ line = 1;
+ column = 0;
+
+ // Set up the buffers for data and names
+ dataBufferPos = 0;
+ dataBuffer = new char[DATA_BUFFER_INITIAL];
+ nameBufferPos = 0;
+ nameBuffer = new char[NAME_BUFFER_INITIAL];
+
+ // Set up the DTD hash tables
+ elementInfo = new HashMap();
+ entityInfo = new HashMap();
+ notationInfo = new HashMap();
+ skippedPE = false;
+
+ // Set up the variables for the current
+ // element context.
+ currentElement = null;
+ currentElementContent = CONTENT_UNDECLARED;
+
+ // Set up the input variables
+ sourceType = INPUT_NONE;
+ inputStack = new LinkedList();
+ entityStack = new LinkedList();
+ externalEntity = null;
+ tagAttributePos = 0;
+ tagAttributes = new String[100];
+ rawReadBuffer = new byte[READ_BUFFER_MAX];
+ readBufferOverflow = -1;
+
+ scratch = new InputSource();
+
+ inLiteral = false;
+ expandPE = false;
+ peIsError = false;
+
+ doReport = false;
+
+ inCDATA = false;
+
+ symbolTable = new Object[SYMBOL_TABLE_LENGTH][];
+ }
+
+ static class ExternalIdentifiers
+ {
+
+ String publicId;
+ String systemId;
+ String baseUri;
+
+ ExternalIdentifiers()
+ {
+ }
+
+ ExternalIdentifiers(String publicId, String systemId, String baseUri)
+ {
+ this.publicId = publicId;
+ this.systemId = systemId;
+ this.baseUri = baseUri;
+ }
+
+ }
+
+ static class EntityInfo
+ {
+
+ int type;
+ ExternalIdentifiers ids;
+ String value;
+ String notationName;
+
+ }
+
+ static class AttributeDecl
+ {
+
+ String type;
+ String value;
+ int valueType;
+ String enumeration;
+ String defaultValue;
+
+ }
+
+ static class ElementDecl
+ {
+
+ int contentType;
+ String contentModel;
+ HashMap attributes;
+
+ }
+
+ static class Input
+ {
+
+ int sourceType;
+ URLConnection externalEntity;
+ char[] readBuffer;
+ int readBufferPos;
+ int readBufferLength;
+ int line;
+ int encoding;
+ int readBufferOverflow;
+ InputStream is;
+ int currentByteCount;
+ int column;
+ Reader reader;
+
+ }
+
+}
+
Added: llvm-gcc-4.2/trunk/libjava/classpath/gnu/xml/aelfred2/XmlReader.java
URL: http://llvm.org/viewvc/llvm-project/llvm-gcc-4.2/trunk/libjava/classpath/gnu/xml/aelfred2/XmlReader.java?rev=43913&view=auto
==============================================================================
--- llvm-gcc-4.2/trunk/libjava/classpath/gnu/xml/aelfred2/XmlReader.java (added)
+++ llvm-gcc-4.2/trunk/libjava/classpath/gnu/xml/aelfred2/XmlReader.java Thu Nov 8 16:56:19 2007
@@ -0,0 +1,374 @@
+/* XmlReader.java --
+ Copyright (C) 1999,2000,2001 Free Software Foundation, Inc.
+
+This file is part of GNU Classpath.
+
+GNU Classpath is free software; you can redistribute it and/or modify
+it under the terms of the GNU General Public License as published by
+the Free Software Foundation; either version 2, or (at your option)
+any later version.
+
+GNU Classpath is distributed in the hope that it will be useful, but
+WITHOUT ANY WARRANTY; without even the implied warranty of
+MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+General Public License for more details.
+
+You should have received a copy of the GNU General Public License
+along with GNU Classpath; see the file COPYING. If not, write to the
+Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA
+02110-1301 USA.
+
+Linking this library statically or dynamically with other modules is
+making a combined work based on this library. Thus, the terms and
+conditions of the GNU General Public License cover the whole
+combination.
+
+As a special exception, the copyright holders of this library give you
+permission to link this library with independent modules to produce an
+executable, regardless of the license terms of these independent
+modules, and to copy and distribute the resulting executable under
+terms of your choice, provided that you also meet, for each linked
+independent module, the terms and conditions of the license of that
+module. An independent module is a module which is not derived from
+or based on this library. If you modify this library, you may extend
+this exception to your version of the library, but you are not
+obligated to do so. If you do not wish to do so, delete this
+exception statement from your version. */
+
+package gnu.xml.aelfred2;
+
+import java.io.IOException;
+import java.util.Locale;
+
+import org.xml.sax.*;
+import org.xml.sax.ext.*;
+
+import gnu.xml.pipeline.EventFilter;
+import gnu.xml.pipeline.ValidationConsumer;
+
+
+/**
+ * This SAX2 parser optionally layers a validator over the Ælfred2
+ * SAX2 parser. While this will not evaluate every XML validity constraint,
+ * it does support all the validity constraints that are of any real utility
+ * outside the strict SGML-compatible world. See the documentation for the
+ * SAXDriver class for information about the SAX2 features and properties
+ * that are supported, and documentation for the ValidationConsumer for
+ * information about what validity constraints may not be supported.
+ * (Ælfred2 tests some of those, even in non-validating mode, to
+ * achieve better conformance.)
+ *
+ * <p> Note that due to its internal construction, you can't change most
+ * handlers until parse() returns. This diverges slightly from SAX, which
+ * expects later binding to be supported. Early binding involves less
+ * runtime overhead, which is an issue for event pipelines as used inside
+ * this parser. Rather than relying on the parser to handle late binding
+ * to your own handlers, do it yourself.
+ *
+ * @see SAXDriver
+ * @see gnu.xml.pipeline.ValidationConsumer
+ *
+ * @author David Brownell
+ */
+public final class XmlReader
+ implements XMLReader
+{
+
+ static class FatalErrorHandler
+ extends DefaultHandler2
+ {
+
+ public void error(SAXParseException e)
+ throws SAXException
+ {
+ throw e;
+ }
+
+ }
+
+ private SAXDriver aelfred2 = new SAXDriver();
+ private EventFilter filter = new EventFilter();
+ private boolean isValidating;
+ private boolean active;
+
+ /**
+ * Constructs a SAX Parser.
+ */
+ public XmlReader()
+ {
+ }
+
+ /**
+ * Constructs a SAX Parser, optionally treating validity errors
+ * as if they were fatal errors.
+ */
+ public XmlReader(boolean invalidIsFatal)
+ {
+ if (invalidIsFatal)
+ {
+ setErrorHandler(new FatalErrorHandler());
+ }
+ }
+
+ /**
+ * <b>SAX2</b>: Returns the object used to report the logical
+ * content of an XML document.
+ */
+ public ContentHandler getContentHandler()
+ {
+ return filter.getContentHandler();
+ }
+
+ /**
+ * <b>SAX2</b>: Assigns the object used to report the logical
+ * content of an XML document.
+ * @exception IllegalStateException if called mid-parse
+ */
+ public void setContentHandler(ContentHandler handler)
+ {
+ if (active)
+ {
+ throw new IllegalStateException("already parsing");
+ }
+ filter.setContentHandler(handler);
+ }
+
+ /**
+ * <b>SAX2</b>: Returns the object used to process declarations related
+ * to notations and unparsed entities.
+ */
+ public DTDHandler getDTDHandler()
+ {
+ return filter.getDTDHandler();
+ }
+
+ /**
+ * <b>SAX1</b> Assigns DTD handler
+ * @exception IllegalStateException if called mid-parse
+ */
+ public void setDTDHandler(DTDHandler handler)
+ {
+ if (active)
+ {
+ throw new IllegalStateException("already parsing");
+ }
+ filter.setDTDHandler(handler);
+ }
+
+ /**
+ * <b>SAX2</b>: Returns the object used when resolving external
+ * entities during parsing (both general and parameter entities).
+ */
+ public EntityResolver getEntityResolver()
+ {
+ return aelfred2.getEntityResolver();
+ }
+
+ /**
+ * <b>SAX1</b> Assigns parser's entity resolver
+ */
+ public void setEntityResolver(EntityResolver handler)
+ {
+ aelfred2.setEntityResolver(handler);
+ }
+
+ /**
+ * <b>SAX2</b>: Returns the object used to receive callbacks for XML
+ * errors of all levels (fatal, nonfatal, warning); this is never null;
+ */
+ public ErrorHandler getErrorHandler()
+ {
+ return aelfred2.getErrorHandler();
+ }
+
+ /**
+ * <b>SAX1</b> Assigns error handler
+ * @exception IllegalStateException if called mid-parse
+ */
+ public void setErrorHandler(ErrorHandler handler)
+ {
+ if (active)
+ {
+ throw new IllegalStateException("already parsing");
+ }
+ aelfred2.setErrorHandler(handler);
+ }
+
+ /**
+ * <b>SAX2</b>: Assigns the specified property.
+ * @exception IllegalStateException if called mid-parse
+ */
+ public void setProperty(String propertyId, Object value)
+ throws SAXNotRecognizedException, SAXNotSupportedException
+ {
+ if (active)
+ {
+ throw new IllegalStateException("already parsing");
+ }
+ if (getProperty(propertyId) != value)
+ {
+ filter.setProperty(propertyId, value);
+ }
+ }
+
+ /**
+ * <b>SAX2</b>: Returns the specified property.
+ */
+ public Object getProperty(String propertyId)
+ throws SAXNotRecognizedException
+ {
+ if ((SAXDriver.PROPERTY + "declaration-handler").equals(propertyId)
+ || (SAXDriver.PROPERTY + "lexical-handler").equals(propertyId))
+ {
+ return filter.getProperty(propertyId);
+ }
+ throw new SAXNotRecognizedException(propertyId);
+ }
+
+ private void forceValidating()
+ throws SAXNotRecognizedException, SAXNotSupportedException
+ {
+ aelfred2.setFeature(SAXDriver.FEATURE + "namespace-prefixes",
+ true);
+ aelfred2.setFeature(SAXDriver.FEATURE + "external-general-entities",
+ true);
+ aelfred2.setFeature(SAXDriver.FEATURE + "external-parameter-entities",
+ true);
+ }
+
+ /**
+ * <b>SAX2</b>: Sets the state of features supported in this parser.
+ * Note that this parser requires reporting of namespace prefixes when
+ * validating.
+ */
+ public void setFeature(String featureId, boolean state)
+ throws SAXNotRecognizedException, SAXNotSupportedException
+ {
+ boolean value = getFeature(featureId);
+
+ if (state == value)
+ {
+ return;
+ }
+
+ if ((SAXDriver.FEATURE + "validation").equals(featureId))
+ {
+ if (active)
+ {
+ throw new SAXNotSupportedException("already parsing");
+ }
+ if (state)
+ {
+ forceValidating();
+ }
+ isValidating = state;
+ }
+ else
+ {
+ aelfred2.setFeature(featureId, state);
+ }
+ }
+
+ /**
+ * <b>SAX2</b>: Tells whether this parser supports the specified feature.
+ * At this time, this directly parallels the underlying SAXDriver,
+ * except that validation is optionally supported.
+ *
+ * @see SAXDriver
+ */
+ public boolean getFeature(String featureId)
+ throws SAXNotRecognizedException, SAXNotSupportedException
+ {
+ if ((SAXDriver.FEATURE + "validation").equals(featureId))
+ {
+ return isValidating;
+ }
+
+ return aelfred2.getFeature(featureId);
+ }
+
+ /**
+ * <b>SAX1</b>: Sets the locale used for diagnostics; currently,
+ * only locales using the English language are supported.
+ * @param locale The locale for which diagnostics will be generated
+ */
+ public void setLocale(Locale locale)
+ throws SAXException
+ {
+ aelfred2.setLocale(locale);
+ }
+
+ /**
+ * <b>SAX1</b>: Preferred API to parse an XML document, using a
+ * system identifier (URI).
+ */
+ public void parse(String systemId)
+ throws SAXException, IOException
+ {
+ parse(new InputSource(systemId));
+ }
+
+ /**
+ * <b>SAX1</b>: Underlying API to parse an XML document, used
+ * directly when no URI is available. When this is invoked,
+ * and the parser is set to validate, some features will be
+ * automatically reset to appropriate values: for reporting
+ * namespace prefixes, and incorporating external entities.
+ *
+ * @param source The XML input source.
+ *
+ * @exception IllegalStateException if called mid-parse
+ * @exception SAXException The handlers may throw any SAXException,
+ * and the parser normally throws SAXParseException objects.
+ * @exception IOException IOExceptions are normally through through
+ * the parser if there are problems reading the source document.
+ */
+ public void parse(InputSource source)
+ throws SAXException, IOException
+ {
+ EventFilter next;
+ boolean nsdecls;
+
+ synchronized (aelfred2)
+ {
+ if (active)
+ {
+ throw new IllegalStateException("already parsing");
+ }
+ active = true;
+ }
+
+ // set up the output pipeline
+ if (isValidating)
+ {
+ forceValidating();
+ next = new ValidationConsumer(filter);
+ }
+ else
+ {
+ next = filter;
+ }
+
+ // connect pipeline and error handler
+ // don't let _this_ call to bind() affect xmlns* attributes
+ nsdecls = aelfred2.getFeature(SAXDriver.FEATURE + "namespace-prefixes");
+ EventFilter.bind(aelfred2, next);
+ if (!nsdecls)
+ {
+ aelfred2.setFeature(SAXDriver.FEATURE + "namespace-prefixes",
+ false);
+ }
+
+ // parse, clean up
+ try
+ {
+ aelfred2.parse(source);
+ }
+ finally
+ {
+ active = false;
+ }
+ }
+
+}
+
Added: llvm-gcc-4.2/trunk/libjava/classpath/gnu/xml/aelfred2/package.html
URL: http://llvm.org/viewvc/llvm-project/llvm-gcc-4.2/trunk/libjava/classpath/gnu/xml/aelfred2/package.html?rev=43913&view=auto
==============================================================================
--- llvm-gcc-4.2/trunk/libjava/classpath/gnu/xml/aelfred2/package.html (added)
+++ llvm-gcc-4.2/trunk/libjava/classpath/gnu/xml/aelfred2/package.html Thu Nov 8 16:56:19 2007
@@ -0,0 +1,506 @@
+<!DOCTYPE html PUBLIC
+ '-//W3C//DTD XHTML 1.0 Transitional//EN'
+ 'http://www.w3.org/TR/xhtml1/DTD/transitional.dtd'>
+
+<html><head>
+ <title>package overview</title>
+<!--
+/*
+ * Copyright (C) 1999,2000,2001 The Free Software Foundation, Inc.
+ */
+-->
+</head><body>
+
+<p> This package contains Ælfred2, which includes an
+enhanced SAX2-compatible version of the Ælfred
+non-validating XML parser, a modular (and hence optional)
+DTD validating parser, and modular (and hence optional)
+JAXP glue to those.
+Use these like any other SAX2 parsers. </p>
+
+<ul>
+ <li><a href="#about">About Ælfred</a><ul>
+ <li><a href="#principles">Design Principles</a></li>
+ <li><a href="#name">About the Name Ælfred</a></li>
+ <li><a href="#encodings">Character Encodings</a></li>
+ <li><a href="#violations">Known Conformance Violations</a></li>
+ <li><a href="#copyright">Licensing</a></li>
+ </ul></li>
+
+ <li><a href="#changes">Changes Since the Last Microstar Release</a><ul>
+ <li><a href="#sax2">SAX2 Support</a></li>
+ <li><a href="#validation">Validation</a></li>
+ <li><a href="#smaller">You Want Smaller?</a></li>
+ <li><a href="#bugfixes">Bugs Fixed</a></li>
+ </ul></li>
+
+</ul>
+
+<h2><a name="about">About Ælfred</a></h2>
+
+<p>Ælfred is a XML parser written in the java programming language.
+
+<h3><a name="principles">Design Principles</a></h3>
+
+<p>In most Java applets and applications, XML should not be the central
+feature; instead, XML is the means to another end, such as loading
+configuration information, reading meta-data, or parsing transactions.</p>
+
+<p> When an XML parser is only a single component of a much larger
+program, it cannot be large, slow, or resource-intensive. With Java
+applets, in particular, code size is a significant issue. The standard
+modem is still not operating at 56 Kbaud, or sometimes even with data
+compression. Assuming an uncompressed 28.8 Kbaud modem, only about
+3 KBytes can be downloaded in one second; compression often doubles
+that speed, but a V.90 modem may not provide another doubling. When
+used with embedded processors, similar size concerns apply. </p>
+
+<p> Ælfred is designed for easy and efficient use over the Internet,
+based on the following principles: </p> <ol>
+
+<li> Ælfred must be as small as possible, so that it doesn't add too
+ much to an applet's download time. </li>
+
+<li> Ælfred must use as few class files as possible, to minimize the
+ number of HTTP connections necessary. (The use of JAR files has made this
+ be less of a concern.) </li>
+
+<li> Ælfred must be compatible with most or all Java implementations
+ and platforms. (Write once, run anywhere.) </li>
+
+<li> Ælfred must use as little memory as possible, so that it does
+ not take away resources from the rest of your program. (It doesn't force
+ you to use DOM or a similar costly data structure API.)</li>
+
+<li> Ælfred must run as fast as possible, so that it does not slow down
+ the rest of your program. </li>
+
+<li> Ælfred must produce correct output for well-formed and valid
+ documents, but need not reject every document that is not valid or
+ not well-formed. (In Ælfred2, correctness was a bigger concern
+ than in the original version; and a validation option is available.) </li>
+
+<li> Ælfred must provide full internationalization from the first
+ release. (Ælfred2 now automatically handles all encodings
+ supported by the underlying JVM; previous versions handled only
+ UTF-8, UTF_16, ASCII, and ISO-8859-1.)</li>
+
+</ol>
+
+<p>As you can see from this list, Ælfred is designed for production
+use, but neither validation nor perfect conformance was a requirement.
+Good validating parsers exist, including one in this package,
+and you should use them as appropriate. (See conformance reviews
+available at <a href="http://www.xml.com/">http://www.xml.com</a>)
+</p>
+
+<p> One of the main goals of Ælfred2 was to significantly improve
+conformance, while not significantly affecting the other goals stated above.
+Since the only use of this parser is with SAX, some classes could be
+removed, and so the overall size of Ælfred was actually reduced.
+Subsequent performance work produced a notable speedup (over twenty
+percent on larger files). That is, the tradeoffs between speed, size, and
+conformance were re-targeted towards conformance and support of newer APIs
+(SAX2), with a a positive performance impact. </p>
+
+<p> The role anticipated for this version of Ælfred is as a
+lightweight Free Software SAX parser that can be used in essentially every
+Java program where the handful of conformance violations (noted below)
+are acceptable.
+That certainly includes applets, and
+nowadays one must also mention embedded systems as being even more
+size-critical.
+At this writing, all parsers that are more conformant are
+significantly larger, even when counting the optional
+validation support in this version of Ælfred. </p>
+
+
+<h3><a name="name">About the Name <em>Ælfred</em></a></h3>
+
+<p>Ælfred the Great (AElfred in ASCII) was King of Wessex, and
+some say of King of England, at the time of his death in 899 AD.
+Ælfred introduced a wide-spread literacy program in the hope that
+his people would learn to read English, at least, if Latin was too
+difficult for them. This Ælfred hopes to bring another sort of
+literacy to Java, using XML, at least, if full SGML is too difficult.</p>
+
+<p>The initial Æ ligature ("AE)" is also a reminder that XML is
+not limited to ASCII.</p>
+
+
+<h3><a name="encodings">Character Encodings</a></h3>
+
+<p> The Ælfred parser currently builds in support for a handful
+of input encodings. Of course these include UTF-8 and UTF-16, which
+all XML parsers are required to support:</p> <ul>
+
+ <li> UTF-8 ... the standard eight bit encoding, used unless
+ you provide an encoding declaration or a MIME charset tag.</li>
+
+ <li> US-ASCII ... an extremely common seven bit encoding,
+ which happens to be a subset of UTF-8 and ISO-8859-1 as well
+ as many other encodings. XHTML web pages using US-ASCII
+ (without an encoding declaration) are probably more
+ widely interoperable than those in any other encoding. </li>
+
+ <li> ISO-8859-1 ... includes accented characters used in
+ much of western Europe (but excluding the Euro currency
+ symbol).</li>
+
+ <li> UTF-16 ... with several variants, this encodes each
+ sixteen bit Unicode character in sixteen bits of output.
+ Variants include UTF-16BE (big endian, no byte order mark),
+ UTF-16LE (little endian, no byte order mark), and
+ ISO-10646-UCS-2 (an older and less used encoding, using a
+ version of Unicode without surrogate pairs). This is
+ essentially the native encoding used by Java. </li>
+
+ <li> ISO-10646-UCS-4 ... a seldom-used four byte encoding,
+ also known as UTF-32BE. Four byte order variants are supported,
+ including one known as UTF-32LE. Some operating systems
+ standardized on UCS-4 despite its significant size penalty,
+ in anticipation that Unicode (even with surrogate pairs)
+ would eventually become limiting. UCS-4 permits encoding
+ of non-Unicode characters, which Java can't represent (and
+ XML doesn't allow).
+ </li>
+
+ </ul>
+
+<p> If you use any encoding other than UTF-8 or UTF-16 you should
+make sure to label your data appropriately: </p>
+
+<blockquote>
+<?xml version="1.0" encoding="<b>ISO-8859-15</b>"?>
+</blockquote>
+
+<p> Encodings accessed through <code>java.io.InputStreamReader</code>
+are now fully supported for both external labels (such as MIME types)
+and internal types (as shown above).
+There is one limitation in the support for internal labels:
+the encodings must be derived from the US-ASCII encoding,
+the EBCDIC family of encodings is not recognized.
+Note that Java defines its
+own encoding names, which don't always correspond to the standard
+Internet encoding names defined by the IETF/IANA, and that Java
+may even <em>require</em> use of nonstandard encoding names.
+Please report
+such problems; some of them can be worked around in this parser,
+and many can be worked around by using external labels.
+</p>
+
+<p>Note that if you are using the Euro symbol with an fixed length
+eight bit encoding, you should probably be using the encoding label
+<em>iso-8859-15</em> or, with a Microsoft OS, <em>cp-1252</em>.
+Of course, UTF-8 and UTF-16 handle the Euro symbol directly.
+</p>
+
+
+<h3><a name="violations">Known Conformance Violations</a></h3>
+
+<p>Known conformance issues should be of negligible importance for
+most applications, and include: </p><ul>
+
+ <li> Rather than following the voluminous "Appendix B" rules about
+ what characters may appear in names (and name tokens), the Unicode
+ rules embedded in <em>java.lang.Character</em> are used.
+ This means mostly that some names are inappropriately accepted,
+ though a few are inappropriately rejected. (It's much simpler
+ to avoid that much special case code. Recent OASIS/NIST test
+ cases may have these rules be realistically testable.) </li>
+
+ <li> Text containing "]]>" is not rejected unless it fully resides
+ in an internal buffer ... which is, thankfully, the typical case. This
+ text is illegal, but sometimes appears in illegal attempts to
+ nest CDATA sections. (Not catching that boundary condition
+ substantially simplifies parsing text.) </li>
+
+ <li> Surrogate characters that aren't correctly paired are ignored
+ rather than rejected, unless they were encoded using UTF-8. (This
+ simplifies parsing text.) Unicode 3.1 assigned the first characters
+ to those character codes, in early 2001, so few documents (or tools)
+ use such characters in any case. </li>
+
+ <li> Declarations following references to an undefined parameter
+ entity reference are not ignored. (Not maintaining and using state
+ about this validity error simplifies declaration handling; few
+ XML parsers address this constraint in any case.) </li>
+
+ <li> Well formedness constraints for general entity references
+ are not enforced. (The code to handle the "content" production
+ is merged with the element parsing code, making it hard to reuse
+ for this additional situation.) </li>
+
+</ul>
+
+<p> When tested against the July 12, 1999 version of the OASIS
+XML Conformance test suite, an earlier version passed 1057 of 1067 tests.
+That contrasts with the original version, which passed 867. The
+current parser is top-ranked in terms of conformance, as is its
+validating sibling (which has some additional conformance violations
+imposed on it by SAX2 API deficiencies as well as some of the more
+curious SGML layering artifacts found in the XML specification). </p>
+
+<p> The XML 1.0 specification itself was not without problems,
+and after some delays the W3C has come out with a revised
+"second edition" specification. While that doesn't resolve all
+the problems identified the XML specification, many of the most
+egregious problems have been resolved. (You still need to drink
+magic Kool-Aid before some DTD-related issues make sense.)
+To the extent possible, this parser conforms to that second
+edition specification, and does well against corrected versions
+of the OASIS/NIST XML conformance test cases. See <a href=
+"http://xmlconf.sourceforge.net">http://xmlconf.sourceforge.net</a>
+for more information about SAX2/XML conformance testing. </p>
+
+
+<h3><a name="copyright">Copyright and distribution terms</a></h3>
+
+<p>
+The software in this package is distributed under the GNU General Public
+License (with a special exception described below).
+</p>
+
+<p>
+A copy of GNU General Public License (GPL) is included in this distribution,
+in the file COPYING. If you do not have the source code, it is available at:
+
+ <a href="http://www.gnu.org/software/classpath/">http://www.gnu.org/software/classpath/</a>
+</p>
+
+<pre>
+ Linking this library statically or dynamically with other modules is
+ making a combined work based on this library. Thus, the terms and
+ conditions of the GNU General Public License cover the whole
+ combination.
+
+ As a special exception, the copyright holders of this library give you
+ permission to link this library with independent modules to produce an
+ executable, regardless of the license terms of these independent
+ modules, and to copy and distribute the resulting executable under
+ terms of your choice, provided that you also meet, for each linked
+ independent module, the terms and conditions of the license of that
+ module. An independent module is a module which is not derived from
+ or based on this library. If you modify this library, you may extend
+ this exception to your version of the library, but you are not
+ obligated to do so. If you do not wish to do so, delete this
+ exception statement from your version.
+
+ Parts derived from code which carried the following notice:
+
+ Copyright (c) 1997, 1998 by Microstar Software Ltd.
+
+ AElfred is free for both commercial and non-commercial use and
+ redistribution, provided that Microstar's copyright and disclaimer are
+ retained intact. You are free to modify AElfred for your own use and
+ to redistribute AElfred with your modifications, provided that the
+ modifications are clearly documented.
+
+ This program is distributed in the hope that it will be useful, but
+ WITHOUT ANY WARRANTY; without even the implied warranty of
+ merchantability or fitness for a particular purpose. Please use it AT
+ YOUR OWN RISK.
+</pre>
+
+<p> Some of this documentation was modified from the original
+Ælfred README.txt file. All of it has been updated. </p>
+
+</p>
+
+
+<h2><a name="changes">Changes Since the last Microstar Release</a></h2>
+
+<p> As noted above, Microstar has not updated this parser since
+the summer of 1998, when it released version 1.2a on its web site.
+This release is intended to benefit the developer community by
+refocusing the API on SAX2, and improving conformance to the extent
+that most developers should not need to use another XML parser. </p>
+
+<p> The code has been cleaned up (referring to the XML 1.0 spec in
+all the production numbers in
+comments, rather than some preliminary draft, for one example) and
+has been sped up a bit as well.
+JAXP support has been added, although developers are still
+strongly encouraged to use the SAX2 APIs directly. </p>
+
+
+<h3><a name="sax2">SAX2 Support</a></h3>
+
+<p> The original version of Ælfred did not support the
+SAX2 APIs. </p>
+
+<p> This version supports the SAX2 APIs, exposing the standard
+boolean feature descriptors. It supports the "DeclHandler" property
+to provide access to all DTD declarations not already exposed
+through the SAX1 API. The "LexicalHandler" property is supported,
+exposing entity boundaries (including the unnamed external subset) and
+things like comments and CDATA boundaries. SAX1 compatibility is
+currently provided.</p>
+
+
+<h3><a name="validation">Validation</a></h3>
+
+<p> In the 'pipeline' package in this same software distribution is an
+<a href="../pipeline/ValidationConsumer.html">XML Validation component</a>
+using any full SAX2 event stream (including all document type declarations)
+to validate. There is now a <a href="XmlReader.html">XmlReader</a> class
+which combines that class and this enhanced Ælfred parser, creating
+an optionally validating SAX2 parser. </p>
+
+<p> As noted in the documentation for that validating component, certain
+validity constraints can't reliably be tested by a layered validator.
+These include all constraints relying on
+layering violations (exposing XML at the level of tokens or below,
+required since XML isn't a context-free grammar), some that
+SAX2 doesn't support, and a few others. The resulting validating
+parser is conformant enough for most applications that aren't doing
+strange SGML tricks with DTDs.
+Moreover, that validating filter can be used without
+a parser ... any application component that emits SAX event streams
+can DTD-validate its output on demand. </p>
+
+<h3><a name="smaller">You want Smaller?</a></h3>
+
+<p> You'll have noticed that the original version of Ælfred
+had small size as a top goal. Ælfred2 normally includes a
+DTD validation layer, but you can package without that.
+Similarly, JAXP factory support is available but optional.
+Then the main added cost due to this revision are for
+supporting the SAX2 API itself; DTD validation is as
+cleanly layered as allowed by SAX2.</p>
+
+<h3><a name="bugfixes">Bugs Fixed</a></h3>
+
+<p> Bugs fixed in Ælfred2 include: </p>
+
+<ol>
+ <li> Originally Ælfred didn't close file descriptors, which
+ led to file descriptor leakage on programs which ran for any
+ length of time. </li>
+
+ <li> NOTATION declarations without system identifiers are
+ now handled correctly. </li>
+
+ <li> DTD events are now reported for all invocations of a
+ given parser, not just the first one. </li>
+
+ <li> More correct character handling: <ul>
+
+ <li> Rejects out-of-range characters, both in text and in
+ character references. </li>
+
+ <li> Correctly handles character references that expand to
+ surrogate pairs. </li>
+
+ <li> Correctly handles UTF-8 encodings of surrogate pairs. </li>
+
+ <li> Correctly handles Unicode 3.1 rules about illegal UTF-8
+ encodings: there is only one legal encoding per character. </li>
+
+ <li> PUBLIC identifiers are now rejected if they have illegal
+ characters. </li>
+
+ <li> The parser is more correct about what characters are allowed
+ in names and name tokens. Uses Unicode rules (built in to Java)
+ rather than the voluminous XML rules, although some extensions
+ have been made to match XML rules more closely.</li>
+
+ <li> Line ends are now normalized to newlines in all known
+ cases. </li>
+
+ </ul></li>
+
+ <li> Certain validity errors were previously treated as well
+ formedness violations. <ul>
+
+ <li> Repeated declarations of an element type are no
+ longer fatal errors. </li>
+
+ <li> Undeclared parameter entity references are no longer
+ fatal errors. </li>
+
+ </ul></li>
+
+ <li> Attribute handling is improved: <ul>
+
+ <li> Whitespace must exist between attributes. </li>
+
+ <li> Only one value for a given attribute is permitted. </li>
+
+ <li> ATTLIST declarations don't need to declare attributes. </li>
+
+ <li> Attribute values are normalized when required. </li>
+
+ <li> Tabs in attribute values are normalized to spaces. </li>
+
+ <li> Attribute values containing a literal "<" are rejected. </li>
+
+ </ul></li>
+
+ <li> More correct entity handling: <ul>
+
+ <li> Whitespace must precede NDATA when declaring unparsed
+ entities.</li>
+
+ <li> Parameter entity declarations may not have NDATA annotations. </li>
+
+ <li> The XML specification has a bug in that it doesn't specify
+ that certain contexts exist within which parameter entity
+ expansion must not be performed. Lacking an offical erratum,
+ this parser now disables such expansion inside comments,
+ processing instructions, ignored sections, public identifiers,
+ and parts of entity declarations. </li>
+
+ <li> Entity expansions that include quote characters no longer
+ confuse parsing of strings using such expansions. </li>
+
+ <li> Whitespace in the values of internal entities is not mapped
+ to space characters. </li>
+
+ <li> General Entity references in attribute defaults within the
+ DTD now cause fatal errors when the entity is not defined at the
+ time it is referenced. </li>
+
+ <li> Malformed general entity references in entity declarations are
+ now detected. </li>
+
+ </ul></li>
+
+ <li> Neither conditional sections
+ nor parameter entity references within markup declarations
+ are permitted in the internal subset. </li>
+
+ <li> Processing instructions whose target names are "XML"
+ (ignoring case) are now rejected. </li>
+
+ <li> Comments may not include "--".</li>
+
+ <li> Most "]]>" sequences in text are rejected. </li>
+
+ <li> Correct syntax for standalone declarations is enforced. </li>
+
+ <li> Setting a locale for diagnostics only produces an exception
+ if the language of that locale isn't English. </li>
+
+ <li> Some more encoding names are recognized. These include the
+ Unicode 3.0 variants of UTF-16 (UTF-16BE, UTF-16LE) as well as
+ US-ASCII and a few commonly seen synonyms. </li>
+
+ <li> Text (from character content, PIs, or comments) large enough
+ not to fit into internal buffers is now handled correctly even in
+ some cases which were originally handled incorrectly.</li>
+
+ <li> Content is now reported for element types for which attributes
+ have been declared, but no content model is known. (Such documents
+ are invalid, but may still be well formed.) </li>
+
+</ol>
+
+<p> Other bugs may also have been fixed. </p>
+
+<p> For better overall validation support, some of the validity
+constraints that can't be verified using the SAX2 event stream
+are now reported directly by Ælfred2. </p>
+
+</body></html>
+
Added: llvm-gcc-4.2/trunk/libjava/classpath/gnu/xml/dom/Consumer.java
URL: http://llvm.org/viewvc/llvm-project/llvm-gcc-4.2/trunk/libjava/classpath/gnu/xml/dom/Consumer.java?rev=43913&view=auto
==============================================================================
--- llvm-gcc-4.2/trunk/libjava/classpath/gnu/xml/dom/Consumer.java (added)
+++ llvm-gcc-4.2/trunk/libjava/classpath/gnu/xml/dom/Consumer.java Thu Nov 8 16:56:19 2007
@@ -0,0 +1,352 @@
+/* Consumer.java --
+ Copyright (C) 2001,2004 Free Software Foundation, Inc.
+
+This file is part of GNU Classpath.
+
+GNU Classpath is free software; you can redistribute it and/or modify
+it under the terms of the GNU General Public License as published by
+the Free Software Foundation; either version 2, or (at your option)
+any later version.
+
+GNU Classpath is distributed in the hope that it will be useful, but
+WITHOUT ANY WARRANTY; without even the implied warranty of
+MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+General Public License for more details.
+
+You should have received a copy of the GNU General Public License
+along with GNU Classpath; see the file COPYING. If not, write to the
+Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA
+02110-1301 USA.
+
+Linking this library statically or dynamically with other modules is
+making a combined work based on this library. Thus, the terms and
+conditions of the GNU General Public License cover the whole
+combination.
+
+As a special exception, the copyright holders of this library give you
+permission to link this library with independent modules to produce an
+executable, regardless of the license terms of these independent
+modules, and to copy and distribute the resulting executable under
+terms of your choice, provided that you also meet, for each linked
+independent module, the terms and conditions of the license of that
+module. An independent module is a module which is not derived from
+or based on this library. If you modify this library, you may extend
+this exception to your version of the library, but you are not
+obligated to do so. If you do not wish to do so, delete this
+exception statement from your version. */
+
+
+package gnu.xml.dom;
+
+import org.w3c.dom.DocumentType;
+import org.w3c.dom.Node;
+import org.w3c.dom.Text;
+
+import org.xml.sax.Attributes;
+import org.xml.sax.SAXException;
+import org.xml.sax.ext.Attributes2;
+
+import gnu.xml.pipeline.DomConsumer;
+import gnu.xml.pipeline.EventConsumer;
+
+
+/**
+ * Event consumer which constructs DOM documents using the implementation
+ * in this package, using SAX2 events. This packages various backdoors
+ * into this DOM implementation, as needed to address DOM requirements
+ * that can't be met by strictly conforming implementations of DOM.
+ *
+ * <p> These requirements all relate to {@link DocumentType} nodes and
+ * features of that node type. These features are normally not used,
+ * because that interface only exposes a subset of the information found
+ * in DTDs. More, that subset does not include the most important typing
+ * information. For example, it excludes element content models and
+ * attribute typing. It does expose some entity management issues,
+ * although entity management doesn't relate to document typing.
+ *
+ * <p> Note that SAX2 does not expose the literal text of the DTD's
+ * internal subset, so it will not be present in DOM trees constructed
+ * using this API. (Though with a good SAX2 implementation, it could
+ * be partially recreated...)
+ *
+ * @author David Brownell
+ */
+public class Consumer extends DomConsumer
+{
+ /**
+ * Constructs an unconfigured event consumer,
+ * as a terminus in a SAX event pipeline.
+ */
+ // used by PipelineFactory [terminus]
+ public Consumer ()
+ throws SAXException
+ {
+ super (DomDocument.class);
+ setHandler (new Backdoor (this));
+ }
+
+ /**
+ * Constructs an unconfigured event consumer,
+ * as a stage in a SAX event pipeline.
+ */
+ // used by PipelineFactory [filter]
+ public Consumer (EventConsumer next)
+ throws SAXException
+ {
+ super (DomDocument.class, next);
+ setHandler (new Backdoor (this));
+ }
+
+ /**
+ * Implements the backdoors needed by DOM.
+ * All methods in this class use implementation-specific APIs that are
+ * implied by the DOM specification (needed to implement testable
+ * behavior) but which are excluded from the DOM specification.
+ */
+ public static class Backdoor extends DomConsumer.Handler
+ {
+ /**
+ * Constructor.
+ * @param consumer must have been initialized to use the
+ * {@link DomDocument} class (or a subclass) for
+ * constructing DOM trees
+ */
+ protected Backdoor (DomConsumer consumer)
+ throws SAXException
+ { super (consumer); }
+
+ // helper routine
+ private DomDoctype getDoctype ()
+ throws SAXException
+ {
+ DomDocument doc = (DomDocument) getDocument ();
+ DocumentType dt = doc.getDoctype ();
+
+ if (dt == null)
+ throw new SAXException ("doctype missing!");
+ return (DomDoctype) dt;
+ }
+
+ // SAX2 "lexical" event
+ public void startDTD (String name, String publicId, String systemId)
+ throws SAXException
+ {
+ DomDocument doc = (DomDocument) getDocument ();
+
+ super.startDTD (name, publicId, systemId);
+ // DOM L2 doctype creation model is bizarre
+ DomDoctype dt = new DomDoctype (doc, name, publicId, systemId);
+ doc.appendChild (dt);
+ }
+
+ // SAX2 "lexical" event
+ public void endDTD ()
+ throws SAXException
+ {
+ super.endDTD ();
+ // DOM L2 has no way to make things readonly
+ getDoctype ().makeReadonly ();
+ }
+
+ // SAX1 DTD event
+ public void notationDecl (
+ String name,
+ String publicId, String systemId
+ ) throws SAXException
+ {
+ // DOM L2 can't create/save notation nodes
+ getDoctype ().declareNotation (name, publicId, systemId);
+ }
+
+ // SAX1 DTD event
+ public void unparsedEntityDecl (
+ String name,
+ String publicId, String systemId,
+ String notationName
+ ) throws SAXException
+ {
+ // DOM L2 can't create/save entity nodes
+ getDoctype ().declareEntity (name, publicId, systemId,
+ notationName);
+ }
+
+ // SAX2 declaration event
+ public void internalEntityDecl (String name, String value)
+ throws SAXException
+ {
+ // DOM L2 can't create/save entity nodes
+ // NOTE: this doesn't save the value as a child of this
+ // node, though it could realistically do so.
+ getDoctype ().declareEntity (name, null, null, null);
+ }
+
+ // SAX2 declaration event
+ public void externalEntityDecl (
+ String name,
+ String publicId,
+ String systemId
+ ) throws SAXException
+ {
+ // DOM L2 can't create/save entity nodes
+ // NOTE: DOM allows for these to have children, if
+ // they don't have unbound namespace references.
+ getDoctype ().declareEntity (name, publicId, systemId, null);
+ }
+
+ // SAX2 element
+ public void startElement (
+ String uri,
+ String localName,
+ String qName,
+ Attributes atts
+ ) throws SAXException
+ {
+ Node top;
+
+ super.startElement (uri, localName, qName, atts);
+
+ // might there be more work?
+ top = getTop ();
+ if (!top.hasAttributes () || !(atts instanceof Attributes2))
+ return;
+
+ // remember any attributes that got defaulted
+ DomNamedNodeMap map = (DomNamedNodeMap) top.getAttributes ();
+ Attributes2 attrs = (Attributes2) atts;
+ int length = atts.getLength ();
+
+ //map.compact ();
+ for (int i = 0; i < length; i++) {
+ if (attrs.isSpecified (i))
+ continue;
+
+ // value was defaulted.
+ String temp = attrs.getQName (i);
+ DomAttr attr;
+
+ if ("".equals (temp))
+ attr = (DomAttr) map.getNamedItemNS (attrs.getURI (i),
+ atts.getLocalName (i));
+ else
+ attr = (DomAttr) map.getNamedItem (temp);
+
+ // DOM L2 can't write this flag, only read it
+ attr.setSpecified (false);
+ }
+ }
+
+ public void endElement (
+ String uri,
+ String localName,
+ String qName
+ ) throws SAXException
+ {
+ DomNode top = (DomNode) getTop ();
+ top.compact ();
+ super.endElement (uri, localName, qName);
+ }
+
+ protected Text createText (
+ boolean isCDATA,
+ char buf [],
+ int off,
+ int len
+ ) {
+ DomDocument doc = (DomDocument) getDocument ();
+
+ if (isCDATA)
+ return doc.createCDATASection (buf, off, len);
+ else
+ return doc.createTextNode (buf, off, len);
+ }
+
+ public void elementDecl(String name, String model)
+ throws SAXException
+ {
+ getDoctype().elementDecl(name, model);
+ }
+
+ public void attributeDecl (
+ String ename,
+ String aname,
+ String type,
+ String mode,
+ String value
+ ) throws SAXException
+ {
+ getDoctype().attributeDecl(ename, aname, type, mode, value);
+ /*
+ if (value == null && !"ID".equals (type))
+ return;
+
+ DomDoctype.ElementInfo info;
+
+ info = getDoctype ().getElementInfo (ename);
+ if (value != null)
+ info.setAttrDefault (aname, value);
+ if ("ID".equals (type))
+ info.setIdAttr (aname);
+ */
+
+ }
+
+ // force duplicate name checking off while we're
+ // using parser output (don't duplicate the work)
+ public void startDocument () throws SAXException
+ {
+ super.startDocument ();
+
+ DomDocument doc = (DomDocument) getDocument ();
+ doc.setStrictErrorChecking(false);
+ doc.setBuilding(true);
+ }
+
+ public void endDocument ()
+ throws SAXException
+ {
+ DomDocument doc = (DomDocument) getDocument ();
+ doc.setStrictErrorChecking(true);
+ doc.setBuilding(false);
+ doc.compact ();
+ DomDoctype doctype = (DomDoctype) doc.getDoctype();
+ if (doctype != null)
+ {
+ doctype.makeReadonly();
+ }
+ super.endDocument ();
+ }
+
+ // these three methods collaborate to populate entity
+ // refs, marking contents readonly on end-of-entity
+
+ public boolean canPopulateEntityRefs ()
+ { return true; }
+
+ public void startEntity (String name)
+ throws SAXException
+ {
+ if (name.charAt (0) == '%' || "[dtd]".equals (name))
+ return;
+ super.startEntity (name);
+
+ DomNode top = (DomNode) getTop ();
+
+ if (top.getNodeType () == Node.ENTITY_REFERENCE_NODE)
+ top.readonly = false;
+ }
+
+ public void endEntity (String name)
+ throws SAXException
+ {
+ if (name.charAt (0) == '%' || "[dtd]".equals (name))
+ return;
+ DomNode top = (DomNode) getTop ();
+
+ if (top.getNodeType () == Node.ENTITY_REFERENCE_NODE) {
+ top.compact ();
+ top.makeReadonly ();
+ }
+ super.endEntity (name);
+ }
+ }
+}
Added: llvm-gcc-4.2/trunk/libjava/classpath/gnu/xml/dom/DTDAttributeTypeInfo.java
URL: http://llvm.org/viewvc/llvm-project/llvm-gcc-4.2/trunk/libjava/classpath/gnu/xml/dom/DTDAttributeTypeInfo.java?rev=43913&view=auto
==============================================================================
--- llvm-gcc-4.2/trunk/libjava/classpath/gnu/xml/dom/DTDAttributeTypeInfo.java (added)
+++ llvm-gcc-4.2/trunk/libjava/classpath/gnu/xml/dom/DTDAttributeTypeInfo.java Thu Nov 8 16:56:19 2007
@@ -0,0 +1,84 @@
+/* DTDAttributeTypeInfo.java --
+ Copyright (C) 2004 Free Software Foundation, Inc.
+
+This file is part of GNU Classpath.
+
+GNU Classpath is free software; you can redistribute it and/or modify
+it under the terms of the GNU General Public License as published by
+the Free Software Foundation; either version 2, or (at your option)
+any later version.
+
+GNU Classpath is distributed in the hope that it will be useful, but
+WITHOUT ANY WARRANTY; without even the implied warranty of
+MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+General Public License for more details.
+
+You should have received a copy of the GNU General Public License
+along with GNU Classpath; see the file COPYING. If not, write to the
+Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA
+02110-1301 USA.
+
+Linking this library statically or dynamically with other modules is
+making a combined work based on this library. Thus, the terms and
+conditions of the GNU General Public License cover the whole
+combination.
+
+As a special exception, the copyright holders of this library give you
+permission to link this library with independent modules to produce an
+executable, regardless of the license terms of these independent
+modules, and to copy and distribute the resulting executable under
+terms of your choice, provided that you also meet, for each linked
+independent module, the terms and conditions of the license of that
+module. An independent module is a module which is not derived from
+or based on this library. If you modify this library, you may extend
+this exception to your version of the library, but you are not
+obligated to do so. If you do not wish to do so, delete this
+exception statement from your version. */
+
+package gnu.xml.dom;
+
+import org.w3c.dom.TypeInfo;
+
+/**
+ * Attribute type information supplied by a DTD attribute declaration.
+ *
+ * @author <a href='mailto:dog at gnu.org'>Chris Burdess</a>
+ */
+class DTDAttributeTypeInfo
+ implements TypeInfo
+{
+
+ final String elementName;
+ final String name;
+ final String type;
+ final String mode;
+ final String value;
+
+ DTDAttributeTypeInfo(String elementName, String name, String type,
+ String mode, String value)
+ {
+ this.elementName = elementName;
+ this.name = name;
+ this.type = type;
+ this.mode = mode;
+ this.value = value;
+ }
+
+ public final String getTypeName()
+ {
+ return type;
+ }
+
+ public final String getTypeNamespace()
+ {
+ return "http://www.w3.org/TR/REC-xml";
+ }
+
+ public final boolean isDerivedFrom(String typeNamespace, String typeName,
+ int derivationMethod)
+ {
+ return false;
+ }
+
+}
+
Added: llvm-gcc-4.2/trunk/libjava/classpath/gnu/xml/dom/DTDElementTypeInfo.java
URL: http://llvm.org/viewvc/llvm-project/llvm-gcc-4.2/trunk/libjava/classpath/gnu/xml/dom/DTDElementTypeInfo.java?rev=43913&view=auto
==============================================================================
--- llvm-gcc-4.2/trunk/libjava/classpath/gnu/xml/dom/DTDElementTypeInfo.java (added)
+++ llvm-gcc-4.2/trunk/libjava/classpath/gnu/xml/dom/DTDElementTypeInfo.java Thu Nov 8 16:56:19 2007
@@ -0,0 +1,112 @@
+/* DTDElementTypeInfo.java --
+ Copyright (C) 2004 Free Software Foundation, Inc.
+
+This file is part of GNU Classpath.
+
+GNU Classpath is free software; you can redistribute it and/or modify
+it under the terms of the GNU General Public License as published by
+the Free Software Foundation; either version 2, or (at your option)
+any later version.
+
+GNU Classpath is distributed in the hope that it will be useful, but
+WITHOUT ANY WARRANTY; without even the implied warranty of
+MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+General Public License for more details.
+
+You should have received a copy of the GNU General Public License
+along with GNU Classpath; see the file COPYING. If not, write to the
+Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA
+02110-1301 USA.
+
+Linking this library statically or dynamically with other modules is
+making a combined work based on this library. Thus, the terms and
+conditions of the GNU General Public License cover the whole
+combination.
+
+As a special exception, the copyright holders of this library give you
+permission to link this library with independent modules to produce an
+executable, regardless of the license terms of these independent
+modules, and to copy and distribute the resulting executable under
+terms of your choice, provided that you also meet, for each linked
+independent module, the terms and conditions of the license of that
+module. An independent module is a module which is not derived from
+or based on this library. If you modify this library, you may extend
+this exception to your version of the library, but you are not
+obligated to do so. If you do not wish to do so, delete this
+exception statement from your version. */
+
+package gnu.xml.dom;
+
+import java.util.HashMap;
+import java.util.Iterator;
+import org.w3c.dom.TypeInfo;
+
+/**
+ * Element type information provided by a DTD element declaration.
+ *
+ * @author <a href='mailto:dog at gnu.org'>Chris Burdess</a>
+ */
+class DTDElementTypeInfo
+ implements TypeInfo
+{
+
+ final String name;
+ String model;
+ HashMap attributes;
+ String idAttrName;
+
+ DTDElementTypeInfo(String name, String model)
+ {
+ this.name = name;
+ this.model = model;
+ }
+
+ public final String getTypeName()
+ {
+ return null;
+ }
+
+ public final String getTypeNamespace()
+ {
+ return "http://www.w3.org/TR/REC-xml";
+ }
+
+ public final boolean isDerivedFrom(String typeNamespace, String typeName,
+ int derivationMethod)
+ {
+ return false;
+ }
+
+ DTDAttributeTypeInfo getAttributeTypeInfo(String name)
+ {
+ if (attributes == null)
+ {
+ return null;
+ }
+ return (DTDAttributeTypeInfo) attributes.get(name);
+ }
+
+ void setAttributeTypeInfo(String name, DTDAttributeTypeInfo info)
+ {
+ if (attributes == null)
+ {
+ attributes = new HashMap();
+ }
+ attributes.put(name, info);
+ if ("ID".equals(info.type))
+ {
+ idAttrName = name;
+ }
+ }
+
+ Iterator attributes()
+ {
+ if (attributes == null)
+ {
+ return null;
+ }
+ return attributes.values().iterator();
+ }
+
+}
+
Added: llvm-gcc-4.2/trunk/libjava/classpath/gnu/xml/dom/DomAttr.java
URL: http://llvm.org/viewvc/llvm-project/llvm-gcc-4.2/trunk/libjava/classpath/gnu/xml/dom/DomAttr.java?rev=43913&view=auto
==============================================================================
--- llvm-gcc-4.2/trunk/libjava/classpath/gnu/xml/dom/DomAttr.java (added)
+++ llvm-gcc-4.2/trunk/libjava/classpath/gnu/xml/dom/DomAttr.java Thu Nov 8 16:56:19 2007
@@ -0,0 +1,380 @@
+/* DomAttr.java --
+ Copyright (C) 1999,2000,2001,2004 Free Software Foundation, Inc.
+
+This file is part of GNU Classpath.
+
+GNU Classpath is free software; you can redistribute it and/or modify
+it under the terms of the GNU General Public License as published by
+the Free Software Foundation; either version 2, or (at your option)
+any later version.
+
+GNU Classpath is distributed in the hope that it will be useful, but
+WITHOUT ANY WARRANTY; without even the implied warranty of
+MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+General Public License for more details.
+
+You should have received a copy of the GNU General Public License
+along with GNU Classpath; see the file COPYING. If not, write to the
+Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA
+02110-1301 USA.
+
+Linking this library statically or dynamically with other modules is
+making a combined work based on this library. Thus, the terms and
+conditions of the GNU General Public License cover the whole
+combination.
+
+As a special exception, the copyright holders of this library give you
+permission to link this library with independent modules to produce an
+executable, regardless of the license terms of these independent
+modules, and to copy and distribute the resulting executable under
+terms of your choice, provided that you also meet, for each linked
+independent module, the terms and conditions of the license of that
+module. An independent module is a module which is not derived from
+or based on this library. If you modify this library, you may extend
+this exception to your version of the library, but you are not
+obligated to do so. If you do not wish to do so, delete this
+exception statement from your version. */
+
+package gnu.xml.dom;
+
+import org.w3c.dom.Attr;
+import org.w3c.dom.DOMException;
+import org.w3c.dom.Element;
+import org.w3c.dom.Node;
+import org.w3c.dom.TypeInfo;
+import org.w3c.dom.events.MutationEvent;
+
+
+/**
+ * <p> "Attr" implementation. In DOM, attributes cost quite a lot of
+ * memory because their values are complex structures rather than just
+ * simple strings. To reduce your costs, avoid having more than one
+ * child of an attribute; stick to a single Text node child, and ignore
+ * even that by using the attribute's "nodeValue" property.</p>
+ *
+ * <p> As a bit of general advice, only look at attribute modification
+ * events through the DOMAttrModified event (sent to the associated
+ * element). Implementations are not guaranteed to report other events
+ * in the same order, so you're very likely to write nonportable code if
+ * you monitor events at the "children of Attr" level.</p>
+ *
+ * <p> At this writing, not all attribute modifications will cause the
+ * DOMAttrModified event to be triggered ... only the ones using the string
+ * methods (setNodeValue, setValue, and Element.setAttribute) to modify
+ * those values. That is, if you manipulate those children directly,
+ * elements won't get notified that attribute values have changed.
+ * The natural fix for that will report other modifications, but won't
+ * be able to expose "previous" attribute value; it'll need to be cached
+ * or something (at which point why bother using child nodes). </p>
+ *
+ * <p><em>You are strongly advised not to use "children" of any attribute
+ * nodes you work with.</em> </p>
+ *
+ * @author David Brownell
+ * @author <a href='mailto:dog at gnu.org'>Chris Burdess</a>
+ */
+public class DomAttr
+ extends DomNsNode
+ implements Attr
+{
+
+ private boolean specified;
+ private String value; // string value cache
+
+ /**
+ * Constructs an Attr node associated with the specified document.
+ * The "specified" flag is initialized to true, since this DOM has
+ * no current "back door" mechanisms to manage default values so
+ * that every value must effectively be "specified".
+ *
+ * <p>This constructor should only be invoked by a Document as part of
+ * its createAttribute functionality, or through a subclass which is
+ * similarly used in a "Sub-DOM" style layer.
+ *
+ * @param owner The document with which this node is associated
+ * @param namespaceURI Combined with the local part of the name,
+ * this is used to uniquely identify a type of attribute
+ * @param name Name of this attribute, which may include a prefix
+ */
+ protected DomAttr(DomDocument owner, String namespaceURI, String name)
+ {
+ super(ATTRIBUTE_NODE, owner, namespaceURI, name);
+ specified = true;
+ length = 1;
+
+ // XXX register self to get insertion/removal events
+ // and character data change events and when they happen,
+ // report self-mutation
+ }
+
+ /**
+ * <b>DOM L1</b>
+ * Returns the attribute name (same as getNodeName)
+ */
+ public final String getName()
+ {
+ return getNodeName();
+ }
+
+ /**
+ * <b>DOM L1</b>
+ * Returns true if a parser reported this was in the source text.
+ */
+ public final boolean getSpecified()
+ {
+ return specified;
+ }
+
+ /**
+ * Records whether this attribute was in the source text.
+ */
+ public final void setSpecified(boolean value)
+ {
+ specified = value;
+ }
+
+ /**
+ * <b>DOM L1</b>
+ * Returns the attribute value, with character and entity
+ * references substituted.
+ * <em>NOTE: entity refs as children aren't currently handled.</em>
+ */
+ public String getNodeValue()
+ {
+ // If we have a simple node-value, use that
+ if (first == null)
+ {
+ return (value == null) ? "" : value;
+ }
+ // Otherwise collect child node-values
+ StringBuffer buf = new StringBuffer();
+ for (DomNode ctx = first; ctx != null; ctx = ctx.next)
+ {
+ switch (ctx.nodeType)
+ {
+ case Node.TEXT_NODE:
+ buf.append(ctx.getNodeValue());
+ break;
+ case Node.ENTITY_REFERENCE_NODE:
+ // TODO
+ break;
+ }
+ }
+ return buf.toString();
+ }
+
+ /**
+ * <b>DOM L1</b>
+ * Assigns the value of the attribute; it will have one child,
+ * which is a text node with the specified value (same as
+ * setNodeValue).
+ */
+ public final void setValue(String value)
+ {
+ setNodeValue(value);
+ }
+
+ /**
+ * <b>DOM L1</b>
+ * Returns the value of the attribute as a non-null string; same
+ * as getNodeValue.
+ * <em>NOTE: entity refs as children aren't currently handled.</em>
+ */
+ public final String getValue()
+ {
+ return getNodeValue();
+ }
+
+ /**
+ * <b>DOM L1</b>
+ * Assigns the attribute value; using this API, no entity or
+ * character references will exist.
+ * Causes a DOMAttrModified mutation event to be sent.
+ */
+ public void setNodeValue(String value)
+ {
+ if (readonly)
+ {
+ throw new DomDOMException(DOMException.NO_MODIFICATION_ALLOWED_ERR);
+ }
+ if (value == null)
+ {
+ value = "";
+ }
+ String oldValue = getNodeValue();
+ while (last != null)
+ {
+ removeChild(last);
+ }
+ // don't create a new node just for this...
+ /*
+ Node text = owner.createTextNode(value);
+ appendChild(text);
+ */
+ this.value = value;
+ length = 1;
+ specified = true;
+
+ mutating(oldValue, value, MutationEvent.MODIFICATION);
+ }
+
+ public final Node getFirstChild()
+ {
+ // Create a child text node if necessary
+ if (first == null)
+ {
+ length = 0;
+ Node text = owner.createTextNode((value == null) ? "" : value);
+ appendChild(text);
+ }
+ return first;
+ }
+
+ public final Node getLastChild()
+ {
+ // Create a child text node if necessary
+ if (last == null)
+ {
+ length = 0;
+ Node text = owner.createTextNode((value == null) ? "" : value);
+ appendChild(text);
+ }
+ return last;
+ }
+
+ public Node item(int index)
+ {
+ // Create a child text node if necessary
+ if (first == null)
+ {
+ length = 0;
+ Node text = owner.createTextNode((value == null) ? "" : value);
+ appendChild(text);
+ }
+ return super.item(index);
+ }
+
+ /**
+ * <b>DOM L2</b>
+ * Returns the element with which this attribute is associated.
+ */
+ public final Element getOwnerElement()
+ {
+ return (Element) parent;
+ }
+
+ public final Node getNextSibling()
+ {
+ return null;
+ }
+
+ public final Node getPreviousSibling()
+ {
+ return null;
+ }
+
+ public Node getParentNode()
+ {
+ return null;
+ }
+
+ /**
+ * Records the element with which this attribute is associated.
+ */
+ public final void setOwnerElement(Element e)
+ {
+ if (parent != null)
+ {
+ throw new DomDOMException(DOMException.HIERARCHY_REQUEST_ERR);
+ }
+ if (!(e instanceof DomElement))
+ {
+ throw new DomDOMException(DOMException.WRONG_DOCUMENT_ERR);
+ }
+ parent = (DomElement) e;
+ depth = parent.depth + 1;
+ }
+
+ /**
+ * The base URI of an Attr is always <code>null</code>.
+ */
+ public final String getBaseURI()
+ {
+ return null;
+ }
+
+ /**
+ * Shallow clone of the attribute, breaking all ties with any
+ * elements.
+ */
+ public Object clone()
+ {
+ DomAttr retval = (DomAttr) super.clone();
+ retval.specified = true;
+ return retval;
+ }
+
+ private void mutating(String oldValue, String newValue, short why)
+ {
+ if (!reportMutations || parent == null)
+ {
+ return;
+ }
+
+ // EVENT: DOMAttrModified, target = parent,
+ // prev/new values provided, also attr name
+ MutationEvent event;
+
+ event = (MutationEvent) createEvent ("MutationEvents");
+ event.initMutationEvent ("DOMAttrModified",
+ true /* bubbles */, false /* nocancel */,
+ null, oldValue, newValue, getNodeName (), why);
+ parent.dispatchEvent (event);
+ }
+
+ // DOM Level 3 methods
+
+ public TypeInfo getSchemaTypeInfo()
+ {
+ if (parent != null)
+ {
+ // DTD implementation
+ DomDoctype doctype = (DomDoctype) parent.owner.getDoctype();
+ if (doctype != null)
+ {
+ return doctype.getAttributeTypeInfo(parent.getNodeName(),
+ getNodeName());
+ }
+ // TODO XML Schema implementation
+ }
+ return null;
+ }
+
+ public boolean isId()
+ {
+ if (parent != null)
+ {
+ DomDoctype doctype = (DomDoctype) parent.owner.getDoctype();
+ if (doctype != null)
+ {
+ DTDAttributeTypeInfo info =
+ doctype.getAttributeTypeInfo(parent.getNodeName(),
+ getNodeName());
+ if (info != null && "ID".equals(info.type))
+ {
+ return true;
+ }
+ }
+ DomElement element = (DomElement) parent;
+ if (element.userIdAttrs != null &&
+ element.userIdAttrs.contains(this))
+ {
+ return true;
+ }
+ // TODO XML Schema implementation
+ }
+ return false;
+ }
+
+}
+
Added: llvm-gcc-4.2/trunk/libjava/classpath/gnu/xml/dom/DomCDATASection.java
URL: http://llvm.org/viewvc/llvm-project/llvm-gcc-4.2/trunk/libjava/classpath/gnu/xml/dom/DomCDATASection.java?rev=43913&view=auto
==============================================================================
--- llvm-gcc-4.2/trunk/libjava/classpath/gnu/xml/dom/DomCDATASection.java (added)
+++ llvm-gcc-4.2/trunk/libjava/classpath/gnu/xml/dom/DomCDATASection.java Thu Nov 8 16:56:19 2007
@@ -0,0 +1,91 @@
+/* DomCDATASection.java --
+ Copyright (C) 1999,2000,2001,2004 Free Software Foundation, Inc.
+
+This file is part of GNU Classpath.
+
+GNU Classpath is free software; you can redistribute it and/or modify
+it under the terms of the GNU General Public License as published by
+the Free Software Foundation; either version 2, or (at your option)
+any later version.
+
+GNU Classpath is distributed in the hope that it will be useful, but
+WITHOUT ANY WARRANTY; without even the implied warranty of
+MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+General Public License for more details.
+
+You should have received a copy of the GNU General Public License
+along with GNU Classpath; see the file COPYING. If not, write to the
+Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA
+02110-1301 USA.
+
+Linking this library statically or dynamically with other modules is
+making a combined work based on this library. Thus, the terms and
+conditions of the GNU General Public License cover the whole
+combination.
+
+As a special exception, the copyright holders of this library give you
+permission to link this library with independent modules to produce an
+executable, regardless of the license terms of these independent
+modules, and to copy and distribute the resulting executable under
+terms of your choice, provided that you also meet, for each linked
+independent module, the terms and conditions of the license of that
+module. An independent module is a module which is not derived from
+or based on this library. If you modify this library, you may extend
+this exception to your version of the library, but you are not
+obligated to do so. If you do not wish to do so, delete this
+exception statement from your version. */
+
+package gnu.xml.dom;
+
+import org.w3c.dom.CDATASection;
+
+/**
+ * <p> "CDATASection" implementation.
+ * This is a non-core DOM class, supporting the "XML" feature.
+ * CDATA sections are just ways to represent text using different
+ * delimeters. </p>
+ *
+ * <p> <em>You are strongly advised not to use CDATASection nodes.</em>
+ * The advantage of having slightly prettier ways to print text that may
+ * have lots of embedded XML delimiters, such as "&" and "<",
+ * can be dwarfed by the cost of dealing with multiple kinds of text
+ * nodes in all your algorithms. </p>
+ *
+ * @author David Brownell
+ * @author <a href='mailto:dog at gnu.org'>Chris Burdess</a>
+ */
+public class DomCDATASection
+ extends DomText
+ implements CDATASection
+{
+
+ /**
+ * Constructs a CDATA section node associated with the specified
+ * document and holding the specified data.
+ *
+ * <p>This constructor should only be invoked by a Document as part of
+ * its createCDATASection functionality, or through a subclass which is
+ * similarly used in a "Sub-DOM" style layer.
+ *
+ */
+ protected DomCDATASection(DomDocument owner, String value)
+ {
+ super(CDATA_SECTION_NODE, owner, value);
+ }
+
+ protected DomCDATASection(DomDocument owner, char buf [], int off, int len)
+ {
+ super(CDATA_SECTION_NODE, owner, buf, off, len);
+ }
+
+ /**
+ * <b>DOM L1</b>
+ * Returns the string "#cdata-section".
+ */
+ final public String getNodeName()
+ {
+ return "#cdata-section";
+ }
+
+}
+
Added: llvm-gcc-4.2/trunk/libjava/classpath/gnu/xml/dom/DomCharacterData.java
URL: http://llvm.org/viewvc/llvm-project/llvm-gcc-4.2/trunk/libjava/classpath/gnu/xml/dom/DomCharacterData.java?rev=43913&view=auto
==============================================================================
--- llvm-gcc-4.2/trunk/libjava/classpath/gnu/xml/dom/DomCharacterData.java (added)
+++ llvm-gcc-4.2/trunk/libjava/classpath/gnu/xml/dom/DomCharacterData.java Thu Nov 8 16:56:19 2007
@@ -0,0 +1,345 @@
+/* DomCharacterData.java --
+ Copyright (C) 1999,2000,2001,2004,2006 Free Software Foundation, Inc.
+
+This file is part of GNU Classpath.
+
+GNU Classpath is free software; you can redistribute it and/or modify
+it under the terms of the GNU General Public License as published by
+the Free Software Foundation; either version 2, or (at your option)
+any later version.
+
+GNU Classpath is distributed in the hope that it will be useful, but
+WITHOUT ANY WARRANTY; without even the implied warranty of
+MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+General Public License for more details.
+
+You should have received a copy of the GNU General Public License
+along with GNU Classpath; see the file COPYING. If not, write to the
+Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA
+02110-1301 USA.
+
+Linking this library statically or dynamically with other modules is
+making a combined work based on this library. Thus, the terms and
+conditions of the GNU General Public License cover the whole
+combination.
+
+As a special exception, the copyright holders of this library give you
+permission to link this library with independent modules to produce an
+executable, regardless of the license terms of these independent
+modules, and to copy and distribute the resulting executable under
+terms of your choice, provided that you also meet, for each linked
+independent module, the terms and conditions of the license of that
+module. An independent module is a module which is not derived from
+or based on this library. If you modify this library, you may extend
+this exception to your version of the library, but you are not
+obligated to do so. If you do not wish to do so, delete this
+exception statement from your version. */
+
+package gnu.xml.dom;
+
+import org.w3c.dom.CharacterData;
+import org.w3c.dom.DOMException;
+import org.w3c.dom.Node;
+import org.w3c.dom.NodeList;
+import org.w3c.dom.events.MutationEvent;
+
+
+/**
+ * <p> Abstract "CharacterData" implementation. This
+ * facilitates reusing code in classes implementing subtypes of that DOM
+ * interface (Text, Comment, CDATASection). </p>
+ *
+ * @author David Brownell
+ * @author <a href='mailto:dog at gnu.org'>Chris Burdess</a>
+ */
+public abstract class DomCharacterData
+ extends DomNode
+ implements CharacterData
+{
+
+ /**
+ * Empty node list representing the children of character data nodes.
+ */
+ static class EmptyNodeList
+ implements NodeList
+ {
+
+ public int getLength()
+ {
+ return 0;
+ }
+
+ public Node item(int index)
+ {
+ return null;
+ }
+
+ }
+
+ /**
+ * Singleton empty node list for character data nodes.
+ */
+ static final NodeList CHILD_NODES = new EmptyNodeList();
+
+ private String text;
+
+ // package private
+ DomCharacterData(short nodeType, DomDocument doc, String value)
+ {
+ super(nodeType, doc);
+ text = (value == null) ? "" : value;
+ }
+
+ // package private
+ DomCharacterData(short nodeType, DomDocument doc,
+ char[] buf, int offset, int length)
+ {
+ super(nodeType, doc);
+ text = (buf == null) ? "" : new String(buf, offset, length);
+ }
+
+ /**
+ * <b>DOM L1</b>
+ * Appends the specified data to the value of this node.
+ * Causes a DOMCharacterDataModified mutation event to be reported.
+ */
+ public void appendData(String arg)
+ {
+ if (isReadonly())
+ {
+ throw new DomDOMException(DOMException.NO_MODIFICATION_ALLOWED_ERR);
+ }
+ String value = text + arg;
+ mutating(value);
+ text = value;
+ }
+
+ /**
+ * <b>DOM L1</b>
+ * Modifies the value of this node.
+ * Causes a DOMCharacterDataModified mutation event to be reported.
+ */
+ public void deleteData(int offset, int count)
+ {
+ if (isReadonly())
+ {
+ throw new DomDOMException(DOMException.NO_MODIFICATION_ALLOWED_ERR);
+ }
+ char[] raw = text.toCharArray();
+ if (offset < 0 || count < 0 || offset > raw.length)
+ {
+ throw new DomDOMException(DOMException.INDEX_SIZE_ERR);
+ }
+ if ((offset + count) > raw.length)
+ {
+ count = raw.length - offset;
+ }
+ if (count == 0)
+ {
+ return;
+ }
+ try
+ {
+ char[] buf = new char[raw.length - count];
+ System.arraycopy(raw, 0, buf, 0, offset);
+ System.arraycopy(raw, offset + count, buf, offset,
+ raw.length - (offset + count));
+ String value = new String(buf);
+ mutating(value);
+ text = value;
+ }
+ catch (IndexOutOfBoundsException x)
+ {
+ throw new DomDOMException(DOMException.INDEX_SIZE_ERR);
+ }
+ }
+
+ /**
+ * <b>DOM L1</b>
+ * Returns the value of this node.
+ */
+ public String getNodeValue()
+ {
+ return text;
+ }
+
+ /**
+ * <b>DOM L1</b>
+ * Returns the value of this node; same as getNodeValue.
+ */
+ public final String getData()
+ {
+ return text;
+ }
+
+ /**
+ * <b>DOM L1</b>
+ * Returns the length of the data.
+ */
+ public int getLength()
+ {
+ return text.length();
+ }
+
+ /**
+ * <b>DOM L1</b>
+ * Modifies the value of this node.
+ */
+ public void insertData(int offset, String arg)
+ {
+ if (isReadonly())
+ {
+ throw new DomDOMException(DOMException.NO_MODIFICATION_ALLOWED_ERR);
+ }
+ char[] raw = text.toCharArray();
+ char[] tmp = arg.toCharArray ();
+ char[] buf = new char[raw.length + tmp.length];
+
+ try
+ {
+ System.arraycopy(raw, 0, buf, 0, offset);
+ System.arraycopy(tmp, 0, buf, offset, tmp.length);
+ System.arraycopy(raw, offset, buf, offset + tmp.length,
+ raw.length - offset);
+ String value = new String(buf);
+ mutating(value);
+ text = value;
+ }
+ catch (IndexOutOfBoundsException x)
+ {
+ throw new DomDOMException(DOMException.INDEX_SIZE_ERR);
+ }
+ }
+
+ /**
+ * <b>DOM L1</b>
+ * Modifies the value of this node. Causes DOMCharacterDataModified
+ * mutation events to be reported (at least one).
+ */
+ public void replaceData(int offset, int count, String arg)
+ {
+ if (readonly)
+ {
+ throw new DomDOMException(DOMException.NO_MODIFICATION_ALLOWED_ERR);
+ }
+ char[] raw = text.toCharArray();
+
+ // deleteData
+ if (offset < 0 || count < 0 || offset > raw.length)
+ {
+ throw new DomDOMException(DOMException.INDEX_SIZE_ERR);
+ }
+ if ((offset + count) > raw.length)
+ {
+ count = raw.length - offset;
+ }
+ try
+ {
+ char[] buf = new char[raw.length - count];
+ System.arraycopy(raw, 0, buf, 0, offset);
+ System.arraycopy(raw, offset + count, buf, offset,
+ raw.length - (offset + count));
+
+ // insertData
+ char[] tmp = arg.toCharArray ();
+ char[] buf2 = new char[buf.length + tmp.length];
+ System.arraycopy(raw, 0, buf, 0, offset);
+ System.arraycopy(tmp, 0, buf, offset, tmp.length);
+ System.arraycopy(raw, offset, buf, offset + tmp.length,
+ raw.length - offset);
+ String value = new String(buf);
+ mutating(value);
+ text = value;
+ }
+ catch (IndexOutOfBoundsException x)
+ {
+ throw new DomDOMException(DOMException.INDEX_SIZE_ERR);
+ }
+ }
+
+ /**
+ * <b>DOM L1</b>
+ * Assigns the value of this node.
+ * Causes a DOMCharacterDataModified mutation event to be reported.
+ */
+ public void setNodeValue(String value)
+ {
+ if (isReadonly())
+ {
+ throw new DomDOMException(DOMException.NO_MODIFICATION_ALLOWED_ERR);
+ }
+ if (value == null)
+ {
+ value = "";
+ }
+ mutating(value);
+ text = value;
+ }
+
+ /**
+ * <b>DOM L1</b>
+ * Assigns the value of this node; same as setNodeValue.
+ */
+ final public void setData(String data)
+ {
+ setNodeValue(data);
+ }
+
+ /**
+ * <b>DOM L1</b>
+ * Returns the specified substring.
+ */
+ public String substringData(int offset, int count)
+ {
+ try
+ {
+ return text.substring(offset, count);
+ }
+ catch (StringIndexOutOfBoundsException e)
+ {
+ if (offset >= 0 && count >= 0 && offset < text.length())
+ {
+ return text.substring(offset);
+ }
+ throw new DomDOMException(DOMException.INDEX_SIZE_ERR);
+ }
+ }
+
+ /**
+ * Returns an empty node list.
+ * Character data nodes do not have children.
+ */
+ public NodeList getChildNodes()
+ {
+ return CHILD_NODES;
+ }
+
+ /**
+ * The base URI for character data is <code>null</code>.
+ * @since DOM Level 3 Core
+ */
+ public final String getBaseURI()
+ {
+ return null;
+ }
+
+ private void mutating(String newValue)
+ {
+ if (!reportMutations)
+ {
+ return;
+ }
+
+ // EVENT: DOMCharacterDataModified, target = this,
+ // prev/new values provided
+ MutationEvent event;
+
+ event = (MutationEvent) createEvent("MutationEvents");
+ event.initMutationEvent("DOMCharacterDataModified",
+ true /* bubbles */, false /* nocancel */,
+ null, text, newValue, null, (short) 0);
+ dispatchEvent(event);
+ }
+
+}
+
Added: llvm-gcc-4.2/trunk/libjava/classpath/gnu/xml/dom/DomComment.java
URL: http://llvm.org/viewvc/llvm-project/llvm-gcc-4.2/trunk/libjava/classpath/gnu/xml/dom/DomComment.java?rev=43913&view=auto
==============================================================================
--- llvm-gcc-4.2/trunk/libjava/classpath/gnu/xml/dom/DomComment.java (added)
+++ llvm-gcc-4.2/trunk/libjava/classpath/gnu/xml/dom/DomComment.java Thu Nov 8 16:56:19 2007
@@ -0,0 +1,81 @@
+/* DomComment.java --
+ Copyright (C) 1999,2000,2001,2004 Free Software Foundation, Inc.
+
+This file is part of GNU Classpath.
+
+GNU Classpath is free software; you can redistribute it and/or modify
+it under the terms of the GNU General Public License as published by
+the Free Software Foundation; either version 2, or (at your option)
+any later version.
+
+GNU Classpath is distributed in the hope that it will be useful, but
+WITHOUT ANY WARRANTY; without even the implied warranty of
+MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+General Public License for more details.
+
+You should have received a copy of the GNU General Public License
+along with GNU Classpath; see the file COPYING. If not, write to the
+Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA
+02110-1301 USA.
+
+Linking this library statically or dynamically with other modules is
+making a combined work based on this library. Thus, the terms and
+conditions of the GNU General Public License cover the whole
+combination.
+
+As a special exception, the copyright holders of this library give you
+permission to link this library with independent modules to produce an
+executable, regardless of the license terms of these independent
+modules, and to copy and distribute the resulting executable under
+terms of your choice, provided that you also meet, for each linked
+independent module, the terms and conditions of the license of that
+module. An independent module is a module which is not derived from
+or based on this library. If you modify this library, you may extend
+this exception to your version of the library, but you are not
+obligated to do so. If you do not wish to do so, delete this
+exception statement from your version. */
+
+package gnu.xml.dom;
+
+import org.w3c.dom.Comment;
+
+/**
+ * <p> "Comment" implementation.
+ * Comments hold data intended for direct consumption by people;
+ * programs should only use ProcessingInstruction nodes. Note that
+ * since SAX makes comment reporting optional, XML systems that
+ * rely on comments (such as by using this class) will often lose
+ * those comments at some point in the processing pipeline. </p>
+ *
+ * @author David Brownell
+ * @author <a href='mailto:dog at gnu.org'>Chris Burdess</a>
+ */
+public class DomComment
+ extends DomCharacterData
+ implements Comment
+{
+
+ /**
+ * Constructs a comment node associated with the specified
+ * document and holding the specified data.
+ *
+ * <p>This constructor should only be invoked by a Document as part of
+ * its createComment functionality, or through a subclass which is
+ * similarly used in a "Sub-DOM" style layer.
+ */
+ protected DomComment(DomDocument owner, String value)
+ {
+ super(COMMENT_NODE, owner, value);
+ }
+
+ /**
+ * <b>DOM L1</b>
+ * Returns the string "#comment".
+ */
+ final public String getNodeName()
+ {
+ return "#comment";
+ }
+
+}
+
Added: llvm-gcc-4.2/trunk/libjava/classpath/gnu/xml/dom/DomDOMException.java
URL: http://llvm.org/viewvc/llvm-project/llvm-gcc-4.2/trunk/libjava/classpath/gnu/xml/dom/DomDOMException.java?rev=43913&view=auto
==============================================================================
--- llvm-gcc-4.2/trunk/libjava/classpath/gnu/xml/dom/DomDOMException.java (added)
+++ llvm-gcc-4.2/trunk/libjava/classpath/gnu/xml/dom/DomDOMException.java Thu Nov 8 16:56:19 2007
@@ -0,0 +1,175 @@
+/* DomDOMException.java --
+ Copyright (C) 1999,2000,2001,2004 Free Software Foundation, Inc.
+
+This file is part of GNU Classpath.
+
+GNU Classpath is free software; you can redistribute it and/or modify
+it under the terms of the GNU General Public License as published by
+the Free Software Foundation; either version 2, or (at your option)
+any later version.
+
+GNU Classpath is distributed in the hope that it will be useful, but
+WITHOUT ANY WARRANTY; without even the implied warranty of
+MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+General Public License for more details.
+
+You should have received a copy of the GNU General Public License
+along with GNU Classpath; see the file COPYING. If not, write to the
+Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA
+02110-1301 USA.
+
+Linking this library statically or dynamically with other modules is
+making a combined work based on this library. Thus, the terms and
+conditions of the GNU General Public License cover the whole
+combination.
+
+As a special exception, the copyright holders of this library give you
+permission to link this library with independent modules to produce an
+executable, regardless of the license terms of these independent
+modules, and to copy and distribute the resulting executable under
+terms of your choice, provided that you also meet, for each linked
+independent module, the terms and conditions of the license of that
+module. An independent module is a module which is not derived from
+or based on this library. If you modify this library, you may extend
+this exception to your version of the library, but you are not
+obligated to do so. If you do not wish to do so, delete this
+exception statement from your version. */
+
+package gnu.xml.dom;
+
+import org.w3c.dom.DOMException;
+import org.w3c.dom.Node;
+
+/**
+ * <p> DOMException implementation. The version that
+ * is provided by the W3C is abstract, so it can't be instantiated.
+ *
+ * <p> This also provides a bit more information about the error
+ * that is being reported, in terms of the relevant DOM structures
+ * and data.
+ *
+ * @author David Brownell
+ */
+public class DomDOMException
+ extends DOMException
+{
+
+ /** @serial Data that caused an error to be reported */
+ private String data;
+
+ /** @serial Node associated with the error. */
+ private Node node;
+
+ /** @serial Data associated with the error. */
+ private int value;
+
+ /**
+ * Constructs an exception, with the diagnostic message
+ * corresponding to the specified code.
+ */
+ public DomDOMException(short code)
+ {
+ super(code, diagnostic(code));
+ }
+
+ /**
+ * Constructs an exception, with the diagnostic message
+ * corresponding to the specified code and additional
+ * information as provided.
+ */
+ public DomDOMException(short code, String data, Node node, int value)
+ {
+ super(code, diagnostic(code));
+ this.data = data;
+ this.node = node;
+ this.value = value;
+ }
+
+ /** Returns the node to which the diagnotic applies, or null. */
+ final public Node getNode()
+ {
+ return node;
+ }
+
+ /** Returns data to which the diagnotic applies, or null. */
+ final public String getData()
+ {
+ return data;
+ }
+
+ /** Returns data to which the diagnotic applies, or null. */
+ final public int getValue()
+ {
+ return value;
+ }
+
+ /**
+ * Returns a diagnostic message that may be slightly more useful
+ * than the generic one, where possible.
+ */
+ public String getMessage()
+ {
+ String retval = super.getMessage();
+
+ if (data != null)
+ {
+ retval += "\nMore Information: " + data;
+ }
+ if (value != 0)
+ {
+ retval += "\nNumber: " + value;
+ }
+ if (node != null)
+ {
+ retval += "\nNode Name: " + node.getNodeName();
+ }
+ return retval;
+ }
+
+ // these strings should be localizable.
+
+ private static String diagnostic(short code)
+ {
+ switch (code)
+ {
+ // DOM L1:
+ case INDEX_SIZE_ERR:
+ return "An index or size is out of range.";
+ case DOMSTRING_SIZE_ERR:
+ return "A string is too big.";
+ case HIERARCHY_REQUEST_ERR:
+ return "The node doesn't belong here.";
+ case WRONG_DOCUMENT_ERR:
+ return "The node belongs in another document.";
+ case INVALID_CHARACTER_ERR:
+ return "That character is not permitted.";
+ case NO_DATA_ALLOWED_ERR:
+ return "This node does not permit data.";
+ case NO_MODIFICATION_ALLOWED_ERR:
+ return "No changes are allowed.";
+ case NOT_FOUND_ERR:
+ return "The node was not found in that context.";
+ case NOT_SUPPORTED_ERR:
+ return "That object is not supported.";
+ case INUSE_ATTRIBUTE_ERR:
+ return "The attribute belongs to a different element.";
+
+ // DOM L2:
+ case INVALID_STATE_ERR:
+ return "The object is not usable.";
+ case SYNTAX_ERR:
+ return "An illegal string was provided.";
+ case INVALID_MODIFICATION_ERR:
+ return "An object's type may not be changed.";
+ case NAMESPACE_ERR:
+ return "The operation violates XML Namespaces.";
+ case INVALID_ACCESS_ERR:
+ return "Parameter or operation isn't supported by this node.";
+ case TYPE_MISMATCH_ERR:
+ return "The type of the argument is incompatible with the expected type.";
+ }
+ return "Reserved exception number: " + code;
+ }
+
+}
+
Added: llvm-gcc-4.2/trunk/libjava/classpath/gnu/xml/dom/DomDoctype.java
URL: http://llvm.org/viewvc/llvm-project/llvm-gcc-4.2/trunk/libjava/classpath/gnu/xml/dom/DomDoctype.java?rev=43913&view=auto
==============================================================================
--- llvm-gcc-4.2/trunk/libjava/classpath/gnu/xml/dom/DomDoctype.java (added)
+++ llvm-gcc-4.2/trunk/libjava/classpath/gnu/xml/dom/DomDoctype.java Thu Nov 8 16:56:19 2007
@@ -0,0 +1,455 @@
+/* DomDoctype.java --
+ Copyright (C) 1999,2000,2001,2004 Free Software Foundation, Inc.
+
+This file is part of GNU Classpath.
+
+GNU Classpath is free software; you can redistribute it and/or modify
+it under the terms of the GNU General Public License as published by
+the Free Software Foundation; either version 2, or (at your option)
+any later version.
+
+GNU Classpath is distributed in the hope that it will be useful, but
+WITHOUT ANY WARRANTY; without even the implied warranty of
+MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+General Public License for more details.
+
+You should have received a copy of the GNU General Public License
+along with GNU Classpath; see the file COPYING. If not, write to the
+Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA
+02110-1301 USA.
+
+Linking this library statically or dynamically with other modules is
+making a combined work based on this library. Thus, the terms and
+conditions of the GNU General Public License cover the whole
+combination.
+
+As a special exception, the copyright holders of this library give you
+permission to link this library with independent modules to produce an
+executable, regardless of the license terms of these independent
+modules, and to copy and distribute the resulting executable under
+terms of your choice, provided that you also meet, for each linked
+independent module, the terms and conditions of the license of that
+module. An independent module is a module which is not derived from
+or based on this library. If you modify this library, you may extend
+this exception to your version of the library, but you are not
+obligated to do so. If you do not wish to do so, delete this
+exception statement from your version. */
+
+package gnu.xml.dom;
+
+import java.util.HashMap;
+import org.w3c.dom.DocumentType;
+import org.w3c.dom.DOMException;
+import org.w3c.dom.DOMImplementation;
+import org.w3c.dom.Entity;
+import org.w3c.dom.NamedNodeMap;
+import org.w3c.dom.Node;
+import org.w3c.dom.Notation;
+
+/**
+ * <p> "DocumentType" implementation (with no extensions for supporting
+ * any document typing information). This is a non-core DOM class,
+ * supporting the "XML" feature. </p>
+ *
+ * <p> <em>Few XML applications will actually care about this partial
+ * DTD support</em>, since it doesn't expose any (!) of the data typing
+ * facilities which can motivate applications to use DTDs. It does not
+ * expose element content models, or information about attribute typing
+ * rules. Plus the information it exposes isn't very useful; as one example,
+ * DOM exposes information about unparsed ENTITY objects, which is only used
+ * with certain element attributes, but does not expose the information about
+ * those attributes which is needed to apply that data! </p>
+ *
+ * <p> Also, note that there are no nonportable ways to associate even the
+ * notation and entity information exposed by DOM with a DocumentType. While
+ * there is a DOM L2 method to construct a DocumentType, it only gives access
+ * to the textual content of the <!DOCTYPE ...> declaration. </p>
+ *
+ * <p> In short, <em>you are strongly advised not to rely on this incomplete
+ * DTD functionality</em> in your application code.</p>
+ *
+ * @see DomEntity
+ * @see DomEntityReference
+ * @see DomNotation
+ *
+ * @author David Brownell
+ * @author <a href='mailto:dog at gnu.org'>Chris Burdess</a>
+ */
+public class DomDoctype
+ extends DomExtern
+ implements DocumentType
+{
+
+ private DomNamedNodeMap notations;
+ private DomNamedNodeMap entities;
+ private final DOMImplementation implementation;
+ private String subset;
+
+ private HashMap elements = new HashMap();
+ private boolean ids;
+
+ /**
+ * Constructs a DocumentType node associated with the specified
+ * implementation, with the specified name.
+ *
+ * <p>This constructor should only be invoked by a DOMImplementation as
+ * part of its createDocumentType functionality, or through a subclass
+ * which is similarly used in a "Sub-DOM" style layer.
+ *
+ * <p> Note that at this time there is no standard SAX API granting
+ * access to the internal subset text, so that relying on that value
+ * is not currently portable.
+ *
+ * @param impl The implementation with which this object is associated
+ * @param name Name of this root element
+ * @param publicId If non-null, provides the external subset's
+ * PUBLIC identifier
+ * @param systemId If non-null, provides the external subset's
+ * SYSTEM identifier
+ * @param internalSubset Provides the literal value (unparsed, no
+ * entities expanded) of the DTD's internal subset.
+ */
+ protected DomDoctype(DOMImplementation impl,
+ String name,
+ String publicId,
+ String systemId,
+ String internalSubset)
+ {
+ super(DOCUMENT_TYPE_NODE, null, name, publicId, systemId);
+ implementation = impl;
+ subset = internalSubset;
+ }
+
+ /**
+ * JAXP builder constructor.
+ * @param doc the document
+ * @param name the name of the document element
+ * @param publicId the public ID of the document type declaration
+ * @param systemId the system ID of the document type declaration
+ */
+ public DomDoctype(DomDocument doc,
+ String name,
+ String publicId,
+ String systemId)
+ {
+ super(DOCUMENT_TYPE_NODE, doc, name, publicId, systemId);
+ implementation = doc.getImplementation();
+ }
+
+ /**
+ * <b>DOM L1</b>
+ * Returns the root element's name (just like getNodeName).
+ */
+ final public String getName()
+ {
+ return getNodeName();
+ }
+
+ /**
+ * <b>DOM L1</b>
+ * Returns information about any general entities declared
+ * in the DTD.
+ *
+ * <p><em>Note: DOM L1 doesn't throw a DOMException here, but
+ * then it doesn't have the strange construction rules of L2.</em>
+ *
+ * @exception DOMException HIERARCHY_REQUEST_ERR if the DocumentType
+ * is not associated with a document.
+ */
+ public NamedNodeMap getEntities()
+ {
+ if (entities == null)
+ {
+ entities = new DomNamedNodeMap(this, Node.ENTITY_NODE);
+ }
+ return entities;
+ }
+
+ /**
+ * Records the declaration of a general entity in this DocumentType.
+ *
+ * @param name Name of the entity
+ * @param publicId If non-null, provides the entity's PUBLIC identifier
+ * @param systemId Provides the entity's SYSTEM identifier
+ * @param notation If non-null, provides the entity's notation
+ * (indicating an unparsed entity)
+ * @return The Entity that was declared, or null if the entity wasn't
+ * recorded (because it's a parameter entity or because an entity with
+ * this name was already declared).
+ *
+ * @exception DOMException NO_MODIFICATION_ALLOWED_ERR if the
+ * DocumentType is no longer writable.
+ * @exception DOMException HIERARCHY_REQUEST_ERR if the DocumentType
+ * is not associated with a document.
+ */
+ public Entity declareEntity(String name,
+ String publicId,
+ String systemId,
+ String notation)
+ {
+ DomEntity entity;
+
+ if (name.charAt(0) == '%' || "[dtd]".equals(name))
+ {
+ return null;
+ }
+ if (isReadonly())
+ {
+ throw new DomDOMException(DOMException.NO_MODIFICATION_ALLOWED_ERR);
+ }
+ getEntities();
+
+ DomDocument.checkName(name, (owner != null) ?
+ "1.1".equals(owner.getXmlVersion()) : false);
+ if (entities.getNamedItem(name) != null)
+ {
+ return null;
+ }
+
+ entity = new DomEntity(owner, name, publicId, systemId, notation);
+ entities.setNamedItem(entity);
+ return entity;
+ }
+
+ /**
+ * <b>DOM L1</b>
+ * Returns information about any notations declared in the DTD.
+ *
+ * <p><em>Note: DOM L1 doesn't throw a DOMException here, but
+ * then it doesn't have the strange construction rules of L2.</em>
+ *
+ * @exception DOMException HIERARCHY_REQUEST_ERR if the DocumentType
+ * is not associated with a document.
+ */
+ public NamedNodeMap getNotations()
+ {
+ if (notations == null)
+ {
+ notations = new DomNamedNodeMap(this, Node.NOTATION_NODE);
+ }
+ return notations;
+ }
+
+ /**
+ * Records the declaration of a notation in this DocumentType.
+ *
+ * @param name Name of the notation
+ * @param publicId If non-null, provides the notation's PUBLIC identifier
+ * @param systemId If non-null, provides the notation's SYSTEM identifier
+ * @return The notation that was declared.
+ *
+ * @exception DOMException NO_MODIFICATION_ALLOWED_ERR if the
+ * DocumentType is no longer writable.
+ * @exception DOMException HIERARCHY_REQUEST_ERR if the DocumentType
+ * is not associated with a document.
+ */
+ public Notation declareNotation(String name,
+ String publicId,
+ String systemId)
+ {
+ DomNotation notation;
+
+ if (isReadonly())
+ {
+ throw new DomDOMException(DOMException.NO_MODIFICATION_ALLOWED_ERR);
+ }
+ getNotations();
+
+ DomDocument.checkName(name, (owner != null) ?
+ "1.1".equals(owner.getXmlVersion()) : false);
+
+ notation = new DomNotation(owner, name, publicId, systemId);
+ notations.setNamedItem(notation);
+ return notation;
+ }
+
+ /**
+ * <b>DOM L2</b>
+ * Returns the internal subset of the document, as a string of unparsed
+ * XML declarations (and comments, PIs, whitespace); or returns null if
+ * there is no such subset. There is no vendor-independent expectation
+ * that this attribute be set, or that declarations found in it be
+ * reflected in the <em>entities</em> or <em>notations</em> attributes
+ * of this Document "Type" object.
+ *
+ * <p> Some application-specific XML profiles require that documents
+ * only use specific PUBLIC identifiers, without an internal subset
+ * to modify the interperetation of the declarations associated with
+ * that PUBLIC identifier through some standard.
+ */
+ public String getInternalSubset()
+ {
+ return subset;
+ }
+
+ /**
+ * The base URI of a DocumentType is always <code>null</code>.
+ * See the Infoset Mapping, appendix C.
+ */
+ public final String getBaseURI()
+ {
+ return null;
+ }
+
+ /**
+ * Sets the internal "readonly" flag so the node and its associated
+ * data (only lists of entities and notations, no type information
+ * at the moment) can't be changed.
+ */
+ public void makeReadonly()
+ {
+ super.makeReadonly();
+ if (entities != null)
+ {
+ entities.makeReadonly();
+ }
+ if (notations != null)
+ {
+ notations.makeReadonly();
+ }
+ }
+
+ void setOwner(DomDocument doc)
+ {
+ if (entities != null)
+ {
+ for (DomNode ctx = entities.first; ctx != null; ctx = ctx.next)
+ {
+ ctx.setOwner(doc);
+ }
+ }
+ if (notations != null)
+ {
+ for (DomNode ctx = notations.first; ctx != null; ctx = ctx.next)
+ {
+ ctx.setOwner(doc);
+ }
+ }
+ super.setOwner(doc);
+ }
+
+ /**
+ * <b>DOM L2</b>
+ * Consults the DOM implementation to determine if the requested
+ * feature is supported.
+ */
+ final public boolean supports(String feature, String version)
+ {
+ return implementation.hasFeature(feature, version);
+ }
+
+ /**
+ * Returns the implementation associated with this document type.
+ */
+ final public DOMImplementation getImplementation()
+ {
+ return implementation;
+ }
+
+ public void elementDecl(String name, String model)
+ {
+ DTDElementTypeInfo info = getElementTypeInfo(name);
+ if (info == null)
+ {
+ info = new DTDElementTypeInfo(name, model);
+ elements.put(name, info);
+ }
+ else
+ {
+ info.model = model;
+ }
+ }
+
+ DTDElementTypeInfo getElementTypeInfo(String name)
+ {
+ return (DTDElementTypeInfo) elements.get(name);
+ }
+
+ public void attributeDecl(String eName, String aName, String type,
+ String mode, String value)
+ {
+ DTDAttributeTypeInfo info = new DTDAttributeTypeInfo(eName, aName, type,
+ mode, value);
+ DTDElementTypeInfo elementInfo = getElementTypeInfo(eName);
+ if (elementInfo == null)
+ {
+ elementInfo = new DTDElementTypeInfo(eName, null);
+ elements.put(eName, elementInfo);
+ }
+ elementInfo.setAttributeTypeInfo(aName, info);
+ if ("ID".equals(type))
+ {
+ ids = true;
+ }
+ }
+
+ DTDAttributeTypeInfo getAttributeTypeInfo(String elementName, String name)
+ {
+ DTDElementTypeInfo elementInfo =
+ (DTDElementTypeInfo) elements.get(elementName);
+ return (elementInfo == null) ? null :
+ elementInfo.getAttributeTypeInfo(name);
+ }
+
+ boolean hasIds()
+ {
+ return ids;
+ }
+
+ public boolean isSameNode(Node arg)
+ {
+ if (equals(arg))
+ {
+ return true;
+ }
+ if (!(arg instanceof DocumentType))
+ {
+ return false;
+ }
+ DocumentType doctype = (DocumentType) arg;
+ if (!equal(getPublicId(), doctype.getPublicId()))
+ {
+ return false;
+ }
+ if (!equal(getSystemId(), doctype.getSystemId()))
+ {
+ return false;
+ }
+ if (!equal(getInternalSubset(), doctype.getInternalSubset()))
+ {
+ return false;
+ }
+ // TODO entities
+ // TODO notations
+ return true;
+ }
+
+ /**
+ * Shallow clone of the doctype, except that associated
+ * entities and notations are (deep) cloned.
+ */
+ public Object clone()
+ {
+ DomDoctype node = (DomDoctype) super.clone();
+
+ if (entities != null)
+ {
+ node.entities = new DomNamedNodeMap(node, Node.ENTITY_NODE);
+ for (DomNode ctx = entities.first; ctx != null; ctx = ctx.next)
+ {
+ node.entities.setNamedItem(ctx.cloneNode(true));
+ }
+ }
+ if (notations != null)
+ {
+ node.notations = new DomNamedNodeMap(node, Node.NOTATION_NODE);
+ for (DomNode ctx = notations.first; ctx != null; ctx = ctx.next)
+ {
+ node.notations.setNamedItem(ctx.cloneNode(true));
+ }
+ }
+ return node;
+ }
+
+
+}
Added: llvm-gcc-4.2/trunk/libjava/classpath/gnu/xml/dom/DomDocument.java
URL: http://llvm.org/viewvc/llvm-project/llvm-gcc-4.2/trunk/libjava/classpath/gnu/xml/dom/DomDocument.java?rev=43913&view=auto
==============================================================================
--- llvm-gcc-4.2/trunk/libjava/classpath/gnu/xml/dom/DomDocument.java (added)
+++ llvm-gcc-4.2/trunk/libjava/classpath/gnu/xml/dom/DomDocument.java Thu Nov 8 16:56:19 2007
@@ -0,0 +1,1543 @@
+/* DomDocument.java --
+ Copyright (C) 1999,2000,2001,2004 Free Software Foundation, Inc.
+
+This file is part of GNU Classpath.
+
+GNU Classpath is free software; you can redistribute it and/or modify
+it under the terms of the GNU General Public License as published by
+the Free Software Foundation; either version 2, or (at your option)
+any later version.
+
+GNU Classpath is distributed in the hope that it will be useful, but
+WITHOUT ANY WARRANTY; without even the implied warranty of
+MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+General Public License for more details.
+
+You should have received a copy of the GNU General Public License
+along with GNU Classpath; see the file COPYING. If not, write to the
+Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA
+02110-1301 USA.
+
+Linking this library statically or dynamically with other modules is
+making a combined work based on this library. Thus, the terms and
+conditions of the GNU General Public License cover the whole
+combination.
+
+As a special exception, the copyright holders of this library give you
+permission to link this library with independent modules to produce an
+executable, regardless of the license terms of these independent
+modules, and to copy and distribute the resulting executable under
+terms of your choice, provided that you also meet, for each linked
+independent module, the terms and conditions of the license of that
+module. An independent module is a module which is not derived from
+or based on this library. If you modify this library, you may extend
+this exception to your version of the library, but you are not
+obligated to do so. If you do not wish to do so, delete this
+exception statement from your version. */
+
+package gnu.xml.dom;
+
+import java.util.Iterator;
+import javax.xml.XMLConstants;
+
+import org.w3c.dom.Attr;
+import org.w3c.dom.CDATASection;
+import org.w3c.dom.Comment;
+import org.w3c.dom.Document;
+import org.w3c.dom.DocumentFragment;
+import org.w3c.dom.DocumentType;
+import org.w3c.dom.DOMConfiguration;
+import org.w3c.dom.DOMImplementation;
+import org.w3c.dom.DOMException;
+import org.w3c.dom.Element;
+import org.w3c.dom.Entity;
+import org.w3c.dom.EntityReference;
+import org.w3c.dom.NamedNodeMap;
+import org.w3c.dom.Node;
+import org.w3c.dom.Notation;
+import org.w3c.dom.ProcessingInstruction;
+import org.w3c.dom.Text;
+import org.w3c.dom.UserDataHandler;
+import org.w3c.dom.traversal.DocumentTraversal;
+import org.w3c.dom.traversal.NodeFilter;
+import org.w3c.dom.traversal.NodeIterator;
+import org.w3c.dom.traversal.TreeWalker;
+import org.w3c.dom.xpath.XPathEvaluator;
+import org.w3c.dom.xpath.XPathException;
+import org.w3c.dom.xpath.XPathExpression;
+import org.w3c.dom.xpath.XPathNSResolver;
+
+/**
+ * <p> "Document" and "DocumentTraversal" implementation.
+ *
+ * <p> Note that when this checks names for legality, it uses an
+ * approximation of the XML rules, not the real ones. Specifically,
+ * it uses Unicode rules, with sufficient tweaks to pass a majority
+ * of basic XML conformance tests. (The huge XML character tables are
+ * hairy to implement.)
+ *
+ * @author David Brownell
+ * @author <a href='mailto:dog at gnu.org'>Chris Burdess</a>
+ */
+public class DomDocument
+ extends DomNode
+ implements Document, DocumentTraversal, XPathEvaluator
+{
+
+ private final DOMImplementation implementation;
+ private boolean checkingCharacters = true;
+ boolean checkingWellformedness = true;
+
+ boolean building; // if true, skip mutation events in the tree
+
+ DomDocumentConfiguration config;
+
+ String inputEncoding;
+ String encoding;
+ String version = "1.0";
+ boolean standalone;
+ String systemId;
+
+ /**
+ * Constructs a Document node, associating it with an instance
+ * of the DomImpl class.
+ *
+ * <p> Note that this constructor disables character checking.
+ * It is normally used when connecting a DOM to an XML parser,
+ * and duplicating such checks is undesirable. When used for
+ * purposes other than connecting to a parser, you should
+ * re-enable that checking.
+ *
+ * @see #setCheckingCharacters
+ */
+ public DomDocument()
+ {
+ this(new DomImpl());
+ }
+
+ /**
+ * Constructs a Document node, associating it with the specified
+ * implementation. This should only be used in conjunction with
+ * a specialized implementation; it will normally be called by
+ * that implementation.
+ *
+ * @see DomImpl
+ * @see #setCheckingCharacters
+ */
+ protected DomDocument(DOMImplementation impl)
+ {
+ super(DOCUMENT_NODE, null);
+ implementation = impl;
+ }
+
+ /**
+ * Sets the <code>building</code> flag.
+ * Mutation events in the document are not reported.
+ */
+ public void setBuilding(boolean flag)
+ {
+ building = flag;
+ }
+
+ /**
+ * Sets whether to check for document well-formedness.
+ * If true, an exception will be raised if a second doctype or root
+ * element node is added to the document.
+ */
+ public void setCheckWellformedness(boolean flag)
+ {
+ checkingWellformedness = flag;
+ }
+
+ /**
+ * Sets whether to check for document characters.
+ */
+ public void setCheckingCharacters(boolean flag)
+ {
+ checkingCharacters = flag;
+ }
+
+ /**
+ * <b>DOM L1</b>
+ * Returns the constant "#document".
+ */
+ final public String getNodeName()
+ {
+ return "#document";
+ }
+
+ /**
+ * <b>DOM L1</b>
+ * Returns the document's root element, or null.
+ */
+ final public Element getDocumentElement()
+ {
+ for (DomNode ctx = first; ctx != null; ctx = ctx.next)
+ {
+ if (ctx.nodeType == ELEMENT_NODE)
+ {
+ return (Element) ctx;
+ }
+ }
+ return null;
+ }
+
+ /**
+ * <b>DOM L1</b>
+ * Returns the document's DocumentType, or null.
+ */
+ final public DocumentType getDoctype()
+ {
+ for (DomNode ctx = first; ctx != null; ctx = ctx.next)
+ {
+ if (ctx.nodeType == DOCUMENT_TYPE_NODE)
+ {
+ return (DocumentType) ctx;
+ }
+ }
+ return null;
+ }
+
+ /**
+ * <b>DOM L1</b>
+ * Returns the document's DOMImplementation.
+ */
+ final public DOMImplementation getImplementation()
+ {
+ return implementation;
+ }
+
+ /**
+ * <b>DOM L1 (relocated in DOM L2)</b>
+ * Returns the element with the specified "ID" attribute, or null.
+ *
+ * <p>Returns null unless {@link Consumer} was used to populate internal
+ * DTD declaration information, using package-private APIs. If that
+ * internal DTD information is available, the document may be searched for
+ * the element with that ID.
+ */
+ public Element getElementById(String id)
+ {
+ if (id == null || id.length() == 0)
+ {
+ return null;
+ }
+ DomDoctype doctype = (DomDoctype) getDoctype();
+ if (doctype != null && !doctype.hasIds())
+ {
+ doctype = null;
+ }
+
+ // yes, this is linear in size of document.
+ // it'd be easy enough to maintain a hashtable.
+ Node current = getDocumentElement();
+ Node temp;
+
+ if (current == null)
+ {
+ return null;
+ }
+ while (current != this)
+ {
+ // done?
+ if (current.getNodeType() == ELEMENT_NODE)
+ {
+ DomElement element = (DomElement) current;
+ if (element.userIdAttrs != null)
+ {
+ for (Iterator i = element.userIdAttrs.iterator();
+ i.hasNext(); )
+ {
+ Node idAttr = (Node) i.next();
+ if (id.equals(idAttr.getNodeValue()))
+ {
+ return element;
+ }
+ }
+ }
+ if (doctype != null)
+ {
+ DTDElementTypeInfo info =
+ doctype.getElementTypeInfo(current.getNodeName());
+ if (info != null &&
+ id.equals(element.getAttribute(info.idAttrName)))
+ {
+ return element;
+ }
+ }
+ // xml:id
+ String xmlId = element.getAttribute("xml:id");
+ if (xmlId == null)
+ {
+ xmlId = element.getAttributeNS(XMLConstants.XML_NS_URI,
+ "id");
+ }
+ if (id.equals(xmlId))
+ {
+ return element;
+ }
+ }
+
+ // descend?
+ if (current.hasChildNodes())
+ {
+ current = current.getFirstChild();
+ continue;
+ }
+
+ // lateral?
+ temp = current.getNextSibling();
+ if (temp != null)
+ {
+ current = temp;
+ continue;
+ }
+
+ // back up ...
+ do
+ {
+ temp = current.getParentNode();
+ if (temp == null)
+ {
+ return null;
+ }
+ current = temp;
+ temp = current.getNextSibling();
+ }
+ while (temp == null);
+ current = temp;
+ }
+ return null;
+ }
+
+ private void checkNewChild(Node newChild)
+ {
+ if (newChild.getNodeType() == ELEMENT_NODE
+ && getDocumentElement() != null)
+ {
+ throw new DomDOMException(DOMException.HIERARCHY_REQUEST_ERR,
+ "document element already present: " +
+ getDocumentElement(), newChild, 0);
+ }
+ if (newChild.getNodeType() == DOCUMENT_TYPE_NODE
+ && getDoctype() != null)
+ {
+ throw new DomDOMException(DOMException.HIERARCHY_REQUEST_ERR,
+ "document type already present: " +
+ getDoctype(), newChild, 0);
+ }
+ }
+
+ /**
+ * <b>DOM L1</b>
+ * Appends the specified node to this node's list of children,
+ * enforcing the constraints that there be only one root element
+ * and one document type child.
+ */
+ public Node appendChild(Node newChild)
+ {
+ if (checkingWellformedness)
+ {
+ checkNewChild(newChild);
+ }
+ return super.appendChild(newChild);
+ }
+
+ /**
+ * <b>DOM L1</b>
+ * Inserts the specified node in this node's list of children,
+ * enforcing the constraints that there be only one root element
+ * and one document type child.
+ */
+ public Node insertBefore(Node newChild, Node refChild)
+ {
+ if (checkingWellformedness)
+ {
+ checkNewChild(newChild);
+ }
+ return super.insertBefore(newChild, refChild);
+ }
+
+ /**
+ * <b>DOM L1</b>
+ * Replaces the specified node in this node's list of children,
+ * enforcing the constraints that there be only one root element
+ * and one document type child.
+ */
+ public Node replaceChild(Node newChild, Node refChild)
+ {
+ if (checkingWellformedness &&
+ ((newChild.getNodeType() == ELEMENT_NODE &&
+ refChild.getNodeType() != ELEMENT_NODE) ||
+ (newChild.getNodeType() == DOCUMENT_TYPE_NODE &&
+ refChild.getNodeType() != DOCUMENT_TYPE_NODE)))
+ {
+ checkNewChild(newChild);
+ }
+ return super.replaceChild(newChild, refChild);
+ }
+
+ // NOTE: DOM can't really tell when the name of an entity,
+ // notation, or PI must follow the namespace rules (excluding
+ // colons) instead of the XML rules (which allow them without
+ // much restriction). That's an API issue. verifyXmlName
+ // aims to enforce the XML rules, not the namespace rules.
+
+ /**
+ * Throws a DOM exception if the specified name is not a legal XML 1.0
+ * Name.
+ * @deprecated This method is deprecated and may be removed in future
+ * versions of GNU JAXP
+ */
+ public static void verifyXmlName(String name)
+ {
+ // XXX why is this public?
+ checkName(name, false);
+ }
+
+ static void checkName(String name, boolean xml11)
+ {
+ if (name == null)
+ {
+ throw new DomDOMException(DOMException.NAMESPACE_ERR, name, null, 0);
+ }
+ int len = name.length();
+ if (len == 0)
+ {
+ throw new DomDOMException(DOMException.NAMESPACE_ERR, name, null, 0);
+ }
+
+ // dog: rewritten to use the rules for XML 1.0 and 1.1
+
+ // Name start character
+ char c = name.charAt(0);
+ if (xml11)
+ {
+ // XML 1.1
+ if ((c < 0x0041 || c > 0x005a) &&
+ (c < 0x0061 || c > 0x007a) &&
+ c != ':' && c != '_' &&
+ (c < 0x00c0 || c > 0x00d6) &&
+ (c < 0x00d8 || c > 0x00f6) &&
+ (c < 0x00f8 || c > 0x02ff) &&
+ (c < 0x0370 || c > 0x037d) &&
+ (c < 0x037f || c > 0x1fff) &&
+ (c < 0x200c || c > 0x200d) &&
+ (c < 0x2070 || c > 0x218f) &&
+ (c < 0x2c00 || c > 0x2fef) &&
+ (c < 0x3001 || c > 0xd7ff) &&
+ (c < 0xf900 || c > 0xfdcf) &&
+ (c < 0xfdf0 || c > 0xfffd) &&
+ (c < 0x10000 || c > 0xeffff))
+ {
+ throw new DomDOMException(DOMException.INVALID_CHARACTER_ERR,
+ name, null, c);
+ }
+ }
+ else
+ {
+ // XML 1.0
+ int type = Character.getType(c);
+ switch (type)
+ {
+ case Character.LOWERCASE_LETTER: // Ll
+ case Character.UPPERCASE_LETTER: // Lu
+ case Character.OTHER_LETTER: // Lo
+ case Character.TITLECASE_LETTER: // Lt
+ case Character.LETTER_NUMBER: // Nl
+ if ((c > 0xf900 && c < 0xfffe) ||
+ (c >= 0x20dd && c <= 0x20e0))
+ {
+ // Compatibility area and Unicode 2.0 exclusions
+ throw new DomDOMException(DOMException.INVALID_CHARACTER_ERR,
+ name, null, c);
+ }
+ break;
+ default:
+ if (c != ':' && c != '_' && (c < 0x02bb || c > 0x02c1) &&
+ c != 0x0559 && c != 0x06e5 && c != 0x06e6)
+ {
+ throw new DomDOMException(DOMException.INVALID_CHARACTER_ERR,
+ name, null, c);
+ }
+ }
+ }
+
+ // Subsequent characters
+ for (int i = 1; i < len; i++)
+ {
+ c = name.charAt(i);
+ if (xml11)
+ {
+ // XML 1.1
+ if ((c < 0x0041 || c > 0x005a) &&
+ (c < 0x0061 || c > 0x007a) &&
+ (c < 0x0030 || c > 0x0039) &&
+ c != ':' && c != '_' && c != '-' && c != '.' &&
+ (c < 0x00c0 || c > 0x00d6) &&
+ (c < 0x00d8 || c > 0x00f6) &&
+ (c < 0x00f8 || c > 0x02ff) &&
+ (c < 0x0370 || c > 0x037d) &&
+ (c < 0x037f || c > 0x1fff) &&
+ (c < 0x200c || c > 0x200d) &&
+ (c < 0x2070 || c > 0x218f) &&
+ (c < 0x2c00 || c > 0x2fef) &&
+ (c < 0x3001 || c > 0xd7ff) &&
+ (c < 0xf900 || c > 0xfdcf) &&
+ (c < 0xfdf0 || c > 0xfffd) &&
+ (c < 0x10000 || c > 0xeffff) &&
+ c != 0x00b7 &&
+ (c < 0x0300 || c > 0x036f) &&
+ (c < 0x203f || c > 0x2040))
+ {
+ throw new DomDOMException(DOMException.INVALID_CHARACTER_ERR, name,
+ null, c);
+ }
+ }
+ else
+ {
+ // XML 1.0
+ int type = Character.getType(c);
+ switch (type)
+ {
+ case Character.LOWERCASE_LETTER: // Ll
+ case Character.UPPERCASE_LETTER: // Lu
+ case Character.DECIMAL_DIGIT_NUMBER: // Nd
+ case Character.OTHER_LETTER: // Lo
+ case Character.TITLECASE_LETTER: // Lt
+ case Character.LETTER_NUMBER: // Nl
+ case Character.COMBINING_SPACING_MARK: // Mc
+ case Character.ENCLOSING_MARK: // Me
+ case Character.NON_SPACING_MARK: // Mn
+ case Character.MODIFIER_LETTER: // Lm
+ if ((c > 0xf900 && c < 0xfffe) ||
+ (c >= 0x20dd && c <= 0x20e0))
+ {
+ // Compatibility area and Unicode 2.0 exclusions
+ throw new DomDOMException(DOMException.INVALID_CHARACTER_ERR,
+ name, null, c);
+ }
+ break;
+ default:
+ if (c != '-' && c != '.' && c != ':' && c != '_' &&
+ c != 0x0387 && (c < 0x02bb || c > 0x02c1) &&
+ c != 0x0559 && c != 0x06e5 && c != 0x06e6 && c != 0x00b7)
+ {
+ throw new DomDOMException(DOMException.INVALID_CHARACTER_ERR,
+ name, null, c);
+ }
+ }
+ }
+ }
+
+ // FIXME characters with a font or compatibility decomposition (i.e.
+ // those with a "compatibility formatting tag" in field 5 of the
+ // database -- marked by field 5 beginning with a "<") are not allowed.
+ }
+
+ // package private
+ static void checkNCName(String name, boolean xml11)
+ {
+ checkName(name, xml11);
+ int len = name.length();
+ int index = name.indexOf(':');
+ if (index != -1)
+ {
+ if (index == 0 || index == (len - 1) || name.lastIndexOf(':') != index)
+ {
+ throw new DomDOMException(DOMException.NAMESPACE_ERR, name, null, 0);
+ }
+ }
+ }
+
+ // package private
+ static void checkChar(String value, boolean xml11)
+ {
+ char[] chars = value.toCharArray();
+ checkChar(chars, 0, chars.length, xml11);
+ }
+
+ static void checkChar(char[] buf, int off, int len, boolean xml11)
+ {
+ for (int i = 0; i < len; i++)
+ {
+ char c = buf[i];
+
+ // assume surrogate pairing checks out OK, for simplicity
+ if ((c >= 0x0020 && c <= 0xd7ff) ||
+ (c == 0x000a || c == 0x000d || c == 0x0009) ||
+ (c >= 0xe000 && c <= 0xfffd) ||
+ (c >= 0x10000 && c <= 0x10ffff))
+ {
+ continue;
+ }
+ if (xml11)
+ {
+ if ((c >= 0x0001 && c <= 0x001f) ||
+ (c >= 0x007f && c <= 0x0084) ||
+ (c >= 0x0086 && c <= 0x009f))
+ {
+ continue;
+ }
+ }
+ throw new DomDOMException(DOMException.INVALID_CHARACTER_ERR,
+ new String(buf, off, len), null, c);
+ }
+ }
+
+ /**
+ * <b>DOM L1</b>
+ * Returns a newly created element with the specified name.
+ */
+ public Element createElement(String name)
+ {
+ Element element;
+
+ if (checkingCharacters)
+ {
+ checkName(name, "1.1".equals(version));
+ }
+ if (name.startsWith("xml:"))
+ {
+ element = createElementNS(null, name);
+ }
+ else
+ {
+ DomElement domElement = new DomElement(this, null, name);
+ domElement.localName = null;
+ element = domElement;
+ }
+ defaultAttributes(element, name);
+ return element;
+ }
+
+ /**
+ * <b>DOM L2</b>
+ * Returns a newly created element with the specified name
+ * and namespace information.
+ */
+ public Element createElementNS(String namespaceURI, String name)
+ {
+ if (checkingCharacters)
+ {
+ checkNCName(name, "1.1".equals(version));
+ }
+
+ if ("".equals(namespaceURI))
+ {
+ namespaceURI = null;
+ }
+ if (name.startsWith("xml:"))
+ {
+ if (namespaceURI != null
+ && !XMLConstants.XML_NS_URI.equals(namespaceURI))
+ {
+ throw new DomDOMException(DOMException.NAMESPACE_ERR,
+ "xml namespace is always " +
+ XMLConstants.XML_NS_URI, this, 0);
+ }
+ namespaceURI = XMLConstants.XML_NS_URI;
+ }
+ else if (XMLConstants.XMLNS_ATTRIBUTE.equals(name) ||
+ name.startsWith("xmlns:"))
+ {
+ throw new DomDOMException(DOMException.NAMESPACE_ERR,
+ "xmlns is reserved", this, 0);
+ }
+ else if (namespaceURI == null && name.indexOf(':') != -1)
+ {
+ throw new DomDOMException(DOMException.NAMESPACE_ERR,
+ "prefixed name '" + name +
+ "' needs a URI", this, 0);
+ }
+
+ Element element = new DomElement(this, namespaceURI, name);
+ defaultAttributes(element, name);
+ return element;
+ }
+
+ private void defaultAttributes(Element element, String name)
+ {
+ DomDoctype doctype = (DomDoctype) getDoctype();
+ if (doctype == null)
+ {
+ return;
+ }
+
+ // default any attributes that need it
+ DTDElementTypeInfo info = doctype.getElementTypeInfo(name);
+ if (info != null)
+ {
+ for (Iterator i = info.attributes(); i != null && i.hasNext(); )
+ {
+ DTDAttributeTypeInfo attr = (DTDAttributeTypeInfo) i.next();
+ DomAttr node = (DomAttr) createAttribute(attr.name);
+
+ String value = attr.value;
+ if (value == null)
+ {
+ value = "";
+ }
+ node.setValue(value);
+ node.setSpecified(false);
+ element.setAttributeNode(node);
+ }
+ }
+ }
+
+ /**
+ * <b>DOM L1</b>
+ * Returns a newly created document fragment.
+ */
+ public DocumentFragment createDocumentFragment()
+ {
+ return new DomDocumentFragment(this);
+ }
+
+ /**
+ * <b>DOM L1</b>
+ * Returns a newly created text node with the specified value.
+ */
+ public Text createTextNode(String value)
+ {
+ if (checkingCharacters)
+ {
+ checkChar(value, "1.1".equals(version));
+ }
+ return new DomText(this, value);
+ }
+
+ /**
+ * Returns a newly created text node with the specified value.
+ */
+ public Text createTextNode(char[] buf, int off, int len)
+ {
+ if (checkingCharacters)
+ {
+ checkChar(buf, off, len, "1.1".equals(version));
+ }
+ return new DomText(this, buf, off, len);
+ }
+
+ /**
+ * <b>DOM L1</b>
+ * Returns a newly created comment node with the specified value.
+ */
+ public Comment createComment(String value)
+ {
+ if (checkingCharacters)
+ {
+ checkChar(value, "1.1".equals(version));
+ }
+ return new DomComment(this, value);
+ }
+
+ /**
+ * <b>DOM L1</b>
+ * Returns a newly created CDATA section node with the specified value.
+ */
+ public CDATASection createCDATASection(String value)
+ {
+ if (checkingCharacters)
+ {
+ checkChar(value, "1.1".equals(version));
+ }
+ return new DomCDATASection(this, value);
+ }
+
+ /**
+ * Returns a newly created CDATA section node with the specified value.
+ */
+ public CDATASection createCDATASection(char[] buf, int off, int len)
+ {
+ if (checkingCharacters)
+ {
+ checkChar(buf, off, len, "1.1".equals(version));
+ }
+ return new DomCDATASection(this, buf, off, len);
+ }
+
+ /**
+ * <b>DOM L1</b>
+ * Returns a newly created processing instruction.
+ */
+ public ProcessingInstruction createProcessingInstruction(String target,
+ String data)
+ {
+ if (checkingCharacters)
+ {
+ boolean xml11 = "1.1".equals(version);
+ checkName(target, xml11);
+ if ("xml".equalsIgnoreCase(target))
+ {
+ throw new DomDOMException(DOMException.SYNTAX_ERR,
+ "illegal PI target name",
+ this, 0);
+ }
+ checkChar(data, xml11);
+ }
+ return new DomProcessingInstruction(this, target, data);
+ }
+
+ /**
+ * <b>DOM L1</b>
+ * Returns a newly created attribute with the specified name.
+ */
+ public Attr createAttribute(String name)
+ {
+ if (checkingCharacters)
+ {
+ checkName(name, "1.1".equals(version));
+ }
+ if (name.startsWith("xml:"))
+ {
+ return createAttributeNS(XMLConstants.XML_NS_URI, name);
+ }
+ else if (XMLConstants.XMLNS_ATTRIBUTE.equals(name) ||
+ name.startsWith("xmlns:"))
+ {
+ return createAttributeNS(XMLConstants.XMLNS_ATTRIBUTE_NS_URI, name);
+ }
+ else
+ {
+ DomAttr ret = new DomAttr(this, null, name);
+ ret.localName = null;
+ return ret;
+ }
+ }
+
+ /**
+ * <b>DOM L2</b>
+ * Returns a newly created attribute with the specified name
+ * and namespace information.
+ */
+ public Attr createAttributeNS(String namespaceURI, String name)
+ {
+ if (checkingCharacters)
+ {
+ checkNCName(name, "1.1".equals(version));
+ }
+
+ if ("".equals(namespaceURI))
+ {
+ namespaceURI = null;
+ }
+ if (name.startsWith ("xml:"))
+ {
+ if (namespaceURI == null)
+ {
+ namespaceURI = XMLConstants.XML_NS_URI;
+ }
+ else if (!XMLConstants.XML_NS_URI.equals(namespaceURI))
+ {
+ throw new DomDOMException(DOMException.NAMESPACE_ERR,
+ "xml namespace is always " +
+ XMLConstants.XML_NS_URI,
+ this, 0);
+ }
+ }
+ else if (XMLConstants.XMLNS_ATTRIBUTE.equals(name) ||
+ name.startsWith("xmlns:"))
+ {
+ if (namespaceURI == null)
+ {
+ namespaceURI = XMLConstants.XMLNS_ATTRIBUTE_NS_URI;
+ }
+ else if (!XMLConstants.XMLNS_ATTRIBUTE_NS_URI.equals(namespaceURI))
+ {
+ throw new DomDOMException(DOMException.NAMESPACE_ERR,
+ "xmlns namespace must be " +
+ XMLConstants.XMLNS_ATTRIBUTE_NS_URI,
+ this, 0);
+ }
+ }
+ else if (namespaceURI == null && name.indexOf(':') != -1)
+ {
+ throw new DomDOMException(DOMException.NAMESPACE_ERR,
+ "prefixed name needs a URI: " + name, this, 0);
+ }
+ return new DomAttr(this, namespaceURI, name);
+ }
+
+ /**
+ * <b>DOM L1</b>
+ * Returns a newly created reference to the specified entity.
+ * The caller should populate this with the appropriate children
+ * and then mark it as readonly.
+ *
+ * @see DomNode#makeReadonly
+ */
+ public EntityReference createEntityReference(String name)
+ {
+ DomEntityReference ret = new DomEntityReference(this, name);
+ DocumentType doctype = getDoctype();
+ if (doctype != null)
+ {
+ DomEntity ent = (DomEntity) doctype.getEntities().getNamedItem(name);
+ if (ent != null)
+ {
+ for (DomNode ctx = ent.first; ctx != null; ctx = ctx.next)
+ {
+ ret.appendChild(ctx.cloneNode(true));
+ }
+ }
+ }
+ ret.makeReadonly();
+ return ret;
+ }
+
+ /**
+ * <b>DOM L2</b>
+ * Makes a copy of the specified node, with all nodes "owned" by
+ * this document and with children optionally copied. This type
+ * of standard utility has become, well, a standard utility.
+ *
+ * <p> Note that EntityReference nodes created through this method (either
+ * directly, or recursively) never have children, and that there is no
+ * portable way to associate them with such children.
+ *
+ * <p> Note also that there is no requirement that the specified node
+ * be associated with a different document. This differs from the
+ * <em>cloneNode</em> operation in that the node itself is not given
+ * an opportunity to participate, so that any information managed
+ * by node subclasses will be lost.
+ */
+ public Node importNode(Node src, boolean deep)
+ {
+ Node dst = null;
+ switch (src.getNodeType())
+ {
+ case TEXT_NODE:
+ dst = createTextNode(src.getNodeValue());
+ break;
+ case CDATA_SECTION_NODE:
+ dst = createCDATASection(src.getNodeValue());
+ break;
+ case COMMENT_NODE:
+ dst = createComment(src.getNodeValue());
+ break;
+ case PROCESSING_INSTRUCTION_NODE:
+ dst = createProcessingInstruction(src.getNodeName(),
+ src.getNodeValue());
+ break;
+ case NOTATION_NODE:
+ // NOTE: There's no standard way to create
+ // these, or add them to a doctype. Useless.
+ Notation notation = (Notation) src;
+ dst = new DomNotation(this, notation.getNodeName(),
+ notation.getPublicId(),
+ notation.getSystemId());
+ break;
+ case ENTITY_NODE:
+ // NOTE: There's no standard way to create
+ // these, or add them to a doctype. Useless.
+ Entity entity = (Entity) src;
+ dst = new DomEntity(this, entity.getNodeName(),
+ entity.getPublicId(),
+ entity.getSystemId(),
+ entity.getNotationName());
+ if (deep)
+ {
+ for (Node ctx = src.getFirstChild(); ctx != null;
+ ctx = ctx.getNextSibling())
+ {
+ dst.appendChild(importNode(ctx, deep));
+ }
+ }
+ break;
+ case ENTITY_REFERENCE_NODE:
+ dst = createEntityReference(src.getNodeName());
+ break;
+ case DOCUMENT_FRAGMENT_NODE:
+ dst = new DomDocumentFragment(this);
+ if (deep)
+ {
+ for (Node ctx = src.getFirstChild(); ctx != null;
+ ctx = ctx.getNextSibling())
+ {
+ dst.appendChild(importNode(ctx, deep));
+ }
+ }
+ break;
+ case ATTRIBUTE_NODE:
+ String attr_nsuri = src.getNamespaceURI();
+ if (attr_nsuri != null)
+ {
+ dst = createAttributeNS(attr_nsuri, src.getNodeName());
+ }
+ else
+ {
+ dst = createAttribute(src.getNodeName());
+ }
+ // this is _always_ done regardless of "deep" setting
+ for (Node ctx = src.getFirstChild(); ctx != null;
+ ctx = ctx.getNextSibling())
+ {
+ dst.appendChild(importNode(ctx, false));
+ }
+ break;
+ case ELEMENT_NODE:
+ String elem_nsuri = src.getNamespaceURI();
+ if (elem_nsuri != null)
+ {
+ dst = createElementNS(elem_nsuri, src.getNodeName());
+ }
+ else
+ {
+ dst = createElement(src.getNodeName());
+ }
+ NamedNodeMap srcAttrs = src.getAttributes();
+ NamedNodeMap dstAttrs = dst.getAttributes();
+ int len = srcAttrs.getLength();
+ for (int i = 0; i < len; i++)
+ {
+ Attr a = (Attr) srcAttrs.item(i);
+ Attr dflt;
+
+ // maybe update defaulted attributes
+ dflt = (Attr) dstAttrs.getNamedItem(a.getNodeName());
+ if (dflt != null)
+ {
+ String newval = a.getNodeValue();
+ if (!dflt.getNodeValue().equals(newval)
+ || a.getSpecified () == true)
+ {
+ dflt.setNodeValue (newval);
+ }
+ continue;
+ }
+
+ dstAttrs.setNamedItem((Attr) importNode(a, false));
+ }
+ if (deep)
+ {
+ for (Node ctx = src.getFirstChild(); ctx != null;
+ ctx = ctx.getNextSibling())
+ {
+ dst.appendChild(importNode(ctx, true));
+ }
+ }
+ break;
+ // can't import document or doctype nodes
+ case DOCUMENT_NODE:
+ case DOCUMENT_TYPE_NODE:
+ // FALLTHROUGH
+ // can't import unrecognized or nonstandard nodes
+ default:
+ throw new DomDOMException(DOMException.NOT_SUPPORTED_ERR, null, src, 0);
+ }
+
+ // FIXME cleanup a bit -- for deep copies, copy those
+ // children in one place, here (code sharing is healthy)
+
+ if (src instanceof DomNode)
+ {
+ ((DomNode) src).notifyUserDataHandlers(UserDataHandler.NODE_IMPORTED,
+ src, dst);
+ }
+ return dst;
+ }
+
+ /**
+ * <b>DOM L2 (Traversal)</b>
+ * Returns a newly created node iterator. Don't forget to detach
+ * this iterator when you're done using it!
+ *
+ * @see DomIterator
+ */
+ public NodeIterator createNodeIterator(Node root,
+ int whatToShow,
+ NodeFilter filter,
+ boolean expandEntities)
+ {
+ return new DomNodeIterator(root, whatToShow, filter, expandEntities,
+ false);
+ }
+
+ public TreeWalker createTreeWalker(Node root,
+ int whatToShow,
+ NodeFilter filter,
+ boolean expandEntities)
+ {
+ return new DomNodeIterator(root, whatToShow, filter, expandEntities,
+ true);
+ }
+
+ // DOM Level 3 methods
+
+ /**
+ * DOM L3
+ */
+ public String getInputEncoding()
+ {
+ return inputEncoding;
+ }
+
+ public void setInputEncoding(String inputEncoding)
+ {
+ this.inputEncoding = inputEncoding;
+ }
+
+ /**
+ * DOM L3
+ */
+ public String getXmlEncoding()
+ {
+ return encoding;
+ }
+
+ public void setXmlEncoding(String encoding)
+ {
+ this.encoding = encoding;
+ }
+
+ public boolean getXmlStandalone()
+ {
+ return standalone;
+ }
+
+ public void setXmlStandalone(boolean xmlStandalone)
+ {
+ standalone = xmlStandalone;
+ }
+
+ public String getXmlVersion()
+ {
+ return version;
+ }
+
+ public void setXmlVersion(String xmlVersion)
+ {
+ if (xmlVersion == null)
+ {
+ xmlVersion = "1.0";
+ }
+ if ("1.0".equals(xmlVersion) ||
+ "1.1".equals(xmlVersion))
+ {
+ version = xmlVersion;
+ }
+ else
+ {
+ throw new DomDOMException(DOMException.NOT_SUPPORTED_ERR);
+ }
+ }
+
+ public boolean getStrictErrorChecking()
+ {
+ return checkingCharacters;
+ }
+
+ public void setStrictErrorChecking(boolean strictErrorChecking)
+ {
+ checkingCharacters = strictErrorChecking;
+ }
+
+ public String lookupPrefix(String namespaceURI)
+ {
+ Node root = getDocumentElement();
+ return (root == null) ? null : root.lookupPrefix(namespaceURI);
+ }
+
+ public boolean isDefaultNamespace(String namespaceURI)
+ {
+ Node root = getDocumentElement();
+ return (root == null) ? false : root.isDefaultNamespace(namespaceURI);
+ }
+
+ public String lookupNamespaceURI(String prefix)
+ {
+ Node root = getDocumentElement();
+ return (root == null) ? null : root.lookupNamespaceURI(prefix);
+ }
+
+ public String getBaseURI()
+ {
+ return getDocumentURI();
+ /*
+ Node root = getDocumentElement();
+ if (root != null)
+ {
+ NamedNodeMap attrs = root.getAttributes();
+ Node xmlBase = attrs.getNamedItemNS(XMLConstants.XML_NS_URI, "base");
+ if (xmlBase != null)
+ {
+ return xmlBase.getNodeValue();
+ }
+ }
+ return systemId;
+ */
+ }
+
+ public String getDocumentURI()
+ {
+ return systemId;
+ }
+
+ public void setDocumentURI(String documentURI)
+ {
+ systemId = documentURI;
+ }
+
+ public Node adoptNode(Node source)
+ {
+ int sourceNodeType = source.getNodeType();
+ switch (sourceNodeType)
+ {
+ case DOCUMENT_NODE:
+ case DOCUMENT_TYPE_NODE:
+ throw new DomDOMException(DOMException.NOT_SUPPORTED_ERR);
+ case ENTITY_NODE:
+ case NOTATION_NODE:
+ throw new DomDOMException(DOMException.NO_MODIFICATION_ALLOWED_ERR);
+ }
+ if (source instanceof DomNode)
+ {
+ // GNU native
+ DomNode src = (DomNode) source;
+ DomNode dst = src;
+ if (dst.parent != null)
+ {
+ dst = (DomNode) dst.cloneNode(true);
+ }
+ dst.setOwner(this);
+ src.notifyUserDataHandlers(UserDataHandler.NODE_ADOPTED, src, dst);
+ return dst;
+ }
+ else
+ {
+ // Some other implementation
+ Node dst = null;
+ switch (sourceNodeType)
+ {
+ case Node.ATTRIBUTE_NODE:
+ {
+ Attr src = (Attr) source;
+ String nodeName = src.getNodeName();
+ String localName = src.getLocalName();
+ String namespaceUri = src.getNamespaceURI();
+ dst = (localName == null) ?
+ createAttribute(nodeName) :
+ createAttributeNS(namespaceUri, nodeName);
+ adoptChildren(src, dst);
+ break;
+ }
+ case Node.CDATA_SECTION_NODE:
+ {
+ CDATASection src = (CDATASection) source;
+ dst = createCDATASection(src.getData());
+ break;
+ }
+ case Node.COMMENT_NODE:
+ {
+ Comment src = (Comment) source;
+ dst = createComment(src.getData());
+ break;
+ }
+ case Node.DOCUMENT_FRAGMENT_NODE:
+ {
+ DocumentFragment src = (DocumentFragment) source;
+ dst = createDocumentFragment();
+ adoptChildren(src, dst);
+ break;
+ }
+ case Node.ELEMENT_NODE:
+ {
+ Element src = (Element) source;
+ String nodeName = src.getNodeName();
+ String localName = src.getLocalName();
+ String namespaceUri = src.getNamespaceURI();
+ dst = (localName == null) ?
+ createElement(nodeName) :
+ createElementNS(namespaceUri, nodeName);
+ adoptAttributes(src, dst);
+ adoptChildren(src, dst);
+ break;
+ }
+ case Node.ENTITY_REFERENCE_NODE:
+ {
+ EntityReference src = (EntityReference) source;
+ dst = createEntityReference(src.getNodeName());
+ adoptChildren(src, dst);
+ break;
+ }
+ case Node.PROCESSING_INSTRUCTION_NODE:
+ {
+ ProcessingInstruction src = (ProcessingInstruction) source;
+ dst = createProcessingInstruction(src.getTarget(),
+ src.getData());
+ break;
+ }
+ case Node.TEXT_NODE:
+ {
+ Text src = (Text) source;
+ dst = createTextNode(src.getData());
+ break;
+ }
+ }
+ return dst;
+ }
+ }
+
+ void adoptChildren(Node src, Node dst)
+ {
+ Node node = src.getFirstChild();
+ while (node != null)
+ {
+ Node next = node.getNextSibling();
+ dst.appendChild(adoptNode(node));
+ node = next;
+ }
+ }
+
+ void adoptAttributes(Node src, Node dst)
+ {
+ NamedNodeMap srcAttrs = src.getAttributes();
+ NamedNodeMap dstAttrs = dst.getAttributes();
+ int len = srcAttrs.getLength();
+ for (int i = 0; i < len; i++)
+ {
+ Node node = srcAttrs.item(i);
+ String localName = node.getLocalName();
+ if (localName == null)
+ {
+ dstAttrs.setNamedItem(adoptNode(node));
+ }
+ else
+ {
+ dstAttrs.setNamedItemNS(adoptNode(node));
+ }
+ }
+ }
+
+ public DOMConfiguration getDomConfig()
+ {
+ if (config == null)
+ {
+ config = new DomDocumentConfiguration();
+ }
+ return config;
+ }
+
+ public boolean isEqualNode(Node arg)
+ {
+ if (!super.isEqualNode(arg))
+ return false;
+ Document d = (Document) arg;
+ String dversion = d.getXmlVersion();
+ if (dversion == null || !dversion.equals(version))
+ return false;
+ boolean dstandalone = d.getXmlStandalone();
+ if (dstandalone != standalone)
+ return false;
+ String dencoding = d.getXmlEncoding();
+ if (dencoding == null || dencoding.equalsIgnoreCase("UTF-8"))
+ {
+ if (encoding != null && !encoding.equalsIgnoreCase("UTF-8"))
+ return false;
+ }
+ else
+ {
+ if (!dencoding.equals(encoding))
+ return false;
+ }
+ return true;
+ }
+
+ public void normalizeDocument()
+ {
+ boolean save = building;
+ building = true;
+ normalizeNode(this);
+ building = save;
+ }
+
+ void normalizeNode(DomNode node)
+ {
+ node.normalize();
+ if (config != null)
+ {
+ switch (node.nodeType)
+ {
+ case CDATA_SECTION_NODE:
+ if (!config.cdataSections)
+ {
+ // replace CDATA section with text node
+ Text text = createTextNode(node.getNodeValue());
+ node.parent.insertBefore(text, node);
+ node.parent.removeChild(node);
+ // merge adjacent text nodes
+ String data = text.getWholeText();
+ node = (DomNode) text.replaceWholeText(data);
+ }
+ else if (config.splitCdataSections)
+ {
+ String value = node.getNodeValue();
+ int i = value.indexOf("]]>");
+ while (i != -1)
+ {
+ Node node2 = createCDATASection(value.substring(0, i));
+ node.parent.insertBefore(node2, node);
+ value = value.substring(i + 3);
+ node.setNodeValue(value);
+ i = value.indexOf("]]>");
+ }
+ }
+ break;
+ case COMMENT_NODE:
+ if (!config.comments)
+ {
+ node.parent.removeChild(node);
+ }
+ break;
+ case TEXT_NODE:
+ if (!config.elementContentWhitespace &&
+ ((Text) node).isElementContentWhitespace())
+ {
+ node.parent.removeChild(node);
+ }
+ break;
+ case ENTITY_REFERENCE_NODE:
+ if (!config.entities)
+ {
+ for (DomNode ctx = node.first; ctx != null; )
+ {
+ DomNode ctxNext = ctx.next;
+ node.parent.insertBefore(ctx, node);
+ ctx = ctxNext;
+ }
+ node.parent.removeChild(node);
+ }
+ break;
+ case ELEMENT_NODE:
+ if (!config.namespaceDeclarations)
+ {
+ DomNamedNodeMap attrs =
+ (DomNamedNodeMap) node.getAttributes();
+ boolean aro = attrs.readonly;
+ attrs.readonly = false; // Ensure we can delete if necessary
+ int len = attrs.getLength();
+ for (int i = 0; i < len; i++)
+ {
+ Node attr = attrs.item(i);
+ String namespace = attr.getNamespaceURI();
+ if (XMLConstants.XMLNS_ATTRIBUTE_NS_URI.equals(namespace))
+ {
+ attrs.removeNamedItemNS(namespace,
+ attr.getLocalName());
+ i--;
+ len--;
+ }
+ }
+ attrs.readonly = aro;
+ }
+ break;
+ }
+ }
+ for (DomNode ctx = node.first; ctx != null; )
+ {
+ DomNode ctxNext = ctx.next;
+ normalizeNode(ctx);
+ ctx = ctxNext;
+ }
+ }
+
+ public Node renameNode(Node n, String namespaceURI, String qualifiedName)
+ throws DOMException
+ {
+ if (n instanceof DomNsNode)
+ {
+ DomNsNode src = (DomNsNode) n;
+ if (src == null)
+ {
+ throw new DomDOMException(DOMException.NOT_FOUND_ERR);
+ }
+ if (src.owner != this)
+ {
+ throw new DomDOMException(DOMException.WRONG_DOCUMENT_ERR,
+ null, src, 0);
+ }
+ boolean xml11 = "1.1".equals(version);
+ checkName(qualifiedName, xml11);
+ int ci = qualifiedName.indexOf(':');
+ if ("".equals(namespaceURI))
+ {
+ namespaceURI = null;
+ }
+ if (namespaceURI != null)
+ {
+ checkNCName(qualifiedName, xml11);
+ String prefix = (ci == -1) ? "" :
+ qualifiedName.substring(0, ci);
+ if (XMLConstants.XML_NS_PREFIX.equals(prefix) &&
+ !XMLConstants.XML_NS_URI.equals(namespaceURI))
+ {
+ throw new DomDOMException(DOMException.NAMESPACE_ERR,
+ "xml namespace must be " +
+ XMLConstants.XML_NS_URI, src, 0);
+ }
+ else if (src.nodeType == ATTRIBUTE_NODE &&
+ (XMLConstants.XMLNS_ATTRIBUTE.equals(prefix) ||
+ XMLConstants.XMLNS_ATTRIBUTE.equals(qualifiedName)) &&
+ !XMLConstants.XMLNS_ATTRIBUTE_NS_URI.equals(namespaceURI))
+ {
+ throw new DomDOMException(DOMException.NAMESPACE_ERR,
+ "xmlns namespace must be " +
+ XMLConstants.XMLNS_ATTRIBUTE_NS_URI, src, 0);
+ }
+ if (XMLConstants.XML_NS_URI.equals(namespaceURI) &&
+ !XMLConstants.XML_NS_PREFIX.equals(prefix))
+ {
+ throw new DomDOMException(DOMException.NAMESPACE_ERR,
+ "xml namespace must be " +
+ XMLConstants.XML_NS_URI, src, 0);
+ }
+ else if (src.nodeType == ATTRIBUTE_NODE &&
+ XMLConstants.XMLNS_ATTRIBUTE_NS_URI.equals(namespaceURI) &&
+ !(XMLConstants.XMLNS_ATTRIBUTE.equals(prefix) ||
+ XMLConstants.XMLNS_ATTRIBUTE.equals(qualifiedName)))
+ {
+ throw new DomDOMException(DOMException.NAMESPACE_ERR,
+ "xmlns namespace must be " +
+ XMLConstants.XMLNS_ATTRIBUTE_NS_URI, src, 0);
+ }
+
+ }
+ src.setNodeName(qualifiedName);
+ src.setNamespaceURI(namespaceURI);
+ src.notifyUserDataHandlers(UserDataHandler.NODE_RENAMED, src, src);
+ // TODO MutationNameEvents
+ // DOMElementNameChanged or DOMAttributeNameChanged
+ return src;
+ }
+ throw new DomDOMException(DOMException.NOT_SUPPORTED_ERR, null, n, 0);
+ }
+
+ // -- XPathEvaluator --
+
+ public XPathExpression createExpression(String expression,
+ XPathNSResolver resolver)
+ throws XPathException, DOMException
+ {
+ return new DomXPathExpression(this, expression, resolver);
+ }
+
+ public XPathNSResolver createNSResolver(Node nodeResolver)
+ {
+ return new DomXPathNSResolver(nodeResolver);
+ }
+
+ public Object evaluate(String expression,
+ Node contextNode,
+ XPathNSResolver resolver,
+ short type,
+ Object result)
+ throws XPathException, DOMException
+ {
+ XPathExpression xpe =
+ new DomXPathExpression(this, expression, resolver);
+ return xpe.evaluate(contextNode, type, result);
+ }
+
+}
+
Added: llvm-gcc-4.2/trunk/libjava/classpath/gnu/xml/dom/DomDocumentBuilder.java
URL: http://llvm.org/viewvc/llvm-project/llvm-gcc-4.2/trunk/libjava/classpath/gnu/xml/dom/DomDocumentBuilder.java?rev=43913&view=auto
==============================================================================
--- llvm-gcc-4.2/trunk/libjava/classpath/gnu/xml/dom/DomDocumentBuilder.java (added)
+++ llvm-gcc-4.2/trunk/libjava/classpath/gnu/xml/dom/DomDocumentBuilder.java Thu Nov 8 16:56:19 2007
@@ -0,0 +1,183 @@
+/* DomDocumentBuilder.java --
+ Copyright (C) 2004,2006 Free Software Foundation, Inc.
+
+This file is part of GNU Classpath.
+
+GNU Classpath is free software; you can redistribute it and/or modify
+it under the terms of the GNU General Public License as published by
+the Free Software Foundation; either version 2, or (at your option)
+any later version.
+
+GNU Classpath is distributed in the hope that it will be useful, but
+WITHOUT ANY WARRANTY; without even the implied warranty of
+MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+General Public License for more details.
+
+You should have received a copy of the GNU General Public License
+along with GNU Classpath; see the file COPYING. If not, write to the
+Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA
+02110-1301 USA.
+
+Linking this library statically or dynamically with other modules is
+making a combined work based on this library. Thus, the terms and
+conditions of the GNU General Public License cover the whole
+combination.
+
+As a special exception, the copyright holders of this library give you
+permission to link this library with independent modules to produce an
+executable, regardless of the license terms of these independent
+modules, and to copy and distribute the resulting executable under
+terms of your choice, provided that you also meet, for each linked
+independent module, the terms and conditions of the license of that
+module. An independent module is a module which is not derived from
+or based on this library. If you modify this library, you may extend
+this exception to your version of the library, but you are not
+obligated to do so. If you do not wish to do so, delete this
+exception statement from your version. */
+
+package gnu.xml.dom;
+
+import java.io.File;
+import java.io.InputStream;
+import java.io.IOException;
+import java.io.Reader;
+import java.net.MalformedURLException;
+import java.net.URL;
+import javax.xml.parsers.DocumentBuilder;
+import org.w3c.dom.Document;
+import org.w3c.dom.DOMConfiguration;
+import org.w3c.dom.DOMImplementation;
+import org.w3c.dom.ls.DOMImplementationLS;
+import org.w3c.dom.ls.LSInput;
+import org.w3c.dom.ls.LSParser;
+import org.xml.sax.EntityResolver;
+import org.xml.sax.ErrorHandler;
+import org.xml.sax.InputSource;
+import org.xml.sax.SAXException;
+
+/**
+ * Document builder using the GNU DOM Load & Save implementation.
+ *
+ * @author <a href='mailto:dog at gnu.org'>Chris Burdess</a>
+ */
+class DomDocumentBuilder
+ extends DocumentBuilder
+{
+
+ final DOMImplementation impl;
+ final DOMImplementationLS ls;
+ final LSParser parser;
+
+ DomDocumentBuilder(DOMImplementation impl,
+ DOMImplementationLS ls,
+ LSParser parser)
+ {
+ this.impl = impl;
+ this.ls = ls;
+ this.parser = parser;
+ }
+
+ public boolean isNamespaceAware()
+ {
+ DOMConfiguration config = parser.getDomConfig();
+ return ((Boolean) config.getParameter("namespaces")).booleanValue();
+ }
+
+ public boolean isValidating()
+ {
+ DOMConfiguration config = parser.getDomConfig();
+ return ((Boolean) config.getParameter("validating")).booleanValue();
+ }
+
+ public boolean isXIncludeAware()
+ {
+ DOMConfiguration config = parser.getDomConfig();
+ return ((Boolean) config.getParameter("xinclude-aware")).booleanValue();
+ }
+
+ public void setEntityResolver(EntityResolver resolver)
+ {
+ DOMConfiguration config = parser.getDomConfig();
+ config.setParameter("entity-resolver", resolver);
+ }
+
+ public void setErrorHandler(ErrorHandler handler)
+ {
+ DOMConfiguration config = parser.getDomConfig();
+ config.setParameter("error-handler", handler);
+ }
+
+ public DOMImplementation getDOMImplementation()
+ {
+ return impl;
+ }
+
+ public Document newDocument()
+ {
+ return impl.createDocument(null, null, null);
+ }
+
+ public Document parse(InputStream in)
+ throws SAXException, IOException
+ {
+ LSInput input = ls.createLSInput();
+ input.setByteStream(in);
+ return parser.parse(input);
+ }
+
+ public Document parse(InputStream in, String systemId)
+ throws SAXException, IOException
+ {
+ LSInput input = ls.createLSInput();
+ input.setByteStream(in);
+ input.setSystemId(systemId);
+ return parser.parse(input);
+ }
+
+ public Document parse(String systemId)
+ throws SAXException, IOException
+ {
+ return parser.parseURI(systemId);
+ }
+
+ public Document parse(InputSource is)
+ throws SAXException, IOException
+ {
+ LSInput input = ls.createLSInput();
+ String systemId = is.getSystemId();
+ InputStream in = is.getByteStream();
+ if (in != null)
+ {
+ input.setByteStream(in);
+ }
+ else
+ {
+ Reader reader = is.getCharacterStream();
+ if (reader != null)
+ {
+ input.setCharacterStream(reader);
+ }
+ else
+ {
+ try
+ {
+ URL url = new URL(systemId);
+ input.setByteStream(url.openStream());
+ }
+ catch (MalformedURLException e)
+ {
+ // Maybe this is a relative file URL
+ File cwd = new File(System.getProperty("user.dir"));
+ URL url = new URL(cwd.toURL(), systemId);
+ input.setByteStream(url.openStream());
+ }
+ }
+ }
+ input.setPublicId(is.getPublicId());
+ input.setSystemId(systemId);
+ input.setEncoding(is.getEncoding());
+ return parser.parse(input);
+ }
+
+}
+
Added: llvm-gcc-4.2/trunk/libjava/classpath/gnu/xml/dom/DomDocumentBuilderFactory.java
URL: http://llvm.org/viewvc/llvm-project/llvm-gcc-4.2/trunk/libjava/classpath/gnu/xml/dom/DomDocumentBuilderFactory.java?rev=43913&view=auto
==============================================================================
--- llvm-gcc-4.2/trunk/libjava/classpath/gnu/xml/dom/DomDocumentBuilderFactory.java (added)
+++ llvm-gcc-4.2/trunk/libjava/classpath/gnu/xml/dom/DomDocumentBuilderFactory.java Thu Nov 8 16:56:19 2007
@@ -0,0 +1,151 @@
+/* DomDocumentBuilderFactory.java --
+ Copyright (C) 2004 Free Software Foundation, Inc.
+
+This file is part of GNU Classpath.
+
+GNU Classpath is free software; you can redistribute it and/or modify
+it under the terms of the GNU General Public License as published by
+the Free Software Foundation; either version 2, or (at your option)
+any later version.
+
+GNU Classpath is distributed in the hope that it will be useful, but
+WITHOUT ANY WARRANTY; without even the implied warranty of
+MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+General Public License for more details.
+
+You should have received a copy of the GNU General Public License
+along with GNU Classpath; see the file COPYING. If not, write to the
+Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA
+02110-1301 USA.
+
+Linking this library statically or dynamically with other modules is
+making a combined work based on this library. Thus, the terms and
+conditions of the GNU General Public License cover the whole
+combination.
+
+As a special exception, the copyright holders of this library give you
+permission to link this library with independent modules to produce an
+executable, regardless of the license terms of these independent
+modules, and to copy and distribute the resulting executable under
+terms of your choice, provided that you also meet, for each linked
+independent module, the terms and conditions of the license of that
+module. An independent module is a module which is not derived from
+or based on this library. If you modify this library, you may extend
+this exception to your version of the library, but you are not
+obligated to do so. If you do not wish to do so, delete this
+exception statement from your version. */
+
+package gnu.xml.dom;
+
+import javax.xml.XMLConstants;
+import javax.xml.parsers.DocumentBuilder;
+import javax.xml.parsers.DocumentBuilderFactory;
+import javax.xml.parsers.FactoryConfigurationError;
+import javax.xml.parsers.ParserConfigurationException;
+import org.w3c.dom.DOMConfiguration;
+import org.w3c.dom.DOMImplementation;
+import org.w3c.dom.bootstrap.DOMImplementationRegistry;
+import org.w3c.dom.ls.DOMImplementationLS;
+import org.w3c.dom.ls.LSParser;
+
+/**
+ * Document builder factory that uses a DOM Level 3 Load & Save
+ * implementation.
+ *
+ * @author <a href='mailto:dog at gnu.org'>Chris Burdess</a>
+ */
+public class DomDocumentBuilderFactory
+ extends DocumentBuilderFactory
+{
+
+ final DOMImplementation impl;
+ final DOMImplementationLS ls;
+ private boolean secureProcessing;
+
+ public DomDocumentBuilderFactory()
+ {
+ try
+ {
+ DOMImplementationRegistry reg =
+ DOMImplementationRegistry.newInstance();
+ impl = reg.getDOMImplementation("LS 3.0");
+ if (impl == null)
+ {
+ throw new FactoryConfigurationError("no LS implementations found");
+ }
+ ls = (DOMImplementationLS) impl;
+ }
+ catch (Exception e)
+ {
+ throw new FactoryConfigurationError(e);
+ }
+ }
+
+ public DocumentBuilder newDocumentBuilder()
+ throws ParserConfigurationException
+ {
+ LSParser parser = ls.createLSParser(DOMImplementationLS.MODE_ASYNCHRONOUS,
+ "http://www.w3.org/TR/REC-xml");
+ DOMConfiguration config = parser.getDomConfig();
+ setParameter(config, "namespaces",
+ isNamespaceAware() ? Boolean.TRUE : Boolean.FALSE);
+ setParameter(config, "element-content-whitespace",
+ isIgnoringElementContentWhitespace() ? Boolean.FALSE :
+ Boolean.TRUE);
+ setParameter(config, "comments",
+ isIgnoringComments() ? Boolean.FALSE : Boolean.TRUE);
+ setParameter(config, "expand-entity-references",
+ isExpandEntityReferences() ? Boolean.TRUE : Boolean.FALSE);
+ setParameter(config, "coalescing",
+ isCoalescing() ? Boolean.TRUE : Boolean.FALSE);
+ setParameter(config, "validating",
+ isValidating() ? Boolean.TRUE : Boolean.FALSE);
+ setParameter(config, "xinclude-aware",
+ isXIncludeAware() ? Boolean.TRUE : Boolean.FALSE);
+ return new DomDocumentBuilder(impl, ls, parser);
+ }
+
+ void setParameter(DOMConfiguration config, String name, Object value)
+ throws ParserConfigurationException
+ {
+ if (!config.canSetParameter(name, value))
+ {
+ throw new ParserConfigurationException(name);
+ }
+ config.setParameter(name, value);
+ }
+
+ public Object getAttribute(String name)
+ {
+ // TODO
+ return null;
+ }
+
+ public void setAttribute(String name, Object value)
+ {
+ // TODO
+ }
+
+ public void setFeature(String name, boolean value)
+ throws ParserConfigurationException
+ {
+ if (name == null)
+ throw new NullPointerException();
+ if (XMLConstants.FEATURE_SECURE_PROCESSING.equals(name))
+ {
+ secureProcessing = true;
+ return;
+ }
+ throw new ParserConfigurationException(name);
+ }
+
+ public boolean getFeature(String name)
+ throws ParserConfigurationException
+ {
+ if (XMLConstants.FEATURE_SECURE_PROCESSING.equals(name))
+ return secureProcessing;
+ throw new ParserConfigurationException(name);
+ }
+
+}
+
Added: llvm-gcc-4.2/trunk/libjava/classpath/gnu/xml/dom/DomDocumentConfiguration.java
URL: http://llvm.org/viewvc/llvm-project/llvm-gcc-4.2/trunk/libjava/classpath/gnu/xml/dom/DomDocumentConfiguration.java?rev=43913&view=auto
==============================================================================
--- llvm-gcc-4.2/trunk/libjava/classpath/gnu/xml/dom/DomDocumentConfiguration.java (added)
+++ llvm-gcc-4.2/trunk/libjava/classpath/gnu/xml/dom/DomDocumentConfiguration.java Thu Nov 8 16:56:19 2007
@@ -0,0 +1,260 @@
+/* DomDocumentConfiguration.java --
+ Copyright (C) 2004 Free Software Foundation, Inc.
+
+This file is part of GNU Classpath.
+
+GNU Classpath is free software; you can redistribute it and/or modify
+it under the terms of the GNU General Public License as published by
+the Free Software Foundation; either version 2, or (at your option)
+any later version.
+
+GNU Classpath is distributed in the hope that it will be useful, but
+WITHOUT ANY WARRANTY; without even the implied warranty of
+MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+General Public License for more details.
+
+You should have received a copy of the GNU General Public License
+along with GNU Classpath; see the file COPYING. If not, write to the
+Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA
+02110-1301 USA.
+
+Linking this library statically or dynamically with other modules is
+making a combined work based on this library. Thus, the terms and
+conditions of the GNU General Public License cover the whole
+combination.
+
+As a special exception, the copyright holders of this library give you
+permission to link this library with independent modules to produce an
+executable, regardless of the license terms of these independent
+modules, and to copy and distribute the resulting executable under
+terms of your choice, provided that you also meet, for each linked
+independent module, the terms and conditions of the license of that
+module. An independent module is a module which is not derived from
+or based on this library. If you modify this library, you may extend
+this exception to your version of the library, but you are not
+obligated to do so. If you do not wish to do so, delete this
+exception statement from your version. */
+
+package gnu.xml.dom;
+
+import java.util.Arrays;
+import java.util.List;
+import org.w3c.dom.DOMConfiguration;
+import org.w3c.dom.DOMErrorHandler;
+import org.w3c.dom.DOMException;
+import org.w3c.dom.DOMStringList;
+
+/**
+ * Document configuration, used to store normalization and other parameters.
+ *
+ * @author <a href='mailto:dog at gnu.org'>Chris Burdess</a>
+ */
+class DomDocumentConfiguration
+ implements DOMConfiguration, DOMStringList
+{
+
+ private static final List SUPPORTED_PARAMETERS =
+ Arrays.asList(new String[] { "cdata-sections",
+ "comments",
+ "element-content-whitespace",
+ "entities",
+ "error-handler",
+ "namespace-declarations",
+ "split-cdata-sections",
+ "infoset"});
+
+ boolean cdataSections = true;
+ boolean comments = true;
+ boolean elementContentWhitespace = true;
+ boolean entities = true;
+ DOMErrorHandler errorHandler;
+ boolean namespaceDeclarations = true;
+ boolean splitCdataSections = true;
+
+ public void setParameter(String name, Object value)
+ throws DOMException
+ {
+ name = name.toLowerCase();
+ if ("cdata-sections".equals(name))
+ {
+ cdataSections = "true".equals(value.toString());
+ }
+ else if ("comments".equals(name))
+ {
+ comments = "true".equals(value.toString());
+ }
+ else if ("element-content-whitespace".equals(name))
+ {
+ elementContentWhitespace = "true".equals(value.toString());
+ }
+ else if ("entities".equals(name))
+ {
+ entities = "true".equals(value.toString());
+ }
+ else if ("error-handler".equals(name))
+ {
+ try
+ {
+ errorHandler = (DOMErrorHandler) value;
+ }
+ catch (ClassCastException e)
+ {
+ throw new DomDOMException(DOMException.TYPE_MISMATCH_ERR,
+ value.getClass().getName(), null, 0);
+ }
+ }
+ else if ("namespace-declarations".equals(name))
+ {
+ namespaceDeclarations = "true".equals(value.toString());
+ }
+ else if ("split-cdata-sections".equals(name))
+ {
+ comments = "true".equals(value.toString());
+ }
+ else if ("infoset".equals(name))
+ {
+ if ("true".equals(value.toString()))
+ {
+ entities = false;
+ cdataSections = false;
+ namespaceDeclarations = true;
+ elementContentWhitespace = true;
+ comments = true;
+ }
+ }
+ else if (("canonical-form".equals(name) ||
+ "check-character-normalization".equals(name) ||
+ "datatype-normalization".equals(name) ||
+ "normalize-characters".equals(name) ||
+ "validate".equals(name) ||
+ "validate-if-schema".equals(name)) &&
+ "false".equals(value.toString()))
+ {
+ // NOOP
+ }
+ else if (("namespaces".equals(name) ||
+ "well-formed".equals(name)) &&
+ "true".equals(value.toString()))
+ {
+ // NOOP
+ }
+ else
+ {
+ throw new DomDOMException(DOMException.NOT_SUPPORTED_ERR,
+ name, null, 0);
+ }
+ }
+
+ public Object getParameter(String name)
+ throws DOMException
+ {
+ name = name.toLowerCase();
+ if ("cdata-sections".equals(name))
+ {
+ return cdataSections ? Boolean.TRUE : Boolean.FALSE;
+ }
+ else if ("comments".equals(name))
+ {
+ return comments ? Boolean.TRUE : Boolean.FALSE;
+ }
+ else if ("element-content-whitespace".equals(name))
+ {
+ return elementContentWhitespace ? Boolean.TRUE : Boolean.FALSE;
+ }
+ else if ("entities".equals(name))
+ {
+ return entities ? Boolean.TRUE : Boolean.FALSE;
+ }
+ else if ("error-handler".equals(name))
+ {
+ return errorHandler;
+ }
+ else if ("namespace-declarations".equals(name))
+ {
+ return namespaceDeclarations ? Boolean.TRUE : Boolean.FALSE;
+ }
+ else if ("split-cdata-sections".equals(name))
+ {
+ return comments ? Boolean.TRUE : Boolean.FALSE;
+ }
+ else if ("canonical-form".equals(name) ||
+ "check-character-normalization".equals(name) ||
+ "datatype-normalization".equals(name) ||
+ "normalize-characters".equals(name) ||
+ "validate".equals(name) ||
+ "validate-if-schema".equals(name))
+ {
+ return Boolean.FALSE;
+ }
+ else if ("namespaces".equals(name) ||
+ "well-formed".equals(name))
+ {
+ return Boolean.TRUE;
+ }
+ else if ("infoset".equals(name))
+ {
+ return (entities == false &&
+ cdataSections == false &&
+ namespaceDeclarations == true &&
+ comments == true) ? Boolean.TRUE : Boolean.FALSE;
+ }
+ throw new DomDOMException(DOMException.NOT_SUPPORTED_ERR, name, null, 0);
+ }
+
+ public boolean canSetParameter(String name, Object value)
+ {
+ name = name.toLowerCase();
+ if ("error-handler".equals(name))
+ {
+ return (value == null || value instanceof DOMErrorHandler);
+ }
+ else if (contains(name))
+ {
+ return true;
+ }
+ else if ("canonical-form".equals(name) ||
+ "check-character-normalization".equals(name) ||
+ "datatype-normalization".equals(name) ||
+ "normalize-characters".equals(name) ||
+ "validate".equals(name) ||
+ "validate-if-schema".equals(name))
+ {
+ return "false".equals(value.toString());
+ }
+ else if ("namespaces".equals(name) ||
+ "well-formed".equals(name))
+ {
+ return "true".equals(value.toString());
+ }
+ return false;
+ }
+
+ public DOMStringList getParameterNames()
+ {
+ return this;
+ }
+
+ public String item(int i)
+ {
+ try
+ {
+ return (String) SUPPORTED_PARAMETERS.get(i);
+ }
+ catch (IndexOutOfBoundsException e)
+ {
+ return null;
+ }
+ }
+
+ public int getLength()
+ {
+ return SUPPORTED_PARAMETERS.size();
+ }
+
+ public boolean contains(String str)
+ {
+ str = str.toLowerCase();
+ return SUPPORTED_PARAMETERS.contains(str);
+ }
+
+}
Added: llvm-gcc-4.2/trunk/libjava/classpath/gnu/xml/dom/DomDocumentFragment.java
URL: http://llvm.org/viewvc/llvm-project/llvm-gcc-4.2/trunk/libjava/classpath/gnu/xml/dom/DomDocumentFragment.java?rev=43913&view=auto
==============================================================================
--- llvm-gcc-4.2/trunk/libjava/classpath/gnu/xml/dom/DomDocumentFragment.java (added)
+++ llvm-gcc-4.2/trunk/libjava/classpath/gnu/xml/dom/DomDocumentFragment.java Thu Nov 8 16:56:19 2007
@@ -0,0 +1,76 @@
+/* DomDocumentFragment.java --
+ Copyright (C) 1999,2000,2001,2004 Free Software Foundation, Inc.
+
+This file is part of GNU Classpath.
+
+GNU Classpath is free software; you can redistribute it and/or modify
+it under the terms of the GNU General Public License as published by
+the Free Software Foundation; either version 2, or (at your option)
+any later version.
+
+GNU Classpath is distributed in the hope that it will be useful, but
+WITHOUT ANY WARRANTY; without even the implied warranty of
+MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+General Public License for more details.
+
+You should have received a copy of the GNU General Public License
+along with GNU Classpath; see the file COPYING. If not, write to the
+Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA
+02110-1301 USA.
+
+Linking this library statically or dynamically with other modules is
+making a combined work based on this library. Thus, the terms and
+conditions of the GNU General Public License cover the whole
+combination.
+
+As a special exception, the copyright holders of this library give you
+permission to link this library with independent modules to produce an
+executable, regardless of the license terms of these independent
+modules, and to copy and distribute the resulting executable under
+terms of your choice, provided that you also meet, for each linked
+independent module, the terms and conditions of the license of that
+module. An independent module is a module which is not derived from
+or based on this library. If you modify this library, you may extend
+this exception to your version of the library, but you are not
+obligated to do so. If you do not wish to do so, delete this
+exception statement from your version. */
+
+package gnu.xml.dom;
+
+import org.w3c.dom.DocumentFragment;
+
+/**
+ * <p> "DocumentFragment" implementation. </p>
+ *
+ * @author David Brownell
+ * @author <a href='mailto:dog at gnu.org'>Chris Burdess</a>
+ */
+public class DomDocumentFragment
+ extends DomNode
+ implements DocumentFragment
+{
+
+ /**
+ * Constructs a DocumentFragment node associated with the
+ * specified document.
+ *
+ * <p>This constructor should only be invoked by a Document as part of
+ * its createDocumentFragment functionality, or through a subclass which
+ * is similarly used in a "Sub-DOM" style layer.
+ */
+ protected DomDocumentFragment(DomDocument owner)
+ {
+ super(DOCUMENT_FRAGMENT_NODE, owner);
+ }
+
+ /**
+ * <b>DOM L1</b>
+ * Returns the string "#document-fragment".
+ */
+ final public String getNodeName()
+ {
+ return "#document-fragment";
+ }
+
+}
+
Added: llvm-gcc-4.2/trunk/libjava/classpath/gnu/xml/dom/DomElement.java
URL: http://llvm.org/viewvc/llvm-project/llvm-gcc-4.2/trunk/libjava/classpath/gnu/xml/dom/DomElement.java?rev=43913&view=auto
==============================================================================
--- llvm-gcc-4.2/trunk/libjava/classpath/gnu/xml/dom/DomElement.java (added)
+++ llvm-gcc-4.2/trunk/libjava/classpath/gnu/xml/dom/DomElement.java Thu Nov 8 16:56:19 2007
@@ -0,0 +1,556 @@
+/* DomElement.java --
+ Copyright (C) 1999,2000,2001,2004 Free Software Foundation, Inc.
+
+This file is part of GNU Classpath.
+
+GNU Classpath is free software; you can redistribute it and/or modify
+it under the terms of the GNU General Public License as published by
+the Free Software Foundation; either version 2, or (at your option)
+any later version.
+
+GNU Classpath is distributed in the hope that it will be useful, but
+WITHOUT ANY WARRANTY; without even the implied warranty of
+MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+General Public License for more details.
+
+You should have received a copy of the GNU General Public License
+along with GNU Classpath; see the file COPYING. If not, write to the
+Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA
+02110-1301 USA.
+
+Linking this library statically or dynamically with other modules is
+making a combined work based on this library. Thus, the terms and
+conditions of the GNU General Public License cover the whole
+combination.
+
+As a special exception, the copyright holders of this library give you
+permission to link this library with independent modules to produce an
+executable, regardless of the license terms of these independent
+modules, and to copy and distribute the resulting executable under
+terms of your choice, provided that you also meet, for each linked
+independent module, the terms and conditions of the license of that
+module. An independent module is a module which is not derived from
+or based on this library. If you modify this library, you may extend
+this exception to your version of the library, but you are not
+obligated to do so. If you do not wish to do so, delete this
+exception statement from your version. */
+
+package gnu.xml.dom;
+
+import java.util.HashSet;
+import java.util.Set;
+import javax.xml.XMLConstants;
+
+import org.w3c.dom.Attr;
+import org.w3c.dom.DOMException;
+import org.w3c.dom.Element;
+import org.w3c.dom.NamedNodeMap;
+import org.w3c.dom.Node;
+import org.w3c.dom.TypeInfo;
+
+/**
+ * <p> "Element" implementation.
+ *
+ * @author David Brownell
+ * @author <a href='mailto:dog at gnu.org'>Chris Burdess</a>
+ */
+public class DomElement
+ extends DomNsNode
+ implements Element
+{
+
+ /**
+ * User-defined ID attributes.
+ * Used by DomAttr.isId and DomDocument.getElementById
+ */
+ Set userIdAttrs;
+
+ // Attributes are VERY expensive in DOM, and not just for
+ // this implementation. Avoid creating them.
+ private DomNamedNodeMap attributes;
+
+ // xml:space cache
+ String xmlSpace = "";
+
+ /**
+ * Constructs an Element node associated with the specified document.
+ *
+ * <p>This constructor should only be invoked by a Document as part
+ * of its createElement functionality, or through a subclass which is
+ * similarly used in a "Sub-DOM" style layer.
+ *
+ * @param owner The document with which this node is associated
+ * @param namespaceURI Combined with the local part of the name,
+ * this is used to uniquely identify a type of element
+ * @param name Name of this element, which may include a prefix
+ */
+ protected DomElement(DomDocument owner, String namespaceURI, String name)
+ {
+ super(ELEMENT_NODE, owner, namespaceURI, name);
+ }
+
+ /**
+ * <b>DOM L1</b>
+ * Returns the element's attributes
+ */
+ public NamedNodeMap getAttributes()
+ {
+ if (attributes == null)
+ {
+ attributes = new DomNamedNodeMap(this, Node.ATTRIBUTE_NODE);
+ }
+ return attributes;
+ }
+
+ /**
+ * <b>DOM L2></b>
+ * Returns true iff this is an element node with attributes.
+ */
+ public boolean hasAttributes()
+ {
+ return attributes != null && attributes.length != 0;
+ }
+
+ /**
+ * Shallow clone of the element, except that associated
+ * attributes are (deep) cloned.
+ */
+ public Object clone()
+ {
+ DomElement node = (DomElement) super.clone();
+
+ if (attributes != null)
+ {
+ node.attributes = new DomNamedNodeMap(node, Node.ATTRIBUTE_NODE);
+ for (DomNode ctx = attributes.first; ctx != null; ctx = ctx.next)
+ {
+ node.attributes.setNamedItemNS(ctx.cloneNode(true));
+ }
+ }
+ return node;
+ }
+
+ void setOwner(DomDocument doc)
+ {
+ if (attributes != null)
+ {
+ for (DomNode ctx = attributes.first; ctx != null; ctx = ctx.next)
+ {
+ ctx.setOwner(doc);
+ }
+ }
+ super.setOwner(doc);
+ }
+
+ /**
+ * Marks this element, its children, and its associated attributes as
+ * readonly.
+ */
+ public void makeReadonly()
+ {
+ super.makeReadonly();
+ if (attributes != null)
+ {
+ attributes.makeReadonly();
+ }
+ }
+
+ /**
+ * <b>DOM L1</b>
+ * Returns the element name (same as getNodeName).
+ */
+ final public String getTagName()
+ {
+ return getNodeName();
+ }
+
+ /**
+ * <b>DOM L1</b>
+ * Returns the value of the specified attribute, or an
+ * empty string.
+ */
+ public String getAttribute(String name)
+ {
+ if ("xml:space" == name) // NB only works on interned string
+ {
+ // Use cached value
+ return xmlSpace;
+ }
+ Attr attr = getAttributeNode(name);
+ return (attr == null) ? "" : attr.getValue();
+ }
+
+ /**
+ * <b>DOM L2</b>
+ * Returns true if the element has an attribute with the
+ * specified name (specified or DTD defaulted).
+ */
+ public boolean hasAttribute(String name)
+ {
+ return getAttributeNode(name) != null;
+ }
+
+ /**
+ * <b>DOM L2</b>
+ * Returns true if the element has an attribute with the
+ * specified name (specified or DTD defaulted).
+ */
+ public boolean hasAttributeNS(String namespaceURI, String local)
+ {
+ return getAttributeNodeNS(namespaceURI, local) != null;
+ }
+
+ /**
+ * <b>DOM L2</b>
+ * Returns the value of the specified attribute, or an
+ * empty string.
+ */
+ public String getAttributeNS(String namespaceURI, String local)
+ {
+ Attr attr = getAttributeNodeNS(namespaceURI, local);
+ return (attr == null) ? "" : attr.getValue();
+ }
+
+ /**
+ * <b>DOM L1</b>
+ * Returns the appropriate attribute node; the name is the
+ * nodeName property of the attribute.
+ */
+ public Attr getAttributeNode(String name)
+ {
+ return (attributes == null) ? null :
+ (Attr) attributes.getNamedItem(name);
+ }
+
+ /**
+ * <b>DOM L2</b>
+ * Returns the appropriate attribute node; the name combines
+ * the namespace name and the local part.
+ */
+ public Attr getAttributeNodeNS(String namespace, String localPart)
+ {
+ return (attributes == null) ? null :
+ (Attr) attributes.getNamedItemNS(namespace, localPart);
+ }
+
+ /**
+ * <b>DOM L1</b>
+ * Modifies an existing attribute to have the specified value,
+ * or creates a new one with that value. The name used is the
+ * nodeName value.
+ */
+ public void setAttribute(String name, String value)
+ {
+ Attr attr = getAttributeNode(name);
+ if (attr != null)
+ {
+ attr.setNodeValue(value);
+ ((DomAttr) attr).setSpecified(true);
+ return;
+ }
+ attr = owner.createAttribute(name);
+ attr.setNodeValue(value);
+ setAttributeNode(attr);
+ }
+
+ /**
+ * <b>DOM L2</b>
+ * Modifies an existing attribute to have the specified value,
+ * or creates a new one with that value.
+ */
+ public void setAttributeNS(String uri, String aname, String value)
+ {
+ if (("xmlns".equals (aname) || aname.startsWith ("xmlns:"))
+ && !XMLConstants.XMLNS_ATTRIBUTE_NS_URI.equals (uri))
+ {
+ throw new DomDOMException(DOMException.NAMESPACE_ERR,
+ "setting xmlns attribute to illegal value", this, 0);
+ }
+
+ Attr attr = getAttributeNodeNS(uri, aname);
+ if (attr != null)
+ {
+ attr.setNodeValue(value);
+ return;
+ }
+ attr = owner.createAttributeNS(uri, aname);
+ attr.setNodeValue(value);
+ setAttributeNodeNS(attr);
+ }
+
+ /**
+ * <b>DOM L1</b>
+ * Stores the specified attribute, optionally overwriting any
+ * existing one with that name.
+ */
+ public Attr setAttributeNode(Attr attr)
+ {
+ return (Attr) getAttributes().setNamedItem(attr);
+ }
+
+ /**
+ * <b>DOM L2</b>
+ * Stores the specified attribute, optionally overwriting any
+ * existing one with that name.
+ */
+ public Attr setAttributeNodeNS(Attr attr)
+ {
+ return (Attr) getAttributes().setNamedItemNS(attr);
+ }
+
+ /**
+ * <b>DOM L1</b>
+ * Removes the appropriate attribute node.
+ * If there is no such node, this is (bizarrely enough) a NOP so you
+ * won't see exceptions if your code deletes non-existent attributes.
+ *
+ * <p>Note that since there is no portable way for DOM to record
+ * DTD information, default values for attributes will never be
+ * provided automatically.
+ */
+ public void removeAttribute(String name)
+ {
+ if (attributes == null)
+ {
+ return;
+ }
+
+ try
+ {
+ attributes.removeNamedItem(name);
+ }
+ catch (DomDOMException e)
+ {
+ if (e.code != DOMException.NOT_FOUND_ERR)
+ {
+ throw e;
+ }
+ }
+ }
+
+ /**
+ * <b>DOM L1</b>
+ * Removes the appropriate attribute node; the name is the
+ * nodeName property of the attribute.
+ *
+ * <p>Note that since there is no portable way for DOM to record
+ * DTD information, default values for attributes will never be
+ * provided automatically.
+ */
+ public Attr removeAttributeNode(Attr node)
+ {
+ if (attributes == null)
+ {
+ throw new DomDOMException(DOMException.NOT_FOUND_ERR, null, node, 0);
+ }
+ return (Attr) attributes.removeNamedItem(node.getNodeName());
+ }
+
+ /**
+ * <b>DOM L2</b>
+ * Removes the appropriate attribute node; the name combines
+ * the namespace name and the local part.
+ *
+ * <p>Note that since there is no portable way for DOM to record
+ * DTD information, default values for attributes will never be
+ * provided automatically.
+ */
+ public void removeAttributeNS(String namespace, String localPart)
+ {
+ if (attributes == null)
+ {
+ throw new DomDOMException(DOMException.NOT_FOUND_ERR, localPart, null, 0);
+ }
+ attributes.removeNamedItemNS (namespace, localPart);
+ }
+
+ // DOM Level 3 methods
+
+ public String lookupPrefix(String namespaceURI)
+ {
+ if (namespaceURI == null)
+ {
+ return null;
+ }
+ String namespace = getNamespaceURI();
+ if (namespace != null && namespace.equals(namespaceURI))
+ {
+ return getPrefix();
+ }
+ if (attributes != null)
+ {
+ for (DomNode ctx = attributes.first; ctx != null; ctx = ctx.next)
+ {
+ if (XMLConstants.XMLNS_ATTRIBUTE_NS_URI
+ .equals(ctx.getNamespaceURI()))
+ {
+ String value = ctx.getNodeValue();
+ if (value.equals(namespaceURI))
+ {
+ return ctx.getLocalName();
+ }
+ }
+ }
+ }
+ return super.lookupPrefix(namespaceURI);
+ }
+
+ public boolean isDefaultNamespace(String namespaceURI)
+ {
+ String namespace = getNamespaceURI();
+ if (namespace != null && namespace.equals(namespaceURI))
+ {
+ return getPrefix() == null;
+ }
+ if (attributes != null)
+ {
+ for (DomNode ctx = attributes.first; ctx != null; ctx = ctx.next)
+ {
+ if (XMLConstants.XMLNS_ATTRIBUTE_NS_URI
+ .equals(ctx.getNamespaceURI()))
+ {
+ String qName = ctx.getNodeName();
+ return (XMLConstants.XMLNS_ATTRIBUTE.equals(qName));
+ }
+ }
+ }
+ return super.isDefaultNamespace(namespaceURI);
+ }
+
+ public String lookupNamespaceURI(String prefix)
+ {
+ String namespace = getNamespaceURI();
+ if (namespace != null && equal(prefix, getPrefix()))
+ {
+ return namespace;
+ }
+ if (attributes != null)
+ {
+ for (DomNode ctx = attributes.first; ctx != null; ctx = ctx.next)
+ {
+ if (XMLConstants.XMLNS_ATTRIBUTE_NS_URI
+ .equals(ctx.getNamespaceURI()))
+ {
+ if (prefix == null)
+ {
+ if (XMLConstants.XMLNS_ATTRIBUTE.equals(ctx.getNodeName()))
+ {
+ return ctx.getNodeValue();
+ }
+ }
+ else
+ {
+ if (prefix.equals(ctx.getLocalName()))
+ {
+ return ctx.getNodeValue();
+ }
+ }
+ }
+ }
+ }
+ return super.lookupNamespaceURI(prefix);
+ }
+
+ public String getBaseURI()
+ {
+ if (attributes != null)
+ {
+ Node xmlBase =
+ attributes.getNamedItemNS(XMLConstants.XML_NS_URI, "base");
+ if (xmlBase != null)
+ {
+ return xmlBase.getNodeValue();
+ }
+ }
+ return super.getBaseURI();
+ }
+
+ public TypeInfo getSchemaTypeInfo()
+ {
+ // DTD implementation
+ DomDoctype doctype = (DomDoctype) owner.getDoctype();
+ if (doctype != null)
+ {
+ return doctype.getElementTypeInfo(getNodeName());
+ }
+ // TODO XML Schema implementation
+ return null;
+ }
+
+ public void setIdAttribute(String name, boolean isId)
+ {
+ NamedNodeMap attrs = getAttributes();
+ Attr attr = (Attr) attrs.getNamedItem(name);
+ setIdAttributeNode(attr, isId);
+ }
+
+ public void setIdAttributeNode(Attr attr, boolean isId)
+ {
+ if (readonly)
+ {
+ throw new DomDOMException(DOMException.NO_MODIFICATION_ALLOWED_ERR);
+ }
+ if (attr == null || attr.getOwnerElement() != this)
+ {
+ throw new DomDOMException(DOMException.NOT_FOUND_ERR);
+ }
+ if (isId)
+ {
+ if (userIdAttrs == null)
+ {
+ userIdAttrs = new HashSet();
+ }
+ userIdAttrs.add(attr);
+ }
+ else if (userIdAttrs != null)
+ {
+ userIdAttrs.remove(attr);
+ if (userIdAttrs.isEmpty())
+ {
+ userIdAttrs = null;
+ }
+ }
+ }
+
+ public void setIdAttributeNS(String namespaceURI, String localName,
+ boolean isId)
+ {
+ NamedNodeMap attrs = getAttributes();
+ Attr attr = (Attr) attrs.getNamedItemNS(namespaceURI, localName);
+ setIdAttributeNode(attr, isId);
+ }
+
+ public boolean isEqualNode(Node arg)
+ {
+ if (!super.isEqualNode(arg))
+ return false;
+ getAttributes();
+ NamedNodeMap argAttrs = arg.getAttributes();
+ int len = argAttrs.getLength();
+ if (argAttrs == null || (len != attributes.length))
+ return false;
+ for (int i = 0; i < len; i++)
+ {
+ Node argCtx = argAttrs.item(i);
+ // Don't compare namespace nodes
+ if (XMLConstants.XMLNS_ATTRIBUTE_NS_URI
+ .equals(argCtx.getNamespaceURI()))
+ continue;
+ // Find corresponding attribute node
+ DomNode ctx = attributes.first;
+ for (; ctx != null; ctx = ctx.next)
+ {
+ if (XMLConstants.XMLNS_ATTRIBUTE_NS_URI
+ .equals(ctx.getNamespaceURI()))
+ continue;
+ if (!ctx.isEqualNode(argCtx))
+ continue;
+ break;
+ }
+ if (ctx == null)
+ return false; // not found
+ }
+ return true;
+ }
+
+}
Added: llvm-gcc-4.2/trunk/libjava/classpath/gnu/xml/dom/DomEntity.java
URL: http://llvm.org/viewvc/llvm-project/llvm-gcc-4.2/trunk/libjava/classpath/gnu/xml/dom/DomEntity.java?rev=43913&view=auto
==============================================================================
--- llvm-gcc-4.2/trunk/libjava/classpath/gnu/xml/dom/DomEntity.java (added)
+++ llvm-gcc-4.2/trunk/libjava/classpath/gnu/xml/dom/DomEntity.java Thu Nov 8 16:56:19 2007
@@ -0,0 +1,147 @@
+/* DomEntity.java --
+ Copyright (C) 1999,2000,2004 Free Software Foundation, Inc.
+
+This file is part of GNU Classpath.
+
+GNU Classpath is free software; you can redistribute it and/or modify
+it under the terms of the GNU General Public License as published by
+the Free Software Foundation; either version 2, or (at your option)
+any later version.
+
+GNU Classpath is distributed in the hope that it will be useful, but
+WITHOUT ANY WARRANTY; without even the implied warranty of
+MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+General Public License for more details.
+
+You should have received a copy of the GNU General Public License
+along with GNU Classpath; see the file COPYING. If not, write to the
+Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA
+02110-1301 USA.
+
+Linking this library statically or dynamically with other modules is
+making a combined work based on this library. Thus, the terms and
+conditions of the GNU General Public License cover the whole
+combination.
+
+As a special exception, the copyright holders of this library give you
+permission to link this library with independent modules to produce an
+executable, regardless of the license terms of these independent
+modules, and to copy and distribute the resulting executable under
+terms of your choice, provided that you also meet, for each linked
+independent module, the terms and conditions of the license of that
+module. An independent module is a module which is not derived from
+or based on this library. If you modify this library, you may extend
+this exception to your version of the library, but you are not
+obligated to do so. If you do not wish to do so, delete this
+exception statement from your version. */
+
+package gnu.xml.dom;
+
+import org.w3c.dom.Entity;
+
+/**
+ * <p> "Entity" implementation. This is a non-core DOM class, supporting the
+ * "XML" feature. There are two types of entities, neither of which works
+ * particularly well in this API:</p><dl>
+ *
+ * <dt><em>Unparsed Entities</em></dt>
+ * <dd>Since ENTITY/ENTITIES attributes, the only legal use of unparsed
+ * entities in XML, can't be detected with DOM, there isn't much point in
+ * trying to use unparsed entities in DOM applications. (XML Linking is
+ * working to provide a better version of this functionality.) </dd>
+ *
+ * <dt><em>Parsed Entities</em></dt>
+ * <dd> While the DOM specification permits nodes for parsed entities
+ * to have a readonly set of children, this is not required and there
+ * is no portable way to provide such children. <em>This implementation
+ * currently does not permit children to be added to Entities.</em>
+ * There are related issues with the use of EntityReference nodes. </dd>
+ *
+ * </dl>
+ *
+ * <p> In short, <em>avoid using this DOM functionality</em>.
+ *
+ * @see DomDoctype
+ * @see DomEntityReference
+ * @see DomNotation
+ *
+ * @author David Brownell
+ * @author <a href='mailto:dog at gnu.org'>Chris Burdess</a>
+ */
+public class DomEntity
+ extends DomExtern
+ implements Entity
+{
+
+ private String notation;
+
+ /**
+ * Constructs an Entity node associated with the specified document,
+ * with the specified descriptive data.
+ *
+ * <p>This constructor should only be invoked by a DomDoctype as part
+ * of its declareEntity functionality, or through a subclass which is
+ * similarly used in a "Sub-DOM" style layer.
+ *
+ * @param owner The document with which this entity is associated
+ * @param name Name of this entity
+ * @param publicId If non-null, provides the entity's PUBLIC identifier
+ * @param systemId Provides the entity's SYSTEM identifier (URI)
+ * @param notation If non-null, provides the unparsed entity's notation.
+ */
+ protected DomEntity(DomDocument owner,
+ String name,
+ String publicId,
+ String systemId,
+ String notation)
+ {
+ super(ENTITY_NODE, owner, name, publicId, systemId);
+ this.notation = notation;
+
+ // NOTE: if notation == null, this is a parsed entity
+ // which could reasonably be given child nodes ...
+ makeReadonly();
+ }
+
+ /**
+ * <b>DOM L1</b>
+ * Returns the NOTATION identifier associated with this entity, if any.
+ */
+ final public String getNotationName()
+ {
+ return notation;
+ }
+
+ // DOM Level 3 methods
+
+ public String getInputEncoding()
+ {
+ // TODO
+ return null;
+ }
+
+ public String getXmlEncoding()
+ {
+ // TODO
+ return null;
+ }
+
+ public String getXmlVersion()
+ {
+ // TODO
+ return null;
+ }
+
+ /**
+ * The base URI of an external entity is its system ID.
+ * The base URI of an internal entity is the parent document's base URI.
+ * @since DOM Level 3 Core
+ */
+ public String getBaseURI()
+ {
+ String systemId = getSystemId();
+ return (systemId == null) ? owner.getBaseURI() : systemId;
+ }
+
+}
+
Added: llvm-gcc-4.2/trunk/libjava/classpath/gnu/xml/dom/DomEntityReference.java
URL: http://llvm.org/viewvc/llvm-project/llvm-gcc-4.2/trunk/libjava/classpath/gnu/xml/dom/DomEntityReference.java?rev=43913&view=auto
==============================================================================
--- llvm-gcc-4.2/trunk/libjava/classpath/gnu/xml/dom/DomEntityReference.java (added)
+++ llvm-gcc-4.2/trunk/libjava/classpath/gnu/xml/dom/DomEntityReference.java Thu Nov 8 16:56:19 2007
@@ -0,0 +1,130 @@
+/* DomEntityReference.java --
+ Copyright (C) 1999,2000,2001,2004 Free Software Foundation, Inc.
+
+This file is part of GNU Classpath.
+
+GNU Classpath is free software; you can redistribute it and/or modify
+it under the terms of the GNU General Public License as published by
+the Free Software Foundation; either version 2, or (at your option)
+any later version.
+
+GNU Classpath is distributed in the hope that it will be useful, but
+WITHOUT ANY WARRANTY; without even the implied warranty of
+MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+General Public License for more details.
+
+You should have received a copy of the GNU General Public License
+along with GNU Classpath; see the file COPYING. If not, write to the
+Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA
+02110-1301 USA.
+
+Linking this library statically or dynamically with other modules is
+making a combined work based on this library. Thus, the terms and
+conditions of the GNU General Public License cover the whole
+combination.
+
+As a special exception, the copyright holders of this library give you
+permission to link this library with independent modules to produce an
+executable, regardless of the license terms of these independent
+modules, and to copy and distribute the resulting executable under
+terms of your choice, provided that you also meet, for each linked
+independent module, the terms and conditions of the license of that
+module. An independent module is a module which is not derived from
+or based on this library. If you modify this library, you may extend
+this exception to your version of the library, but you are not
+obligated to do so. If you do not wish to do so, delete this
+exception statement from your version. */
+
+package gnu.xml.dom;
+
+import org.w3c.dom.DocumentType;
+import org.w3c.dom.Entity;
+import org.w3c.dom.EntityReference;
+
+/**
+ * <p> "EntityReference" implementation (reference to parsed entity).
+ * This is a non-core DOM class, supporting the "XML" feature.
+ * It does not represent builtin entities (such as "&")
+ * or character references, which are always directly expanded in
+ * DOM trees.</p>
+ *
+ * <p> Note that while the DOM specification permits these nodes to have
+ * a readonly set of children, this is not required. Similarly, it does
+ * not require a DOM to couple EntityReference nodes with any Entity nodes
+ * that have the same entity name (and equivalent children). It also
+ * effectively guarantees that references created directly or indirectly
+ * through the <em>Document.ImportNode</em> method will not have children.
+ * The level of functionality you may get is extremely variable.
+ *
+ * <p> Also significant is that even at their most functional level, the fact
+ * that EntityReference children must be readonly has caused significant
+ * problems when modifying work products held in DOM trees. Other problems
+ * include issues related to undeclared namespace prefixes (and references
+ * to the current default namespace) that may be found in the text of such
+ * parsed entities nodes. These must be contextually bound as part of DOM
+ * tree construction. When such nodes are moved, the namespace associated
+ * with a given prefix (or default) may change to be in conflict with the
+ * namespace bound to the node at creation time.
+ *
+ * <p> In short, <em>avoid using this DOM functionality</em>.
+ *
+ * @see DomDoctype
+ * @see DomEntity
+ *
+ * @author David Brownell
+ * @author <a href='mailto:dog at gnu.org'>Chris Burdess</a>
+ */
+public class DomEntityReference
+ extends DomNode
+ implements EntityReference
+{
+
+ private String name;
+
+ /**
+ * Constructs an EntityReference node associated with the specified
+ * document. The creator should populate this with whatever contents
+ * are appropriate, and then mark it as readonly.
+ *
+ * <p>This constructor should only be invoked by a Document as part of
+ * its createEntityReference functionality, or through a subclass which
+ * is similarly used in a "Sub-DOM" style layer.
+ *
+ * @see DomNode#makeReadonly
+ */
+ protected DomEntityReference(DomDocument owner, String name)
+ {
+ super(ENTITY_REFERENCE_NODE, owner);
+ this.name = name;
+ }
+
+ /**
+ * Returns the name of the referenced entity.
+ * @since DOM Level 1 Core
+ */
+ public final String getNodeName()
+ {
+ return name;
+ }
+
+ /**
+ * The base URI of an entity reference is the base URI where the entity
+ * declaration occurs.
+ * @since DOM Level 3 Core
+ */
+ public final String getBaseURI()
+ {
+ DocumentType doctype = owner.getDoctype();
+ if (doctype == null)
+ {
+ return null;
+ }
+ Entity entity = (Entity) doctype.getEntities().getNamedItem(name);
+ if (entity == null)
+ {
+ return null;
+ }
+ return entity.getBaseURI();
+ }
+
+}
Added: llvm-gcc-4.2/trunk/libjava/classpath/gnu/xml/dom/DomEvent.java
URL: http://llvm.org/viewvc/llvm-project/llvm-gcc-4.2/trunk/libjava/classpath/gnu/xml/dom/DomEvent.java?rev=43913&view=auto
==============================================================================
--- llvm-gcc-4.2/trunk/libjava/classpath/gnu/xml/dom/DomEvent.java (added)
+++ llvm-gcc-4.2/trunk/libjava/classpath/gnu/xml/dom/DomEvent.java Thu Nov 8 16:56:19 2007
@@ -0,0 +1,345 @@
+/* DomEvent.java --
+ Copyright (C) 1999,2000,2001 Free Software Foundation, Inc.
+
+This file is part of GNU Classpath.
+
+GNU Classpath is free software; you can redistribute it and/or modify
+it under the terms of the GNU General Public License as published by
+the Free Software Foundation; either version 2, or (at your option)
+any later version.
+
+GNU Classpath is distributed in the hope that it will be useful, but
+WITHOUT ANY WARRANTY; without even the implied warranty of
+MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+General Public License for more details.
+
+You should have received a copy of the GNU General Public License
+along with GNU Classpath; see the file COPYING. If not, write to the
+Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA
+02110-1301 USA.
+
+Linking this library statically or dynamically with other modules is
+making a combined work based on this library. Thus, the terms and
+conditions of the GNU General Public License cover the whole
+combination.
+
+As a special exception, the copyright holders of this library give you
+permission to link this library with independent modules to produce an
+executable, regardless of the license terms of these independent
+modules, and to copy and distribute the resulting executable under
+terms of your choice, provided that you also meet, for each linked
+independent module, the terms and conditions of the license of that
+module. An independent module is a module which is not derived from
+or based on this library. If you modify this library, you may extend
+this exception to your version of the library, but you are not
+obligated to do so. If you do not wish to do so, delete this
+exception statement from your version. */
+
+package gnu.xml.dom;
+
+import org.w3c.dom.*;
+import org.w3c.dom.events.*;
+import org.w3c.dom.views.AbstractView; // used by UIEvent
+
+/**
+ * "Event" implementation. Events are
+ * created (through DocumentEvent interface methods on the document object),
+ * and are sent to any target node in the document.
+ *
+ * <p> Applications may define application specific event subclasses, but
+ * should otherwise use the <em>DocumentTraversal</em> interface to acquire
+ * event objects.
+ *
+ * @author David Brownell
+ */
+public class DomEvent
+ implements Event
+{
+
+ String type; // init
+ EventTarget target;
+ EventTarget currentNode;
+ short eventPhase;
+ boolean bubbles; // init
+ boolean cancelable; // init
+ long timeStamp; // ?
+
+ /** Returns the event's type (name) as initialized */
+ public final String getType()
+ {
+ return type;
+ }
+
+ /**
+ * Returns event's target; delivery of an event is initiated
+ * by a <em>target.dispatchEvent(event)</em> invocation.
+ */
+ public final EventTarget getTarget()
+ {
+ return target;
+ }
+
+ /**
+ * Returns the target to which events are currently being
+ * delivered. When capturing or bubbling, this will not
+ * be what <em>getTarget</em> returns.
+ */
+ public final EventTarget getCurrentTarget()
+ {
+ return currentNode;
+ }
+
+ /**
+ * Returns CAPTURING_PHASE, AT_TARGET, or BUBBLING;
+ * only meaningful within EventListener.handleEvent
+ */
+ public final short getEventPhase()
+ {
+ return eventPhase;
+ }
+
+ /**
+ * Returns true if the news of the event bubbles to tree tops
+ * (as specified during initialization).
+ */
+ public final boolean getBubbles()
+ {
+ return bubbles;
+ }
+
+ /**
+ * Returns true if the default handling may be canceled
+ * (as specified during initialization).
+ */
+ public final boolean getCancelable()
+ {
+ return cancelable;
+ }
+
+ /**
+ * Returns the event's timestamp.
+ */
+ public final long getTimeStamp()
+ {
+ return timeStamp;
+ }
+
+ boolean stop;
+ boolean doDefault;
+
+ /**
+ * Requests the event no longer be captured or bubbled; only
+ * listeners on the event target will see the event, if they
+ * haven't yet been notified.
+ *
+ * <p> <em> Avoid using this </em> except for application-specific
+ * events, for which you the protocol explicitly "blesses" the use
+ * of this with some event types. Otherwise, you are likely to break
+ * algorithms which depend on event notification either directly or
+ * through bubbling or capturing. </p>
+ *
+ * <p> Note that this method is not final, specifically to enable
+ * enforcing of policies about events always propagating. </p>
+ */
+ public void stopPropagation()
+ {
+ stop = true;
+ }
+
+ /**
+ * Requests that whoever dispatched the event not perform their
+ * default processing when event delivery completes. Initializes
+ * event timestamp.
+ */
+ public final void preventDefault()
+ {
+ doDefault = false;
+ }
+
+ /** Initializes basic event state. */
+ public void initEvent(String typeArg,
+ boolean canBubbleArg,
+ boolean cancelableArg)
+ {
+ eventPhase = 0;
+ type = typeArg;
+ bubbles = canBubbleArg;
+ cancelable = cancelableArg;
+ timeStamp = System.currentTimeMillis();
+ }
+
+ /** Constructs, but does not initialize, an event. */
+ public DomEvent(String type)
+ {
+ this.type = type;
+ }
+
+ /**
+ * Returns a basic printable description of the event's type,
+ * state, and delivery conditions
+ */
+ public String toString()
+ {
+ StringBuffer buf = new StringBuffer("[Event ");
+ buf.append(type);
+ switch (eventPhase)
+ {
+ case CAPTURING_PHASE:
+ buf.append(", CAPTURING");
+ break;
+ case AT_TARGET:
+ buf.append(", AT TARGET");
+ break;
+ case BUBBLING_PHASE:
+ buf.append(", BUBBLING");
+ break;
+ default:
+ buf.append(", (inactive)");
+ break;
+ }
+ if (bubbles && eventPhase != BUBBLING_PHASE)
+ {
+ buf.append(", bubbles");
+ }
+ if (cancelable)
+ {
+ buf.append(", can cancel");
+ }
+ // were we to provide subclass info, this's where it'd live
+ buf.append("]");
+ return buf.toString();
+ }
+
+ /**
+ * "MutationEvent" implementation.
+ */
+ public static final class DomMutationEvent
+ extends DomEvent
+ implements MutationEvent
+ {
+
+ // package private
+ Node relatedNode; // init
+
+ private String prevValue; // init
+ private String newValue; // init
+
+ private String attrName; // init
+ private short attrChange; // init
+
+ /** Returns any "related" node provided by this type of event */
+ public final Node getRelatedNode()
+ {
+ return relatedNode;
+ }
+
+ /** Returns any "previous value" provided by this type of event */
+ public final String getPrevValue()
+ {
+ return prevValue;
+ }
+
+ /** Returns any "new value" provided by this type of event */
+ public final String getNewValue()
+ {
+ return newValue;
+ }
+
+ /** For attribute change events, returns the attribute's name */
+ public final String getAttrName()
+ {
+ return attrName;
+ }
+
+ /** For attribute change events, returns how the attribuet changed */
+ public final short getAttrChange()
+ {
+ return attrChange;
+ }
+
+ /** Initializes a mutation event */
+ public final void initMutationEvent(String typeArg,
+ boolean canBubbleArg,
+ boolean cancelableArg,
+ Node relatedNodeArg,
+ String prevValueArg,
+ String newValueArg,
+ String attrNameArg,
+ short attrChangeArg)
+ {
+ // super.initEvent is inlined here for speed
+ // (mutation events are issued on all DOM changes)
+ eventPhase = 0;
+ type = typeArg;
+ bubbles = canBubbleArg;
+ cancelable = cancelableArg;
+ timeStamp = System.currentTimeMillis();
+
+ relatedNode = relatedNodeArg;
+ prevValue = prevValueArg;
+ newValue = newValueArg;
+ attrName = attrNameArg;
+ attrChange = attrChangeArg;
+ }
+
+ // clear everything that should be GC-able
+ void clear()
+ {
+ type = null;
+ target = null;
+ relatedNode = null;
+ currentNode = null;
+ prevValue = newValue = attrName = null;
+ }
+
+ /** Constructs an uninitialized mutation event. */
+ public DomMutationEvent(String type)
+ {
+ super(type);
+ }
+
+ }
+
+ /**
+ * "UIEvent" implementation.
+ */
+ public static class DomUIEvent
+ extends DomEvent
+ implements UIEvent
+ {
+
+ private AbstractView view; // init
+ private int detail; // init
+
+ /** Constructs an uninitialized User Interface (UI) event */
+ public DomUIEvent (String type) { super (type); }
+
+ public final AbstractView getView () { return view; }
+ public final int getDetail () { return detail; }
+
+ /** Initializes a UI event */
+ public final void initUIEvent(String typeArg,
+ boolean canBubbleArg,
+ boolean cancelableArg,
+ AbstractView viewArg,
+ int detailArg)
+ {
+ super.initEvent(typeArg, canBubbleArg, cancelableArg);
+ view = viewArg;
+ detail = detailArg;
+ }
+
+ }
+
+ /*
+
+ static final class DomMouseEvent extends DomUIEvent
+ implements MouseEvent
+ {
+ // another half dozen state variables/accessors
+ }
+
+ */
+
+}
+
Added: llvm-gcc-4.2/trunk/libjava/classpath/gnu/xml/dom/DomExtern.java
URL: http://llvm.org/viewvc/llvm-project/llvm-gcc-4.2/trunk/libjava/classpath/gnu/xml/dom/DomExtern.java?rev=43913&view=auto
==============================================================================
--- llvm-gcc-4.2/trunk/libjava/classpath/gnu/xml/dom/DomExtern.java (added)
+++ llvm-gcc-4.2/trunk/libjava/classpath/gnu/xml/dom/DomExtern.java Thu Nov 8 16:56:19 2007
@@ -0,0 +1,117 @@
+/* DomExtern.java --
+ Copyright (C) 1999,2000,2001,2004 Free Software Foundation, Inc.
+
+This file is part of GNU Classpath.
+
+GNU Classpath is free software; you can redistribute it and/or modify
+it under the terms of the GNU General Public License as published by
+the Free Software Foundation; either version 2, or (at your option)
+any later version.
+
+GNU Classpath is distributed in the hope that it will be useful, but
+WITHOUT ANY WARRANTY; without even the implied warranty of
+MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+General Public License for more details.
+
+You should have received a copy of the GNU General Public License
+along with GNU Classpath; see the file COPYING. If not, write to the
+Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA
+02110-1301 USA.
+
+Linking this library statically or dynamically with other modules is
+making a combined work based on this library. Thus, the terms and
+conditions of the GNU General Public License cover the whole
+combination.
+
+As a special exception, the copyright holders of this library give you
+permission to link this library with independent modules to produce an
+executable, regardless of the license terms of these independent
+modules, and to copy and distribute the resulting executable under
+terms of your choice, provided that you also meet, for each linked
+independent module, the terms and conditions of the license of that
+module. An independent module is a module which is not derived from
+or based on this library. If you modify this library, you may extend
+this exception to your version of the library, but you are not
+obligated to do so. If you do not wish to do so, delete this
+exception statement from your version. */
+
+package gnu.xml.dom;
+
+/**
+ * <p> Abstract implemention of nodes describing external DTD-related
+ * objects. This facilitates reusing code for Entity, Notation, and
+ * DocumentType (really, external subset) nodes. Such support is not
+ * part of the core DOM; it's for the "XML" feature. </p>
+ *
+ * <p> Note that you are strongly advised to avoid using the DOM
+ * features that take advantage of this class, since (as of L2) none
+ * of them is defined fully enough to permit full use of the
+ * XML feature they partially expose. </p>
+ *
+ * @author David Brownell
+ * @author <a href='mailto:dog at gnu.org'>Chris Burdess</a>
+ */
+public abstract class DomExtern
+ extends DomNode
+{
+
+ private final String name;
+ private final String publicId;
+ private final String systemId;
+
+ /**
+ * Constructs a node associated with the specified document,
+ * with the specified descriptive data.
+ *
+ * @param owner The document with which this object is associated
+ * @param name Name of this object
+ * @param publicId If non-null, provides the entity's PUBLIC identifier
+ * @param systemId If non-null, provides the entity's SYSTEM identifier
+ */
+ // package private
+ DomExtern(short nodeType,
+ DomDocument owner,
+ String name,
+ String publicId,
+ String systemId)
+ {
+ super(nodeType, owner);
+ this.name = name;
+ this.publicId = publicId;
+ this.systemId = systemId;
+ }
+
+ /**
+ * <b>DOM L1</b>
+ * Returns the SYSTEM identifier associated with this object, if any.
+ */
+ public final String getSystemId()
+ {
+ return systemId;
+ }
+
+ /**
+ * <b>DOM L1</b>
+ * Returns the PUBLIC identifier associated with this object, if any.
+ */
+ public final String getPublicId()
+ {
+ return publicId;
+ }
+
+ /**
+ * <b>DOM L1</b>
+ * Returns the object's name.
+ */
+ public final String getNodeName()
+ {
+ return name;
+ }
+
+ public final String getLocalName()
+ {
+ return name;
+ }
+
+}
+
Added: llvm-gcc-4.2/trunk/libjava/classpath/gnu/xml/dom/DomImpl.java
URL: http://llvm.org/viewvc/llvm-project/llvm-gcc-4.2/trunk/libjava/classpath/gnu/xml/dom/DomImpl.java?rev=43913&view=auto
==============================================================================
--- llvm-gcc-4.2/trunk/libjava/classpath/gnu/xml/dom/DomImpl.java (added)
+++ llvm-gcc-4.2/trunk/libjava/classpath/gnu/xml/dom/DomImpl.java Thu Nov 8 16:56:19 2007
@@ -0,0 +1,278 @@
+/* DomImpl.java --
+ Copyright (C) 1999,2000,2001,2004 Free Software Foundation, Inc.
+
+This file is part of GNU Classpath.
+
+GNU Classpath is free software; you can redistribute it and/or modify
+it under the terms of the GNU General Public License as published by
+the Free Software Foundation; either version 2, or (at your option)
+any later version.
+
+GNU Classpath is distributed in the hope that it will be useful, but
+WITHOUT ANY WARRANTY; without even the implied warranty of
+MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+General Public License for more details.
+
+You should have received a copy of the GNU General Public License
+along with GNU Classpath; see the file COPYING. If not, write to the
+Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA
+02110-1301 USA.
+
+Linking this library statically or dynamically with other modules is
+making a combined work based on this library. Thus, the terms and
+conditions of the GNU General Public License cover the whole
+combination.
+
+As a special exception, the copyright holders of this library give you
+permission to link this library with independent modules to produce an
+executable, regardless of the license terms of these independent
+modules, and to copy and distribute the resulting executable under
+terms of your choice, provided that you also meet, for each linked
+independent module, the terms and conditions of the license of that
+module. An independent module is a module which is not derived from
+or based on this library. If you modify this library, you may extend
+this exception to your version of the library, but you are not
+obligated to do so. If you do not wish to do so, delete this
+exception statement from your version. */
+
+package gnu.xml.dom;
+
+import org.w3c.dom.Document;
+import org.w3c.dom.DocumentType;
+import org.w3c.dom.DOMException;
+import org.w3c.dom.DOMImplementation;
+import org.w3c.dom.Element;
+import org.w3c.dom.ls.DOMImplementationLS;
+import org.w3c.dom.ls.LSInput;
+import org.w3c.dom.ls.LSOutput;
+import org.w3c.dom.ls.LSParser;
+import org.w3c.dom.ls.LSSerializer;
+import gnu.xml.dom.html2.DomHTMLImpl;
+import gnu.xml.dom.ls.DomLSInput;
+import gnu.xml.dom.ls.DomLSOutput;
+import gnu.xml.dom.ls.DomLSParser;
+import gnu.xml.dom.ls.DomLSSerializer;
+
+/**
+ * <p> "DOMImplementation" implementation. </p>
+ *
+ * <p> At this writing, the following features are supported:
+ * "XML" (L1, L2, L3),
+ * "Events" (L2), "MutationEvents" (L2), "USER-Events" (a conformant extension),
+ * "HTMLEvents" (L2), "UIEvents" (L2), "Traversal" (L2), "XPath" (L3),
+ * "LS" (L3) "LS-Async" (L3).
+ * It is possible to compile the package so it doesn't support some of these
+ * features (notably, Traversal).
+ *
+ * @author David Brownell
+ * @author <a href='mailto:dog at gnu.org'>Chris Burdess</a>
+ */
+public class DomImpl
+ implements DOMImplementation, DOMImplementationLS
+{
+
+ /**
+ * Constructs a DOMImplementation object which supports
+ * "XML" and other DOM Level 2 features.
+ */
+ public DomImpl()
+ {
+ }
+
+ /**
+ * <b>DOM L1</b>
+ * Returns true if the specified feature and version are
+ * supported. Note that the case of the feature name is ignored.
+ */
+ public boolean hasFeature(String name, String version)
+ {
+ if (name.length() == 0)
+ {
+ return false;
+ }
+ name = name.toLowerCase();
+ if (name.charAt(0) == '+')
+ {
+ name = name.substring(1);
+ }
+
+ if ("xml".equals(name) || "core".equals(name))
+ {
+ return (version == null ||
+ "".equals(version) ||
+ "1.0".equals(version) ||
+ "2.0".equals(version) ||
+ "3.0".equals(version));
+
+ }
+ else if ("ls".equals(name) || "ls-async".equals(name))
+ {
+ return (version == null ||
+ "".equals(version) ||
+ "3.0".equals(version));
+ }
+ else if ("events".equals(name)
+ || "mutationevents".equals(name)
+ || "uievents".equals(name)
+ // || "mouseevents".equals(name)
+ || "htmlevents".equals(name))
+ {
+ return (version == null ||
+ "".equals(version) ||
+ "2.0".equals(version));
+
+ // Extension: "USER-" prefix event types can
+ // be created and passed through the DOM.
+
+ }
+ else if ("user-events".equals(name))
+ {
+ return (version == null ||
+ "".equals(version) ||
+ "0.1".equals(version));
+
+ // NOTE: "hasFeature" for events is here interpreted to
+ // mean the DOM can manufacture those sorts of events,
+ // since actually choosing to report the events is more
+ // often part of the environment or application. It's
+ // only really an issue for mutation events.
+
+ }
+ else if (DomNode.reportMutations
+ && "traversal".equals(name))
+ {
+ return (version == null ||
+ "".equals(version) ||
+ "2.0".equals(version));
+ }
+ else if ("xpath".equals(name))
+ {
+ return (version == null ||
+ "".equals(version) ||
+ "3.0".equals(version));
+ }
+ else if ("html".equals(name) || "xhtml".equals(name))
+ {
+ return (version == null ||
+ "".equals(version) ||
+ "2.0".equals(version));
+ }
+
+ // views
+ // stylesheets
+ // css, css2
+ // range
+
+ return false;
+ }
+
+ /**
+ * <b>DOM L2</b>
+ * Creates and returns a DocumentType, associated with this
+ * implementation. This DocumentType can have no associated
+ * objects(notations, entities) until the DocumentType is
+ * first associated with a document.
+ *
+ * <p> Note that there is no implication that this DTD will
+ * be parsed by the DOM, or ever have contents. Moreover, the
+ * DocumentType created here can only be added to a document by
+ * the createDocument method(below). <em>That means that the only
+ * portable way to create a Document object is to start parsing,
+ * queue comment and processing instruction (PI) nodes, and then only
+ * create a DOM Document after <b>(a)</b> it's known if a DocumentType
+ * object is needed, and <b>(b) the name and namespace of the root
+ * element is known. Queued comment and PI nodes would then be
+ * inserted appropriately in the document prologue, both before and
+ * after the DTD node, and additional attributes assigned to the
+ * root element.</em>
+ *(One hopes that the final DOM REC fixes this serious botch.)
+ */
+ public DocumentType createDocumentType(String rootName,
+ String publicId,
+ String systemId)
+ // CR2 deleted internal subset, ensuring DocumentType
+ // is 100% useless instead of just 90% so.
+ {
+ DomDocument.checkNCName(rootName, false);
+ return new DomDoctype(this, rootName, publicId, systemId, null);
+ }
+
+ /**
+ * <b>DOM L2</b>
+ * Creates and returns a Document, populated only with a root element and
+ * optionally a document type(if that was provided).
+ */
+ public Document createDocument(String namespaceURI,
+ String rootName,
+ DocumentType doctype)
+ {
+ Document doc = createDocument();
+ Element root = null;
+
+ if (rootName != null)
+ {
+ root = doc.createElementNS(namespaceURI, rootName);
+ if (rootName.startsWith("xmlns:"))
+ {
+ throw new DomDOMException(DOMException.NAMESPACE_ERR,
+ "xmlns is reserved", null, 0);
+ }
+ }
+ // Bleech -- L2 seemingly _requires_ omission of xmlns attributes.
+ if (doctype != null)
+ {
+ doc.appendChild(doctype); // handles WRONG_DOCUMENT error
+ }
+ if (root != null)
+ {
+ doc.appendChild(root);
+ }
+ return doc;
+ }
+
+ protected Document createDocument()
+ {
+ return new DomDocument(this);
+ }
+
+ // DOM Level 3
+
+ public Object getFeature(String feature, String version)
+ {
+ if (hasFeature(feature, version))
+ {
+ if ("html".equalsIgnoreCase(feature) ||
+ "xhtml".equalsIgnoreCase(feature))
+ {
+ return new DomHTMLImpl();
+ }
+ return this;
+ }
+ return null;
+ }
+
+ // -- DOMImplementationLS --
+
+ public LSParser createLSParser(short mode, String schemaType)
+ throws DOMException
+ {
+ return new DomLSParser(mode, schemaType);
+ }
+
+ public LSSerializer createLSSerializer()
+ {
+ return new DomLSSerializer();
+ }
+
+ public LSInput createLSInput()
+ {
+ return new DomLSInput();
+ }
+
+ public LSOutput createLSOutput()
+ {
+ return new DomLSOutput();
+ }
+
+}
+
Added: llvm-gcc-4.2/trunk/libjava/classpath/gnu/xml/dom/DomIterator.java
URL: http://llvm.org/viewvc/llvm-project/llvm-gcc-4.2/trunk/libjava/classpath/gnu/xml/dom/DomIterator.java?rev=43913&view=auto
==============================================================================
--- llvm-gcc-4.2/trunk/libjava/classpath/gnu/xml/dom/DomIterator.java (added)
+++ llvm-gcc-4.2/trunk/libjava/classpath/gnu/xml/dom/DomIterator.java Thu Nov 8 16:56:19 2007
@@ -0,0 +1,381 @@
+/* DomIterator.java --
+ Copyright (C) 1999, 2000, 2001, 2006 Free Software Foundation, Inc.
+
+This file is part of GNU Classpath.
+
+GNU Classpath is free software; you can redistribute it and/or modify
+it under the terms of the GNU General Public License as published by
+the Free Software Foundation; either version 2, or (at your option)
+any later version.
+
+GNU Classpath is distributed in the hope that it will be useful, but
+WITHOUT ANY WARRANTY; without even the implied warranty of
+MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+General Public License for more details.
+
+You should have received a copy of the GNU General Public License
+along with GNU Classpath; see the file COPYING. If not, write to the
+Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA
+02110-1301 USA.
+
+Linking this library statically or dynamically with other modules is
+making a combined work based on this library. Thus, the terms and
+conditions of the GNU General Public License cover the whole
+combination.
+
+As a special exception, the copyright holders of this library give you
+permission to link this library with independent modules to produce an
+executable, regardless of the license terms of these independent
+modules, and to copy and distribute the resulting executable under
+terms of your choice, provided that you also meet, for each linked
+independent module, the terms and conditions of the license of that
+module. An independent module is a module which is not derived from
+or based on this library. If you modify this library, you may extend
+this exception to your version of the library, but you are not
+obligated to do so. If you do not wish to do so, delete this
+exception statement from your version. */
+
+package gnu.xml.dom;
+
+import org.w3c.dom.DOMException;
+import org.w3c.dom.Node;
+import org.w3c.dom.events.Event;
+import org.w3c.dom.events.EventListener;
+import org.w3c.dom.events.EventTarget;
+import org.w3c.dom.events.MutationEvent;
+import org.w3c.dom.traversal.NodeFilter;
+import org.w3c.dom.traversal.NodeIterator;
+
+/**
+ * <p> "NodeIterator" implementation, usable with any L2 DOM which
+ * supports MutationEvents. </p>
+ *
+ * @author David Brownell
+ */
+public final class DomIterator
+ implements NodeIterator, EventListener
+{
+
+ private Node reference;
+ private boolean right;
+ private boolean done;
+
+ private final Node root;
+ private final int whatToShow;
+ private final NodeFilter filter;
+ private final boolean expandEntityReferences;
+
+ /**
+ * Constructs and initializes an iterator.
+ */
+ protected DomIterator(Node root,
+ int whatToShow,
+ NodeFilter filter,
+ boolean entityReferenceExpansion)
+ {
+ if (!root.isSupported("MutationEvents", "2.0"))
+ {
+ throw new DomDOMException(DOMException.NOT_SUPPORTED_ERR,
+ "Iterator needs mutation events", root, 0);
+ }
+
+ this.root = root;
+ this.whatToShow = whatToShow;
+ this.filter = filter;
+ this.expandEntityReferences = entityReferenceExpansion;
+
+ // start condition: going right, seen nothing yet.
+ reference = null;
+ right = true;
+
+ EventTarget target = (EventTarget) root;
+ target.addEventListener("DOMNodeRemoved", this, false);
+ }
+
+ /**
+ * <b>DOM L2</b>
+ * Flags the iterator as done, unregistering its event listener so
+ * that the iterator can be garbage collected without relying on weak
+ * references (a "Java 2" feature) in the event subsystem.
+ */
+ public void detach()
+ {
+ EventTarget target = (EventTarget) root;
+ target.removeEventListener("DOMNodeRemoved", this, false);
+ done = true;
+ }
+
+ /**
+ * <b>DOM L2</b>
+ * Returns the flag controlling whether iteration descends
+ * through entity references.
+ */
+ public boolean getExpandEntityReferences()
+ {
+ return expandEntityReferences;
+ }
+
+ /**
+ * <b>DOM L2</b>
+ * Returns the filter provided during construction.
+ */
+ public NodeFilter getFilter()
+ {
+ return filter;
+ }
+
+ /**
+ * <b>DOM L2</b>
+ * Returns the root of the tree this is iterating through.
+ */
+ public Node getRoot()
+ {
+ return root;
+ }
+
+ /**
+ * <b>DOM L2</b>
+ * Returns the mask of flags provided during construction.
+ */
+ public int getWhatToShow()
+ {
+ return whatToShow;
+ }
+
+ /**
+ * <b>DOM L2</b>
+ * Returns the next node in a forward iteration, masked and filtered.
+ * Note that the node may be read-only due to entity expansions.
+ * A null return indicates the iteration is complete, but may still
+ * be processed backwards.
+ */
+ public Node nextNode()
+ {
+ if (done)
+ {
+ throw new DomDOMException(DOMException.INVALID_STATE_ERR);
+ }
+ right = true;
+ return walk(true);
+ }
+
+ /**
+ * <b>DOM L2</b>
+ * Returns the next node in a backward iteration, masked and filtered.
+ * Note that the node may be read-only due to entity expansions.
+ * A null return indicates the iteration is complete, but may still
+ * be processed forwards.
+ */
+ public Node previousNode()
+ {
+ if (done)
+ {
+ throw new DomDOMException(DOMException.INVALID_STATE_ERR);
+ }
+ Node previous = reference;
+ right = false;
+ walk(false);
+ return previous;
+ }
+
+ private boolean shouldShow(Node node)
+ // raises Runtime exceptions indirectly, via acceptNode()
+ {
+ if ((whatToShow & (1 << (node.getNodeType() - 1))) == 0)
+ {
+ return false;
+ }
+ if (filter == null)
+ {
+ return true;
+ }
+ return filter.acceptNode(node) == NodeFilter.FILTER_ACCEPT;
+ }
+
+ //
+ // scenario: root = 1, sequence = 1 2 ... 3 4
+ // forward walk: 1 2 ... 3 4 null
+ // then backward: 4 3 ... 2 1 null
+ //
+ // At the leftmost end, "previous" == null
+ // At the rightmost end, "previous" == 4
+ //
+ // The current draft spec really seem to make no sense re the
+ // role of the reference node, so what it says is ignored here.
+ //
+ private Node walk(boolean forward)
+ {
+ Node here = reference;
+
+ while ((here = successor(here, forward)) != null
+ && !shouldShow(here))
+ {
+ continue;
+ }
+ if (here != null || !forward)
+ {
+ reference = here;
+ }
+ return here;
+ }
+
+ private boolean isLeaf(Node here)
+ {
+ boolean leaf = !here.hasChildNodes();
+ if (!leaf && !expandEntityReferences)
+ {
+ leaf = (here.getNodeType() == Node.ENTITY_REFERENCE_NODE);
+ }
+ return leaf;
+ }
+
+ //
+ // Returns the immediate successor in a forward (or backward)
+ // document order walk, sans filtering ... except that it knows
+ // how to stop, returning null when done. This is a depth first
+ // preorder traversal when run in the forward direction.
+ //
+ private Node successor(Node here, boolean forward)
+ {
+ Node next;
+
+ // the "leftmost" end is funky
+ if (here == null)
+ {
+ return forward ? root : null;
+ }
+
+ //
+ // Forward, this is preorder: children before siblings.
+ // Backward, it's postorder: we saw the children already.
+ //
+ if (forward && !isLeaf(here))
+ {
+ return here.getFirstChild();
+ }
+
+ // There's no way up or sideways from the root, so if we
+ // couldn't move down to a child, there's nowhere to go.
+ //
+ if (here == root)
+ return null;
+
+ //
+ // Siblings ... if forward, we visit them, if backwards
+ // we visit their children first.
+ //
+ if (forward)
+ {
+ if ((next = here.getNextSibling()) != null)
+ {
+ return next;
+ }
+ }
+ else if ((next = here.getPreviousSibling()) != null)
+ {
+ if (isLeaf(next))
+ {
+ return next;
+ }
+ next = next.getLastChild();
+ while (!isLeaf(next))
+ {
+ next = next.getLastChild();
+ }
+ return next;
+ }
+
+ //
+ // We can't go down or lateral -- it's up, then. The logic is
+ // the converse of what's above: backwards is easy (the parent
+ // is next), forwards isn't.
+ //
+ next = here.getParentNode();
+ if (!forward)
+ {
+ return next;
+ }
+
+ Node temp = null;
+ while (next != null
+ && next != root
+ && (temp = next.getNextSibling()) == null)
+ {
+ next = next.getParentNode();
+ }
+
+ // If we have exceeded the root node then stop traversing.
+ if (next == root.getParentNode())
+ {
+ return null;
+ }
+ return temp;
+ }
+
+ /**
+ * Not for public use. This lets the iterator know when its
+ * reference node will be removed from the tree, so that a new
+ * one may be selected.
+ *
+ * <p> This version works by watching removal events as they
+ * bubble up. So, don't prevent them from bubbling.
+ */
+ public void handleEvent(Event e)
+ {
+ MutationEvent event;
+ Node ancestor, removed;
+
+ if (reference == null
+ || !"DOMNodeRemoved".equals(e.getType())
+ || e.getEventPhase() != Event.BUBBLING_PHASE)
+ {
+ return;
+ }
+
+ event = (MutationEvent) e;
+ removed = (Node) event.getTarget();
+
+ // See if the removal will cause trouble for this iterator
+ // by being the reference node or an ancestor of it.
+ for (ancestor = reference;
+ ancestor != null && ancestor != root;
+ ancestor = ancestor.getParentNode())
+ {
+ if (ancestor == removed)
+ {
+ break;
+ }
+ }
+ if (ancestor != removed)
+ {
+ return;
+ }
+
+ // OK, it'll cause trouble. We want to make the "next"
+ // node in our current traversal direction seem right.
+ // So we pick the nearest node that's not getting removed,
+ // but go in the _opposite_ direction from our current
+ // traversal ... so the "next" doesn't skip anything.
+ Node candidate;
+
+search:
+ while ((candidate = walk(!right)) != null)
+ {
+ for (ancestor = candidate;
+ ancestor != null && ancestor != root;
+ ancestor = ancestor.getParentNode())
+ {
+ if (ancestor == removed)
+ {
+ continue search;
+ }
+ }
+ return;
+ }
+
+ // The current DOM WD talks about a special case here;
+ // I've not yet seen it.
+ }
+
+}
+
Added: llvm-gcc-4.2/trunk/libjava/classpath/gnu/xml/dom/DomNSResolverContext.java
URL: http://llvm.org/viewvc/llvm-project/llvm-gcc-4.2/trunk/libjava/classpath/gnu/xml/dom/DomNSResolverContext.java?rev=43913&view=auto
==============================================================================
--- llvm-gcc-4.2/trunk/libjava/classpath/gnu/xml/dom/DomNSResolverContext.java (added)
+++ llvm-gcc-4.2/trunk/libjava/classpath/gnu/xml/dom/DomNSResolverContext.java Thu Nov 8 16:56:19 2007
@@ -0,0 +1,90 @@
+/* DomNSResolverContext.java --
+ Copyright (C) 2004 Free Software Foundation, Inc.
+
+This file is part of GNU Classpath.
+
+GNU Classpath is free software; you can redistribute it and/or modify
+it under the terms of the GNU General Public License as published by
+the Free Software Foundation; either version 2, or (at your option)
+any later version.
+
+GNU Classpath is distributed in the hope that it will be useful, but
+WITHOUT ANY WARRANTY; without even the implied warranty of
+MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+General Public License for more details.
+
+You should have received a copy of the GNU General Public License
+along with GNU Classpath; see the file COPYING. If not, write to the
+Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA
+02110-1301 USA.
+
+Linking this library statically or dynamically with other modules is
+making a combined work based on this library. Thus, the terms and
+conditions of the GNU General Public License cover the whole
+combination.
+
+As a special exception, the copyright holders of this library give you
+permission to link this library with independent modules to produce an
+executable, regardless of the license terms of these independent
+modules, and to copy and distribute the resulting executable under
+terms of your choice, provided that you also meet, for each linked
+independent module, the terms and conditions of the license of that
+module. An independent module is a module which is not derived from
+or based on this library. If you modify this library, you may extend
+this exception to your version of the library, but you are not
+obligated to do so. If you do not wish to do so, delete this
+exception statement from your version. */
+
+package gnu.xml.dom;
+
+import java.util.Iterator;
+import javax.xml.namespace.NamespaceContext;
+import org.w3c.dom.xpath.XPathNSResolver;
+
+/**
+ * Namespace content wrapper for an XPathNSResolver.
+ *
+ * @author <a href='mailto:dog at gnu.org'>Chris Burdess</a>
+ */
+class DomNSResolverContext
+ implements NamespaceContext, Iterator
+{
+
+ final XPathNSResolver resolver;
+
+ DomNSResolverContext(XPathNSResolver resolver)
+ {
+ this.resolver = resolver;
+ }
+
+ public String getNamespaceURI(String prefix)
+ {
+ return resolver.lookupNamespaceURI(prefix);
+ }
+
+ public String getPrefix(String namespaceURI)
+ {
+ return null;
+ }
+
+ public Iterator getPrefixes(String namespaceURI)
+ {
+ return this;
+ }
+
+ public boolean hasNext()
+ {
+ return false;
+ }
+
+ public Object next()
+ {
+ return null;
+ }
+
+ public void remove()
+ {
+ throw new UnsupportedOperationException();
+ }
+
+}
Added: llvm-gcc-4.2/trunk/libjava/classpath/gnu/xml/dom/DomNamedNodeMap.java
URL: http://llvm.org/viewvc/llvm-project/llvm-gcc-4.2/trunk/libjava/classpath/gnu/xml/dom/DomNamedNodeMap.java?rev=43913&view=auto
==============================================================================
--- llvm-gcc-4.2/trunk/libjava/classpath/gnu/xml/dom/DomNamedNodeMap.java (added)
+++ llvm-gcc-4.2/trunk/libjava/classpath/gnu/xml/dom/DomNamedNodeMap.java Thu Nov 8 16:56:19 2007
@@ -0,0 +1,421 @@
+/* DomNamedNodeMap.java --
+ Copyright (C) 1999,2000,2001,2004 Free Software Foundation, Inc.
+
+This file is part of GNU Classpath.
+
+GNU Classpath is free software; you can redistribute it and/or modify
+it under the terms of the GNU General Public License as published by
+the Free Software Foundation; either version 2, or (at your option)
+any later version.
+
+GNU Classpath is distributed in the hope that it will be useful, but
+WITHOUT ANY WARRANTY; without even the implied warranty of
+MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+General Public License for more details.
+
+You should have received a copy of the GNU General Public License
+along with GNU Classpath; see the file COPYING. If not, write to the
+Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA
+02110-1301 USA.
+
+Linking this library statically or dynamically with other modules is
+making a combined work based on this library. Thus, the terms and
+conditions of the GNU General Public License cover the whole
+combination.
+
+As a special exception, the copyright holders of this library give you
+permission to link this library with independent modules to produce an
+executable, regardless of the license terms of these independent
+modules, and to copy and distribute the resulting executable under
+terms of your choice, provided that you also meet, for each linked
+independent module, the terms and conditions of the license of that
+module. An independent module is a module which is not derived from
+or based on this library. If you modify this library, you may extend
+this exception to your version of the library, but you are not
+obligated to do so. If you do not wish to do so, delete this
+exception statement from your version. */
+
+package gnu.xml.dom;
+
+import org.w3c.dom.DOMException;
+import org.w3c.dom.NamedNodeMap;
+import org.w3c.dom.Node;
+
+/**
+ * <p> "NamedNodeMap" implementation. </p>
+ * Used mostly to hold element attributes, but sometimes also
+ * to list notations or entities.
+ *
+ * @author David Brownell
+ * @author <a href='mailto:dog at gnu.org'>Chris Burdess</a>
+ */
+public class DomNamedNodeMap
+ implements NamedNodeMap
+{
+
+ final DomNode owner;
+ final short type;
+
+ DomNode first;
+ int length;
+ boolean readonly;
+
+ // package private
+ DomNamedNodeMap(DomNode owner, short type)
+ {
+ this.owner = owner;
+ this.type = type;
+ }
+
+ /**
+ * Exposes the internal "readonly" flag. In DOM, all NamedNodeMap
+ * objects found in a DocumentType object are read-only (after
+ * they are fully constructed), and those holding attributes of
+ * a readonly element will also be readonly.
+ */
+ public final boolean isReadonly()
+ {
+ return readonly;
+ }
+
+ /**
+ * Sets the internal "readonly" flag so the node and its
+ * children can't be changed.
+ */
+ public void makeReadonly()
+ {
+ readonly = true;
+ for (DomNode ctx = first; ctx != null; ctx = ctx.next)
+ {
+ ctx.makeReadonly();
+ }
+ }
+
+ /**
+ * <b>DOM L1</b>
+ * Returns the named item from the map, or null; names are just
+ * the nodeName property.
+ */
+ public Node getNamedItem(String name)
+ {
+ for (DomNode ctx = first; ctx != null; ctx = ctx.next)
+ {
+ if (ctx.getNodeName().equals(name))
+ {
+ return ctx;
+ }
+ }
+ return null;
+ }
+
+ /**
+ * <b>DOM L2</b>
+ * Returns the named item from the map, or null; names are the
+ * localName and namespaceURI properties, ignoring any prefix.
+ */
+ public Node getNamedItemNS(String namespaceURI, String localName)
+ {
+ if ("".equals(namespaceURI))
+ {
+ namespaceURI = null;
+ }
+ for (DomNode ctx = first; ctx != null; ctx = ctx.next)
+ {
+ String name = ctx.getLocalName();
+ if ((localName == null && name == null) ||
+ (localName != null && localName.equals(name)))
+ {
+ String uri = ctx.getNamespaceURI();
+ if ("".equals(uri))
+ {
+ uri = null;
+ }
+ if ((namespaceURI == null && uri == null) ||
+ (namespaceURI != null && namespaceURI.equals(uri)))
+ {
+ return ctx;
+ }
+ }
+ }
+ return null;
+ }
+
+ /**
+ * <b>DOM L1</b>
+ * Stores the named item into the map, optionally overwriting
+ * any existing node with that name. The name used is just
+ * the nodeName attribute.
+ */
+ public Node setNamedItem(Node arg)
+ {
+ return setNamedItem(arg, false);
+ }
+
+ /**
+ * <b>DOM L2</b>
+ * Stores the named item into the map, optionally overwriting
+ * any existing node with that fully qualified name. The name
+ * used incorporates the localName and namespaceURI properties,
+ * and ignores any prefix.
+ */
+ public Node setNamedItemNS(Node arg)
+ {
+ return setNamedItem(arg, true);
+ }
+
+ Node setNamedItem(Node arg, boolean ns)
+ {
+ if (readonly)
+ {
+ throw new DomDOMException(DOMException.NO_MODIFICATION_ALLOWED_ERR);
+ }
+
+ DomNode node = (DomNode) arg;
+ if (node.owner != owner.owner)
+ {
+ throw new DomDOMException(DOMException.WRONG_DOCUMENT_ERR);
+ }
+ if (node.nodeType != type)
+ {
+ throw new DomDOMException(DOMException.HIERARCHY_REQUEST_ERR);
+ }
+ if (node.nodeType == Node.ATTRIBUTE_NODE)
+ {
+ DomNode element = node.parent;
+ if (element != null && element != owner)
+ {
+ throw new DomDOMException(DOMException.INUSE_ATTRIBUTE_ERR);
+ }
+ node.parent = owner;
+ node.depth = owner.depth + 1;
+ }
+
+ String nodeName = node.getNodeName();
+ String localName = ns ? node.getLocalName() : null;
+ String namespaceURI = ns ? node.getNamespaceURI() : null;
+ if ("".equals(namespaceURI))
+ {
+ namespaceURI = null;
+ }
+
+ // maybe attribute ADDITION events (?)
+ DomNode last = null;
+ for (DomNode ctx = first; ctx != null; ctx = ctx.next)
+ {
+ boolean test = false;
+ if (ns)
+ {
+ String tln = ctx.getLocalName();
+ if (tln == null)
+ {
+ tln = ctx.getNodeName();
+ }
+ if (tln.equals(localName))
+ {
+ String tu = ctx.getNamespaceURI();
+ if ((tu == null && namespaceURI == null) ||
+ (tu != null && tu.equals(namespaceURI)))
+ {
+ test = true;
+ }
+ }
+ }
+ else
+ {
+ test = ctx.getNodeName().equals(nodeName);
+ }
+ if (test)
+ {
+ // replace
+ node.previous = ctx.previous;
+ node.next = ctx.next;
+ if (ctx.previous != null)
+ {
+ ctx.previous.next = node;
+ }
+ if (ctx.next != null)
+ {
+ ctx.next.previous = node;
+ }
+ if (first == ctx)
+ {
+ first = node;
+ }
+ reparent(node, nodeName, ctx.index);
+ ctx.parent = null;
+ ctx.next = null;
+ ctx.previous = null;
+ ctx.setDepth(0);
+ ctx.index = 0;
+ return ctx;
+ }
+ last = ctx;
+ }
+ // append
+ if (last != null)
+ {
+ last.next = node;
+ node.previous = last;
+ }
+ else
+ {
+ first = node;
+ }
+ length++;
+ reparent(node, nodeName, 0);
+ return null;
+ }
+
+ void reparent(DomNode node, String nodeName, int i)
+ {
+ node.parent = owner;
+ node.setDepth(owner.depth + 1);
+ // index renumbering
+ for (DomNode ctx = node; ctx != null; ctx = ctx.next)
+ {
+ ctx.index = i++;
+ }
+ // cache xml:space
+ boolean xmlSpace = "xml:space".equals(nodeName);
+ if (xmlSpace && owner instanceof DomElement)
+ {
+ ((DomElement) owner).xmlSpace = node.getNodeValue();
+ }
+ }
+
+ /**
+ * <b>DOM L1</b>
+ * Removes the named item from the map, or reports an exception;
+ * names are just the nodeName property.
+ */
+ public Node removeNamedItem(String name)
+ {
+ return removeNamedItem(null, name, false);
+ }
+
+ /**
+ * <b>DOM L2</b>
+ * Removes the named item from the map, or reports an exception;
+ * names are the localName and namespaceURI properties.
+ */
+ public Node removeNamedItemNS(String namespaceURI, String localName)
+ {
+ return removeNamedItem(namespaceURI, localName, true);
+ }
+
+ Node removeNamedItem(String uri, String name, boolean ns)
+ {
+ if (readonly)
+ {
+ throw new DomDOMException(DOMException.NO_MODIFICATION_ALLOWED_ERR);
+ }
+
+ // report attribute REMOVAL event?
+
+ for (DomNode ctx = first; ctx != null; ctx = ctx.next)
+ {
+ boolean test = false;
+ String nodeName = ctx.getNodeName();
+ if (ns)
+ {
+ String tln = ctx.getLocalName();
+ if (name != null && name.equals(tln))
+ {
+ String tu = ctx.getNamespaceURI();
+ if ((tu == null && uri == null) ||
+ (tu != null && tu.equals(uri)))
+ {
+ test = true;
+ }
+ }
+ }
+ else
+ {
+ test = nodeName.equals(name);
+ }
+ if (test)
+ {
+ // uncache xml:space
+ boolean xmlSpace = "xml:space".equals(nodeName);
+ if (xmlSpace && owner instanceof DomElement)
+ {
+ ((DomElement) owner).xmlSpace = "";
+ }
+ // is this a default attribute?
+ if (ctx.nodeType == Node.ATTRIBUTE_NODE)
+ {
+ String def = getDefaultValue(ctx.getNodeName());
+ if (def != null)
+ {
+ ctx.setNodeValue(def);
+ ((DomAttr) ctx).setSpecified(false);
+ return null;
+ }
+ }
+ // remove
+ if (ctx == first)
+ {
+ first = ctx.next;
+ }
+ if (ctx.previous != null)
+ {
+ ctx.previous.next = ctx.next;
+ }
+ if (ctx.next != null)
+ {
+ ctx.next.previous = ctx.previous;
+ }
+ length--;
+ ctx.previous = null;
+ ctx.next = null;
+ ctx.parent = null;
+ ctx.setDepth(0);
+ ctx.index = 0;
+ return ctx;
+ }
+ }
+ throw new DomDOMException(DOMException.NOT_FOUND_ERR);
+ }
+
+ String getDefaultValue(String name)
+ {
+ DomDoctype doctype = (DomDoctype) owner.owner.getDoctype();
+ if (doctype == null)
+ {
+ return null;
+ }
+ DTDAttributeTypeInfo info =
+ doctype.getAttributeTypeInfo(owner.getNodeName(), name);
+ if (info == null)
+ {
+ return null;
+ }
+ return info.value;
+ }
+
+ /**
+ * <b>DOM L1</b>
+ * Returns the indexed item from the map, or null.
+ */
+ public Node item(int index)
+ {
+ DomNode ctx = first;
+ int count = 0;
+ while (ctx != null && count < index)
+ {
+ ctx = ctx.next;
+ count++;
+ }
+ return ctx;
+ }
+
+ /**
+ * <b>DOM L1</b>
+ * Returns the length of the map.
+ */
+ public int getLength()
+ {
+ return length;
+ }
+
+}
Added: llvm-gcc-4.2/trunk/libjava/classpath/gnu/xml/dom/DomNode.java
URL: http://llvm.org/viewvc/llvm-project/llvm-gcc-4.2/trunk/libjava/classpath/gnu/xml/dom/DomNode.java?rev=43913&view=auto
==============================================================================
--- llvm-gcc-4.2/trunk/libjava/classpath/gnu/xml/dom/DomNode.java (added)
+++ llvm-gcc-4.2/trunk/libjava/classpath/gnu/xml/dom/DomNode.java Thu Nov 8 16:56:19 2007
@@ -0,0 +1,2199 @@
+/* DomNode.java --
+ Copyright (C) 1999,2000,2001,2004 Free Software Foundation, Inc.
+
+This file is part of GNU Classpath.
+
+GNU Classpath is free software; you can redistribute it and/or modify
+it under the terms of the GNU General Public License as published by
+the Free Software Foundation; either version 2, or (at your option)
+any later version.
+
+GNU Classpath is distributed in the hope that it will be useful, but
+WITHOUT ANY WARRANTY; without even the implied warranty of
+MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+General Public License for more details.
+
+You should have received a copy of the GNU General Public License
+along with GNU Classpath; see the file COPYING. If not, write to the
+Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA
+02110-1301 USA.
+
+Linking this library statically or dynamically with other modules is
+making a combined work based on this library. Thus, the terms and
+conditions of the GNU General Public License cover the whole
+combination.
+
+As a special exception, the copyright holders of this library give you
+permission to link this library with independent modules to produce an
+executable, regardless of the license terms of these independent
+modules, and to copy and distribute the resulting executable under
+terms of your choice, provided that you also meet, for each linked
+independent module, the terms and conditions of the license of that
+module. An independent module is a module which is not derived from
+or based on this library. If you modify this library, you may extend
+this exception to your version of the library, but you are not
+obligated to do so. If you do not wish to do so, delete this
+exception statement from your version. */
+
+package gnu.xml.dom;
+
+import java.util.HashMap;
+import java.util.HashSet;
+import java.util.Iterator;
+import java.util.Map;
+
+import org.w3c.dom.Document;
+import org.w3c.dom.DOMException;
+import org.w3c.dom.DOMImplementation;
+import org.w3c.dom.NamedNodeMap;
+import org.w3c.dom.Node;
+import org.w3c.dom.NodeList;
+import org.w3c.dom.Text;
+import org.w3c.dom.UserDataHandler;
+import org.w3c.dom.events.DocumentEvent;
+import org.w3c.dom.events.Event;
+import org.w3c.dom.events.EventException;
+import org.w3c.dom.events.EventListener;
+import org.w3c.dom.events.EventTarget;
+import org.w3c.dom.events.MutationEvent;
+import org.w3c.dom.traversal.NodeFilter;
+import org.w3c.dom.traversal.NodeIterator;
+
+/**
+ * <p> "Node", "EventTarget", and "DocumentEvent" implementation.
+ * This provides most of the core DOM functionality; only more
+ * specialized features are provided by subclasses. Those subclasses may
+ * have some particular constraints they must implement, by overriding
+ * methods defined here. Such constraints are noted here in the method
+ * documentation. </p>
+ *
+ * <p> Note that you can create events with type names prefixed with "USER-",
+ * and pass them through this DOM. This lets you use the DOM event scheme
+ * for application specific purposes, although you must use a predefined event
+ * structure (such as MutationEvent) to pass data along with those events.
+ * Test for existence of this feature with the "USER-Events" DOM feature
+ * name.</p>
+ *
+ * <p> Other kinds of events you can send include the "html" events,
+ * like "load", "unload", "abort", "error", and "blur"; and the mutation
+ * events. If this DOM has been compiled with mutation event support
+ * enabled, it will send mutation events when you change parts of the
+ * tree; otherwise you may create and send such events yourself, but
+ * they won't be generated by the DOM itself. </p>
+ *
+ * <p> Note that there is a namespace-aware name comparison method,
+ * <em>nameAndTypeEquals</em>, which compares the names (and types) of
+ * two nodes in conformance with the "Namespaces in XML" specification.
+ * While mostly intended for use with elements and attributes, this should
+ * also be helpful for ProcessingInstruction nodes and some others which
+ * do not have namespace URIs.
+ *
+ * @author David Brownell
+ * @author <a href='mailto:dog at gnu.org'>Chris Burdess</a>
+ */
+public abstract class DomNode
+ implements Node, NodeList, EventTarget, DocumentEvent, Cloneable, Comparable
+{
+
+ // package private
+ //final static String xmlNamespace = "http://www.w3.org/XML/1998/namespace";
+ //final static String xmlnsURI = "http://www.w3.org/2000/xmlns/";
+
+ // tunable
+ // NKIDS_* affects arrays of children (which grow)
+ // (currently) fixed size:
+ // ANCESTORS_* is for event capture/bubbling, # ancestors
+ // NOTIFICATIONS_* is for per-node event delivery, # events
+ private static final int NKIDS_DELTA = 8;
+ private static final int ANCESTORS_INIT = 20;
+ private static final int NOTIFICATIONS_INIT = 10;
+
+ // tunable: enable mutation events or not? Enabling it costs about
+ // 10-15% in DOM construction time, last time it was measured.
+
+ // package private !!!
+ static final boolean reportMutations = true;
+
+ // locking protocol changeable only within this class
+ private static final Object lockNode = new Object();
+
+ // NON-FINAL class data
+
+ // Optimize event dispatch by not allocating memory each time
+ private static boolean dispatchDataLock;
+ private static DomNode[] ancestors = new DomNode[ANCESTORS_INIT];
+ private static ListenerRecord[] notificationSet
+ = new ListenerRecord[NOTIFICATIONS_INIT];
+
+ // Ditto for the (most common) event object itself!
+ private static boolean eventDataLock;
+ private static DomEvent.DomMutationEvent mutationEvent
+ = new DomEvent.DomMutationEvent(null);
+
+ //
+ // PER-INSTANCE DATA
+ //
+
+ DomDocument owner;
+ DomNode parent; // parent node;
+ DomNode previous; // previous sibling node
+ DomNode next; // next sibling node
+ DomNode first; // first child node
+ DomNode last; // last child node
+ int index; // index of this node in its parent's children
+ int depth; // depth of the node in the document
+ int length; // number of children
+ final short nodeType;
+
+ // Bleech ... "package private" so a builder can populate entity refs.
+ // writable during construction. DOM spec is nasty.
+ boolean readonly;
+
+ // event registrations
+ private HashSet listeners;
+ private int nListeners;
+
+ // DOM Level 3 userData dictionary.
+ private HashMap userData;
+ private HashMap userDataHandlers;
+
+ //
+ // Some of the methods here are declared 'final' because
+ // knowledge about their implementation is built into this
+ // class -- for both integrity and performance.
+ //
+
+ /**
+ * Reduces space utilization for this node.
+ */
+ public void compact()
+ {
+ }
+
+ /**
+ * Constructs a node and associates it with its owner. Only
+ * Document and DocumentType nodes may be created with no owner,
+ * and DocumentType nodes get an owner as soon as they are
+ * associated with a document.
+ */
+ protected DomNode(short nodeType, DomDocument owner)
+ {
+ this.nodeType = nodeType;
+
+ if (owner == null)
+ {
+ // DOM calls never go down this path
+ if (nodeType != DOCUMENT_NODE && nodeType != DOCUMENT_TYPE_NODE)
+ {
+ throw new IllegalArgumentException ("no owner!");
+ }
+ }
+ this.owner = owner;
+ this.listeners = new HashSet();
+ }
+
+
+ /**
+ * <b>DOM L1</b>
+ * Returns null; Element subclasses must override this method.
+ */
+ public NamedNodeMap getAttributes()
+ {
+ return null;
+ }
+
+ /**
+ * <b>DOM L2></b>
+ * Returns true iff this is an element node with attributes.
+ */
+ public boolean hasAttributes()
+ {
+ return false;
+ }
+
+ /**
+ * <b>DOM L1</b>
+ * Returns a list, possibly empty, of the children of this node.
+ * In this implementation, to conserve memory, nodes are the same
+ * as their list of children. This can have ramifications for
+ * subclasses, which may need to provide their own getLength method
+ * for reasons unrelated to the NodeList method of the same name.
+ */
+ public NodeList getChildNodes()
+ {
+ return this;
+ }
+
+ /**
+ * <b>DOM L1</b>
+ * Returns the first child of this node, or null if there are none.
+ */
+ public Node getFirstChild()
+ {
+ return first;
+ }
+
+ /**
+ * <b>DOM L1</b>
+ * Returns the last child of this node, or null if there are none.
+ */
+ public Node getLastChild()
+ {
+ return last;
+ }
+
+ /**
+ * <b>DOM L1</b>
+ * Returns true if this node has children.
+ */
+ public boolean hasChildNodes()
+ {
+ return length != 0;
+ }
+
+
+ /**
+ * Exposes the internal "readonly" flag. In DOM, children of
+ * entities and entity references are readonly, as are the
+ * objects associated with DocumentType objets.
+ */
+ public final boolean isReadonly()
+ {
+ return readonly;
+ }
+
+ /**
+ * Sets the internal "readonly" flag so this subtree can't be changed.
+ * Subclasses need to override this method for any associated content
+ * that's not a child node, such as an element's attributes or the
+ * (few) declarations associated with a DocumentType.
+ */
+ public void makeReadonly()
+ {
+ readonly = true;
+ for (DomNode child = first; child != null; child = child.next)
+ {
+ child.makeReadonly();
+ }
+ }
+
+ /**
+ * Used to adopt a node to a new document.
+ */
+ void setOwner(DomDocument doc)
+ {
+ this.owner = doc;
+ for (DomNode ctx = first; ctx != null; ctx = ctx.next)
+ {
+ ctx.setOwner(doc);
+ }
+ }
+
+ // just checks the node for inclusion -- may be called many
+ // times (docfrag) before anything is allowed to change
+ private void checkMisc(DomNode child)
+ {
+ if (readonly && !owner.building)
+ {
+ throw new DomDOMException(DOMException.NO_MODIFICATION_ALLOWED_ERR,
+ null, this, 0);
+ }
+ for (DomNode ctx = this; ctx != null; ctx = ctx.parent)
+ {
+ if (child == ctx)
+ {
+ throw new DomDOMException(DOMException.HIERARCHY_REQUEST_ERR,
+ "can't make ancestor into a child",
+ this, 0);
+ }
+ }
+
+ DomDocument owner = (nodeType == DOCUMENT_NODE) ? (DomDocument) this :
+ this.owner;
+ DomDocument childOwner = child.owner;
+ short childNodeType = child.nodeType;
+
+ if (childOwner != owner)
+ {
+ // new in DOM L2, this case -- patch it up later, in reparent()
+ if (!(childNodeType == DOCUMENT_TYPE_NODE && childOwner == null))
+ {
+ throw new DomDOMException(DOMException.WRONG_DOCUMENT_ERR,
+ null, child, 0);
+ }
+ }
+
+ // enforce various structural constraints
+ switch (nodeType)
+ {
+ case DOCUMENT_NODE:
+ switch (childNodeType)
+ {
+ case ELEMENT_NODE:
+ case PROCESSING_INSTRUCTION_NODE:
+ case COMMENT_NODE:
+ case DOCUMENT_TYPE_NODE:
+ return;
+ }
+ break;
+
+ case ATTRIBUTE_NODE:
+ switch (childNodeType)
+ {
+ case TEXT_NODE:
+ case ENTITY_REFERENCE_NODE:
+ return;
+ }
+ break;
+
+ case DOCUMENT_FRAGMENT_NODE:
+ case ENTITY_REFERENCE_NODE:
+ case ELEMENT_NODE:
+ case ENTITY_NODE:
+ switch (childNodeType)
+ {
+ case ELEMENT_NODE:
+ case TEXT_NODE:
+ case COMMENT_NODE:
+ case PROCESSING_INSTRUCTION_NODE:
+ case CDATA_SECTION_NODE:
+ case ENTITY_REFERENCE_NODE:
+ return;
+ }
+ break;
+ case DOCUMENT_TYPE_NODE:
+ if (!owner.building)
+ break;
+ switch (childNodeType)
+ {
+ case COMMENT_NODE:
+ case PROCESSING_INSTRUCTION_NODE:
+ return;
+ }
+ break;
+ }
+ if (owner.checkingWellformedness)
+ {
+ throw new DomDOMException(DOMException.HIERARCHY_REQUEST_ERR,
+ "can't append " +
+ nodeTypeToString(childNodeType) +
+ " to node of type " +
+ nodeTypeToString(nodeType),
+ this, 0);
+ }
+ }
+
+ // Here's hoping a good optimizer will detect the case when the
+ // next several methods are never called, and won't allocate
+ // object code space of any kind. (Case: not reporting any
+ // mutation events. We can also remove some static variables
+ // listed above.)
+
+ private void insertionEvent(DomEvent.DomMutationEvent event,
+ DomNode target)
+ {
+ if (owner == null || owner.building)
+ {
+ return;
+ }
+ boolean doFree = false;
+
+ if (event == null)
+ {
+ event = getMutationEvent();
+ }
+ if (event != null)
+ {
+ doFree = true;
+ }
+ else
+ {
+ event = new DomEvent.DomMutationEvent(null);
+ }
+ event.initMutationEvent("DOMNodeInserted",
+ true /* bubbles */, false /* nocancel */,
+ this /* related */, null, null, null, (short) 0);
+ target.dispatchEvent(event);
+
+ // XXX should really visit every descendant of 'target'
+ // and sent a DOMNodeInsertedIntoDocument event to it...
+ // bleech, there's no way to keep that acceptably fast.
+
+ if (doFree)
+ {
+ event.target = null;
+ event.relatedNode = null;
+ event.currentNode = null;
+ eventDataLock = false;
+ } // else we created work for the GC
+ }
+
+ private void removalEvent(DomEvent.DomMutationEvent event,
+ DomNode target)
+ {
+ if (owner == null || owner.building)
+ {
+ return;
+ }
+ boolean doFree = false;
+
+ if (event == null)
+ {
+ event = getMutationEvent();
+ }
+ if (event != null)
+ {
+ doFree = true;
+ }
+ else
+ {
+ event = new DomEvent.DomMutationEvent(null);
+ }
+ event.initMutationEvent("DOMNodeRemoved",
+ true /* bubbles */, false /* nocancel */,
+ this /* related */, null, null, null, (short) 0);
+ target.dispatchEvent(event);
+
+ // XXX should really visit every descendant of 'target'
+ // and sent a DOMNodeRemovedFromDocument event to it...
+ // bleech, there's no way to keep that acceptably fast.
+
+ event.target = null;
+ event.relatedNode = null;
+ event.currentNode = null;
+ if (doFree)
+ {
+ eventDataLock = false;
+ }
+ // else we created more work for the GC
+ }
+
+ //
+ // Avoid creating lots of memory management work, by using a simple
+ // allocation strategy for the mutation event objects that get used
+ // at least once per tree modification. We can't use stack allocation,
+ // so we do the next simplest thing -- more or less, static allocation.
+ // Concurrent notifications should be rare, anyway.
+ //
+ // Returns the preallocated object, which needs to be carefully freed,
+ // or null to indicate the caller needs to allocate their own.
+ //
+ static private DomEvent.DomMutationEvent getMutationEvent()
+ {
+ synchronized (lockNode)
+ {
+ if (eventDataLock)
+ {
+ return null;
+ }
+ eventDataLock = true;
+ return mutationEvent;
+ }
+ }
+
+ // NOTE: this is manually inlined in the insertion
+ // and removal event methods above; change in sync.
+ static private void freeMutationEvent()
+ {
+ // clear fields to enable GC
+ mutationEvent.clear();
+ eventDataLock = false;
+ }
+
+ void setDepth(int depth)
+ {
+ this.depth = depth;
+ for (DomNode ctx = first; ctx != null; ctx = ctx.next)
+ {
+ ctx.setDepth(depth + 1);
+ }
+ }
+
+ /**
+ * <b>DOM L1</b>
+ * Appends the specified node to this node's list of children.
+ * Document subclasses must override this to enforce the restrictions
+ * that there be only one element and document type child.
+ *
+ * <p> Causes a DOMNodeInserted mutation event to be reported.
+ * Will first cause a DOMNodeRemoved event to be reported if the
+ * parameter already has a parent. If the new child is a document
+ * fragment node, both events will be reported for each child of
+ * the fragment; the order in which children are removed and
+ * inserted is implementation-specific.
+ *
+ * <p> If this DOM has been compiled without mutation event support,
+ * these events will not be reported.
+ */
+ public Node appendChild(Node newChild)
+ {
+ try
+ {
+ DomNode child = (DomNode) newChild;
+
+ if (child.nodeType == DOCUMENT_FRAGMENT_NODE)
+ {
+ // Append all nodes in the fragment to this node
+ for (DomNode ctx = child.first; ctx != null; ctx = ctx.next)
+ {
+ checkMisc(ctx);
+ }
+ for (DomNode ctx = child.first; ctx != null; )
+ {
+ DomNode ctxNext = ctx.next;
+ appendChild(ctx);
+ ctx = ctxNext;
+ }
+ }
+ else
+ {
+ checkMisc(child);
+ if (child.parent != null)
+ {
+ child.parent.removeChild(child);
+ }
+ child.parent = this;
+ child.index = length++;
+ child.setDepth(depth + 1);
+ child.next = null;
+ if (last == null)
+ {
+ first = child;
+ child.previous = null;
+ }
+ else
+ {
+ last.next = child;
+ child.previous = last;
+ }
+ last = child;
+
+ if (reportMutations)
+ {
+ insertionEvent(null, child);
+ }
+ }
+
+ return child;
+ }
+ catch (ClassCastException e)
+ {
+ throw new DomDOMException(DOMException.WRONG_DOCUMENT_ERR,
+ null, newChild, 0);
+ }
+ }
+
+ /**
+ * <b>DOM L1</b>
+ * Inserts the specified node in this node's list of children.
+ * Document subclasses must override this to enforce the restrictions
+ * that there be only one element and document type child.
+ *
+ * <p> Causes a DOMNodeInserted mutation event to be reported. Will
+ * first cause a DOMNodeRemoved event to be reported if the newChild
+ * parameter already has a parent. If the new child is a document
+ * fragment node, both events will be reported for each child of
+ * the fragment; the order in which children are removed and inserted
+ * is implementation-specific.
+ *
+ * <p> If this DOM has been compiled without mutation event support,
+ * these events will not be reported.
+ */
+ public Node insertBefore(Node newChild, Node refChild)
+ {
+ if (refChild == null)
+ {
+ return appendChild(newChild);
+ }
+
+ try
+ {
+ DomNode child = (DomNode) newChild;
+ DomNode ref = (DomNode) refChild;
+
+ if (child.nodeType == DOCUMENT_FRAGMENT_NODE)
+ {
+ // Append all nodes in the fragment to this node
+ for (DomNode ctx = child.first; ctx != null; ctx = ctx.next)
+ {
+ checkMisc(ctx);
+ }
+ for (DomNode ctx = child.first; ctx != null; )
+ {
+ DomNode ctxNext = ctx.next;
+ insertBefore(ctx, ref);
+ ctx = ctxNext;
+ }
+ }
+ else
+ {
+ checkMisc(child);
+ if (ref == null || ref.parent != this)
+ {
+ throw new DomDOMException(DOMException.NOT_FOUND_ERR,
+ null, ref, 0);
+ }
+ if (ref == child)
+ {
+ throw new DomDOMException(DOMException.HIERARCHY_REQUEST_ERR,
+ "can't insert node before itself",
+ ref, 0);
+ }
+
+ if (child.parent != null)
+ {
+ child.parent.removeChild(child);
+ }
+ child.parent = this;
+ int i = ref.index;
+ child.setDepth(depth + 1);
+ child.next = ref;
+ if (ref.previous != null)
+ {
+ ref.previous.next = child;
+ }
+ child.previous = ref.previous;
+ ref.previous = child;
+ if (first == ref)
+ {
+ first = child;
+ }
+ // index renumbering
+ for (DomNode ctx = child; ctx != null; ctx = ctx.next)
+ {
+ ctx.index = i++;
+ }
+
+ if (reportMutations)
+ {
+ insertionEvent(null, child);
+ }
+ }
+
+ return child;
+ }
+ catch (ClassCastException e)
+ {
+ throw new DomDOMException(DOMException.WRONG_DOCUMENT_ERR,
+ null, newChild, 0);
+ }
+ }
+
+ /**
+ * <b>DOM L1</b>
+ * Replaces the specified node in this node's list of children.
+ * Document subclasses must override this to test the restrictions
+ * that there be only one element and document type child.
+ *
+ * <p> Causes DOMNodeRemoved and DOMNodeInserted mutation event to be
+ * reported. Will cause another DOMNodeRemoved event to be reported if
+ * the newChild parameter already has a parent. These events may be
+ * delivered in any order, except that the event reporting removal
+ * from such an existing parent will always be delivered before the
+ * event reporting its re-insertion as a child of some other node.
+ * The order in which children are removed and inserted is implementation
+ * specific.
+ *
+ * <p> If your application needs to depend on the in which those removal
+ * and insertion events are delivered, don't use this API. Instead,
+ * invoke the removeChild and insertBefore methods directly, to guarantee
+ * a specific delivery order. Similarly, don't use document fragments,
+ * Otherwise your application code may not work on a DOM which implements
+ * this method differently.
+ *
+ * <p> If this DOM has been compiled without mutation event support,
+ * these events will not be reported.
+ */
+ public Node replaceChild(Node newChild, Node refChild)
+ {
+ try
+ {
+ DomNode child = (DomNode) newChild;
+ DomNode ref = (DomNode) refChild;
+
+ DomEvent.DomMutationEvent event = getMutationEvent();
+ boolean doFree = (event != null);
+
+ if (child.nodeType == DOCUMENT_FRAGMENT_NODE)
+ {
+ // Append all nodes in the fragment to this node
+ for (DomNode ctx = child.first; ctx != null; ctx = ctx.next)
+ {
+ checkMisc(ctx);
+ }
+ if (ref == null || ref.parent != this)
+ {
+ throw new DomDOMException(DOMException.NOT_FOUND_ERR,
+ null, ref, 0);
+ }
+
+ if (reportMutations)
+ {
+ removalEvent(event, ref);
+ }
+ length--;
+ length += child.length;
+
+ if (child.length == 0)
+ {
+ // Removal
+ if (ref.previous != null)
+ {
+ ref.previous.next = ref.next;
+ }
+ if (ref.next != null)
+ {
+ ref.next.previous = ref.previous;
+ }
+ if (first == ref)
+ {
+ first = ref.next;
+ }
+ if (last == ref)
+ {
+ last = ref.previous;
+ }
+ }
+ else
+ {
+ int i = ref.index;
+ for (DomNode ctx = child.first; ctx != null; ctx = ctx.next)
+ {
+ // Insertion
+ ctx.parent = this;
+ ctx.index = i++;
+ ctx.setDepth(ref.depth);
+ if (ctx == child.first)
+ {
+ ctx.previous = ref.previous;
+ }
+ if (ctx == child.last)
+ {
+ ctx.next = ref.next;
+ }
+ }
+ if (first == ref)
+ {
+ first = child.first;
+ }
+ if (last == ref)
+ {
+ last = child.last;
+ }
+ }
+ }
+ else
+ {
+ checkMisc(child);
+ if (ref == null || ref.parent != this)
+ {
+ throw new DomDOMException(DOMException.NOT_FOUND_ERR,
+ null, ref, 0);
+ }
+
+ if (reportMutations)
+ {
+ removalEvent(event, ref);
+ }
+
+ if (child.parent != null)
+ {
+ child.parent.removeChild(child);
+ }
+ child.parent = this;
+ child.index = ref.index;
+ child.setDepth(ref.depth);
+ if (ref.previous != null)
+ {
+ ref.previous.next = child;
+ }
+ child.previous = ref.previous;
+ if (ref.next != null)
+ {
+ ref.next.previous = child;
+ }
+ child.next = ref.next;
+ if (first == ref)
+ {
+ first = child;
+ }
+ if (last == ref)
+ {
+ last = child;
+ }
+
+ if (reportMutations)
+ {
+ insertionEvent(event, child);
+ }
+ if (doFree)
+ {
+ freeMutationEvent();
+ }
+ }
+ ref.parent = null;
+ ref.index = 0;
+ ref.setDepth(0);
+ ref.previous = null;
+ ref.next = null;
+
+ return ref;
+ }
+ catch (ClassCastException e)
+ {
+ throw new DomDOMException(DOMException.WRONG_DOCUMENT_ERR,
+ null, newChild, 0);
+ }
+ }
+
+ /**
+ * <b>DOM L1</b>
+ * Removes the specified child from this node's list of children,
+ * or else reports an exception.
+ *
+ * <p> Causes a DOMNodeRemoved mutation event to be reported.
+ *
+ * <p> If this DOM has been compiled without mutation event support,
+ * these events will not be reported.
+ */
+ public Node removeChild(Node refChild)
+ {
+ try
+ {
+ DomNode ref = (DomNode) refChild;
+
+ if (ref == null || ref.parent != this)
+ {
+ throw new DomDOMException(DOMException.NOT_FOUND_ERR,
+ null, ref, 0);
+ }
+ if (readonly && !owner.building)
+ {
+ throw new DomDOMException(DOMException.NO_MODIFICATION_ALLOWED_ERR,
+ null, this, 0);
+ }
+
+ for (DomNode child = first; child != null; child = child.next)
+ {
+ if (child == ref)
+ {
+ if (reportMutations)
+ {
+ removalEvent(null, child);
+ }
+
+ length--;
+ if (ref.previous != null)
+ {
+ ref.previous.next = ref.next;
+ }
+ if (ref.next != null)
+ {
+ ref.next.previous = ref.previous;
+ }
+ if (first == ref)
+ {
+ first = ref.next;
+ }
+ if (last == ref)
+ {
+ last = ref.previous;
+ }
+ // renumber indices
+ int i = 0;
+ for (DomNode ctx = first; ctx != null; ctx = ctx.next)
+ {
+ ctx.index = i++;
+ }
+ ref.parent = null;
+ ref.setDepth(0);
+ ref.index = 0;
+ ref.previous = null;
+ ref.next = null;
+
+ return ref;
+ }
+ }
+ throw new DomDOMException(DOMException.NOT_FOUND_ERR,
+ "that's no child of mine", refChild, 0);
+ }
+ catch (ClassCastException e)
+ {
+ throw new DomDOMException(DOMException.WRONG_DOCUMENT_ERR,
+ null, refChild, 0);
+ }
+ }
+
+ /**
+ * <b>DOM L1 (NodeList)</b>
+ * Returns the item with the specified index in this NodeList,
+ * else null.
+ */
+ public Node item(int index)
+ {
+ DomNode child = first;
+ int count = 0;
+ while (child != null && count < index)
+ {
+ child = child.next;
+ count++;
+ }
+ return child;
+ }
+
+ /**
+ * <b>DOM L1 (NodeList)</b>
+ * Returns the number of elements in this NodeList.
+ * (Note that many interfaces have a "Length" property, not just
+ * NodeList, and if a node subtype must implement one of those,
+ * it will also need to override getChildNodes.)
+ */
+ public int getLength()
+ {
+ return length;
+ }
+
+ /**
+ * Minimize extra space consumed by this node to hold children and event
+ * listeners.
+ */
+ public void trimToSize()
+ {
+ }
+
+ /**
+ * <b>DOM L1</b>
+ * Returns the previous sibling, if one is known.
+ */
+ public Node getNextSibling()
+ {
+ return next;
+ }
+
+ /**
+ * <b>DOM L1</b>
+ * Returns the previous sibling, if one is known.
+ */
+ public Node getPreviousSibling()
+ {
+ return previous;
+ }
+
+ /**
+ * <b>DOM L1</b>
+ * Returns the parent node, if one is known.
+ */
+ public Node getParentNode()
+ {
+ return parent;
+ }
+
+ /**
+ * <b>DOM L2</b>
+ * Consults the DOM implementation to determine if the requested
+ * feature is supported. DocumentType subclasses must override
+ * this method, and associate themselves directly with the
+ * DOMImplementation node used. (This method relies on being able
+ * to access the DOMImplementation from the owner document, but
+ * DocumentType nodes can be created without an owner.)
+ */
+ public boolean isSupported(String feature, String version)
+ {
+ Document doc = owner;
+ DOMImplementation impl = null;
+
+ if (doc == null && nodeType == DOCUMENT_NODE)
+ {
+ doc = (Document) this;
+ }
+
+ if (doc == null)
+ {
+ // possible for DocumentType
+ throw new IllegalStateException ("unbound ownerDocument");
+ }
+
+ impl = doc.getImplementation();
+ return impl.hasFeature(feature, version);
+ }
+
+ /**
+ * <b>DOM L1 (modified in L2)</b>
+ * Returns the owner document. This is only null for Document nodes,
+ * and (new in L2) for DocumentType nodes which have not yet been
+ * associated with the rest of their document.
+ */
+ final public Document getOwnerDocument()
+ {
+ return owner;
+ }
+
+ /**
+ * <b>DOM L1</b>
+ * Does nothing; this must be overridden (along with the
+ * getNodeValue method) for nodes with a non-null defined value.
+ */
+ public void setNodeValue(String value)
+ {
+ }
+
+ /**
+ * <b>DOM L1</b>
+ * Returns null; this must be overridden for nodes types with
+ * a defined value, along with the setNodeValue method.
+ */
+ public String getNodeValue()
+ {
+ return null;
+ }
+
+ /** This forces GCJ compatibility.
+ * Without this method GCJ is unable to compile to byte code.
+ */
+ public final short getNodeType()
+ {
+ return nodeType;
+ }
+
+ /** This forces GCJ compatibility.
+ * Without this method GCJ seems unable to natively compile GNUJAXP.
+ */
+ public abstract String getNodeName();
+
+ /**
+ * <b>DOM L2</b>
+ * Does nothing; this must be overridden (along with the
+ * getPrefix method) for element and attribute nodes.
+ */
+ public void setPrefix(String prefix)
+ {
+ }
+
+ /**
+ * <b>DOM L2</b>
+ * Returns null; this must be overridden for element and
+ * attribute nodes.
+ */
+ public String getPrefix()
+ {
+ return null;
+ }
+
+ /**
+ * <b>DOM L2</b>
+ * Returns null; this must be overridden for element and
+ * attribute nodes.
+ */
+ public String getNamespaceURI()
+ {
+ return null;
+ }
+
+ /**
+ * <b>DOM L2</b>
+ * Returns the node name; this must be overridden for element and
+ * attribute nodes.
+ */
+ public String getLocalName()
+ {
+ return null;
+ }
+
+ /**
+ * <b>DOM L1</b>
+ * Returns a clone of this node which optionally includes cloned
+ * versions of child nodes. Clones are always mutable, except for
+ * entity reference nodes.
+ */
+ public Node cloneNode(boolean deep)
+ {
+ DomNode node = (DomNode) clone();
+
+ if (deep)
+ {
+ DomDocument doc = (nodeType == DOCUMENT_NODE) ?
+ (DomDocument) node : node.owner;
+ boolean building = doc.building;
+ doc.building = true; // Permit certain structural rules
+ for (DomNode ctx = first; ctx != null; ctx = ctx.next)
+ {
+ DomNode newChild = (DomNode) ctx.cloneNode(deep);
+ newChild.setOwner(doc);
+ node.appendChild(newChild);
+ }
+ doc.building = building;
+ }
+ if (nodeType == ENTITY_REFERENCE_NODE)
+ {
+ node.makeReadonly();
+ }
+ notifyUserDataHandlers(UserDataHandler.NODE_CLONED, this, node);
+ return node;
+ }
+
+ void notifyUserDataHandlers(short op, Node src, Node dst)
+ {
+ if (userDataHandlers != null)
+ {
+ for (Iterator i = userDataHandlers.entrySet().iterator(); i.hasNext(); )
+ {
+ Map.Entry entry = (Map.Entry) i.next();
+ String key = (String) entry.getKey();
+ UserDataHandler handler = (UserDataHandler) entry.getValue();
+ Object data = userData.get(key);
+ handler.handle(op, key, data, src, dst);
+ }
+ }
+ }
+
+ /**
+ * Clones this node; roughly equivalent to cloneNode(false).
+ * Element subclasses must provide a new implementation which
+ * invokes this method to handle the basics, and then arranges
+ * to clone any element attributes directly. Attribute subclasses
+ * must make similar arrangements, ensuring that existing ties to
+ * elements are broken by cloning.
+ */
+ public Object clone()
+ {
+ try
+ {
+ DomNode node = (DomNode) super.clone();
+
+ node.parent = null;
+ node.depth = 0;
+ node.index = 0;
+ node.length = 0;
+ node.first = null;
+ node.last = null;
+ node.previous = null;
+ node.next = null;
+
+ node.readonly = false;
+ node.listeners = new HashSet();
+ node.nListeners = 0;
+ return node;
+
+ }
+ catch (CloneNotSupportedException x)
+ {
+ throw new Error("clone didn't work");
+ }
+ }
+
+ // the elements-by-tagname stuff is needed for both
+ // elements and documents ... this is in lieu of a
+ // common base class between Node and NodeNS.
+
+ /**
+ * <b>DOM L1</b>
+ * Creates a NodeList giving array-style access to elements with
+ * the specified name. Access is fastest if indices change by
+ * small values, and the DOM is not modified.
+ */
+ public NodeList getElementsByTagName(String tag)
+ {
+ return new ShadowList(null, tag);
+ }
+
+ /**
+ * <b>DOM L2</b>
+ * Creates a NodeList giving array-style access to elements with
+ * the specified namespace and local name. Access is fastest if
+ * indices change by small values, and the DOM is not modified.
+ */
+ public NodeList getElementsByTagNameNS(String namespace, String local)
+ {
+ return new ShadowList(namespace, local);
+ }
+
+
+ //
+ // This shadow class is GC-able even when the live list it shadows
+ // can't be, because of event registration hookups. Its finalizer
+ // makes that live list become GC-able.
+ //
+ final class ShadowList
+ implements NodeList
+ {
+
+ private LiveNodeList liveList;
+
+ ShadowList(String ns, String local)
+ {
+ liveList = new LiveNodeList(ns, local);
+ }
+
+ public void finalize()
+ {
+ liveList.detach();
+ liveList = null;
+ }
+
+ public Node item(int index)
+ {
+ return liveList.item(index);
+ }
+
+ public int getLength()
+ {
+ return liveList.getLength();
+ }
+ }
+
+ final class LiveNodeList
+ implements NodeList, EventListener, NodeFilter
+ {
+
+ private final boolean matchAnyURI;
+ private final boolean matchAnyName;
+ private final String elementURI;
+ private final String elementName;
+
+ private DomIterator current;
+ private int lastIndex;
+
+ LiveNodeList(String uri, String name)
+ {
+ elementURI = uri;
+ elementName = name;
+ matchAnyURI = "*".equals(uri);
+ matchAnyName = "*".equals(name);
+
+ DomNode.this.addEventListener("DOMNodeInserted", this, true);
+ DomNode.this.addEventListener("DOMNodeRemoved", this, true);
+ }
+
+ void detach()
+ {
+ if (current != null)
+ current.detach();
+ current = null;
+
+ DomNode.this.removeEventListener("DOMNodeInserted", this, true);
+ DomNode.this.removeEventListener("DOMNodeRemoved", this, true);
+ }
+
+ public short acceptNode(Node element)
+ {
+ if (element == DomNode.this)
+ {
+ return FILTER_SKIP;
+ }
+
+ // use namespace-aware matching ...
+ if (elementURI != null)
+ {
+ if (!(matchAnyURI
+ || elementURI.equals(element.getNamespaceURI())))
+ {
+ return FILTER_SKIP;
+ }
+ if (!(matchAnyName
+ || elementName.equals(element.getLocalName())))
+ {
+ return FILTER_SKIP;
+ }
+
+ // ... or qName-based kind.
+ }
+ else
+ {
+ if (!(matchAnyName
+ || elementName.equals(element.getNodeName())))
+ {
+ return FILTER_SKIP;
+ }
+ }
+ return FILTER_ACCEPT;
+ }
+
+ private DomIterator createIterator()
+ {
+ return new DomIterator(DomNode.this,
+ NodeFilter.SHOW_ELEMENT,
+ this, /* filter */
+ true /* expand entity refs */
+ );
+ }
+
+ public void handleEvent(Event e)
+ {
+ MutationEvent mutation = (MutationEvent) e;
+ Node related = mutation.getRelatedNode();
+
+ // XXX if it's got children ... check all kids too, they
+ // will invalidate our saved index
+
+ if (related.getNodeType() != Node.ELEMENT_NODE ||
+ related.getNodeName() != elementName ||
+ related.getNamespaceURI() != elementURI)
+ {
+ return;
+ }
+
+ if (current != null)
+ current.detach();
+ current = null;
+ }
+
+ public Node item(int index)
+ {
+ if (current == null)
+ {
+ current = createIterator();
+ lastIndex = -1;
+ }
+
+ // last node or before? go backwards
+ if (index <= lastIndex) {
+ while (index != lastIndex) {
+ current.previousNode ();
+ lastIndex--;
+ }
+ Node ret = current.previousNode ();
+ current.detach();
+ current = null;
+ return ret;
+ }
+
+ // somewhere after last node
+ while (++lastIndex != index)
+ current.nextNode ();
+
+ Node ret = current.nextNode ();
+ current.detach();
+ current = null;
+ return ret;
+ }
+
+ public int getLength()
+ {
+ int retval = 0;
+ NodeIterator iter = createIterator();
+
+ while (iter.nextNode() != null)
+ {
+ retval++;
+ }
+ iter.detach();
+ return retval;
+ }
+
+ }
+
+ //
+ // EventTarget support
+ //
+ static final class ListenerRecord
+ {
+
+ String type;
+ EventListener listener;
+ boolean useCapture;
+
+ // XXX use JDK 1.2 java.lang.ref.WeakReference to listener,
+ // and we can both get rid of "shadow" classes and remove
+ // the need for applications to apply similar trix ... but
+ // JDK 1.2 support isn't generally available yet
+
+ ListenerRecord(String type, EventListener listener, boolean useCapture)
+ {
+ this.type = type.intern();
+ this.listener = listener;
+ this.useCapture = useCapture;
+ }
+
+ public boolean equals(Object o)
+ {
+ ListenerRecord rec = (ListenerRecord)o;
+ return listener == rec.listener
+ && useCapture == rec.useCapture
+ && type == rec.type;
+ }
+
+ public int hashCode()
+ {
+ return listener.hashCode() ^ type.hashCode();
+ }
+ }
+
+ /**
+ * <b>DOM L2 (Events)</b>
+ * Returns an instance of the specified type of event object.
+ * Understands about DOM Mutation, HTML, and UI events.
+ *
+ * <p>If the name of the event type begins with "USER-", then an object
+ * implementing the "Event" class will be returned; this provides a
+ * limited facility for application-defined events to use the DOM event
+ * infrastructure. Alternatively, use one of the standard DOM event
+ * classes and initialize it using use such a "USER-" event type name;
+ * or defin, instantiate, and initialize an application-specific subclass
+ * of DomEvent and pass that to dispatchEvent().
+ *
+ * @param eventType Identifies the particular DOM feature module
+ * defining the type of event, such as "MutationEvents".
+ * <em>The event "name" is a different kind of "type".</em>
+ */
+ public Event createEvent(String eventType)
+ {
+ eventType = eventType.toLowerCase();
+
+ if ("mutationevents".equals(eventType))
+ {
+ return new DomEvent.DomMutationEvent(null);
+ }
+
+ if ("htmlevents".equals(eventType)
+ || "events".equals(eventType)
+ || "user-events".equals(eventType))
+ {
+ return new DomEvent(null);
+ }
+
+ if ("uievents".equals(eventType))
+ {
+ return new DomEvent.DomUIEvent(null);
+ }
+
+ // mouse events
+
+ throw new DomDOMException(DOMException.NOT_SUPPORTED_ERR,
+ eventType, null, 0);
+ }
+
+ /**
+ * <b>DOM L2 (Events)</b>
+ * Registers an event listener's interest in a class of events.
+ */
+ public final void addEventListener(String type,
+ EventListener listener,
+ boolean useCapture)
+ {
+ // prune duplicates
+ ListenerRecord record;
+
+ record = new ListenerRecord(type, listener, useCapture);
+ listeners.add(record);
+ nListeners = listeners.size();
+ }
+
+ // XXX this exception should be discarded from DOM
+
+ // this class can be instantiated, unlike the one in the spec
+ static final class DomEventException
+ extends EventException
+ {
+
+ DomEventException()
+ {
+ super(UNSPECIFIED_EVENT_TYPE_ERR, "unspecified event type");
+ }
+
+ }
+
+ /**
+ * <b>DOM L2 (Events)</b>
+ * Delivers an event to all relevant listeners, returning true if the
+ * caller should perform their default action. Note that the event
+ * must have been provided by the createEvent() method on this
+ * class, else it can't be dispatched.
+ *
+ * @see #createEvent
+ *
+ * @exception NullPointerException When a null event is passed.
+ * @exception ClassCastException When the event wasn't provided by
+ * the createEvent method, or otherwise isn't a DomEvent.
+ * @exception EventException If the event type wasn't specified
+ */
+ public final boolean dispatchEvent(Event event)
+ throws EventException
+ {
+ DomEvent e = (DomEvent) event;
+ DomNode[] ancestors = null;
+ int ancestorMax = 0;
+ boolean haveDispatchDataLock = false;
+
+ if (e.type == null)
+ {
+ throw new DomEventException();
+ }
+
+ e.doDefault = true;
+ e.target = this;
+
+ //
+ // Typical case: one nonrecursive dispatchEvent call at a time
+ // for this class. If that's our case, we can avoid allocating
+ // garbage, which is overall a big win. Even with advanced GCs
+ // that deal well with short-lived garbage, and wayfast allocators,
+ // it still helps.
+ //
+ // Remember -- EVERY mutation goes though here at least once.
+ //
+ // When populating a DOM tree, trying to send mutation events is
+ // the primary cost; this dominates the critical path.
+ //
+ try
+ {
+ DomNode current;
+ int index;
+ boolean haveAncestorRegistrations = false;
+ ListenerRecord[] notificationSet;
+ int ancestorLen;
+
+ synchronized (lockNode)
+ {
+ if (!dispatchDataLock)
+ {
+ haveDispatchDataLock = dispatchDataLock = true;
+ notificationSet = DomNode.notificationSet;
+ ancestors = DomNode.ancestors;
+ }
+ else
+ {
+ notificationSet = new ListenerRecord[NOTIFICATIONS_INIT];
+ ancestors = new DomNode[ANCESTORS_INIT];
+ }
+ ancestorLen = ancestors.length;
+ }
+
+ // Climb to the top of this subtree and handle capture, letting
+ // each node (from the top down) capture until one stops it or
+ // until we get to this one.
+ current = parent;
+ if (current.depth >= ANCESTORS_INIT)
+ {
+ DomNode[] newants = new DomNode[current.depth + 1];
+ System.arraycopy(ancestors, 0, newants, 0, ancestors.length);
+ ancestors = newants;
+ ancestorLen = ancestors.length;
+ }
+ for (index = 0; index < ancestorLen; index++)
+ {
+ if (current == null || current.depth == 0)
+ break;
+
+ if (current.nListeners != 0)
+ {
+ haveAncestorRegistrations = true;
+ }
+ ancestors [index] = current;
+ current = current.parent;
+ }
+ if (current.depth > 0)
+ {
+ throw new RuntimeException("dispatchEvent capture stack size");
+ }
+
+ ancestorMax = index;
+ e.stop = false;
+
+ if (haveAncestorRegistrations)
+ {
+ e.eventPhase = Event.CAPTURING_PHASE;
+ while (!e.stop && index-- > 0)
+ {
+ current = ancestors [index];
+ if (current.nListeners != 0)
+ {
+ notifyNode(e, current, true, notificationSet);
+ }
+ }
+ }
+
+ // Always deliver events to the target node (this)
+ // unless stopPropagation was called. If we saw
+ // no registrations yet (typical!), we never will.
+ if (!e.stop && nListeners != 0)
+ {
+ e.eventPhase = Event.AT_TARGET;
+ notifyNode (e, this, false, notificationSet);
+ }
+ else if (!haveAncestorRegistrations)
+ {
+ e.stop = true;
+ }
+
+ // If the event bubbles and propagation wasn't halted,
+ // walk back up the ancestor list. Stop bubbling when
+ // any bubbled event handler stops it.
+
+ if (!e.stop && e.bubbles)
+ {
+ e.eventPhase = Event.BUBBLING_PHASE;
+ for (index = 0;
+ !e.stop
+ && index < ancestorMax
+ && (current = ancestors[index]) != null;
+ index++)
+ {
+ if (current.nListeners != 0)
+ {
+ notifyNode(e, current, false, notificationSet);
+ }
+ }
+ }
+ e.eventPhase = 0;
+
+ // Caller chooses whether to perform the default
+ // action based on return from this method.
+ return e.doDefault;
+
+ }
+ finally
+ {
+ if (haveDispatchDataLock)
+ {
+ // synchronize to force write ordering
+ synchronized (lockNode)
+ {
+ // null out refs to ensure they'll be GC'd
+ for (int i = 0; i < ancestorMax; i++)
+ {
+ ancestors [i] = null;
+ }
+ // notificationSet handled by notifyNode
+
+ dispatchDataLock = false;
+ }
+ }
+ }
+ }
+
+ private void notifyNode(DomEvent e,
+ DomNode current,
+ boolean capture,
+ ListenerRecord[] notificationSet)
+ {
+ int count = 0;
+ Iterator iter;
+
+ iter = current.listeners.iterator();
+
+ // do any of this set of listeners get notified?
+ while (iter.hasNext())
+ {
+ ListenerRecord rec = (ListenerRecord)iter.next();
+
+ if (rec.useCapture != capture)
+ {
+ continue;
+ }
+ if (!e.type.equals (rec.type))
+ {
+ continue;
+ }
+ if (count >= notificationSet.length)
+ {
+ // very simple growth algorithm
+ int len = Math.max(notificationSet.length, 1);
+ ListenerRecord[] tmp = new ListenerRecord[len * 2];
+ System.arraycopy(notificationSet, 0, tmp, 0,
+ notificationSet.length);
+ notificationSet = tmp;
+ }
+ notificationSet[count++] = rec;
+ }
+ iter = null;
+
+ // Notify just those listeners
+ e.currentNode = current;
+ for (int i = 0; i < count; i++)
+ {
+ try
+ {
+ iter = current.listeners.iterator();
+ // Late in the DOM CR process (3rd or 4th CR?) the
+ // removeEventListener spec became asymmetric with respect
+ // to addEventListener ... effect is now immediate.
+ while (iter.hasNext())
+ {
+ ListenerRecord rec = (ListenerRecord)iter.next();
+
+ if (rec.equals(notificationSet[i]))
+ {
+ notificationSet[i].listener.handleEvent(e);
+ break;
+ }
+ }
+ iter = null;
+ }
+ catch (Exception x)
+ {
+ // ignore all exceptions
+ }
+ notificationSet[i] = null; // free for GC
+ }
+ }
+
+ /**
+ * <b>DOM L2 (Events)</b>
+ * Unregisters an event listener.
+ */
+ public final void removeEventListener(String type,
+ EventListener listener,
+ boolean useCapture)
+ {
+ listeners.remove(new ListenerRecord(type, listener, useCapture));
+ nListeners = listeners.size();
+ // no exceptions reported
+ }
+
+ /**
+ * <b>DOM L1 (relocated in DOM L2)</b>
+ * In this node and all contained nodes (including attributes if
+ * relevant) merge adjacent text nodes. This is done while ignoring
+ * text which happens to use CDATA delimiters).
+ */
+ public final void normalize()
+ {
+ // Suspend readonly status
+ boolean saved = readonly;
+ readonly = false;
+ for (DomNode ctx = first; ctx != null; ctx = ctx.next)
+ {
+ boolean saved2 = ctx.readonly;
+ ctx.readonly = false;
+ switch (ctx.nodeType)
+ {
+ case TEXT_NODE:
+ case CDATA_SECTION_NODE:
+ while (ctx.next != null &&
+ (ctx.next.nodeType == TEXT_NODE ||
+ ctx.next.nodeType == CDATA_SECTION_NODE))
+ {
+ Text text = (Text) ctx;
+ text.appendData(ctx.next.getNodeValue());
+ removeChild(ctx.next);
+ }
+ break;
+ case ELEMENT_NODE:
+ NamedNodeMap attrs = ctx.getAttributes();
+ int len = attrs.getLength();
+ for (int i = 0; i < len; i++)
+ {
+ DomNode attr = (DomNode) attrs.item(i);
+ boolean saved3 = attr.readonly;
+ attr.readonly = false;
+ attr.normalize();
+ attr.readonly = saved3;
+ }
+ // Fall through
+ case DOCUMENT_NODE:
+ case DOCUMENT_FRAGMENT_NODE:
+ case ATTRIBUTE_NODE:
+ case ENTITY_REFERENCE_NODE:
+ ctx.normalize();
+ break;
+ }
+ ctx.readonly = saved2;
+ }
+ readonly = saved;
+ }
+
+ /**
+ * Returns true iff node types match, and either (a) both nodes have no
+ * namespace and their getNodeName() values are the same, or (b) both
+ * nodes have the same getNamespaceURI() and same getLocalName() values.
+ *
+ * <p>Note that notion of a "Per-Element-Type" attribute name scope, as
+ * found in a non-normative appendix of the XML Namespaces specification,
+ * is not supported here. Your application must implement that notion,
+ * typically by not bothering to check nameAndTypeEquals for attributes
+ * without namespace URIs unless you already know their elements are
+ * nameAndTypeEquals.
+ */
+ public boolean nameAndTypeEquals(Node other)
+ {
+ if (other == this)
+ {
+ return true;
+ }
+ // node types must match
+ if (nodeType != other.getNodeType())
+ {
+ return false;
+ }
+
+ // if both have namespaces, do a "full" comparision
+ // this is a "global" partition
+ String ns1 = this.getNamespaceURI();
+ String ns2 = other.getNamespaceURI();
+
+ if (ns1 != null && ns2 != null)
+ {
+ return ns1.equals(ns2) &&
+ equal(getLocalName(), other.getLocalName());
+ }
+
+ // if neither has a namespace, this is a "no-namespace" name.
+ if (ns1 == null && ns2 == null)
+ {
+ if (!getNodeName().equals(other.getNodeName()))
+ {
+ return false;
+ }
+ // can test the non-normative "per-element-type" scope here.
+ // if this is an attribute node and both nodes have been bound
+ // to elements (!!), then return the nameAndTypeEquals()
+ // comparison of those elements.
+ return true;
+ }
+
+ // otherwise they're unequal: one scoped, one not.
+ return false;
+ }
+
+ // DOM Level 3 methods
+
+ public String getBaseURI()
+ {
+ return (parent != null) ? parent.getBaseURI() : null;
+ }
+
+ public short compareDocumentPosition(Node other)
+ throws DOMException
+ {
+ return (short) compareTo(other);
+ }
+
+ /**
+ * DOM nodes have a natural ordering: document order.
+ */
+ public final int compareTo(Object other)
+ {
+ if (other instanceof DomNode)
+ {
+ DomNode n1 = this;
+ DomNode n2 = (DomNode) other;
+ if (n1.owner != n2.owner)
+ {
+ return 0;
+ }
+ int d1 = n1.depth, d2 = n2.depth;
+ int delta = d1 - d2;
+ while (d1 > d2)
+ {
+ n1 = n1.parent;
+ d1--;
+ }
+ while (d2 > d1)
+ {
+ n2 = n2.parent;
+ d2--;
+ }
+ int c = compareTo2(n1, n2);
+ return (c != 0) ? c : delta;
+ }
+ return 0;
+ }
+
+ /**
+ * Compare two nodes at the same depth.
+ */
+ final int compareTo2(DomNode n1, DomNode n2)
+ {
+ if (n1 == n2 || n1.depth == 0 || n2.depth == 0)
+ {
+ return 0;
+ }
+ int c = compareTo2(n1.parent, n2.parent);
+ return (c != 0) ? c : n1.index - n2.index;
+ }
+
+ public final String getTextContent()
+ throws DOMException
+ {
+ return getTextContent(true);
+ }
+
+ final String getTextContent(boolean topLevel)
+ throws DOMException
+ {
+ switch (nodeType)
+ {
+ case ELEMENT_NODE:
+ case ENTITY_NODE:
+ case ENTITY_REFERENCE_NODE:
+ case DOCUMENT_FRAGMENT_NODE:
+ StringBuffer buffer = new StringBuffer();
+ for (DomNode ctx = first; ctx != null; ctx = ctx.next)
+ {
+ String textContent = ctx.getTextContent(false);
+ if (textContent != null)
+ {
+ buffer.append(textContent);
+ }
+ }
+ return buffer.toString();
+ case TEXT_NODE:
+ case CDATA_SECTION_NODE:
+ if (((Text) this).isElementContentWhitespace())
+ {
+ return "";
+ }
+ return getNodeValue();
+ case ATTRIBUTE_NODE:
+ return getNodeValue();
+ case COMMENT_NODE:
+ case PROCESSING_INSTRUCTION_NODE:
+ return topLevel ? getNodeValue() : "";
+ default:
+ return null;
+ }
+ }
+
+ public void setTextContent(String textContent)
+ throws DOMException
+ {
+ switch (nodeType)
+ {
+ case ELEMENT_NODE:
+ case ATTRIBUTE_NODE:
+ case ENTITY_NODE:
+ case ENTITY_REFERENCE_NODE:
+ case DOCUMENT_FRAGMENT_NODE:
+ for (DomNode ctx = first; ctx != null; )
+ {
+ DomNode n = ctx.next;
+ removeChild(ctx);
+ ctx = n;
+ }
+ if (textContent != null)
+ {
+ Text text = owner.createTextNode(textContent);
+ appendChild(text);
+ }
+ break;
+ case TEXT_NODE:
+ case CDATA_SECTION_NODE:
+ case COMMENT_NODE:
+ case PROCESSING_INSTRUCTION_NODE:
+ setNodeValue(textContent);
+ break;
+ }
+ }
+
+ public boolean isSameNode(Node other)
+ {
+ return this == other;
+ }
+
+ public String lookupPrefix(String namespaceURI)
+ {
+ return (parent == null || parent == owner) ? null :
+ parent.lookupPrefix(namespaceURI);
+ }
+
+ public boolean isDefaultNamespace(String namespaceURI)
+ {
+ return (parent == null || parent == owner) ? false :
+ parent.isDefaultNamespace(namespaceURI);
+ }
+
+ public String lookupNamespaceURI(String prefix)
+ {
+ return (parent == null || parent == owner) ? null :
+ parent.lookupNamespaceURI(prefix);
+ }
+
+ public boolean isEqualNode(Node arg)
+ {
+ if (this == arg)
+ return true;
+ if (arg == null)
+ return false;
+ if (nodeType != arg.getNodeType())
+ return false;
+ switch (nodeType)
+ {
+ case ELEMENT_NODE:
+ case ATTRIBUTE_NODE:
+ if (!equal(getLocalName(), arg.getLocalName()) ||
+ !equal(getNamespaceURI(), arg.getNamespaceURI()))
+ return false;
+ break;
+ case PROCESSING_INSTRUCTION_NODE:
+ if (!equal(getNodeName(), arg.getNodeName()) ||
+ !equal(getNodeValue(), arg.getNodeValue()))
+ return false;
+ break;
+ case COMMENT_NODE:
+ case TEXT_NODE:
+ case CDATA_SECTION_NODE:
+ if (!equal(getNodeValue(), arg.getNodeValue()))
+ return false;
+ break;
+ }
+ // Children
+ Node argCtx = arg.getFirstChild();
+ getFirstChild(); // because of DomAttr lazy children
+ DomNode ctx = first;
+ for (; ctx != null && argCtx != null; ctx = ctx.next)
+ {
+ if (nodeType == DOCUMENT_NODE)
+ {
+ // Ignore whitespace outside document element
+ while (ctx != null && ctx.nodeType == TEXT_NODE)
+ ctx = ctx.next;
+ while (argCtx != null && ctx.getNodeType() == TEXT_NODE)
+ argCtx = argCtx.getNextSibling();
+ if (ctx == null && argCtx != null)
+ return false;
+ else if (argCtx == null && ctx != null)
+ return false;
+ }
+ if (!ctx.isEqualNode(argCtx))
+ return false;
+ argCtx = argCtx.getNextSibling();
+ }
+ if (ctx != null || argCtx != null)
+ return false;
+
+ // TODO DocumentType
+ return true;
+ }
+
+ boolean equal(String arg1, String arg2)
+ {
+ return ((arg1 == null && arg2 == null) ||
+ (arg1 != null && arg1.equals(arg2)));
+ }
+
+ public Object getFeature(String feature, String version)
+ {
+ DOMImplementation impl = (nodeType == DOCUMENT_NODE) ?
+ ((Document) this).getImplementation() : owner.getImplementation();
+ if (impl.hasFeature(feature, version))
+ {
+ return this;
+ }
+ return null;
+ }
+
+ public Object setUserData(String key, Object data, UserDataHandler handler)
+ {
+ if (userData == null)
+ {
+ userData = new HashMap();
+ }
+ if (handler != null)
+ {
+ if (userDataHandlers == null)
+ {
+ userDataHandlers = new HashMap();
+ }
+ userDataHandlers.put(key, handler);
+ }
+ return userData.put(key, data);
+ }
+
+ public Object getUserData(String key)
+ {
+ if (userData == null)
+ {
+ return null;
+ }
+ return userData.get(key);
+ }
+
+ public String toString()
+ {
+ String nodeName = getNodeName();
+ String nodeValue = getNodeValue();
+ StringBuffer buf = new StringBuffer(getClass().getName());
+ buf.append('[');
+ if (nodeName != null)
+ {
+ buf.append(nodeName);
+ }
+ if (nodeValue != null)
+ {
+ if (nodeName != null)
+ {
+ buf.append('=');
+ }
+ buf.append('\'');
+ buf.append(encode(nodeValue));
+ buf.append('\'');
+ }
+ buf.append(']');
+ return buf.toString();
+ }
+
+ String encode(String value)
+ {
+ StringBuffer buf = null;
+ int len = value.length();
+ for (int i = 0; i < len; i++)
+ {
+ char c = value.charAt(i);
+ if (c == '\n')
+ {
+ if (buf == null)
+ {
+ buf = new StringBuffer(value.substring(0, i));
+ }
+ buf.append("\\n");
+ }
+ else if (c == '\r')
+ {
+ if (buf == null)
+ {
+ buf = new StringBuffer(value.substring(0, i));
+ }
+ buf.append("\\r");
+ }
+ else if (buf != null)
+ {
+ buf.append(c);
+ }
+ }
+ return (buf != null) ? buf.toString() : value;
+ }
+
+ String nodeTypeToString(short nodeType)
+ {
+ switch (nodeType)
+ {
+ case ELEMENT_NODE:
+ return "ELEMENT_NODE";
+ case ATTRIBUTE_NODE:
+ return "ATTRIBUTE_NODE";
+ case TEXT_NODE:
+ return "TEXT_NODE";
+ case CDATA_SECTION_NODE:
+ return "CDATA_SECTION_NODE";
+ case DOCUMENT_NODE:
+ return "DOCUMENT_NODE";
+ case DOCUMENT_TYPE_NODE:
+ return "DOCUMENT_TYPE_NODE";
+ case COMMENT_NODE:
+ return "COMMENT_NODE";
+ case PROCESSING_INSTRUCTION_NODE:
+ return "PROCESSING_INSTRUCTION_NODE";
+ case DOCUMENT_FRAGMENT_NODE:
+ return "DOCUMENT_FRAGMENT_NODE";
+ case ENTITY_NODE:
+ return "ENTITY_NODE";
+ case ENTITY_REFERENCE_NODE:
+ return "ENTITY_REFERENCE_NODE";
+ case NOTATION_NODE:
+ return "NOTATION_NODE";
+ default:
+ return "UNKNOWN";
+ }
+ }
+
+ public void list(java.io.PrintStream out, int indent)
+ {
+ for (int i = 0; i < indent; i++)
+ out.print(" ");
+ out.println(toString());
+ for (DomNode ctx = first; ctx != null; ctx = ctx.next)
+ ctx.list(out, indent + 1);
+ }
+
+}
+
Added: llvm-gcc-4.2/trunk/libjava/classpath/gnu/xml/dom/DomNodeIterator.java
URL: http://llvm.org/viewvc/llvm-project/llvm-gcc-4.2/trunk/libjava/classpath/gnu/xml/dom/DomNodeIterator.java?rev=43913&view=auto
==============================================================================
--- llvm-gcc-4.2/trunk/libjava/classpath/gnu/xml/dom/DomNodeIterator.java (added)
+++ llvm-gcc-4.2/trunk/libjava/classpath/gnu/xml/dom/DomNodeIterator.java Thu Nov 8 16:56:19 2007
@@ -0,0 +1,328 @@
+/* DomNodeIterator.java --
+ Copyright (C) 2004 Free Software Foundation, Inc.
+
+This file is part of GNU Classpath.
+
+GNU Classpath is free software; you can redistribute it and/or modify
+it under the terms of the GNU General Public License as published by
+the Free Software Foundation; either version 2, or (at your option)
+any later version.
+
+GNU Classpath is distributed in the hope that it will be useful, but
+WITHOUT ANY WARRANTY; without even the implied warranty of
+MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+General Public License for more details.
+
+You should have received a copy of the GNU General Public License
+along with GNU Classpath; see the file COPYING. If not, write to the
+Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA
+02110-1301 USA.
+
+Linking this library statically or dynamically with other modules is
+making a combined work based on this library. Thus, the terms and
+conditions of the GNU General Public License cover the whole
+combination.
+
+As a special exception, the copyright holders of this library give you
+permission to link this library with independent modules to produce an
+executable, regardless of the license terms of these independent
+modules, and to copy and distribute the resulting executable under
+terms of your choice, provided that you also meet, for each linked
+independent module, the terms and conditions of the license of that
+module. An independent module is a module which is not derived from
+or based on this library. If you modify this library, you may extend
+this exception to your version of the library, but you are not
+obligated to do so. If you do not wish to do so, delete this
+exception statement from your version. */
+package gnu.xml.dom;
+
+import org.w3c.dom.DOMException;
+import org.w3c.dom.Node;
+import org.w3c.dom.traversal.NodeFilter;
+import org.w3c.dom.traversal.NodeIterator;
+import org.w3c.dom.traversal.TreeWalker;
+
+/**
+ * Node iterator and tree walker.
+ *
+ * @author <a href='mailto:dog at gnu.org'>Chris Burdess</a>
+ */
+public class DomNodeIterator
+ implements NodeIterator, TreeWalker
+{
+
+ Node root;
+ final int whatToShow;
+ final NodeFilter filter;
+ final boolean entityReferenceExpansion;
+ final boolean walk;
+ Node current;
+
+ public DomNodeIterator(Node root, int whatToShow, NodeFilter filter,
+ boolean entityReferenceExpansion, boolean walk)
+ {
+ if (root == null)
+ {
+ throw new DOMException(DOMException.NOT_SUPPORTED_ERR, "null root");
+ }
+ this.root = root;
+ this.whatToShow = whatToShow;
+ this.filter = filter;
+ this.entityReferenceExpansion = entityReferenceExpansion;
+ this.walk = walk;
+ current = root;
+ }
+
+ public Node getRoot()
+ {
+ return root;
+ }
+
+ public int getWhatToShow()
+ {
+ return whatToShow;
+ }
+
+ public NodeFilter getFilter()
+ {
+ return filter;
+ }
+
+ public boolean getExpandEntityReferences()
+ {
+ return entityReferenceExpansion;
+ }
+
+ public Node nextNode()
+ throws DOMException
+ {
+ if (root == null)
+ {
+ throw new DOMException(DOMException.INVALID_STATE_ERR, "null root");
+ }
+ Node ret;
+ do
+ {
+ if (current.equals(root))
+ {
+ ret = root.getFirstChild();
+ }
+ else if (walk)
+ {
+ ret = current.getFirstChild();
+ if (ret == null)
+ {
+ ret = current.getNextSibling();
+ }
+ if (ret == null)
+ {
+ Node tmp = current;
+ ret = tmp.getParentNode();
+ while (!ret.equals(root) && tmp.equals(ret.getLastChild()))
+ {
+ tmp = ret;
+ ret = tmp.getParentNode();
+ }
+ if (ret.equals(root))
+ {
+ ret = null;
+ }
+ else
+ {
+ ret = ret.getNextSibling();
+ }
+ }
+ }
+ else
+ {
+ ret = current.getNextSibling();
+ }
+ current = (ret == null) ? current : ret;
+ }
+ while (!accept(ret));
+
+ return ret;
+ }
+
+ public Node previousNode()
+ throws DOMException
+ {
+ if (root == null)
+ {
+ throw new DOMException(DOMException.INVALID_STATE_ERR, "null root");
+ }
+ Node ret;
+ do
+ {
+ if (current.equals(root))
+ {
+ ret = current.getLastChild();
+ }
+ else if (walk)
+ {
+ ret = current.getLastChild();
+ if (ret == null)
+ {
+ ret = current.getPreviousSibling();
+ }
+ if (ret == null)
+ {
+ Node tmp = current;
+ ret = tmp.getParentNode();
+ while (!ret.equals(root) && tmp.equals(ret.getFirstChild()))
+ {
+ tmp = ret;
+ ret = tmp.getParentNode();
+ }
+ if (ret.equals(root))
+ {
+ ret = null;
+ }
+ else
+ {
+ ret = ret.getPreviousSibling();
+ }
+ }
+ }
+ else
+ {
+ ret = current.getPreviousSibling();
+ }
+ }
+ while (!accept(ret));
+ current = (ret == null) ? current : ret;
+ return ret;
+ }
+
+ public Node getCurrentNode()
+ {
+ return current;
+ }
+
+ public void setCurrentNode(Node current)
+ throws DOMException
+ {
+ if (current == null)
+ {
+ throw new DOMException(DOMException.NOT_SUPPORTED_ERR, "null root");
+ }
+ this.current = current;
+ }
+
+ public Node parentNode()
+ {
+ Node ret = current.getParentNode();
+ if (!accept (ret))
+ {
+ ret = null;
+ }
+ current = (ret == null) ? current : ret;
+ return ret;
+ }
+
+ public Node firstChild ()
+ {
+ Node ret = current.getFirstChild();
+ while (!accept(ret))
+ {
+ ret = ret.getNextSibling();
+ }
+ current = (ret == null) ? current : ret;
+ return ret;
+ }
+
+ public Node lastChild()
+ {
+ Node ret = current.getLastChild();
+ while (!accept(ret))
+ {
+ ret = ret.getPreviousSibling();
+ }
+ current = (ret == null) ? current : ret;
+ return ret;
+ }
+
+ public Node previousSibling()
+ {
+ Node ret = current.getPreviousSibling();
+ while (!accept(ret))
+ {
+ ret = ret.getPreviousSibling();
+ }
+ current = (ret == null) ? current : ret;
+ return ret;
+ }
+
+ public Node nextSibling()
+ {
+ Node ret = current.getNextSibling();
+ while (!accept(ret))
+ {
+ ret = ret.getNextSibling();
+ }
+ current = (ret == null) ? current : ret;
+ return ret;
+ }
+
+ public void detach()
+ {
+ root = null;
+ }
+
+ boolean accept(Node node)
+ {
+ if (node == null)
+ {
+ return true;
+ }
+ boolean ret;
+ switch (node.getNodeType())
+ {
+ case Node.ATTRIBUTE_NODE:
+ ret = (whatToShow & NodeFilter.SHOW_ATTRIBUTE) != 0;
+ break;
+ case Node.CDATA_SECTION_NODE:
+ ret = (whatToShow & NodeFilter.SHOW_CDATA_SECTION) != 0;
+ break;
+ case Node.COMMENT_NODE:
+ ret = (whatToShow & NodeFilter.SHOW_COMMENT) != 0;
+ break;
+ case Node.DOCUMENT_NODE:
+ ret = (whatToShow & NodeFilter.SHOW_DOCUMENT) != 0;
+ break;
+ case Node.DOCUMENT_FRAGMENT_NODE:
+ ret = (whatToShow & NodeFilter.SHOW_DOCUMENT_FRAGMENT) != 0;
+ break;
+ case Node.DOCUMENT_TYPE_NODE:
+ ret = (whatToShow & NodeFilter.SHOW_DOCUMENT_TYPE) != 0;
+ break;
+ case Node.ELEMENT_NODE:
+ ret = (whatToShow & NodeFilter.SHOW_ELEMENT) != 0;
+ break;
+ case Node.ENTITY_NODE:
+ ret = (whatToShow & NodeFilter.SHOW_ENTITY) != 0;
+ break;
+ case Node.ENTITY_REFERENCE_NODE:
+ ret = (whatToShow & NodeFilter.SHOW_ENTITY_REFERENCE) != 0;
+ ret = ret && entityReferenceExpansion;
+ break;
+ case Node.NOTATION_NODE:
+ ret = (whatToShow & NodeFilter.SHOW_NOTATION) != 0;
+ break;
+ case Node.PROCESSING_INSTRUCTION_NODE:
+ ret = (whatToShow & NodeFilter.SHOW_PROCESSING_INSTRUCTION) != 0;
+ break;
+ case Node.TEXT_NODE:
+ ret = (whatToShow & NodeFilter.SHOW_TEXT) != 0;
+ break;
+ default:
+ ret = true;
+ }
+ if (ret && filter != null)
+ {
+ ret = (filter.acceptNode(node) == NodeFilter.FILTER_ACCEPT);
+ }
+ return ret;
+ }
+
+}
Added: llvm-gcc-4.2/trunk/libjava/classpath/gnu/xml/dom/DomNotation.java
URL: http://llvm.org/viewvc/llvm-project/llvm-gcc-4.2/trunk/libjava/classpath/gnu/xml/dom/DomNotation.java?rev=43913&view=auto
==============================================================================
--- llvm-gcc-4.2/trunk/libjava/classpath/gnu/xml/dom/DomNotation.java (added)
+++ llvm-gcc-4.2/trunk/libjava/classpath/gnu/xml/dom/DomNotation.java Thu Nov 8 16:56:19 2007
@@ -0,0 +1,103 @@
+/* DomNotation.java --
+ Copyright (C) 1999,2000,2001,2004 Free Software Foundation, Inc.
+
+This file is part of GNU Classpath.
+
+GNU Classpath is free software; you can redistribute it and/or modify
+it under the terms of the GNU General Public License as published by
+the Free Software Foundation; either version 2, or (at your option)
+any later version.
+
+GNU Classpath is distributed in the hope that it will be useful, but
+WITHOUT ANY WARRANTY; without even the implied warranty of
+MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+General Public License for more details.
+
+You should have received a copy of the GNU General Public License
+along with GNU Classpath; see the file COPYING. If not, write to the
+Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA
+02110-1301 USA.
+
+Linking this library statically or dynamically with other modules is
+making a combined work based on this library. Thus, the terms and
+conditions of the GNU General Public License cover the whole
+combination.
+
+As a special exception, the copyright holders of this library give you
+permission to link this library with independent modules to produce an
+executable, regardless of the license terms of these independent
+modules, and to copy and distribute the resulting executable under
+terms of your choice, provided that you also meet, for each linked
+independent module, the terms and conditions of the license of that
+module. An independent module is a module which is not derived from
+or based on this library. If you modify this library, you may extend
+this exception to your version of the library, but you are not
+obligated to do so. If you do not wish to do so, delete this
+exception statement from your version. */
+
+package gnu.xml.dom;
+
+import org.w3c.dom.Notation;
+
+/**
+ * <p> "Notation" implementation. This is a non-core DOM class, supporting
+ * the "XML" feature. </p>
+ *
+ * <p> Although unparsed entities using this notation can be detected using
+ * DOM, neither NOTATIONS nor ENTITY/ENTITIES attributes can be so detected.
+ * More, there is no portable way to construct a Notation node, so there's
+ * no way that vendor-neutral DOM construction APIs could even report a
+ * NOTATION used to identify the intended meaning of a ProcessingInstruction.
+ * </p>
+ *
+ * <p> In short, <em>avoid using this DOM functionality</em>.
+ *
+ * @see DomDoctype
+ * @see DomEntity
+ * @see DomPI
+ *
+ * @author David Brownell
+ * @author <a href='mailto:dog at gnu.org'>Chris Burdess</a>
+ */
+public class DomNotation
+ extends DomExtern
+ implements Notation
+{
+
+ /**
+ * Constructs a Notation node associated with the specified document,
+ * with the specified descriptive data. Note that at least one of
+ * the PUBLIC and SYSTEM identifiers must be provided; unlike other
+ * external objects in XML, notations may have only a PUBLIC identifier.
+ *
+ * <p>This constructor should only be invoked by a DomDoctype object
+ * as part of its declareNotation functionality, or through a subclass
+ * which is similarly used in a "Sub-DOM" style layer.
+ *
+ * @param owner The document with which this notation is associated
+ * @param name Name of this notation
+ * @param publicId If non-null, provides the notation's PUBLIC identifier
+ * @param systemId If non-null, rovides the notation's SYSTEM identifier
+ */
+ protected DomNotation(DomDocument owner,
+ String name,
+ String publicId,
+ String systemId)
+ {
+ super(NOTATION_NODE, owner, name, publicId, systemId);
+ makeReadonly();
+ }
+
+ /**
+ * The base URI of an external entity is its system ID.
+ * The base URI of an internal entity is the parent document's base URI.
+ * @since DOM Level 3 Core
+ */
+ public String getBaseURI()
+ {
+ String systemId = getSystemId();
+ return (systemId == null) ? owner.getBaseURI() : systemId;
+ }
+
+}
+
Added: llvm-gcc-4.2/trunk/libjava/classpath/gnu/xml/dom/DomNsNode.java
URL: http://llvm.org/viewvc/llvm-project/llvm-gcc-4.2/trunk/libjava/classpath/gnu/xml/dom/DomNsNode.java?rev=43913&view=auto
==============================================================================
--- llvm-gcc-4.2/trunk/libjava/classpath/gnu/xml/dom/DomNsNode.java (added)
+++ llvm-gcc-4.2/trunk/libjava/classpath/gnu/xml/dom/DomNsNode.java Thu Nov 8 16:56:19 2007
@@ -0,0 +1,200 @@
+/* DomNsNode.java --
+ Copyright (C) 1999,2000,2001,2004 Free Software Foundation, Inc.
+
+This file is part of GNU Classpath.
+
+GNU Classpath is free software; you can redistribute it and/or modify
+it under the terms of the GNU General Public License as published by
+the Free Software Foundation; either version 2, or (at your option)
+any later version.
+
+GNU Classpath is distributed in the hope that it will be useful, but
+WITHOUT ANY WARRANTY; without even the implied warranty of
+MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+General Public License for more details.
+
+You should have received a copy of the GNU General Public License
+along with GNU Classpath; see the file COPYING. If not, write to the
+Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA
+02110-1301 USA.
+
+Linking this library statically or dynamically with other modules is
+making a combined work based on this library. Thus, the terms and
+conditions of the GNU General Public License cover the whole
+combination.
+
+As a special exception, the copyright holders of this library give you
+permission to link this library with independent modules to produce an
+executable, regardless of the license terms of these independent
+modules, and to copy and distribute the resulting executable under
+terms of your choice, provided that you also meet, for each linked
+independent module, the terms and conditions of the license of that
+module. An independent module is a module which is not derived from
+or based on this library. If you modify this library, you may extend
+this exception to your version of the library, but you are not
+obligated to do so. If you do not wish to do so, delete this
+exception statement from your version. */
+
+package gnu.xml.dom;
+
+import javax.xml.XMLConstants;
+import org.w3c.dom.DOMException;
+
+/**
+ * <p> Abstract implemention of namespace support. This facilitates
+ * sharing code for attribute and element nodes.
+ *
+ * @author David Brownell
+ * @author <a href='mailto:dog at gnu.org'>Chris Burdess</a>
+ */
+public abstract class DomNsNode
+ extends DomNode
+{
+
+ private String name;
+ private String namespace;
+ private String prefix;
+ String localName;
+
+ /**
+ * Constructs a node associated with the specified document, and
+ * with the specified namespace information.
+ *
+ * @param owner The document with which this entity is associated
+ * @param namespaceURI Combined with the local part of the name,
+ * this identifies a type of element or attribute; may be null.
+ * If this is the empty string, it is reassigned as null so that
+ * applications only need to test that case.
+ * @param name Name of this node, which may include a prefix
+ */
+ // package private
+ DomNsNode(short nodeType, DomDocument owner, String namespaceURI, String name)
+ {
+ super(nodeType, owner);
+ setNodeName(name);
+ setNamespaceURI(namespaceURI);
+ }
+
+ /**
+ * <b>DOM L1</b>
+ * Returns the node's name, including any namespace prefix.
+ */
+ public final String getNodeName()
+ {
+ return name;
+ }
+
+ final void setNodeName(String name)
+ {
+ this.name = name.intern();
+ int index = name.indexOf(':');
+ if (index == -1)
+ {
+ prefix = null;
+ localName = this.name;
+ }
+ else
+ {
+ prefix = name.substring(0, index).intern();
+ localName = name.substring(index + 1).intern();
+ }
+ }
+
+ /**
+ * <b>DOM L2</b>
+ * Returns the node's namespace URI
+ * <em>or null</em> if the node name is not namespace scoped.
+ */
+ public final String getNamespaceURI()
+ {
+ return namespace;
+ }
+
+ final void setNamespaceURI(String namespaceURI)
+ {
+ if ("".equals(namespaceURI))
+ {
+ namespaceURI = null;
+ }
+ namespace = (namespaceURI == null) ? null : namespaceURI.intern();
+ }
+
+ /**
+ * <b>DOM L2</b>
+ * Returns any prefix part of the node's name (before any colon).
+ */
+ public final String getPrefix()
+ {
+ return prefix;
+ }
+
+ /**
+ * <b>DOM L2</b>
+ * Assigns the prefix part of the node's name (before any colon).
+ */
+ public final void setPrefix(String prefix)
+ {
+ if (readonly)
+ {
+ throw new DomDOMException(DOMException.NO_MODIFICATION_ALLOWED_ERR);
+ }
+
+ if (prefix == null)
+ {
+ name = localName;
+ return;
+ }
+ else if (namespace == null)
+ {
+ throw new DomDOMException(DOMException.NAMESPACE_ERR,
+ "can't set prefix, node has no namespace URI",
+ this, 0);
+ }
+
+ DomDocument.checkName(prefix, "1.1".equals(owner.getXmlVersion()));
+ if (prefix.indexOf (':') != -1)
+ {
+ throw new DomDOMException(DOMException.NAMESPACE_ERR,
+ "illegal prefix " + prefix, this, 0);
+ }
+
+ if (XMLConstants.XML_NS_PREFIX.equals(prefix)
+ && !XMLConstants.XML_NS_URI.equals(namespace))
+ {
+ throw new DomDOMException(DOMException.NAMESPACE_ERR,
+ "xml namespace is always " +
+ XMLConstants.XML_NS_URI, this, 0);
+ }
+
+ if (XMLConstants.XMLNS_ATTRIBUTE.equals(prefix))
+ {
+ if (namespace != null || getNodeType() != ATTRIBUTE_NODE)
+ {
+ throw new DomDOMException(DOMException.NAMESPACE_ERR,
+ "xmlns attribute prefix is reserved",
+ this, 0);
+ }
+ }
+ else if (getNodeType () == ATTRIBUTE_NODE
+ && (XMLConstants.XMLNS_ATTRIBUTE.equals(name) ||
+ name.startsWith("xmlns:")))
+ {
+ throw new DomDOMException(DOMException.NAMESPACE_ERR,
+ "namespace declarations can't change names",
+ this, 0);
+ }
+
+ this.prefix = prefix.intern();
+ }
+
+ /**
+ * <b>DOM L2</b>
+ * Returns the local part of the node's name (after any colon).
+ */
+ public final String getLocalName()
+ {
+ return localName;
+ }
+
+}
+
Added: llvm-gcc-4.2/trunk/libjava/classpath/gnu/xml/dom/DomProcessingInstruction.java
URL: http://llvm.org/viewvc/llvm-project/llvm-gcc-4.2/trunk/libjava/classpath/gnu/xml/dom/DomProcessingInstruction.java?rev=43913&view=auto
==============================================================================
--- llvm-gcc-4.2/trunk/libjava/classpath/gnu/xml/dom/DomProcessingInstruction.java (added)
+++ llvm-gcc-4.2/trunk/libjava/classpath/gnu/xml/dom/DomProcessingInstruction.java Thu Nov 8 16:56:19 2007
@@ -0,0 +1,147 @@
+/* DomProcessingInstruction.java --
+ Copyright (C) 1999,2000,2001,2004 Free Software Foundation, Inc.
+
+This file is part of GNU Classpath.
+
+GNU Classpath is free software; you can redistribute it and/or modify
+it under the terms of the GNU General Public License as published by
+the Free Software Foundation; either version 2, or (at your option)
+any later version.
+
+GNU Classpath is distributed in the hope that it will be useful, but
+WITHOUT ANY WARRANTY; without even the implied warranty of
+MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+General Public License for more details.
+
+You should have received a copy of the GNU General Public License
+along with GNU Classpath; see the file COPYING. If not, write to the
+Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA
+02110-1301 USA.
+
+Linking this library statically or dynamically with other modules is
+making a combined work based on this library. Thus, the terms and
+conditions of the GNU General Public License cover the whole
+combination.
+
+As a special exception, the copyright holders of this library give you
+permission to link this library with independent modules to produce an
+executable, regardless of the license terms of these independent
+modules, and to copy and distribute the resulting executable under
+terms of your choice, provided that you also meet, for each linked
+independent module, the terms and conditions of the license of that
+module. An independent module is a module which is not derived from
+or based on this library. If you modify this library, you may extend
+this exception to your version of the library, but you are not
+obligated to do so. If you do not wish to do so, delete this
+exception statement from your version. */
+
+package gnu.xml.dom;
+
+import org.w3c.dom.DOMException;
+import org.w3c.dom.ProcessingInstruction;
+
+/**
+ * <p> "ProcessingInstruction" (PI) implementation.
+ * This is a non-core DOM class, supporting the "XML" feature. </p>
+ *
+ * <p> Unlike other DOM APIs in the "XML" feature, this one fully
+ * exposes the functionality it describes. So there is no reason
+ * inherent in DOM to avoid using this API, unless you want to rely
+ * on NOTATION declarations to associate meaning with your PIs;
+ * there is no vendor-neutal way to record those notations in DOM.</p>
+ *
+ * <p> Also of note is that PI support is part of SAX, so that XML
+ * systems using PIs can choose among multiple APIs. </p>
+ *
+ * @see DomNotation
+ *
+ * @author David Brownell
+ * @author <a href='mailto:dog at gnu.org'>Chris Burdess</a>
+ */
+public class DomProcessingInstruction
+ extends DomNode
+ implements ProcessingInstruction
+{
+
+ private String target;
+ private String data;
+
+ /**
+ * Constructs a ProcessingInstruction node associated with the
+ * specified document, with the specified data.
+ *
+ * <p>This constructor should only be invoked by a Document object as
+ * part of its createProcessingInstruction functionality, or through
+ * a subclass which is similarly used in a "Sub-DOM" style layer.
+ */
+ protected DomProcessingInstruction(DomDocument owner,
+ String target, String data)
+ {
+ super(PROCESSING_INSTRUCTION_NODE, owner);
+ this.target = target;
+ this.data = data;
+ }
+
+ /**
+ * <b>DOM L1</b>
+ * Returns the target of the processing instruction.
+ */
+ public final String getTarget()
+ {
+ return target;
+ }
+
+ /**
+ * <b>DOM L1</b>
+ * Returns the target of the processing instruction
+ * (same as getTarget).
+ */
+ public final String getNodeName()
+ {
+ return target;
+ }
+
+ /**
+ * <b>DOM L1</b>
+ * Returns the data associated with the processing instruction.
+ */
+ public final String getData()
+ {
+ return data;
+ }
+
+ /**
+ * <b>DOM L1</b>
+ * Returns the data associated with the processing instruction
+ * (same as getData).
+ */
+ public final String getNodeValue()
+ {
+ return data;
+ }
+
+ /**
+ * <b>DOM L1</b>
+ * Assigns the data associated with the processing instruction;
+ * same as setNodeValue.
+ */
+ public final void setData(String data)
+ {
+ setNodeValue(data);
+ }
+
+ /**
+ * <b>DOM L1</b>
+ * Assigns the data associated with the processing instruction.
+ */
+ public final void setNodeValue(String data)
+ {
+ if (isReadonly())
+ {
+ throw new DomDOMException(DOMException.NO_MODIFICATION_ALLOWED_ERR);
+ }
+ this.data = data;
+ }
+
+}
+
Added: llvm-gcc-4.2/trunk/libjava/classpath/gnu/xml/dom/DomText.java
URL: http://llvm.org/viewvc/llvm-project/llvm-gcc-4.2/trunk/libjava/classpath/gnu/xml/dom/DomText.java?rev=43913&view=auto
==============================================================================
--- llvm-gcc-4.2/trunk/libjava/classpath/gnu/xml/dom/DomText.java (added)
+++ llvm-gcc-4.2/trunk/libjava/classpath/gnu/xml/dom/DomText.java Thu Nov 8 16:56:19 2007
@@ -0,0 +1,220 @@
+/* DomText.java --
+ Copyright (C) 1999, 2000, 2001, 2004 Free Software Foundation, Inc.
+
+This file is part of GNU Classpath.
+
+GNU Classpath is free software; you can redistribute it and/or modify
+it under the terms of the GNU General Public License as published by
+the Free Software Foundation; either version 2, or (at your option)
+any later version.
+
+GNU Classpath is distributed in the hope that it will be useful, but
+WITHOUT ANY WARRANTY; without even the implied warranty of
+MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+General Public License for more details.
+
+You should have received a copy of the GNU General Public License
+along with GNU Classpath; see the file COPYING. If not, write to the
+Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA
+02110-1301 USA.
+
+Linking this library statically or dynamically with other modules is
+making a combined work based on this library. Thus, the terms and
+conditions of the GNU General Public License cover the whole
+combination.
+
+As a special exception, the copyright holders of this library give you
+permission to link this library with independent modules to produce an
+executable, regardless of the license terms of these independent
+modules, and to copy and distribute the resulting executable under
+terms of your choice, provided that you also meet, for each linked
+independent module, the terms and conditions of the license of that
+module. An independent module is a module which is not derived from
+or based on this library. If you modify this library, you may extend
+this exception to your version of the library, but you are not
+obligated to do so. If you do not wish to do so, delete this
+exception statement from your version. */
+
+package gnu.xml.dom;
+
+import org.w3c.dom.DOMException;
+import org.w3c.dom.Text;
+
+/**
+ * <p> "Text" implementation. </p>
+ *
+ * @author David Brownell
+ * @author <a href='mailto:dog at gnu.org'>Chris Burdess</a>
+ */
+public class DomText
+ extends DomCharacterData
+ implements Text
+{
+
+ // NOTE: deleted unused per-instance "isIgnorable"
+ // support to reclaim its space.
+
+ /**
+ * Constructs a text node associated with the specified
+ * document and holding the specified data.
+ *
+ * <p>This constructor should only be invoked by a Document object
+ * as part of its createTextNode functionality, or through a subclass
+ * which is similarly used in a "Sub-DOM" style layer.
+ */
+ protected DomText(DomDocument owner, String value)
+ {
+ super(TEXT_NODE, owner, value);
+ }
+
+ protected DomText(DomDocument owner, char[] buf, int off, int len)
+ {
+ super(TEXT_NODE, owner, buf, off, len);
+ }
+
+ // Used by DomCDATA
+ DomText(short nodeType, DomDocument owner, String value)
+ {
+ super(nodeType, owner, value);
+ }
+
+ DomText(short nodeType, DomDocument owner, char[] buf, int off, int len)
+ {
+ super(nodeType, owner, buf, off, len);
+ }
+
+ /**
+ * <b>DOM L1</b>
+ * Returns the string "#text".
+ */
+ // can't be 'final' with CDATA subclassing
+ public String getNodeName()
+ {
+ return "#text";
+ }
+
+ /**
+ * <b>DOM L1</b>
+ * Splits this text node in two parts at the offset, returning
+ * the new text node (the sibling with the second part).
+ */
+ public Text splitText(int offset)
+ {
+ if (isReadonly())
+ {
+ throw new DomDOMException(DOMException.NO_MODIFICATION_ALLOWED_ERR);
+ }
+ try
+ {
+ String text = getNodeValue();
+ String before = text.substring(0, offset);
+ String after = text.substring(offset);
+ Text next;
+
+ if (getNodeType() == TEXT_NODE)
+ {
+ next = owner.createTextNode(after);
+ }
+ else // CDATA_SECTION_NODE
+ {
+ next = owner.createCDATASection(after);
+ }
+
+ if (this.next != null)
+ {
+ parent.insertBefore(next, this.next);
+ }
+ else
+ {
+ parent.appendChild(next);
+ }
+ setNodeValue(before);
+ return next;
+
+ }
+ catch (IndexOutOfBoundsException x)
+ {
+ throw new DomDOMException(DOMException.INDEX_SIZE_ERR);
+ }
+ }
+
+ // DOM Level 3
+
+ public boolean isElementContentWhitespace()
+ {
+ if (parent != null)
+ {
+ DomDoctype doctype = (DomDoctype) owner.getDoctype();
+ if (doctype != null)
+ {
+ DTDElementTypeInfo info =
+ doctype.getElementTypeInfo(parent.getNodeName());
+ if (info != null)
+ {
+ if (info.model == null && info.model.indexOf("#PCDATA") != -1)
+ {
+ return false;
+ }
+ return getNodeValue().trim().length() == 0;
+ }
+ }
+ }
+ return false;
+ }
+
+ public String getWholeText()
+ {
+ DomNode ref = this;
+ DomNode ctx;
+ for (ctx = previous; ctx != null &&
+ (ctx.nodeType == TEXT_NODE || ctx.nodeType == CDATA_SECTION_NODE);
+ ctx = ctx.previous)
+ {
+ ref = ctx;
+ }
+ StringBuffer buf = new StringBuffer(ref.getNodeValue());
+ for (ctx = ref.next; ctx != null &&
+ (ctx.nodeType == TEXT_NODE || ctx.nodeType == CDATA_SECTION_NODE);
+ ctx = ctx.next)
+ {
+ buf.append(ctx.getNodeValue());
+ }
+ return buf.toString ();
+ }
+
+ public Text replaceWholeText(String content)
+ throws DOMException
+ {
+ boolean isEmpty = (content == null || content.length () == 0);
+ if (!isEmpty)
+ {
+ setNodeValue(content);
+ }
+
+ DomNode ref = this;
+ DomNode ctx;
+ for (ctx = previous; ctx != null &&
+ (ctx.nodeType == TEXT_NODE || ctx.nodeType == CDATA_SECTION_NODE);
+ ctx = ctx.previous)
+ {
+ ref = ctx;
+ }
+ ctx = ref.next;
+ if ((isEmpty || ref != this) && parent != null)
+ {
+ parent.removeChild(ref);
+ }
+ for (; ctx != null &&
+ (ctx.nodeType == TEXT_NODE || ctx.nodeType == CDATA_SECTION_NODE);
+ ctx = ref)
+ {
+ ref = ctx.next;
+ if ((isEmpty || ctx != this) && parent != null)
+ {
+ parent.removeChild(ctx);
+ }
+ }
+ return (isEmpty) ? null : this;
+ }
+
+}
Added: llvm-gcc-4.2/trunk/libjava/classpath/gnu/xml/dom/DomXPathExpression.java
URL: http://llvm.org/viewvc/llvm-project/llvm-gcc-4.2/trunk/libjava/classpath/gnu/xml/dom/DomXPathExpression.java?rev=43913&view=auto
==============================================================================
--- llvm-gcc-4.2/trunk/libjava/classpath/gnu/xml/dom/DomXPathExpression.java (added)
+++ llvm-gcc-4.2/trunk/libjava/classpath/gnu/xml/dom/DomXPathExpression.java Thu Nov 8 16:56:19 2007
@@ -0,0 +1,147 @@
+/* DomXPathExpression.java --
+ Copyright (C) 2004 Free Software Foundation, Inc.
+
+This file is part of GNU Classpath.
+
+GNU Classpath is free software; you can redistribute it and/or modify
+it under the terms of the GNU General Public License as published by
+the Free Software Foundation; either version 2, or (at your option)
+any later version.
+
+GNU Classpath is distributed in the hope that it will be useful, but
+WITHOUT ANY WARRANTY; without even the implied warranty of
+MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+General Public License for more details.
+
+You should have received a copy of the GNU General Public License
+along with GNU Classpath; see the file COPYING. If not, write to the
+Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA
+02110-1301 USA.
+
+Linking this library statically or dynamically with other modules is
+making a combined work based on this library. Thus, the terms and
+conditions of the GNU General Public License cover the whole
+combination.
+
+As a special exception, the copyright holders of this library give you
+permission to link this library with independent modules to produce an
+executable, regardless of the license terms of these independent
+modules, and to copy and distribute the resulting executable under
+terms of your choice, provided that you also meet, for each linked
+independent module, the terms and conditions of the license of that
+module. An independent module is a module which is not derived from
+or based on this library. If you modify this library, you may extend
+this exception to your version of the library, but you are not
+obligated to do so. If you do not wish to do so, delete this
+exception statement from your version. */
+
+package gnu.xml.dom;
+
+import java.util.ArrayList;
+import java.util.Collection;
+import java.util.Collections;
+import java.util.List;
+import javax.xml.namespace.QName;
+import javax.xml.xpath.XPath;
+import javax.xml.xpath.XPathConstants;
+import javax.xml.xpath.XPathExpression;
+import javax.xml.xpath.XPathExpressionException;
+import javax.xml.xpath.XPathFactory;
+import org.w3c.dom.DOMException;
+import org.w3c.dom.Node;
+import org.w3c.dom.xpath.XPathException;
+import org.w3c.dom.xpath.XPathNSResolver;
+import org.w3c.dom.xpath.XPathResult;
+import gnu.xml.xpath.DocumentOrderComparator;
+
+/**
+ * An XPath expression.
+ *
+ * @author <a href='mailto:dog at gnu.org'>Chris Burdess</a>
+ */
+class DomXPathExpression
+implements org.w3c.dom.xpath.XPathExpression
+{
+
+ final DomDocument doc;
+ final XPathExpression expression;
+ final XPathNSResolver resolver;
+
+ DomXPathExpression(DomDocument doc, String expression,
+ XPathNSResolver resolver)
+ throws XPathException
+ {
+ this.doc = doc;
+ this.resolver = resolver;
+
+ XPathFactory factory = XPathFactory.newInstance();
+ XPath xpath = factory.newXPath();
+ if (resolver != null)
+ {
+ xpath.setNamespaceContext(new DomNSResolverContext(resolver));
+ }
+ try
+ {
+ this.expression = xpath.compile(expression);
+ }
+ catch (XPathExpressionException e)
+ {
+ throw new XPathException(XPathException.INVALID_EXPRESSION_ERR,
+ e.getMessage ());
+ }
+ }
+
+ public Object evaluate(Node contextNode, short type, Object result)
+ throws XPathException, DOMException
+ {
+ try
+ {
+ QName typeName = null;
+ switch (type)
+ {
+ case XPathResult.BOOLEAN_TYPE:
+ typeName = XPathConstants.BOOLEAN;
+ break;
+ case XPathResult.NUMBER_TYPE:
+ typeName = XPathConstants.NUMBER;
+ break;
+ case XPathResult.STRING_TYPE:
+ typeName = XPathConstants.STRING;
+ break;
+ case XPathResult.ANY_UNORDERED_NODE_TYPE:
+ case XPathResult.FIRST_ORDERED_NODE_TYPE:
+ typeName = XPathConstants.NODE;
+ break;
+ case XPathResult.UNORDERED_NODE_ITERATOR_TYPE:
+ case XPathResult.UNORDERED_NODE_SNAPSHOT_TYPE:
+ case XPathResult.ORDERED_NODE_ITERATOR_TYPE:
+ case XPathResult.ORDERED_NODE_SNAPSHOT_TYPE:
+ typeName = XPathConstants.NODESET;
+ break;
+ default:
+ throw new XPathException(XPathException.TYPE_ERR, null);
+ }
+ Object val = expression.evaluate(contextNode, typeName);
+ switch (type)
+ {
+ case XPathResult.ORDERED_NODE_ITERATOR_TYPE:
+ case XPathResult.ORDERED_NODE_SNAPSHOT_TYPE:
+ // Sort the nodes
+ List ns = new ArrayList((Collection) val);
+ Collections.sort(ns, new DocumentOrderComparator());
+ val = ns;
+ }
+ return new DomXPathResult(val, type);
+ }
+ catch (javax.xml.xpath.XPathException e)
+ {
+ throw new XPathException(XPathException.TYPE_ERR, e.getMessage());
+ }
+ }
+
+ public String toString ()
+ {
+ return getClass ().getName () + "[expression=" + expression + "]";
+ }
+
+}
Added: llvm-gcc-4.2/trunk/libjava/classpath/gnu/xml/dom/DomXPathNSResolver.java
URL: http://llvm.org/viewvc/llvm-project/llvm-gcc-4.2/trunk/libjava/classpath/gnu/xml/dom/DomXPathNSResolver.java?rev=43913&view=auto
==============================================================================
--- llvm-gcc-4.2/trunk/libjava/classpath/gnu/xml/dom/DomXPathNSResolver.java (added)
+++ llvm-gcc-4.2/trunk/libjava/classpath/gnu/xml/dom/DomXPathNSResolver.java Thu Nov 8 16:56:19 2007
@@ -0,0 +1,64 @@
+/* DomXPathNSResolver.java --
+ Copyright (C) 2004 Free Software Foundation, Inc.
+
+This file is part of GNU Classpath.
+
+GNU Classpath is free software; you can redistribute it and/or modify
+it under the terms of the GNU General Public License as published by
+the Free Software Foundation; either version 2, or (at your option)
+any later version.
+
+GNU Classpath is distributed in the hope that it will be useful, but
+WITHOUT ANY WARRANTY; without even the implied warranty of
+MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+General Public License for more details.
+
+You should have received a copy of the GNU General Public License
+along with GNU Classpath; see the file COPYING. If not, write to the
+Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA
+02110-1301 USA.
+
+Linking this library statically or dynamically with other modules is
+making a combined work based on this library. Thus, the terms and
+conditions of the GNU General Public License cover the whole
+combination.
+
+As a special exception, the copyright holders of this library give you
+permission to link this library with independent modules to produce an
+executable, regardless of the license terms of these independent
+modules, and to copy and distribute the resulting executable under
+terms of your choice, provided that you also meet, for each linked
+independent module, the terms and conditions of the license of that
+module. An independent module is a module which is not derived from
+or based on this library. If you modify this library, you may extend
+this exception to your version of the library, but you are not
+obligated to do so. If you do not wish to do so, delete this
+exception statement from your version. */
+
+package gnu.xml.dom;
+
+import org.w3c.dom.Node;
+import org.w3c.dom.xpath.XPathNSResolver;
+
+/**
+ * Generic XPath namespace resolver using a DOM Node.
+ *
+ * @author <a href='mailto:dog at gnu.org'>Chris Burdess</a>
+ */
+class DomXPathNSResolver
+implements XPathNSResolver
+{
+
+ Node node;
+
+ DomXPathNSResolver (Node node)
+ {
+ this.node = node;
+ }
+
+ public String lookupNamespaceURI (String prefix)
+ {
+ return node.lookupNamespaceURI (prefix);
+ }
+
+}
Added: llvm-gcc-4.2/trunk/libjava/classpath/gnu/xml/dom/DomXPathResult.java
URL: http://llvm.org/viewvc/llvm-project/llvm-gcc-4.2/trunk/libjava/classpath/gnu/xml/dom/DomXPathResult.java?rev=43913&view=auto
==============================================================================
--- llvm-gcc-4.2/trunk/libjava/classpath/gnu/xml/dom/DomXPathResult.java (added)
+++ llvm-gcc-4.2/trunk/libjava/classpath/gnu/xml/dom/DomXPathResult.java Thu Nov 8 16:56:19 2007
@@ -0,0 +1,233 @@
+/* DomXPathResult.java --
+ Copyright (C) 2004 Free Software Foundation, Inc.
+
+This file is part of GNU Classpath.
+
+GNU Classpath is free software; you can redistribute it and/or modify
+it under the terms of the GNU General Public License as published by
+the Free Software Foundation; either version 2, or (at your option)
+any later version.
+
+GNU Classpath is distributed in the hope that it will be useful, but
+WITHOUT ANY WARRANTY; without even the implied warranty of
+MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+General Public License for more details.
+
+You should have received a copy of the GNU General Public License
+along with GNU Classpath; see the file COPYING. If not, write to the
+Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA
+02110-1301 USA.
+
+Linking this library statically or dynamically with other modules is
+making a combined work based on this library. Thus, the terms and
+conditions of the GNU General Public License cover the whole
+combination.
+
+As a special exception, the copyright holders of this library give you
+permission to link this library with independent modules to produce an
+executable, regardless of the license terms of these independent
+modules, and to copy and distribute the resulting executable under
+terms of your choice, provided that you also meet, for each linked
+independent module, the terms and conditions of the license of that
+module. An independent module is a module which is not derived from
+or based on this library. If you modify this library, you may extend
+this exception to your version of the library, but you are not
+obligated to do so. If you do not wish to do so, delete this
+exception statement from your version. */
+
+package gnu.xml.dom;
+
+import java.util.Collection;
+import java.util.Iterator;
+import org.w3c.dom.Node;
+import org.w3c.dom.xpath.XPathException;
+import org.w3c.dom.xpath.XPathResult;
+
+/**
+ * An XPath result object.
+ *
+ * @author <a href='mailto:dog at gnu.org'>Chris Burdess</a>
+ */
+class DomXPathResult
+implements XPathResult
+{
+
+ final Object value;
+ final short type;
+ Iterator iterator;
+
+ DomXPathResult (Object value, short requestedType)
+ {
+ this.value = value;
+ if (value instanceof Boolean)
+ {
+ type = XPathResult.BOOLEAN_TYPE;
+ }
+ else if (value instanceof Double)
+ {
+ type = XPathResult.NUMBER_TYPE;
+ }
+ else if (value instanceof String)
+ {
+ type = XPathResult.STRING_TYPE;
+ }
+ else if (value instanceof Collection)
+ {
+ Collection ns = (Collection) value;
+ switch (requestedType)
+ {
+ case XPathResult.ANY_TYPE:
+ case XPathResult.ANY_UNORDERED_NODE_TYPE:
+ type = (ns.size () == 1) ? XPathResult.FIRST_ORDERED_NODE_TYPE :
+ XPathResult.ORDERED_NODE_ITERATOR_TYPE;
+ break;
+ default:
+ type = requestedType;
+ }
+ iterator = ns.iterator ();
+ }
+ else
+ {
+ throw new IllegalArgumentException ();
+ }
+ }
+
+ public boolean getBooleanValue()
+ {
+ if (type == XPathResult.BOOLEAN_TYPE)
+ {
+ return ((Boolean) value).booleanValue ();
+ }
+ throw new XPathException (XPathException.TYPE_ERR, value.toString ());
+ }
+
+ public boolean getInvalidIteratorState()
+ {
+ return iterator == null;
+ }
+
+ public double getNumberValue()
+ {
+ if (type == XPathResult.NUMBER_TYPE)
+ {
+ return ((Double) value).doubleValue ();
+ }
+ throw new XPathException (XPathException.TYPE_ERR, value.toString ());
+ }
+
+ public short getResultType()
+ {
+ return type;
+ }
+
+ public Node getSingleNodeValue()
+ {
+ switch (type)
+ {
+ case XPathResult.FIRST_ORDERED_NODE_TYPE:
+ case XPathResult.ORDERED_NODE_ITERATOR_TYPE:
+ case XPathResult.ORDERED_NODE_SNAPSHOT_TYPE:
+ case XPathResult.UNORDERED_NODE_ITERATOR_TYPE:
+ case XPathResult.UNORDERED_NODE_SNAPSHOT_TYPE:
+ Collection ns = (Collection) value;
+ if (ns.isEmpty ())
+ {
+ return null;
+ }
+ else
+ {
+ return (Node) ns.iterator ().next ();
+ }
+ }
+ throw new XPathException (XPathException.TYPE_ERR, value.toString ());
+ }
+
+ public int getSnapshotLength()
+ {
+ switch (type)
+ {
+ case XPathResult.FIRST_ORDERED_NODE_TYPE:
+ case XPathResult.ORDERED_NODE_ITERATOR_TYPE:
+ case XPathResult.ORDERED_NODE_SNAPSHOT_TYPE:
+ case XPathResult.UNORDERED_NODE_ITERATOR_TYPE:
+ case XPathResult.UNORDERED_NODE_SNAPSHOT_TYPE:
+ return ((Collection) value).size ();
+ }
+ throw new XPathException (XPathException.TYPE_ERR, value.toString ());
+ }
+
+ public String getStringValue()
+ {
+ if (type == XPathResult.STRING_TYPE)
+ {
+ return (String) value;
+ }
+ throw new XPathException (XPathException.TYPE_ERR, value.toString ());
+ }
+
+ public Node iterateNext()
+ {
+ if (iterator != null)
+ {
+ if (iterator.hasNext ())
+ {
+ return (Node) iterator.next ();
+ }
+ else
+ {
+ iterator = null;
+ return null;
+ }
+ }
+ throw new XPathException (XPathException.TYPE_ERR, value.toString ());
+ }
+
+ public Node snapshotItem(int index)
+ {
+ switch (type)
+ {
+ case XPathResult.FIRST_ORDERED_NODE_TYPE:
+ case XPathResult.ORDERED_NODE_ITERATOR_TYPE:
+ case XPathResult.ORDERED_NODE_SNAPSHOT_TYPE:
+ case XPathResult.UNORDERED_NODE_ITERATOR_TYPE:
+ case XPathResult.UNORDERED_NODE_SNAPSHOT_TYPE:
+ Collection ns = (Collection) value;
+ Node[] nodes = new Node[ns.size ()];
+ ns.toArray (nodes);
+ return nodes[index];
+ }
+ throw new XPathException (XPathException.TYPE_ERR, value.toString ());
+ }
+
+ public String toString ()
+ {
+ return getClass ().getName () + "[type=" + typeName (type) + ",value=" +
+ value + ']';
+ }
+
+ private String typeName (short type)
+ {
+ switch (type)
+ {
+ case XPathResult.BOOLEAN_TYPE:
+ return "BOOLEAN_TYPE";
+ case XPathResult.NUMBER_TYPE:
+ return "NUMBER_TYPE";
+ case XPathResult.STRING_TYPE:
+ return "STRING_TYPE";
+ case XPathResult.FIRST_ORDERED_NODE_TYPE:
+ return "FIRST_ORDERED_NODE_TYPE";
+ case XPathResult.ORDERED_NODE_ITERATOR_TYPE:
+ return "ORDERED_NODE_ITERATOR_TYPE";
+ case XPathResult.ORDERED_NODE_SNAPSHOT_TYPE:
+ return "ORDERED_NODE_SNAPSHOT_TYPE";
+ case XPathResult.UNORDERED_NODE_ITERATOR_TYPE:
+ return "UNORDERED_NODE_ITERATOR_TYPE";
+ case XPathResult.UNORDERED_NODE_SNAPSHOT_TYPE:
+ return "UNORDERED_NODE_SNAPSHOT_TYPE";
+ default:
+ return "(unknown)";
+ }
+ }
+
+}
Added: llvm-gcc-4.2/trunk/libjava/classpath/gnu/xml/dom/ImplementationList.java
URL: http://llvm.org/viewvc/llvm-project/llvm-gcc-4.2/trunk/libjava/classpath/gnu/xml/dom/ImplementationList.java?rev=43913&view=auto
==============================================================================
--- llvm-gcc-4.2/trunk/libjava/classpath/gnu/xml/dom/ImplementationList.java (added)
+++ llvm-gcc-4.2/trunk/libjava/classpath/gnu/xml/dom/ImplementationList.java Thu Nov 8 16:56:19 2007
@@ -0,0 +1,70 @@
+/* ImplementationList.java --
+ Copyright (C) 2004 Free Software Foundation, Inc..
+
+This file is part of GNU Classpath.
+
+GNU Classpath is free software; you can redistribute it and/or modify
+it under the terms of the GNU General Public License as published by
+the Free Software Foundation; either version 2, or (at your option)
+any later version.
+
+GNU Classpath is distributed in the hope that it will be useful, but
+WITHOUT ANY WARRANTY; without even the implied warranty of
+MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+General Public License for more details.
+
+You should have received a copy of the GNU General Public License
+along with GNU Classpath; see the file COPYING. If not, write to the
+Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA
+02110-1301 USA.
+
+Linking this library statically or dynamically with other modules is
+making a combined work based on this library. Thus, the terms and
+conditions of the GNU General Public License cover the whole
+combination.
+
+As a special exception, the copyright holders of this library give you
+permission to link this library with independent modules to produce an
+executable, regardless of the license terms of these independent
+modules, and to copy and distribute the resulting executable under
+terms of your choice, provided that you also meet, for each linked
+independent module, the terms and conditions of the license of that
+module. An independent module is a module which is not derived from
+or based on this library. If you modify this library, you may extend
+this exception to your version of the library, but you are not
+obligated to do so. If you do not wish to do so, delete this
+exception statement from your version. */
+package gnu.xml.dom;
+
+import java.util.List;
+
+import org.w3c.dom.DOMImplementation;
+import org.w3c.dom.DOMImplementationList;
+
+/**
+ * Implementation list for GNU JAXP.
+ *
+ * @author <a href='mailto:dog at gnu.org'>Chris Burdess</a>
+ */
+public class ImplementationList
+ implements DOMImplementationList
+{
+
+ private List list;
+
+ ImplementationList(List list)
+ {
+ this.list = list;
+ }
+
+ public int getLength()
+ {
+ return list.size();
+ }
+
+ public DOMImplementation item(int index)
+ {
+ return (DOMImplementation) list.get(index);
+ }
+
+}
Added: llvm-gcc-4.2/trunk/libjava/classpath/gnu/xml/dom/ImplementationSource.java
URL: http://llvm.org/viewvc/llvm-project/llvm-gcc-4.2/trunk/libjava/classpath/gnu/xml/dom/ImplementationSource.java?rev=43913&view=auto
==============================================================================
--- llvm-gcc-4.2/trunk/libjava/classpath/gnu/xml/dom/ImplementationSource.java (added)
+++ llvm-gcc-4.2/trunk/libjava/classpath/gnu/xml/dom/ImplementationSource.java Thu Nov 8 16:56:19 2007
@@ -0,0 +1,167 @@
+/* ImplementationSource.java --
+ Copyright (C) 2004 Free Software Foundation, Inc..
+
+This file is part of GNU Classpath.
+
+GNU Classpath is free software; you can redistribute it and/or modify
+it under the terms of the GNU General Public License as published by
+the Free Software Foundation; either version 2, or (at your option)
+any later version.
+
+GNU Classpath is distributed in the hope that it will be useful, but
+WITHOUT ANY WARRANTY; without even the implied warranty of
+MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+General Public License for more details.
+
+You should have received a copy of the GNU General Public License
+along with GNU Classpath; see the file COPYING. If not, write to the
+Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA
+02110-1301 USA.
+
+Linking this library statically or dynamically with other modules is
+making a combined work based on this library. Thus, the terms and
+conditions of the GNU General Public License cover the whole
+combination.
+
+As a special exception, the copyright holders of this library give you
+permission to link this library with independent modules to produce an
+executable, regardless of the license terms of these independent
+modules, and to copy and distribute the resulting executable under
+terms of your choice, provided that you also meet, for each linked
+independent module, the terms and conditions of the license of that
+module. An independent module is a module which is not derived from
+or based on this library. If you modify this library, you may extend
+this exception to your version of the library, but you are not
+obligated to do so. If you do not wish to do so, delete this
+exception statement from your version. */
+package gnu.xml.dom;
+
+import java.util.ArrayList;
+import java.util.Arrays;
+import java.util.Iterator;
+import java.util.List;
+
+import org.w3c.dom.DOMImplementation;
+import org.w3c.dom.DOMImplementationList;
+import org.w3c.dom.DOMImplementationSource;
+
+/**
+ * Implementation source for GNU JAXP.
+ *
+ * @author <a href='mailto:dog at gnu.org'>Chris Burdess</a>
+ */
+public class ImplementationSource
+ implements DOMImplementationSource
+{
+
+ private static final String DIGITS = "1234567890";
+
+ /*
+ * GNU DOM implementations.
+ */
+ private static final DOMImplementation[] implementations;
+
+ static
+ {
+ List acc = new ArrayList();
+ acc.add(new gnu.xml.dom.DomImpl());
+ try
+ {
+ Class t = Class.forName("gnu.xml.libxmlj.dom.GnomeDocumentBuilder");
+ acc.add(t.newInstance());
+ }
+ catch (Exception e)
+ {
+ // libxmlj not available
+ }
+ catch (UnsatisfiedLinkError e)
+ {
+ // libxmlj not available
+ }
+ implementations = new DOMImplementation[acc.size()];
+ acc.toArray(implementations);
+ }
+
+ public DOMImplementation getDOMImplementation(String features)
+ {
+ List available = getImplementations(features);
+ if (available.isEmpty())
+ {
+ return null;
+ }
+ return (DOMImplementation) available.get(0);
+ }
+
+ public DOMImplementationList getDOMImplementationList(String features)
+ {
+ List available = getImplementations(features);
+ return new ImplementationList(available);
+ }
+
+ /**
+ * Returns a list of the implementations that support the specified
+ * features.
+ */
+ private final List getImplementations(String features)
+ {
+ List available = new ArrayList(Arrays.asList(implementations));
+ for (Iterator i = parseFeatures(features).iterator(); i.hasNext(); )
+ {
+ String feature = (String) i.next();
+ String version = null;
+ int si = feature.indexOf(' ');
+ if (si != -1)
+ {
+ version = feature.substring(si + 1);
+ feature = feature.substring(0, si);
+ }
+ for (Iterator j = available.iterator(); j.hasNext(); )
+ {
+ DOMImplementation impl = (DOMImplementation) j.next();
+ if (!impl.hasFeature(feature, version))
+ {
+ j.remove();
+ }
+ }
+ }
+ return available;
+ }
+
+ /**
+ * Parses the feature list into feature tokens.
+ */
+ final List parseFeatures(String features)
+ {
+ List list = new ArrayList();
+ int pos = 0, start = 0;
+ int len = features.length();
+ for (; pos < len; pos++)
+ {
+ char c = features.charAt(pos);
+ if (c == ' ')
+ {
+ if (pos + 1 < len &&
+ DIGITS.indexOf(features.charAt(pos + 1)) == -1)
+ {
+ list.add(getFeature(features, start, pos));
+ start = pos + 1;
+ }
+ }
+ }
+ if (pos > start)
+ {
+ list.add(getFeature(features, start, len));
+ }
+ return list;
+ }
+
+ final String getFeature(String features, int start, int end)
+ {
+ if (features.length() > 0 && features.charAt(start) == '+')
+ {
+ return features.substring(start + 1, end);
+ }
+ return features.substring(start, end);
+ }
+
+}
Added: llvm-gcc-4.2/trunk/libjava/classpath/gnu/xml/dom/JAXPFactory.java
URL: http://llvm.org/viewvc/llvm-project/llvm-gcc-4.2/trunk/libjava/classpath/gnu/xml/dom/JAXPFactory.java?rev=43913&view=auto
==============================================================================
--- llvm-gcc-4.2/trunk/libjava/classpath/gnu/xml/dom/JAXPFactory.java (added)
+++ llvm-gcc-4.2/trunk/libjava/classpath/gnu/xml/dom/JAXPFactory.java Thu Nov 8 16:56:19 2007
@@ -0,0 +1,309 @@
+/* JAXPFactory.java --
+ Copyright (C) 2001 Free Software Foundation, Inc.
+
+This file is part of GNU Classpath.
+
+GNU Classpath is free software; you can redistribute it and/or modify
+it under the terms of the GNU General Public License as published by
+the Free Software Foundation; either version 2, or (at your option)
+any later version.
+
+GNU Classpath is distributed in the hope that it will be useful, but
+WITHOUT ANY WARRANTY; without even the implied warranty of
+MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+General Public License for more details.
+
+You should have received a copy of the GNU General Public License
+along with GNU Classpath; see the file COPYING. If not, write to the
+Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA
+02110-1301 USA.
+
+Linking this library statically or dynamically with other modules is
+making a combined work based on this library. Thus, the terms and
+conditions of the GNU General Public License cover the whole
+combination.
+
+As a special exception, the copyright holders of this library give you
+permission to link this library with independent modules to produce an
+executable, regardless of the license terms of these independent
+modules, and to copy and distribute the resulting executable under
+terms of your choice, provided that you also meet, for each linked
+independent module, the terms and conditions of the license of that
+module. An independent module is a module which is not derived from
+or based on this library. If you modify this library, you may extend
+this exception to your version of the library, but you are not
+obligated to do so. If you do not wish to do so, delete this
+exception statement from your version. */
+
+package gnu.xml.dom;
+
+import java.io.IOException;
+
+import org.w3c.dom.Document;
+import org.w3c.dom.DOMImplementation;
+
+import org.xml.sax.EntityResolver;
+import org.xml.sax.ErrorHandler;
+import org.xml.sax.InputSource;
+import org.xml.sax.XMLReader;
+import org.xml.sax.SAXException;
+import org.xml.sax.SAXParseException;
+
+import javax.xml.XMLConstants;
+import javax.xml.parsers.DocumentBuilder;
+import javax.xml.parsers.DocumentBuilderFactory;
+import javax.xml.parsers.ParserConfigurationException;
+import javax.xml.parsers.SAXParserFactory;
+
+
+/**
+ * DOM bootstrapping API, for use with JAXP.
+ *
+ * @see Consumer
+ *
+ * @author David Brownell
+ */
+public final class JAXPFactory
+ extends DocumentBuilderFactory
+{
+
+ private static final String PROPERTY = "http://xml.org/sax/properties/";
+ private static final String FEATURE = "http://xml.org/sax/features/";
+
+ private SAXParserFactory pf;
+ private boolean secureProcessing;
+
+ /**
+ * Default constructor.
+ */
+ public JAXPFactory()
+ {
+ }
+
+ /**
+ * Constructs a JAXP document builder which uses the default
+ * JAXP SAX2 parser and the DOM implementation in this package.
+ */
+ public DocumentBuilder newDocumentBuilder()
+ throws ParserConfigurationException
+ {
+ if (pf == null)
+ {
+ // Force use of AElfred2 since not all JAXP parsers
+ // conform very well to the SAX2 API spec ...
+ pf = new gnu.xml.aelfred2.JAXPFactory();
+ // pf = SAXParserFactory.newInstance ();
+ }
+
+ // JAXP default: false
+ pf.setValidating(isValidating());
+
+ // FIXME: this namespace setup may cause errors in some
+ // conformant SAX2 parsers, which we CAN patch up by
+ // splicing a "NSFilter" stage up front ...
+
+ // JAXP default: false
+ pf.setNamespaceAware(isNamespaceAware());
+
+ try
+ {
+ // undo rude "namespace-prefixes=false" default
+ pf.setFeature(FEATURE + "namespace-prefixes", true);
+
+ return new JAXPBuilder(pf.newSAXParser().getXMLReader(), this);
+ }
+ catch (SAXException e)
+ {
+ String msg = "can't create JAXP DocumentBuilder: " + e.getMessage();
+ throw new ParserConfigurationException(msg);
+ }
+ }
+
+ /** There seems to be no useful specification for attribute names */
+ public void setAttribute(String name, Object value)
+ throws IllegalArgumentException
+ {
+ if ("http://java.sun.com/xml/jaxp/properties/schemaLanguage".equals(name))
+ {
+ // TODO
+ }
+ else
+ {
+ throw new IllegalArgumentException(name);
+ }
+ }
+
+ /** There seems to be no useful specification for attribute names */
+ public Object getAttribute(String name)
+ throws IllegalArgumentException
+ {
+ throw new IllegalArgumentException(name);
+ }
+
+ public void setFeature(String name, boolean value)
+ throws ParserConfigurationException
+ {
+ if (name == null)
+ throw new NullPointerException();
+ if (XMLConstants.FEATURE_SECURE_PROCESSING.equals(name))
+ {
+ secureProcessing = true;
+ return;
+ }
+ throw new ParserConfigurationException(name);
+ }
+
+ public boolean getFeature(String name)
+ throws ParserConfigurationException
+ {
+ if (XMLConstants.FEATURE_SECURE_PROCESSING.equals(name))
+ return secureProcessing;
+ throw new ParserConfigurationException(name);
+ }
+
+ static final class JAXPBuilder
+ extends DocumentBuilder
+ implements ErrorHandler
+ {
+
+ private Consumer consumer;
+ private XMLReader producer;
+ private DomImpl impl;
+
+ JAXPBuilder(XMLReader parser, JAXPFactory factory)
+ throws ParserConfigurationException
+ {
+ impl = new DomImpl();
+
+ // set up consumer side
+ try
+ {
+ consumer = new Consumer();
+ }
+ catch (SAXException e)
+ {
+ throw new ParserConfigurationException(e.getMessage());
+ }
+
+ // JAXP defaults: true, noise nodes are good (bleech)
+ consumer.setHidingReferences(factory.isExpandEntityReferences());
+ consumer.setHidingComments(factory.isIgnoringComments());
+ consumer.setHidingWhitespace(factory.isIgnoringElementContentWhitespace());
+ consumer.setHidingCDATA(factory.isCoalescing());
+
+ // set up producer side
+ producer = parser;
+ producer.setContentHandler(consumer.getContentHandler());
+ producer.setDTDHandler(consumer.getDTDHandler());
+
+ try
+ {
+ String id;
+
+ // if validating, report validity errors, and default
+ // to treating them as fatal
+ if (factory.isValidating ())
+ {
+ producer.setFeature(FEATURE + "validation", true);
+ producer.setErrorHandler(this);
+ }
+
+ // always save prefix info, maybe do namespace processing
+ producer.setFeature(FEATURE + "namespace-prefixes", true);
+ producer.setFeature(FEATURE + "namespaces",
+ factory.isNamespaceAware());
+
+ // set important handlers
+ id = PROPERTY + "lexical-handler";
+ producer.setProperty(id, consumer.getProperty(id));
+
+ id = PROPERTY + "declaration-handler";
+ producer.setProperty(id, consumer.getProperty(id));
+
+ }
+ catch (SAXException e)
+ {
+ throw new ParserConfigurationException(e.getMessage());
+ }
+ }
+
+ public Document parse(InputSource source)
+ throws SAXException, IOException
+ {
+ producer.parse(source);
+ Document doc = consumer.getDocument();
+ // TODO inputEncoding
+ doc.setDocumentURI(source.getSystemId());
+ return doc;
+ }
+
+ public boolean isNamespaceAware()
+ {
+ try
+ {
+ return producer.getFeature(FEATURE + "namespaces");
+ }
+ catch (SAXException e)
+ {
+ // "can't happen"
+ throw new RuntimeException(e.getMessage());
+ }
+ }
+
+ public boolean isValidating()
+ {
+ try
+ {
+ return producer.getFeature(FEATURE + "validation");
+ }
+ catch (SAXException e)
+ {
+ // "can't happen"
+ throw new RuntimeException(e.getMessage());
+ }
+ }
+
+ public void setEntityResolver(EntityResolver resolver)
+ {
+ producer.setEntityResolver(resolver);
+ }
+
+ public void setErrorHandler(ErrorHandler handler)
+ {
+ producer.setErrorHandler(handler);
+ consumer.setErrorHandler(handler);
+ }
+
+ public DOMImplementation getDOMImplementation()
+ {
+ return impl;
+ }
+
+ public Document newDocument()
+ {
+ return new DomDocument();
+ }
+
+ // implementation of error handler that's used when validating
+ public void fatalError(SAXParseException e)
+ throws SAXException
+ {
+ throw e;
+ }
+
+ public void error(SAXParseException e)
+ throws SAXException
+ {
+ throw e;
+ }
+
+ public void warning(SAXParseException e)
+ throws SAXException
+ {
+ /* ignore */
+ }
+
+ }
+
+}
+
Added: llvm-gcc-4.2/trunk/libjava/classpath/gnu/xml/dom/html2/DomHTMLAnchorElement.java
URL: http://llvm.org/viewvc/llvm-project/llvm-gcc-4.2/trunk/libjava/classpath/gnu/xml/dom/html2/DomHTMLAnchorElement.java?rev=43913&view=auto
==============================================================================
--- llvm-gcc-4.2/trunk/libjava/classpath/gnu/xml/dom/html2/DomHTMLAnchorElement.java (added)
+++ llvm-gcc-4.2/trunk/libjava/classpath/gnu/xml/dom/html2/DomHTMLAnchorElement.java Thu Nov 8 16:56:19 2007
@@ -0,0 +1,189 @@
+/* DomHTMLAnchorElement.java --
+ Copyright (C) 2005 Free Software Foundation, Inc.
+
+This file is part of GNU Classpath.
+
+GNU Classpath is free software; you can redistribute it and/or modify
+it under the terms of the GNU General Public License as published by
+the Free Software Foundation; either version 2, or (at your option)
+any later version.
+
+GNU Classpath is distributed in the hope that it will be useful, but
+WITHOUT ANY WARRANTY; without even the implied warranty of
+MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+General Public License for more details.
+
+You should have received a copy of the GNU General Public License
+along with GNU Classpath; see the file COPYING. If not, write to the
+Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA
+02110-1301 USA.
+
+Linking this library statically or dynamically with other modules is
+making a combined work based on this library. Thus, the terms and
+conditions of the GNU General Public License cover the whole
+combination.
+
+As a special exception, the copyright holders of this library give you
+permission to link this library with independent modules to produce an
+executable, regardless of the license terms of these independent
+modules, and to copy and distribute the resulting executable under
+terms of your choice, provided that you also meet, for each linked
+independent module, the terms and conditions of the license of that
+module. An independent module is a module which is not derived from
+or based on this library. If you modify this library, you may extend
+this exception to your version of the library, but you are not
+obligated to do so. If you do not wish to do so, delete this
+exception statement from your version. */
+
+package gnu.xml.dom.html2;
+
+import org.w3c.dom.html2.HTMLAnchorElement;
+
+/**
+ * An HTML 'A' element node.
+ *
+ * @author <a href='mailto:dog at gnu.org'>Chris Burdess</a>
+ */
+public class DomHTMLAnchorElement
+ extends DomHTMLElement
+ implements HTMLAnchorElement
+{
+
+ protected DomHTMLAnchorElement(DomHTMLDocument owner, String namespaceURI,
+ String name)
+ {
+ super(owner, namespaceURI, name);
+ }
+
+ public String getAccessKey()
+ {
+ return getHTMLAttribute("accesskey");
+ }
+
+ public void setAccessKey(String accessKey)
+ {
+ setHTMLAttribute("accesskey", accessKey);
+ }
+
+ public String getCharset()
+ {
+ return getHTMLAttribute("charset");
+ }
+
+ public void setCharset(String charset)
+ {
+ setHTMLAttribute("charset", charset);
+ }
+
+ public String getCoords()
+ {
+ return getHTMLAttribute("coords");
+ }
+
+ public void setCoords(String coords)
+ {
+ setHTMLAttribute("coords", coords);
+ }
+
+ public String getHref()
+ {
+ return getHTMLAttribute("href");
+ }
+
+ public void setHref(String href)
+ {
+ setHTMLAttribute("href", href);
+ }
+
+ public String getHreflang()
+ {
+ return getHTMLAttribute("hreflang");
+ }
+
+ public void setHreflang(String hreflang)
+ {
+ setHTMLAttribute("hreflang", hreflang);
+ }
+
+ public String getName()
+ {
+ return getHTMLAttribute("name");
+ }
+
+ public void setName(String name)
+ {
+ setHTMLAttribute("name", name);
+ }
+
+ public String getRel()
+ {
+ return getHTMLAttribute("rel");
+ }
+
+ public void setRel(String rel)
+ {
+ setHTMLAttribute("rel", rel);
+ }
+
+ public String getRev()
+ {
+ return getHTMLAttribute("rev");
+ }
+
+ public void setRev(String rev)
+ {
+ setHTMLAttribute("rev", rev);
+ }
+
+ public String getShape()
+ {
+ return getHTMLAttribute("shape");
+ }
+
+ public void setShape(String shape)
+ {
+ setHTMLAttribute("shape", shape);
+ }
+
+ public int getTabIndex()
+ {
+ return getIntHTMLAttribute("tabindex");
+ }
+
+ public void setTabIndex(int tabIndex)
+ {
+ setIntHTMLAttribute("tabindex", tabIndex);
+ }
+
+ public String getTarget()
+ {
+ return getHTMLAttribute("target");
+ }
+
+ public void setTarget(String target)
+ {
+ setHTMLAttribute("target", target);
+ }
+
+ public String getType()
+ {
+ return getHTMLAttribute("type");
+ }
+
+ public void setType(String type)
+ {
+ setHTMLAttribute("type", type);
+ }
+
+ public void blur()
+ {
+ dispatchUIEvent("blur");
+ }
+
+ public void focus()
+ {
+ dispatchUIEvent("focus");
+ }
+
+}
+
Added: llvm-gcc-4.2/trunk/libjava/classpath/gnu/xml/dom/html2/DomHTMLAppletElement.java
URL: http://llvm.org/viewvc/llvm-project/llvm-gcc-4.2/trunk/libjava/classpath/gnu/xml/dom/html2/DomHTMLAppletElement.java?rev=43913&view=auto
==============================================================================
--- llvm-gcc-4.2/trunk/libjava/classpath/gnu/xml/dom/html2/DomHTMLAppletElement.java (added)
+++ llvm-gcc-4.2/trunk/libjava/classpath/gnu/xml/dom/html2/DomHTMLAppletElement.java Thu Nov 8 16:56:19 2007
@@ -0,0 +1,188 @@
+/* DomHTMLAppletElement.java --
+ Copyright (C) 2005 Free Software Foundation, Inc.
+
+This file is part of GNU Classpath.
+
+GNU Classpath is free software; you can redistribute it and/or modify
+it under the terms of the GNU General Public License as published by
+the Free Software Foundation; either version 2, or (at your option)
+any later version.
+
+GNU Classpath is distributed in the hope that it will be useful, but
+WITHOUT ANY WARRANTY; without even the implied warranty of
+MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+General Public License for more details.
+
+You should have received a copy of the GNU General Public License
+along with GNU Classpath; see the file COPYING. If not, write to the
+Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA
+02110-1301 USA.
+
+Linking this library statically or dynamically with other modules is
+making a combined work based on this library. Thus, the terms and
+conditions of the GNU General Public License cover the whole
+combination.
+
+As a special exception, the copyright holders of this library give you
+permission to link this library with independent modules to produce an
+executable, regardless of the license terms of these independent
+modules, and to copy and distribute the resulting executable under
+terms of your choice, provided that you also meet, for each linked
+independent module, the terms and conditions of the license of that
+module. An independent module is a module which is not derived from
+or based on this library. If you modify this library, you may extend
+this exception to your version of the library, but you are not
+obligated to do so. If you do not wish to do so, delete this
+exception statement from your version. */
+
+package gnu.xml.dom.html2;
+
+import org.w3c.dom.html2.HTMLAppletElement;
+
+/**
+ * An HTML 'APPLET' element node.
+ *
+ * @author <a href='mailto:dog at gnu.org'>Chris Burdess</a>
+ */
+public class DomHTMLAppletElement
+ extends DomHTMLElement
+ implements HTMLAppletElement
+{
+
+ protected DomHTMLAppletElement(DomHTMLDocument owner, String namespaceURI,
+ String name)
+ {
+ super(owner, namespaceURI, name);
+ }
+
+ public String getAlign()
+ {
+ return getHTMLAttribute("align");
+ }
+
+ public void setAlign(String align)
+ {
+ setHTMLAttribute("align", align);
+ }
+
+ public String getCls()
+ {
+ return getHTMLAttribute("class");
+ }
+
+ public void setCls(String cls)
+ {
+ setHTMLAttribute("class", cls);
+ }
+
+ public String getSrc()
+ {
+ return getHTMLAttribute("src");
+ }
+
+ public void setSrc(String src)
+ {
+ setHTMLAttribute("src", src);
+ }
+
+ public String getAlt()
+ {
+ return getHTMLAttribute("alt");
+ }
+
+ public void setAlt(String alt)
+ {
+ setHTMLAttribute("alt", alt);
+ }
+
+ public String getArchive()
+ {
+ return getHTMLAttribute("archive");
+ }
+
+ public void setArchive(String archive)
+ {
+ setHTMLAttribute("archive", archive);
+ }
+
+ public String getCode()
+ {
+ return getHTMLAttribute("code");
+ }
+
+ public void setCode(String code)
+ {
+ setHTMLAttribute("code", code);
+ }
+
+ public String getCodeBase()
+ {
+ return getHTMLAttribute("codebase");
+ }
+
+ public void setCodeBase(String codeBase)
+ {
+ setHTMLAttribute("codebase", codeBase);
+ }
+
+ public String getHeight()
+ {
+ return getHTMLAttribute("height");
+ }
+
+ public void setHeight(String height)
+ {
+ setHTMLAttribute("height", height);
+ }
+
+ public int getHspace()
+ {
+ return getIntHTMLAttribute("hspace");
+ }
+
+ public void setHspace(int hspace)
+ {
+ setIntHTMLAttribute("hspace", hspace);
+ }
+
+ public String getName()
+ {
+ return getHTMLAttribute("name");
+ }
+
+ public void setName(String name)
+ {
+ setHTMLAttribute("name", name);
+ }
+
+ public String getObject()
+ {
+ return getHTMLAttribute("object");
+ }
+
+ public void setObject(String object)
+ {
+ setHTMLAttribute("object", object);
+ }
+
+ public int getVspace()
+ {
+ return getIntHTMLAttribute("vspace");
+ }
+
+ public void setVspace(int vspace)
+ {
+ setIntHTMLAttribute("vspace", vspace);
+ }
+
+ public String getWidth()
+ {
+ return getHTMLAttribute("width");
+ }
+
+ public void setWidth(String width)
+ {
+ setHTMLAttribute("width", width);
+ }
+}
+
More information about the llvm-commits
mailing list