diff options
author | nitind | 2004-11-23 19:23:00 +0000 |
---|---|---|
committer | nitind | 2004-11-23 19:23:00 +0000 |
commit | 958d79a852fed44e64fc5297402dd49f5f81d24c (patch) | |
tree | e548c626c38f28f0e538b875f82058cfefd6dcd8 /bundles/org.eclipse.wst.html.core/src/org/eclipse/wst/html | |
parent | b0f7b2695ef3646cc3f23f6712d409ff46b2aa7a (diff) | |
download | webtools.sourceediting-958d79a852fed44e64fc5297402dd49f5f81d24c.tar.gz webtools.sourceediting-958d79a852fed44e64fc5297402dd49f5f81d24c.tar.xz webtools.sourceediting-958d79a852fed44e64fc5297402dd49f5f81d24c.zip |
initial check-in
Diffstat (limited to 'bundles/org.eclipse.wst.html.core/src/org/eclipse/wst/html')
314 files changed, 37190 insertions, 0 deletions
diff --git a/bundles/org.eclipse.wst.html.core/src/org/eclipse/wst/html/core/HTML40Namespace.java b/bundles/org.eclipse.wst.html.core/src/org/eclipse/wst/html/core/HTML40Namespace.java new file mode 100644 index 0000000000..9f5485be22 --- /dev/null +++ b/bundles/org.eclipse.wst.html.core/src/org/eclipse/wst/html/core/HTML40Namespace.java @@ -0,0 +1,675 @@ +/******************************************************************************* + * Copyright (c) 2004 IBM Corporation and others. + * All rights reserved. This program and the accompanying materials + * are made available under the terms of the Eclipse Public License v1.0 + * which accompanies this distribution, and is available at + * http://www.eclipse.org/legal/epl-v10.html + * + * Contributors: + * IBM Corporation - initial API and implementation + *******************************************************************************/ +package org.eclipse.wst.html.core; + +/** + * Provide all names defined in the HTML 4.0? specification. + */ +public interface HTML40Namespace { + + // Element names + public static interface ElementName { + public static final String A = "A"; //$NON-NLS-1$ + public static final String ABBR = "ABBR"; //$NON-NLS-1$ + public static final String ACRONYM = "ACRONYM"; //$NON-NLS-1$ + public static final String ADDRESS = "ADDRESS"; //$NON-NLS-1$ + public static final String APPLET = "APPLET"; //$NON-NLS-1$ + public static final String AREA = "AREA"; //$NON-NLS-1$ + public static final String B = "B"; //$NON-NLS-1$ + public static final String BASE = "BASE"; //$NON-NLS-1$ + public static final String BASEFONT = "BASEFONT"; //$NON-NLS-1$ + public static final String BDO = "BDO"; //$NON-NLS-1$ + public static final String BGSOUND = "BGSOUND"; // D205513 //$NON-NLS-1$ + public static final String BIG = "BIG"; //$NON-NLS-1$ + public static final String BLINK = "BLINK"; //$NON-NLS-1$ + public static final String BLOCKQUOTE = "BLOCKQUOTE"; //$NON-NLS-1$ + public static final String BODY = "BODY"; //$NON-NLS-1$ + public static final String BR = "BR"; //$NON-NLS-1$ + public static final String BUTTON = "BUTTON"; //$NON-NLS-1$ + public static final String CAPTION = "CAPTION"; //$NON-NLS-1$ + public static final String CENTER = "CENTER"; //$NON-NLS-1$ + public static final String CITE = "CITE"; //$NON-NLS-1$ + public static final String CODE = "CODE"; //$NON-NLS-1$ + public static final String COL = "COL"; //$NON-NLS-1$ + public static final String COLGROUP = "COLGROUP"; //$NON-NLS-1$ + public static final String DD = "DD"; //$NON-NLS-1$ + public static final String DEL = "DEL"; //$NON-NLS-1$ + public static final String DFN = "DFN"; //$NON-NLS-1$ + public static final String DIR = "DIR"; //$NON-NLS-1$ + public static final String DIV = "DIV"; //$NON-NLS-1$ + public static final String DL = "DL"; //$NON-NLS-1$ + public static final String DT = "DT"; //$NON-NLS-1$ + public static final String EM = "EM"; //$NON-NLS-1$ + public static final String EMBED = "EMBED"; //$NON-NLS-1$ + public static final String FIELDSET = "FIELDSET"; //$NON-NLS-1$ + public static final String FONT = "FONT"; //$NON-NLS-1$ + public static final String FORM = "FORM"; //$NON-NLS-1$ + public static final String FRAME = "FRAME"; //$NON-NLS-1$ + public static final String FRAMESET = "FRAMESET"; //$NON-NLS-1$ + public static final String H1 = "H1"; //$NON-NLS-1$ + public static final String H2 = "H2"; //$NON-NLS-1$ + public static final String H3 = "H3"; //$NON-NLS-1$ + public static final String H4 = "H4"; //$NON-NLS-1$ + public static final String H5 = "H5"; //$NON-NLS-1$ + public static final String H6 = "H6"; //$NON-NLS-1$ + public static final String HEAD = "HEAD"; //$NON-NLS-1$ + public static final String HR = "HR"; //$NON-NLS-1$ + public static final String HTML = "HTML"; //$NON-NLS-1$ + public static final String I = "I"; //$NON-NLS-1$ + public static final String IFRAME = "IFRAME"; //$NON-NLS-1$ + public static final String IMG = "IMG"; //$NON-NLS-1$ + public static final String INPUT = "INPUT"; //$NON-NLS-1$ + public static final String INS = "INS"; //$NON-NLS-1$ + public static final String ISINDEX = "ISINDEX"; //$NON-NLS-1$ + public static final String KBD = "KBD"; //$NON-NLS-1$ + public static final String LABEL = "LABEL"; //$NON-NLS-1$ + public static final String LEGEND = "LEGEND"; //$NON-NLS-1$ + public static final String LI = "LI"; //$NON-NLS-1$ + public static final String LINK = "LINK"; //$NON-NLS-1$ + public static final String MAP = "MAP"; //$NON-NLS-1$ + public static final String MENU = "MENU"; //$NON-NLS-1$ + public static final String META = "META"; //$NON-NLS-1$ + public static final String NOBR = "NOBR"; // D205513 //$NON-NLS-1$ + public static final String NOEMBED = "NOEMBED"; //$NON-NLS-1$ + public static final String NOFRAMES = "NOFRAMES"; //$NON-NLS-1$ + public static final String NOSCRIPT = "NOSCRIPT"; //$NON-NLS-1$ + public static final String OBJECT = "OBJECT"; //$NON-NLS-1$ + public static final String OL = "OL"; //$NON-NLS-1$ + public static final String OPTGROUP = "OPTGROUP"; //$NON-NLS-1$ + public static final String OPTION = "OPTION"; //$NON-NLS-1$ + public static final String P = "P"; //$NON-NLS-1$ + public static final String PARAM = "PARAM"; //$NON-NLS-1$ + public static final String PRE = "PRE"; //$NON-NLS-1$ + public static final String Q = "Q"; //$NON-NLS-1$ + public static final String S = "S"; //$NON-NLS-1$ + public static final String SAMP = "SAMP"; //$NON-NLS-1$ + public static final String SCRIPT = "SCRIPT"; //$NON-NLS-1$ + public static final String SELECT = "SELECT"; //$NON-NLS-1$ + public static final String SMALL = "SMALL"; //$NON-NLS-1$ + public static final String SPAN = "SPAN"; //$NON-NLS-1$ + public static final String STRIKE = "STRIKE"; //$NON-NLS-1$ + public static final String STRONG = "STRONG"; //$NON-NLS-1$ + public static final String STYLE = "STYLE"; //$NON-NLS-1$ + public static final String SUB = "SUB"; //$NON-NLS-1$ + public static final String SUP = "SUP"; //$NON-NLS-1$ + public static final String TABLE = "TABLE"; //$NON-NLS-1$ + public static final String TBODY = "TBODY"; //$NON-NLS-1$ + public static final String TD = "TD"; //$NON-NLS-1$ + public static final String TEXTAREA = "TEXTAREA"; //$NON-NLS-1$ + public static final String TFOOT = "TFOOT"; //$NON-NLS-1$ + public static final String TH = "TH"; //$NON-NLS-1$ + public static final String THEAD = "THEAD"; //$NON-NLS-1$ + public static final String TITLE = "TITLE"; //$NON-NLS-1$ + public static final String TR = "TR"; //$NON-NLS-1$ + public static final String TT = "TT"; //$NON-NLS-1$ + public static final String U = "U"; //$NON-NLS-1$ + public static final String UL = "UL"; //$NON-NLS-1$ + public static final String VAR = "VAR"; //$NON-NLS-1$ + public static final String WBR = "WBR"; // D205513 //$NON-NLS-1$ + public static final String MARQUEE = "MARQUEE"; //$NON-NLS-1$ + public static final String SSI_CONFIG = "SSI:CONFIG"; // D210393 //$NON-NLS-1$ + public static final String SSI_ECHO = "SSI:ECHO"; //$NON-NLS-1$ + public static final String SSI_EXEC = "SSI:EXEC"; //$NON-NLS-1$ + public static final String SSI_FSIZE = "SSI:FSIZE"; //$NON-NLS-1$ + public static final String SSI_FLASTMOD = "SSI:FLASTMOD"; //$NON-NLS-1$ + public static final String SSI_INCLUDE = "SSI:INCLUDE"; //$NON-NLS-1$ + public static final String SSI_PRINTENV = "SSI:PRINTENV"; //$NON-NLS-1$ + public static final String SSI_SET = "SSI:SET"; //$NON-NLS-1$ + public static final String WML_WML = "wml"; //$NON-NLS-1$ + public static final String WML_CARD = "card"; //$NON-NLS-1$ + public static final String WML_TEMPLATE = "template"; //$NON-NLS-1$ + public static final String WML_ACCESS = "access"; //$NON-NLS-1$ + public static final String WML_DO = "do"; //$NON-NLS-1$ + public static final String WML_ONEVENT = "onevent"; //$NON-NLS-1$ + public static final String WML_TIMER = "timer"; //$NON-NLS-1$ + public static final String WML_ANCHOR = "anchor"; //$NON-NLS-1$ + public static final String WML_PREV = "prev"; //$NON-NLS-1$ + public static final String WML_REFRESH = "refresh"; //$NON-NLS-1$ + public static final String WML_GO = "go"; //$NON-NLS-1$ + public static final String WML_NOOP = "noop"; //$NON-NLS-1$ + public static final String WML_SETVAR = "setvar"; //$NON-NLS-1$ + public static final String WML_POSTFIELD = "postfield"; //$NON-NLS-1$ + } + + // Character Entities + public static interface EntityName { + public static final String AACUTE_U = "Aacute"; //$NON-NLS-1$ + public static final String AACUTE_L = "aacute"; //$NON-NLS-1$ + public static final String ACIRC_U = "Acirc"; //$NON-NLS-1$ + public static final String ACIRC_L = "acirc"; //$NON-NLS-1$ + public static final String ACUTE = "acute"; //$NON-NLS-1$ + public static final String AELIG_U = "AElig"; //$NON-NLS-1$ + public static final String AELIG_L = "aelig"; //$NON-NLS-1$ + public static final String AGRAVE_U = "Agrave"; //$NON-NLS-1$ + public static final String AGRAVE_L = "agrave"; //$NON-NLS-1$ + public static final String ALEFSYM = "alefsym"; //$NON-NLS-1$ + public static final String ALPHA_U = "Alpha"; //$NON-NLS-1$ + public static final String ALPHA_L = "alpha"; //$NON-NLS-1$ + public static final String AMP = "amp"; //$NON-NLS-1$ + public static final String AND = "and"; //$NON-NLS-1$ + public static final String ANG = "ang"; //$NON-NLS-1$ + public static final String ARING_U = "Aring"; //$NON-NLS-1$ + public static final String ARING_L = "aring"; //$NON-NLS-1$ + public static final String ASYMP = "asymp"; //$NON-NLS-1$ + public static final String ATILDE_U = "Atilde"; //$NON-NLS-1$ + public static final String ATILDE_L = "atilde"; //$NON-NLS-1$ + public static final String AUML_U = "Auml"; //$NON-NLS-1$ + public static final String AUML_L = "auml"; //$NON-NLS-1$ + public static final String BDQUO = "bdquo"; //$NON-NLS-1$ + public static final String BETA_U = "Beta"; //$NON-NLS-1$ + public static final String BETA_L = "beta"; //$NON-NLS-1$ + public static final String BRVBAR = "brvbar"; //$NON-NLS-1$ + public static final String BULL = "bull"; //$NON-NLS-1$ + public static final String CAP = "cap"; //$NON-NLS-1$ + public static final String CCEDIL_U = "Ccedil"; //$NON-NLS-1$ + public static final String CCEDIL_L = "ccedil"; //$NON-NLS-1$ + public static final String CEDIL = "cedil"; //$NON-NLS-1$ + public static final String CENT = "cent"; //$NON-NLS-1$ + public static final String CHI_U = "Chi"; //$NON-NLS-1$ + public static final String CHI_L = "chi"; //$NON-NLS-1$ + public static final String CIRC = "circ"; //$NON-NLS-1$ + public static final String CLUBS = "clubs"; //$NON-NLS-1$ + public static final String CONG = "cong"; //$NON-NLS-1$ + public static final String COPY = "copy"; //$NON-NLS-1$ + public static final String CRARR = "crarr"; //$NON-NLS-1$ + public static final String CUP = "cup"; //$NON-NLS-1$ + public static final String CURREN = "curren"; //$NON-NLS-1$ + public static final String DAGGER_U = "Dagger"; //$NON-NLS-1$ + public static final String DAGGER_L = "dagger"; //$NON-NLS-1$ + public static final String DARR_U = "dArr"; //$NON-NLS-1$ + public static final String DARR_L = "darr"; //$NON-NLS-1$ + public static final String DEG = "deg"; //$NON-NLS-1$ + public static final String DELTA_U = "Delta"; //$NON-NLS-1$ + public static final String DELTA_L = "delta"; //$NON-NLS-1$ + public static final String DIAMS = "diams"; //$NON-NLS-1$ + public static final String DIVIDE = "divide"; //$NON-NLS-1$ + public static final String EACUTE_U = "Eacute"; //$NON-NLS-1$ + public static final String EACUTE_L = "eacute"; //$NON-NLS-1$ + public static final String ECIRC_U = "Ecirc"; //$NON-NLS-1$ + public static final String ECIRC_L = "ecirc"; //$NON-NLS-1$ + public static final String EGRAVE_U = "Egrave"; //$NON-NLS-1$ + public static final String EGRAVE_L = "egrave"; //$NON-NLS-1$ + public static final String EMPTY = "empty"; //$NON-NLS-1$ + public static final String EMSP = "emsp"; //$NON-NLS-1$ + public static final String ENSP = "ensp"; //$NON-NLS-1$ + public static final String EPSILON_U = "Epsilon"; //$NON-NLS-1$ + public static final String EPSILON_L = "epsilon"; //$NON-NLS-1$ + public static final String EQUIV = "equiv"; //$NON-NLS-1$ + public static final String ETA_U = "Eta"; //$NON-NLS-1$ + public static final String ETA_L = "eta"; //$NON-NLS-1$ + public static final String ETH_U = "ETH"; //$NON-NLS-1$ + public static final String ETH_L = "eth"; //$NON-NLS-1$ + public static final String EUML_U = "Euml"; //$NON-NLS-1$ + public static final String EUML_L = "euml"; //$NON-NLS-1$ + public static final String EURO = "euro"; //$NON-NLS-1$ + public static final String EXIST = "exist"; //$NON-NLS-1$ + public static final String FNOF = "fnof"; //$NON-NLS-1$ + public static final String FORALL = "forall"; //$NON-NLS-1$ + public static final String FRAC12 = "frac12"; //$NON-NLS-1$ + public static final String FRAC14 = "frac14"; //$NON-NLS-1$ + public static final String FRAC34 = "frac34"; //$NON-NLS-1$ + public static final String FRASL = "frasl"; //$NON-NLS-1$ + public static final String GAMMA_U = "Gamma"; //$NON-NLS-1$ + public static final String GAMMA_L = "gamma"; //$NON-NLS-1$ + public static final String GE = "ge"; //$NON-NLS-1$ + public static final String GT = "gt"; //$NON-NLS-1$ + public static final String HARR_U = "hArr"; //$NON-NLS-1$ + public static final String HARR_L = "harr"; //$NON-NLS-1$ + public static final String HEARTS = "hearts"; //$NON-NLS-1$ + public static final String HELLIP = "hellip"; //$NON-NLS-1$ + public static final String IACUTE_U = "Iacute"; //$NON-NLS-1$ + public static final String IACUTE_L = "iacute"; //$NON-NLS-1$ + public static final String ICIRC_U = "Icirc"; //$NON-NLS-1$ + public static final String ICIRC_L = "icirc"; //$NON-NLS-1$ + public static final String IEXCL = "iexcl"; //$NON-NLS-1$ + public static final String IGRAVE_U = "Igrave"; //$NON-NLS-1$ + public static final String IGRAVE_L = "igrave"; //$NON-NLS-1$ + public static final String IMAGE = "image"; //$NON-NLS-1$ + public static final String INFIN = "infin"; //$NON-NLS-1$ + public static final String INT = "int"; //$NON-NLS-1$ + public static final String IOTA_U = "Iota"; //$NON-NLS-1$ + public static final String IOTA_L = "iota"; //$NON-NLS-1$ + public static final String IQUEST = "iquest"; //$NON-NLS-1$ + public static final String ISIN = "isin"; //$NON-NLS-1$ + public static final String IUML_U = "Iuml"; //$NON-NLS-1$ + public static final String IUML_L = "iuml"; //$NON-NLS-1$ + public static final String KAPPA_U = "Kappa"; //$NON-NLS-1$ + public static final String KAPPA_L = "kappa"; //$NON-NLS-1$ + public static final String LAMBDA_U = "Lambda"; //$NON-NLS-1$ + public static final String LAMBDA_L = "lambda"; //$NON-NLS-1$ + public static final String LANG = "lang"; //$NON-NLS-1$ + public static final String LAQUO = "laquo"; //$NON-NLS-1$ + public static final String LARR_U = "lArr"; //$NON-NLS-1$ + public static final String LARR_L = "larr"; //$NON-NLS-1$ + public static final String LCEIL = "lceil"; //$NON-NLS-1$ + public static final String LDQUO = "ldquo"; //$NON-NLS-1$ + public static final String LE = "le"; //$NON-NLS-1$ + public static final String LFLOOR = "lfloor"; //$NON-NLS-1$ + public static final String LOWAST = "lowast"; //$NON-NLS-1$ + public static final String LOZ = "loz"; //$NON-NLS-1$ + public static final String LRM = "lrm"; //$NON-NLS-1$ + public static final String LSAQUO = "lsaquo"; //$NON-NLS-1$ + public static final String LSQUO = "lsquo"; //$NON-NLS-1$ + public static final String LT = "lt"; //$NON-NLS-1$ + public static final String MACR = "macr"; //$NON-NLS-1$ + public static final String MDASH = "mdash"; //$NON-NLS-1$ + public static final String MICRO = "micro"; //$NON-NLS-1$ + public static final String MIDDOT = "middot"; //$NON-NLS-1$ + public static final String MINUS = "minus"; //$NON-NLS-1$ + public static final String MU_U = "Mu"; //$NON-NLS-1$ + public static final String MU_L = "mu"; //$NON-NLS-1$ + public static final String NABLA = "nabla"; //$NON-NLS-1$ + public static final String NBSP = "nbsp"; //$NON-NLS-1$ + public static final String NDASH = "ndash"; //$NON-NLS-1$ + public static final String NE = "ne"; //$NON-NLS-1$ + public static final String NI = "ni"; //$NON-NLS-1$ + public static final String NOT = "not"; //$NON-NLS-1$ + public static final String NOTIN = "notin"; //$NON-NLS-1$ + public static final String NSUB = "nsub"; //$NON-NLS-1$ + public static final String NTILDE_U = "Ntilde"; //$NON-NLS-1$ + public static final String NTILDE_L = "ntilde"; //$NON-NLS-1$ + public static final String NU_U = "Nu"; //$NON-NLS-1$ + public static final String NU_L = "nu"; //$NON-NLS-1$ + public static final String OACUTE_U = "Oacute"; //$NON-NLS-1$ + public static final String OACUTE_L = "oacute"; //$NON-NLS-1$ + public static final String OCIRC_U = "Ocirc"; //$NON-NLS-1$ + public static final String OCIRC_L = "ocirc"; //$NON-NLS-1$ + public static final String OELIG_U = "OElig"; //$NON-NLS-1$ + public static final String OELIG_L = "oelig"; //$NON-NLS-1$ + public static final String OGRAVE_U = "Ograve"; //$NON-NLS-1$ + public static final String OGRAVE_L = "ograve"; //$NON-NLS-1$ + public static final String OLINE = "oline"; //$NON-NLS-1$ + public static final String OMEGA_U = "Omega"; //$NON-NLS-1$ + public static final String OMEGA_L = "omega"; //$NON-NLS-1$ + public static final String OMICRON_U = "Omicron"; //$NON-NLS-1$ + public static final String OMICRON_L = "omicron"; //$NON-NLS-1$ + public static final String OPLUS = "oplus"; //$NON-NLS-1$ + public static final String OR = "or"; //$NON-NLS-1$ + public static final String ORDF = "ordf"; //$NON-NLS-1$ + public static final String ORDM = "ordm"; //$NON-NLS-1$ + public static final String OSLASH_U = "Oslash"; //$NON-NLS-1$ + public static final String OSLASH_L = "oslash"; //$NON-NLS-1$ + public static final String OTILDE_U = "Otilde"; //$NON-NLS-1$ + public static final String OTILDE_L = "otilde"; //$NON-NLS-1$ + public static final String OTIMES = "otimes"; //$NON-NLS-1$ + public static final String OUML_U = "Ouml"; //$NON-NLS-1$ + public static final String OUML_L = "ouml"; //$NON-NLS-1$ + public static final String PARA = "para"; //$NON-NLS-1$ + public static final String PART = "part"; //$NON-NLS-1$ + public static final String PERMIL = "permil"; //$NON-NLS-1$ + public static final String PERP = "perp"; //$NON-NLS-1$ + public static final String PHI_U = "Phi"; //$NON-NLS-1$ + public static final String PHI_L = "phi"; //$NON-NLS-1$ + public static final String PI_U = "Pi"; //$NON-NLS-1$ + public static final String PI_L = "pi"; //$NON-NLS-1$ + public static final String PIV = "piv"; //$NON-NLS-1$ + public static final String PLUSMN = "plusmn"; //$NON-NLS-1$ + public static final String POUND = "pound"; //$NON-NLS-1$ + public static final String PRIME_U = "Prime"; //$NON-NLS-1$ + public static final String PRIME_L = "prime"; //$NON-NLS-1$ + public static final String PROD = "prod"; //$NON-NLS-1$ + public static final String PROP = "prop"; //$NON-NLS-1$ + public static final String PSI_U = "Psi"; //$NON-NLS-1$ + public static final String PSI_L = "psi"; //$NON-NLS-1$ + public static final String QUOT = "quot"; //$NON-NLS-1$ + public static final String RADIC = "radic"; //$NON-NLS-1$ + public static final String RANG = "rang"; //$NON-NLS-1$ + public static final String RAQUO = "raquo"; //$NON-NLS-1$ + public static final String RARR_U = "rArr"; //$NON-NLS-1$ + public static final String RARR_L = "rarr"; //$NON-NLS-1$ + public static final String RCEIL = "rceil"; //$NON-NLS-1$ + public static final String RDQUO = "rdquo"; //$NON-NLS-1$ + public static final String REAL = "real"; //$NON-NLS-1$ + public static final String REG = "reg"; //$NON-NLS-1$ + public static final String RFLOOR = "rfloor"; //$NON-NLS-1$ + public static final String RHO_U = "Rho"; //$NON-NLS-1$ + public static final String RHO_L = "rho"; //$NON-NLS-1$ + public static final String RLM = "rlm"; //$NON-NLS-1$ + public static final String RSAQUO = "rsaquo"; //$NON-NLS-1$ + public static final String RSQUO = "rsquo"; //$NON-NLS-1$ + public static final String SBQUO = "sbquo"; //$NON-NLS-1$ + public static final String SCARON_U = "Scaron"; //$NON-NLS-1$ + public static final String SCARON_L = "scaron"; //$NON-NLS-1$ + public static final String SDOT = "sdot"; //$NON-NLS-1$ + public static final String SECT = "sect"; //$NON-NLS-1$ + public static final String SHY = "shy"; //$NON-NLS-1$ + public static final String SIGMA_U = "Sigma"; //$NON-NLS-1$ + public static final String SIGMA_L = "sigma"; //$NON-NLS-1$ + public static final String SIGMAF = "sigmaf"; //$NON-NLS-1$ + public static final String SIM = "sim"; //$NON-NLS-1$ + public static final String SPADES = "spades"; //$NON-NLS-1$ + public static final String SUB = "sub"; //$NON-NLS-1$ + public static final String SUBE = "sube"; //$NON-NLS-1$ + public static final String SUM = "sum"; //$NON-NLS-1$ + public static final String SUP = "sup"; //$NON-NLS-1$ + public static final String SUP1 = "sup1"; //$NON-NLS-1$ + public static final String SUP2 = "sup2"; //$NON-NLS-1$ + public static final String SUP3 = "sup3"; //$NON-NLS-1$ + public static final String SUPE = "supe"; //$NON-NLS-1$ + public static final String SZLIG = "szlig"; //$NON-NLS-1$ + public static final String TAU_U = "Tau"; //$NON-NLS-1$ + public static final String TAU_L = "tau"; //$NON-NLS-1$ + public static final String THERE4 = "there4"; //$NON-NLS-1$ + public static final String THETA_U = "Theta"; //$NON-NLS-1$ + public static final String THETA_L = "theta"; //$NON-NLS-1$ + public static final String THETASYM = "thetasym"; //$NON-NLS-1$ + public static final String THINSP = "thinsp"; //$NON-NLS-1$ + public static final String THORN_U = "THORN"; //$NON-NLS-1$ + public static final String THORN_L = "thorn"; //$NON-NLS-1$ + public static final String TILDE = "tilde"; //$NON-NLS-1$ + public static final String TIMES = "times"; //$NON-NLS-1$ + public static final String TRADE = "trade"; //$NON-NLS-1$ + public static final String UACUTE_U = "Uacute"; //$NON-NLS-1$ + public static final String UACUTE_L = "uacute"; //$NON-NLS-1$ + public static final String UARR_U = "uArr"; //$NON-NLS-1$ + public static final String UARR_L = "uarr"; //$NON-NLS-1$ + public static final String UCIRC_U = "Ucirc"; //$NON-NLS-1$ + public static final String UCIRC_L = "ucirc"; //$NON-NLS-1$ + public static final String UGRAVE_U = "Ugrave"; //$NON-NLS-1$ + public static final String UGRAVE_L = "ugrave"; //$NON-NLS-1$ + public static final String UML = "uml"; //$NON-NLS-1$ + public static final String UPSIH = "upsih"; //$NON-NLS-1$ + public static final String UPSILON_U = "Upsilon"; //$NON-NLS-1$ + public static final String UPSILON_L = "upsilon"; //$NON-NLS-1$ + public static final String UUML_U = "Uuml"; //$NON-NLS-1$ + public static final String UUML_L = "uuml"; //$NON-NLS-1$ + public static final String WEIERP = "weierp"; //$NON-NLS-1$ + public static final String XI_U = "Xi"; //$NON-NLS-1$ + public static final String XI_L = "xi"; //$NON-NLS-1$ + public static final String YACUTE_U = "Yacute"; //$NON-NLS-1$ + public static final String YACUTE_L = "yacute"; //$NON-NLS-1$ + public static final String YEN = "yen"; //$NON-NLS-1$ + public static final String YUML_U = "Yuml"; //$NON-NLS-1$ + public static final String YUML_L = "yuml"; //$NON-NLS-1$ + public static final String ZETA_U = "Zeta"; //$NON-NLS-1$ + public static final String ZETA_L = "zeta"; //$NON-NLS-1$ + public static final String ZWJ = "zwj"; //$NON-NLS-1$ + public static final String ZWNJ = "zwnj"; //$NON-NLS-1$ + } + + public static final String HTML40_URI = "http://www.w3.org/TR/REC-html40/frameset.dtd"; //$NON-NLS-1$ + public static final String HTML40_TAG_PREFIX = ""; //$NON-NLS-1$ + // global attribute names + public static final String ATTR_NAME_ID = "id"; // %coreattrs; //$NON-NLS-1$ + public static final String ATTR_NAME_CLASS = "class"; // %coreattrs; //$NON-NLS-1$ + public static final String ATTR_NAME_STYLE = "style"; // %coreattrs; //$NON-NLS-1$ + public static final String ATTR_NAME_TITLE = "title"; // %coreattrs; //$NON-NLS-1$ + public static final String ATTR_NAME_LANG = "lang"; // %i18n; //$NON-NLS-1$ + public static final String ATTR_NAME_DIR = "dir"; // %i18n; //$NON-NLS-1$ + public static final String ATTR_NAME_ONCLICK = "onclick"; // %events; //$NON-NLS-1$ + public static final String ATTR_NAME_ONDBLCLICK = "ondblclick"; // %events; //$NON-NLS-1$ + public static final String ATTR_NAME_ONMOUSEDOWN = "onmousedown"; // %events; //$NON-NLS-1$ + public static final String ATTR_NAME_ONMOUSEUP = "onmouseup"; // %events; //$NON-NLS-1$ + public static final String ATTR_NAME_ONMOUSEOVER = "onmouseover"; // %events; //$NON-NLS-1$ + public static final String ATTR_NAME_ONMOUSEMOVE = "onmousemove"; // %events; //$NON-NLS-1$ + public static final String ATTR_NAME_ONMOUSEOUT = "onmouseout"; // %events; //$NON-NLS-1$ + public static final String ATTR_NAME_ONKEYPRESS = "onkeypress"; // %events; //$NON-NLS-1$ + public static final String ATTR_NAME_ONKEYDOWN = "onkeydown"; // %events; //$NON-NLS-1$ + public static final String ATTR_NAME_ONKEYUP = "onkeyup"; // %events; //$NON-NLS-1$ + public static final String ATTR_NAME_ONHELP = "onhelp"; // %events; //$NON-NLS-1$ + public static final String ATTR_NAME_BGCOLOR = "bgcolor"; // %bodycolor;, TABLE //$NON-NLS-1$ + public static final String ATTR_NAME_TEXT = "text"; // %bodycolor; //$NON-NLS-1$ + public static final String ATTR_NAME_LINK = "link"; // %bodycolor; //$NON-NLS-1$ + public static final String ATTR_NAME_VLINK = "vlink"; // %bodycolor; //$NON-NLS-1$ + public static final String ATTR_NAME_ALINK = "alink"; // %bodycolor; //$NON-NLS-1$ + public static final String ATTR_NAME_VERSION = "version"; // HTML //$NON-NLS-1$ + public static final String ATTR_NAME_PROFILE = "profile"; // HEAD //$NON-NLS-1$ + public static final String ATTR_NAME_ONLOAD = "onload"; // BODY //$NON-NLS-1$ + public static final String ATTR_NAME_ONUNLOAD = "onunload"; // BODY //$NON-NLS-1$ + public static final String ATTR_NAME_BACKGROUND = "background"; // BODY, TABLE //$NON-NLS-1$ + public static final String ATTR_NAME_SRC = "src"; // IMG //$NON-NLS-1$ + public static final String ATTR_NAME_ALT = "alt"; // IMG,AREA //$NON-NLS-1$ + public static final String ATTR_NAME_LONGDESC = "longdesc"; // IMG //$NON-NLS-1$ + public static final String ATTR_NAME_NAME = "name"; // IMG //$NON-NLS-1$ + public static final String ATTR_NAME_HEIGHT = "height"; // IMG, TABLE //$NON-NLS-1$ + public static final String ATTR_NAME_WIDTH = "width"; // IMG, TABLE,HR //$NON-NLS-1$ + public static final String ATTR_NAME_USEMAP = "usemap"; // IMG //$NON-NLS-1$ + public static final String ATTR_NAME_ISMAP = "ismap"; // IMG //$NON-NLS-1$ + public static final String ATTR_NAME_ALIGN = "align"; // IMG, TABLE,HR //$NON-NLS-1$ + public static final String ATTR_NAME_BORDER = "border"; // IMG, TABLE //$NON-NLS-1$ + public static final String ATTR_NAME_HSPACE = "hspace"; // IMG //$NON-NLS-1$ + public static final String ATTR_NAME_VSPACE = "vspace"; // IMG //$NON-NLS-1$ + public static final String ATTR_NAME_MAPFILE = "mapfile"; // IMG //$NON-NLS-1$ + public static final String ATTR_NAME_SUMMARY = "summary"; // TABLE //$NON-NLS-1$ + public static final String ATTR_NAME_FRAME = "frame"; // TABLE //$NON-NLS-1$ + public static final String ATTR_NAME_RULES = "rules"; // TABLE //$NON-NLS-1$ + public static final String ATTR_NAME_CELLSPACING = "cellspacing"; // TABLE //$NON-NLS-1$ + public static final String ATTR_NAME_CELLPADDING = "cellpadding"; // TABLE //$NON-NLS-1$ + public static final String ATTR_NAME_DATAPAGESIZE = "datapagesize"; // TABLE,HR //$NON-NLS-1$ + public static final String ATTR_NAME_COLOR = "color"; // BASEFONT,FONT //$NON-NLS-1$ + public static final String ATTR_NAME_FACE = "face"; // BASEFONT,FONT //$NON-NLS-1$ + public static final String ATTR_NAME_SIZE = "size"; // BASEFONT,FONT //$NON-NLS-1$ + public static final String ATTR_NAME_CLEAR = "clear"; // BR //$NON-NLS-1$ + public static final String ATTR_NAME_SHAPE = "shape"; // AREA //$NON-NLS-1$ + public static final String ATTR_NAME_COORDS = "coords"; // AREA //$NON-NLS-1$ + public static final String ATTR_NAME_HREF = "href"; // AREA //$NON-NLS-1$ + public static final String ATTR_NAME_TARGET = "target"; // AREA //$NON-NLS-1$ + public static final String ATTR_NAME_NOHREF = "nohref"; // AREA //$NON-NLS-1$ + public static final String ATTR_NAME_TABINDEX = "tabindex"; // AREA //$NON-NLS-1$ + public static final String ATTR_NAME_ACCESSKEY = "accesskey"; // AREA //$NON-NLS-1$ + public static final String ATTR_NAME_ONFOCUS = "onfocus"; // AREA //$NON-NLS-1$ + public static final String ATTR_NAME_ONBLUR = "onblur"; // AREA //$NON-NLS-1$ + public static final String ATTR_NAME_CHARSET = "charset"; // LINK //$NON-NLS-1$ + public static final String ATTR_NAME_HREFLANG = "hreflang"; // LINK //$NON-NLS-1$ + public static final String ATTR_NAME_TYPE = "type"; // LINK //$NON-NLS-1$ + public static final String ATTR_NAME_REL = "rel"; // LINK //$NON-NLS-1$ + public static final String ATTR_NAME_REV = "rev"; // LINK //$NON-NLS-1$ + public static final String ATTR_NAME_MEDIA = "media"; // LINK //$NON-NLS-1$ + public static final String ATTR_NAME_VALUE = "value"; // PARAM //$NON-NLS-1$ + public static final String ATTR_NAME_VALUETYPE = "valuetype"; // PARAM //$NON-NLS-1$ + public static final String ATTR_NAME_NOSHADE = "noshade"; // HR //$NON-NLS-1$ + public static final String ATTR_NAME_CHECKED = "checked"; // INPUT //$NON-NLS-1$ + public static final String ATTR_NAME_DISABLED = "disabled"; // INPUT //$NON-NLS-1$ + public static final String ATTR_NAME_READONLY = "readonly"; // INPUT //$NON-NLS-1$ + public static final String ATTR_NAME_MAXLENGTH = "maxlength"; // INPUT //$NON-NLS-1$ + public static final String ATTR_NAME_ONSELECT = "onselect"; // INPUT //$NON-NLS-1$ + public static final String ATTR_NAME_ONCHANGE = "onchange"; // INPUT //$NON-NLS-1$ + public static final String ATTR_NAME_ACCEPT = "accept"; // INPUT //$NON-NLS-1$ + public static final String ATTR_NAME_ISTYLE = "istyle"; // INPUT //$NON-NLS-1$ + public static final String ATTR_NAME_CHAR = "char"; // COL //$NON-NLS-1$ + public static final String ATTR_NAME_CHAROFF = "charoff"; // COL //$NON-NLS-1$ + public static final String ATTR_NAME_VALIGN = "valign"; // COL //$NON-NLS-1$ + public static final String ATTR_NAME_SPAN = "span"; // COL //$NON-NLS-1$ + public static final String ATTR_NAME_FRAMEBORDER = "frameborder"; // FRAME //$NON-NLS-1$ + public static final String ATTR_NAME_MARGINWIDTH = "marginwidth"; // FRAME //$NON-NLS-1$ + public static final String ATTR_NAME_MARGINHEIGHT = "marginheight"; // FRAME //$NON-NLS-1$ + public static final String ATTR_NAME_NORESIZE = "noresize"; // FRAME //$NON-NLS-1$ + public static final String ATTR_NAME_SCROLLING = "scrolling"; // FRAME //$NON-NLS-1$ + public static final String ATTR_NAME_PROMPT = "prompt"; // ISINDEX //$NON-NLS-1$ + public static final String ATTR_NAME_HTTP_EQUIV = "http-equiv"; // META //$NON-NLS-1$ + public static final String ATTR_NAME_CONTENT = "content"; // META //$NON-NLS-1$ + public static final String ATTR_NAME_SCHEME = "scheme"; // META //$NON-NLS-1$ + public static final String ATTR_NAME_ERRMSG = "errmsg"; // ssi:config //$NON-NLS-1$ + public static final String ATTR_NAME_SIZEFMT = "sizefmt"; // ssi:config //$NON-NLS-1$ + public static final String ATTR_NAME_TIMEFMT = "timefmt"; // ssi:config //$NON-NLS-1$ + public static final String ATTR_NAME_VAR = "var"; // ssi:echo //$NON-NLS-1$ + public static final String ATTR_NAME_CGI = "cgi"; // ssi:exec //$NON-NLS-1$ + public static final String ATTR_NAME_CMD = "cmd"; // ssi:exec //$NON-NLS-1$ + public static final String ATTR_NAME_FILE = "file"; // ssi:fsize //$NON-NLS-1$ + public static final String ATTR_NAME_VIRTUAL = "virtual"; // ssi:fsize //$NON-NLS-1$ + public static final String ATTR_NAME_SELECTED = "selected"; // OPTION //$NON-NLS-1$ + public static final String ATTR_NAME_LABEL = "label"; // OPTION //$NON-NLS-1$ + public static final String ATTR_NAME_ROWS = "rows"; // TEXTAREA //$NON-NLS-1$ + public static final String ATTR_NAME_COLS = "cols"; // TEXTAREA //$NON-NLS-1$ + public static final String ATTR_NAME_LANGUAGE = "language"; // SCRIPT //$NON-NLS-1$ + public static final String ATTR_NAME_DEFER = "defer"; // SCRIPT //$NON-NLS-1$ + public static final String ATTR_NAME_EVENT = "event"; // SCRIPT //$NON-NLS-1$ + public static final String ATTR_NAME_FOR = "for"; // SCRIPT //$NON-NLS-1$ + public static final String ATTR_NAME_COMPACT = "compact"; // OL/UL //$NON-NLS-1$ + public static final String ATTR_NAME_START = "start"; // OL/UL //$NON-NLS-1$ + public static final String ATTR_NAME_DIRECTKEY = "directkey"; // A //$NON-NLS-1$ + public static final String ATTR_NAME_CODEBASE = "codebase"; // APPLET //$NON-NLS-1$ + public static final String ATTR_NAME_ARCHIVE = "archive"; // APPLET //$NON-NLS-1$ + public static final String ATTR_NAME_CODE = "code"; // APPLET //$NON-NLS-1$ + public static final String ATTR_NAME_OBJECT = "object"; // APPLET //$NON-NLS-1$ + public static final String ATTR_NAME_MAYSCRIPT = "mayscript"; // APPLET //$NON-NLS-1$ + public static final String ATTR_NAME_CITE = "cite"; // BLOCKQUOTE //$NON-NLS-1$ + public static final String ATTR_NAME_MACRO = "macro"; // D2W //$NON-NLS-1$ + public static final String ATTR_NAME_DATETIME = "datetime"; // INS/DEL //$NON-NLS-1$ + public static final String ATTR_NAME_LOOP = "loop"; // EMBED //$NON-NLS-1$ + public static final String ATTR_NAME_HIDDEN = "hidden"; // EMBED //$NON-NLS-1$ + public static final String ATTR_NAME_VOLUME = "volume"; // EMBED //$NON-NLS-1$ + public static final String ATTR_NAME_AUTOSTART = "autostart"; // EMBED //$NON-NLS-1$ + public static final String ATTR_NAME_AUTOPLAY = "autoplay"; // EMBED //$NON-NLS-1$ + public static final String ATTR_NAME_AUTOSIZE = "autosize"; // EMBED //$NON-NLS-1$ + public static final String ATTR_NAME_CONTROLLER = "controller";// EMBED //$NON-NLS-1$ + public static final String ATTR_NAME_SCALE = "scale"; // EMBED //$NON-NLS-1$ + public static final String ATTR_NAME_SHOWCONTROLS = "showcontrols";// EMBED //$NON-NLS-1$ + public static final String ATTR_NAME_PLAYCOUNT = "playcount"; // EMBED //$NON-NLS-1$ + public static final String ATTR_NAME_REPEAT = "repeat"; // EMBED //$NON-NLS-1$ + public static final String ATTR_NAME_PANEL = "panel"; // EMBED //$NON-NLS-1$ + public static final String ATTR_NAME_PALETTE = "palette"; // EMBED //$NON-NLS-1$ + public static final String ATTR_NAME_TEXTFOCUS = "textfocus"; // EMBED //$NON-NLS-1$ + public static final String ATTR_NAME_ACTION = "action"; // FORM //$NON-NLS-1$ + public static final String ATTR_NAME_METHOD = "method"; // FORM //$NON-NLS-1$ + public static final String ATTR_NAME_ENCTYPE = "enctype"; // FORM //$NON-NLS-1$ + public static final String ATTR_NAME_ONSUBMIT = "onsubmit"; // FORM //$NON-NLS-1$ + public static final String ATTR_NAME_ONRESET = "onreset"; // FORM //$NON-NLS-1$ + public static final String ATTR_NAME_ACCEPT_CHARSET = "accept-charset";// FORM //$NON-NLS-1$ + public static final String ATTR_NAME_BEHAVIOR = "behavior"; // MARQUEE //$NON-NLS-1$ + public static final String ATTR_NAME_DIRECTION = "direction"; // MARQUEE //$NON-NLS-1$ + public static final String ATTR_NAME_SCROLLAMOUNT = "scrollamount";// MARQUEE //$NON-NLS-1$ + public static final String ATTR_NAME_SCROLLDELAY = "scrolldelay";// MARQUEE //$NON-NLS-1$ + public static final String ATTR_NAME_TRUESPEED = "truespeed"; // MARQUEE //$NON-NLS-1$ + public static final String ATTR_NAME_DECLARE = "declare"; // OBJECT //$NON-NLS-1$ + public static final String ATTR_NAME_CLASSID = "classid"; // OBJECT //$NON-NLS-1$ + public static final String ATTR_NAME_DATA = "data"; // OBJECT //$NON-NLS-1$ + public static final String ATTR_NAME_CODETYPE = "codetype"; // OBJECT //$NON-NLS-1$ + public static final String ATTR_NAME_STANDBY = "standby"; // OBJECT //$NON-NLS-1$ + public static final String ATTR_NAME_MULTIPLE = "multiple"; // SELECT //$NON-NLS-1$ + public static final String ATTR_NAME_ABBR = "abbr"; // TH/TD //$NON-NLS-1$ + public static final String ATTR_NAME_AXIS = "axis"; // TH/TD //$NON-NLS-1$ + public static final String ATTR_NAME_HEADERS = "headers"; // TH/TD //$NON-NLS-1$ + public static final String ATTR_NAME_SCOPE = "scope"; // TH/TD //$NON-NLS-1$ + public static final String ATTR_NAME_ROWSPAN = "rowspan"; // TH/TD //$NON-NLS-1$ + public static final String ATTR_NAME_COLSPAN = "colspan"; // TH/TD //$NON-NLS-1$ + public static final String ATTR_NAME_NOWRAP = "nowrap"; // TH/TD //$NON-NLS-1$ + // <<D205514 + public static final String ATTR_NAME_TOPMARGIN = "topmargin"; // BODY //$NON-NLS-1$ + public static final String ATTR_NAME_BOTTOMMARGIN = "bottommargin"; // BODY //$NON-NLS-1$ + public static final String ATTR_NAME_LEFTMARGIN = "leftmargin"; // BODY //$NON-NLS-1$ + public static final String ATTR_NAME_RIGHTMARGIN = "rightmargin"; // BODY //$NON-NLS-1$ + public static final String ATTR_NAME_BORDERCOLOR = "bordercolor"; // TABLE/TR/TH/TD/FRAMESET/FRAME //$NON-NLS-1$ + // for WML + public static final String WML_ATTR_NAME_TITLE = "title"; // card //$NON-NLS-1$ + public static final String WML_ATTR_NAME_DOMAIN = "domain"; // access //$NON-NLS-1$ + public static final String WML_ATTR_NAME_PATH = "path"; // access //$NON-NLS-1$ + public static final String WML_ATTR_NAME_ONENTERFORWARD = "onenterforward"; // template,card //$NON-NLS-1$ + public static final String WML_ATTR_NAME_ONENTERBACKWARD = "onenterbackward"; // template,card //$NON-NLS-1$ + public static final String WML_ATTR_NAME_ONPICK = "onpick"; // option //$NON-NLS-1$ + public static final String WML_ATTR_NAME_ONTIMER = "ontimer"; // template,card //$NON-NLS-1$ + public static final String WML_ATTR_NAME_NEWCONTEXT = "newcontext"; // card //$NON-NLS-1$ + public static final String WML_ATTR_NAME_ORDERED = "ordered"; // card //$NON-NLS-1$ + public static final String WML_ATTR_NAME_OPTIONAL = "optional"; // do //$NON-NLS-1$ + public static final String WML_ATTR_NAME_CACHE_CONTROL = "cache-control"; // go //$NON-NLS-1$ + public static final String WML_ATTR_NAME_SENDREFERER = "sendreferer"; // go //$NON-NLS-1$ + public static final String WML_ATTR_NAME_METHOD = "method"; // go //$NON-NLS-1$ + public static final String WML_ATTR_NAME_ENCTYPE = "enctype"; // go //$NON-NLS-1$ + public static final String WML_ATTR_NAME_ACCEPT_CHARSET = "accept-charset"; // go //$NON-NLS-1$ + public static final String WML_ATTR_NAME_COLUMNS = "columns"; // table //$NON-NLS-1$ + // D205514 + //<<D215684 + public static final String ATTR_NAME_FRAMESPACING = "framespacing"; // FRAMESET //$NON-NLS-1$ + //D215684 + // global attribute values; mainly used in enumeration. + public static final String ATTR_VALUE_VERSION_TRANSITIONAL = "-//W3C//DTD HTML 4.01 Transitional//EN"; //$NON-NLS-1$ + public static final String ATTR_VALUE_VERSION_FRAMESET = "-//W3C//DTD HTML 4.01 Frameset//EN"; //$NON-NLS-1$ + public static final String ATTR_VALUE_LTR = "ltr"; // dir //$NON-NLS-1$ + public static final String ATTR_VALUE_RTL = "rtl"; // dir //$NON-NLS-1$ + // for align (top|middle|bottom|left|right) + public static final String ATTR_VALUE_TOP = "top"; // align //$NON-NLS-1$ + public static final String ATTR_VALUE_MIDDLE = "middle"; // align //$NON-NLS-1$ + public static final String ATTR_VALUE_BOTTOM = "bottom"; // align //$NON-NLS-1$ + public static final String ATTR_VALUE_LEFT = "left"; // align //$NON-NLS-1$ + public static final String ATTR_VALUE_CENTER = "center"; // align //$NON-NLS-1$ + public static final String ATTR_VALUE_RIGHT = "right"; // align //$NON-NLS-1$ + public static final String ATTR_VALUE_JUSTIFY = "justify"; // align //$NON-NLS-1$ + public static final String ATTR_VALUE_CHAR = "char"; // align //$NON-NLS-1$ + // for valign (baseline) + public static final String ATTR_VALUE_BASELINE = "baseline"; // valign //$NON-NLS-1$ + // for clear (left|all|right|none): left and right are already defined above. + public static final String ATTR_VALUE_ALL = "all"; // clear //$NON-NLS-1$ + public static final String ATTR_VALUE_NONE = "none"; // clear //$NON-NLS-1$ + // for shape (rect|circle|poly|default) + public static final String ATTR_VALUE_RECT = "rect"; // shape //$NON-NLS-1$ + public static final String ATTR_VALUE_CIRCLE = "circle"; // shape //$NON-NLS-1$ + public static final String ATTR_VALUE_POLY = "poly"; // shape //$NON-NLS-1$ + public static final String ATTR_VALUE_DEFAULT = "default"; // shape //$NON-NLS-1$ + // for valuetype (data|ref|object) + public static final String ATTR_VALUE_DATA = "data"; // valuetype //$NON-NLS-1$ + public static final String ATTR_VALUE_REF = "ref"; // valuetype //$NON-NLS-1$ + public static final String ATTR_VALUE_OBJECT = "object"; // valuetype //$NON-NLS-1$ + // for type of INPUT + // (text | password | checkbox | radio | submit | reset | + // file | hidden | image | button) + public static final String ATTR_VALUE_TEXT = "text"; // INPUT:type //$NON-NLS-1$ + public static final String ATTR_VALUE_PASSWORD = "password"; // INPUT:type //$NON-NLS-1$ + public static final String ATTR_VALUE_CHECKBOX = "checkbox"; // INPUT:type //$NON-NLS-1$ + public static final String ATTR_VALUE_RADIO = "radio"; // INPUT:type //$NON-NLS-1$ + public static final String ATTR_VALUE_SUBMIT = "submit"; // INPUT:type //$NON-NLS-1$ + public static final String ATTR_VALUE_RESET = "reset"; // INPUT:type //$NON-NLS-1$ + public static final String ATTR_VALUE_FILE = "file"; // INPUT:type //$NON-NLS-1$ + public static final String ATTR_VALUE_HIDDEN = "hidden"; // INPUT:type //$NON-NLS-1$ + public static final String ATTR_VALUE_IMAGE = "image"; // INPUT:type //$NON-NLS-1$ + public static final String ATTR_VALUE_BUTTON = "button"; // INPUT:type //$NON-NLS-1$ + // for span, colspan, rowspan + public static final String ATTR_VALUE_1 = "1"; // span //$NON-NLS-1$ + // for frameborder + public static final String ATTR_VALUE_0 = "0"; // FRAME //$NON-NLS-1$ + // for scrolling + public static final String ATTR_VALUE_YES = "yes"; // FRAME //$NON-NLS-1$ + public static final String ATTR_VALUE_NO = "no"; // FRAME //$NON-NLS-1$ + public static final String ATTR_VALUE_AUTO = "auto"; // FRAME //$NON-NLS-1$ + // for UL + public static final String ATTR_VALUE_DISC = "disc"; // UL:type //$NON-NLS-1$ + public static final String ATTR_VALUE_SQUARE = "square"; // UL:type //$NON-NLS-1$ + // for frame of TABLE + public static final String ATTR_VALUE_VOID = "void"; // TABLE:frame //$NON-NLS-1$ + public static final String ATTR_VALUE_ABOVE = "above"; // TABLE:frame //$NON-NLS-1$ + public static final String ATTR_VALUE_BELOW = "below"; // TABLE:frame //$NON-NLS-1$ + public static final String ATTR_VALUE_HSIDES = "hsides"; // TABLE:frame //$NON-NLS-1$ + public static final String ATTR_VALUE_LHS = "lhs"; // TABLE:frame //$NON-NLS-1$ + public static final String ATTR_VALUE_RHS = "rhs"; // TABLE:frame //$NON-NLS-1$ + public static final String ATTR_VALUE_VSIDES = "vsides"; // TABLE:frame //$NON-NLS-1$ + public static final String ATTR_VALUE_BOX = "box"; // TABLE:frame //$NON-NLS-1$ + public static final String ATTR_VALUE_BORDER = "border"; // TABLE:frame //$NON-NLS-1$ + // for rules of TABLE + public static final String ATTR_VALUE_GROUPS = "groups"; // TABLE:rules //$NON-NLS-1$ + public static final String ATTR_VALUE_ROWS = "rows"; // TEXTAREA //$NON-NLS-1$ + public static final String ATTR_VALUE_COLS = "cols"; // TEXTAREA //$NON-NLS-1$ + // for method of FORM + public static final String ATTR_VALUE_GET = "get"; // FORM //$NON-NLS-1$ + public static final String ATTR_VALUE_POST = "post"; // FORM //$NON-NLS-1$ + public static final String ATTR_VALUE_WWW_FORM_URLENCODED = "application/x-www-form-urlencoded"; //$NON-NLS-1$ + // for scope of (TH | TD) + public static final String ATTR_VALUE_ROW = "row"; // (TH|TD):scope //$NON-NLS-1$ + public static final String ATTR_VALUE_COL = "col"; // (TH|TD):scope //$NON-NLS-1$ + public static final String ATTR_VALUE_ROWGROUP = "rowgroup";// (TH|TD):scope //$NON-NLS-1$ + public static final String ATTR_VALUE_COLGROUP = "colgroup";// (TH|TD):scope //$NON-NLS-1$ + // for auto?? of EMBED + public static final String ATTR_VALUE_TRUE = "true"; // EMBED //$NON-NLS-1$ + public static final String ATTR_VALUE_FALSE = "false"; // EMBED //$NON-NLS-1$ + // for behaviro of MARQUEE + public static final String ATTR_VALUE_SCROLL = "scroll"; // MARQUEE //$NON-NLS-1$ + public static final String ATTR_VALUE_SLIDE = "slide"; // MARQUEE //$NON-NLS-1$ + public static final String ATTR_VALUE_ALTERNATE = "alternate"; // MARQUEE //$NON-NLS-1$ + // for direction of MARQUEE + public static final String ATTR_VALUE_UP = "up"; // MARQUEE //$NON-NLS-1$ + public static final String ATTR_VALUE_DOWN = "down"; // MARQUEE //$NON-NLS-1$ + // for type of LI (D19924) + public static final String ATTR_VALUE_NUMBER = "1"; // LI //$NON-NLS-1$ + public static final String ATTR_VALUE_LOWER_ALPHA = "a"; // LI //$NON-NLS-1$ + public static final String ATTR_VALUE_UPPER_ALPHA = "A"; // LI //$NON-NLS-1$ + public static final String ATTR_VALUE_LOWER_ROMAN = "i"; // LI //$NON-NLS-1$ + public static final String ATTR_VALUE_UPPER_ROMAN = "I"; // LI //$NON-NLS-1$ + // for loop of BGSOUND (D205513) + public static final String ATTR_VALUE_INFINITE = "infinite"; // BGSOUND //$NON-NLS-1$ +}
\ No newline at end of file diff --git a/bundles/org.eclipse.wst.html.core/src/org/eclipse/wst/html/core/HTMLCMProperties.java b/bundles/org.eclipse.wst.html.core/src/org/eclipse/wst/html/core/HTMLCMProperties.java new file mode 100644 index 0000000000..16d4719cce --- /dev/null +++ b/bundles/org.eclipse.wst.html.core/src/org/eclipse/wst/html/core/HTMLCMProperties.java @@ -0,0 +1,116 @@ +/******************************************************************************* + * Copyright (c) 2004 IBM Corporation and others. + * All rights reserved. This program and the accompanying materials + * are made available under the terms of the Eclipse Public License v1.0 + * which accompanies this distribution, and is available at + * http://www.eclipse.org/legal/epl-v10.html + * + * Contributors: + * IBM Corporation - initial API and implementation + *******************************************************************************/ +package org.eclipse.wst.html.core; + + +/** + * HTMLCMProperties defines all property names and pre-defined values in HTML CM. + * All of those properties can be retreived from element declarations of HTML CM + * via CMNode#getProperty(String propName). + */ +public interface HTMLCMProperties { + + /** + * "shouldIgnoreCase" returns java.lang.Boolean object. + */ + public static final String SHOULD_IGNORE_CASE = "shouldIgnoreCase";//$NON-NLS-1$ + /** + * "shouldKeepSpace" returns java.lang.Boolean object. + */ + public static final String SHOULD_KEEP_SPACE = "shouldKeepSpace";//$NON-NLS-1$ + /** + * "indentChildSource" returns java.lang.Boolean object. + */ + public static final String SHOULD_INDENT_CHILD_SOURCE = "shouldIndentChildSource";//$NON-NLS-1$ + /** + * "terminators" returns java.util.Iterator (an array of String objects). + */ + public static final String TERMINATORS = "terminators";//$NON-NLS-1$ + /** + * "contentHint" returns CMElementDeclaration instnace. + */ + public static final String CONTENT_HINT = "contentHint";//$NON-NLS-1$ + /** + * "prohibitedAncestors" returns org.eclipse.wst.common.contentmodel.CMNamedNodeMap. + */ + public static final String PROHIBITED_ANCESTORS = "prohibitedAncestors";//$NON-NLS-1$ + /** + * "isJSP" returns java.lang.Boolean object. + */ + public static final String IS_JSP = "isJSP";//$NON-NLS-1$ + /** + * "isXHTML" returns java.lang.Boolean object. + */ + public static final String IS_XHTML = "isXHTML";//$NON-NLS-1$ + /** + * "isSSI" returns java.lang.Boolean object. + */ + public static final String IS_SSI = "isSSI";//$NON-NLS-1$ + /** + * "lineBreakHint" returns String (one of pre-defined values in Values). + */ + public static final String LINE_BREAK_HINT = "lineBreakHint";//$NON-NLS-1$ + /** + * "layoutType" returns String (one of pre-defined values in Values). + */ + public static final String LAYOUT_TYPE = "layoutType";//$NON-NLS-1$ + /** + * "tagInfo" returns String (documentation for this element). + */ + public static final String TAGINFO = "tagInfo";//$NON-NLS-1$ + /** + * "omitType" returns String (one of pre-defined values in Values). + */ + public static final String OMIT_TYPE = "omitType";//$NON-NLS-1$ + /** + * "inclusion" returns org.eclipse.wst.common.contentmodel.CMContent. + */ + public static final String INCLUSION = "inclusion";//$NON-NLS-1$ + /** + * "isScriptable" returns java.lang.Boolean object. + */ + public static final String IS_SCRIPTABLE = "isScriptable"; //$NON-NLS-1$ + + public static interface Values { + /* + * for LINE_BREAK_HINT = "lineBreakHint". + */ + public static final String BREAK_NONE = "breakNone";//$NON-NLS-1$ + public static final String BREAK_AFTER_START = "breakAfterStart";//$NON-NLS-1$ + public static final String BREAK_BEFORE_START_AND_AFTER_END = "breakBeforeStartAndAfterEnd";//$NON-NLS-1$ + /* + * for LAYOUT_TYPE = "layoutType" + */ + public static final String LAYOUT_BLOCK = "layoutBlock";//$NON-NLS-1$ + /** BR */ + public static final String LAYOUT_BREAK = "layoutBreak";//$NON-NLS-1$ + /** Hidden object; like HTML or HEAD */ + public static final String LAYOUT_HIDDEN = "layoutHidden";//$NON-NLS-1$ + public static final String LAYOUT_NONE = "layoutNone";//$NON-NLS-1$ + /** No wrap object; like IMG, APPLET,... */ + public static final String LAYOUT_OBJECT = "layoutObject";//$NON-NLS-1$ + public static final String LAYOUT_WRAP = "layoutWrap";//$NON-NLS-1$ + /* + * for OMIT_TYPE = "omitType" + */ + /** Not ommisible. */ + public static final String OMIT_NONE = "omitNone";//$NON-NLS-1$ + /** Both tags are ommisible. */ + public static final String OMIT_BOTH = "omitBoth";//$NON-NLS-1$ + /** The end tag is ommisible. */ + public static final String OMIT_END = "omitEnd";//$NON-NLS-1$ + /** The end tag is ommitted when created. */ + public static final String OMIT_END_DEFAULT = "omitEndDefault";//$NON-NLS-1$ + /** The end tag must be omitted. */ + public static final String OMIT_END_MUST = "omitEndMust";//$NON-NLS-1$ + + } +}
\ No newline at end of file diff --git a/bundles/org.eclipse.wst.html.core/src/org/eclipse/wst/html/core/HTMLCorePlugin.java b/bundles/org.eclipse.wst.html.core/src/org/eclipse/wst/html/core/HTMLCorePlugin.java new file mode 100644 index 0000000000..a3c7d1eda5 --- /dev/null +++ b/bundles/org.eclipse.wst.html.core/src/org/eclipse/wst/html/core/HTMLCorePlugin.java @@ -0,0 +1,125 @@ +/******************************************************************************* + * Copyright (c) 2004 IBM Corporation and others. + * All rights reserved. This program and the accompanying materials + * are made available under the terms of the Eclipse Public License v1.0 + * which accompanies this distribution, and is available at + * http://www.eclipse.org/legal/epl-v10.html + * + * Contributors: + * IBM Corporation - initial API and implementation + *******************************************************************************/ +package org.eclipse.wst.html.core; + +import java.util.MissingResourceException; +import java.util.ResourceBundle; + +import org.eclipse.core.resources.IWorkspace; +import org.eclipse.core.resources.ResourcesPlugin; +import org.eclipse.core.runtime.IPluginDescriptor; +import org.eclipse.core.runtime.Plugin; +import org.eclipse.core.runtime.Preferences; +import org.eclipse.wst.common.encoding.CommonCharsetNames; +import org.eclipse.wst.common.encoding.CommonEncodingPreferenceNames; +import org.eclipse.wst.sse.core.preferences.CommonModelPreferenceNames; + +/** + * The main plugin class to be used in the desktop. + */ +public class HTMLCorePlugin extends Plugin { + //The shared instance. + private static HTMLCorePlugin plugin; + //Resource bundle. + private ResourceBundle resourceBundle; + + /** + * The constructor. + */ + public HTMLCorePlugin(IPluginDescriptor descriptor) { + super(descriptor); + plugin = this; + try { + resourceBundle = ResourceBundle.getBundle("org.eclipse.wst.html.core.HtmlPluginResources"); //$NON-NLS-1$ + } + catch (MissingResourceException x) { + resourceBundle = null; + } + } + + /** + * Returns the shared instance. + */ + public static HTMLCorePlugin getDefault() { + return plugin; + } + + /** + * Returns the workspace instance. + */ + public static IWorkspace getWorkspace() { + return ResourcesPlugin.getWorkspace(); + } + + /** + * Returns the string from the plugin's resource bundle, + * or 'key' if not found. + */ + public static String getResourceString(String key) { + ResourceBundle bundle = HTMLCorePlugin.getDefault().getResourceBundle(); + try { + return bundle.getString(key); + } + catch (MissingResourceException e) { + return key; + } + } + + /** + * Returns the plugin's resource bundle, + */ + public ResourceBundle getResourceBundle() { + return resourceBundle; + } + + /* (non-Javadoc) + * @see org.eclipse.core.runtime.Plugin#initializeDefaultPluginPreferences() + */ + protected void initializeDefaultPluginPreferences() { + super.initializeDefaultPluginPreferences(); + Preferences prefs = getDefault().getPluginPreferences(); + // set model preference defaults + prefs.setDefault(CommonModelPreferenceNames.CLEANUP_TAG_NAME_CASE, CommonModelPreferenceNames.ASIS); + prefs.setDefault(CommonModelPreferenceNames.CLEANUP_ATTR_NAME_CASE, CommonModelPreferenceNames.ASIS); + prefs.setDefault(CommonModelPreferenceNames.INSERT_REQUIRED_ATTRS, true); + prefs.setDefault(CommonModelPreferenceNames.INSERT_MISSING_TAGS, true); + prefs.setDefault(CommonModelPreferenceNames.QUOTE_ATTR_VALUES, true); + prefs.setDefault(CommonModelPreferenceNames.FORMAT_SOURCE, true); + prefs.setDefault(CommonModelPreferenceNames.CONVERT_EOL_CODES, false); + + prefs.setDefault(CommonEncodingPreferenceNames.INPUT_CODESET, ""); //$NON-NLS-1$ + + String defaultEnc = CommonModelPreferenceNames.UTF_8; + String systemEnc = System.getProperty("file.encoding"); //$NON-NLS-1$ + if (systemEnc != null) { + defaultEnc = CommonCharsetNames.getPreferredDefaultIanaName(systemEnc, CommonModelPreferenceNames.UTF_8); + } + prefs.setDefault(CommonEncodingPreferenceNames.OUTPUT_CODESET, defaultEnc); + + prefs.setDefault(CommonEncodingPreferenceNames.END_OF_LINE_CODE, ""); //$NON-NLS-1$ + prefs.setDefault(CommonModelPreferenceNames.TAB_WIDTH, CommonModelPreferenceNames.DEFAULT_TAB_WIDTH); + + prefs.setDefault(CommonModelPreferenceNames.FORMATTING_SUPPORTED, true); + prefs.setDefault(CommonModelPreferenceNames.LINE_WIDTH, 72); + prefs.setDefault(CommonModelPreferenceNames.SPLIT_MULTI_ATTRS, false); + prefs.setDefault(CommonModelPreferenceNames.INDENT_USING_TABS, true); + prefs.setDefault(CommonModelPreferenceNames.CLEAR_ALL_BLANK_LINES, false); + + prefs.setDefault(CommonModelPreferenceNames.PREFERRED_MARKUP_CASE_SUPPORTED, true); + prefs.setDefault(CommonModelPreferenceNames.TAG_NAME_CASE, CommonModelPreferenceNames.UPPER); + prefs.setDefault(CommonModelPreferenceNames.ATTR_NAME_CASE, CommonModelPreferenceNames.LOWER); + + prefs.setDefault(HTMLFilesPreferenceNames.DEFAULT_SUFFIX, HTMLFilesPreferenceNames.HTML_SUFFIX); + prefs.setDefault(HTMLFilesPreferenceNames.GENERATE_DOCUMENT_TYPE, true); + prefs.setDefault(HTMLFilesPreferenceNames.GENERATE_GENERATOR, true); + } + +}
\ No newline at end of file diff --git a/bundles/org.eclipse.wst.html.core/src/org/eclipse/wst/html/core/HTMLFilesPreferenceNames.java b/bundles/org.eclipse.wst.html.core/src/org/eclipse/wst/html/core/HTMLFilesPreferenceNames.java new file mode 100644 index 0000000000..6072e0f8f7 --- /dev/null +++ b/bundles/org.eclipse.wst.html.core/src/org/eclipse/wst/html/core/HTMLFilesPreferenceNames.java @@ -0,0 +1,31 @@ +/******************************************************************************* + * Copyright (c) 2004 IBM Corporation and others. + * All rights reserved. This program and the accompanying materials + * are made available under the terms of the Eclipse Public License v1.0 + * which accompanies this distribution, and is available at + * http://www.eclipse.org/legal/epl-v10.html + * + * Contributors: + * IBM Corporation - initial API and implementation + *******************************************************************************/ +package org.eclipse.wst.html.core; + +import org.eclipse.core.runtime.IProduct; +import org.eclipse.core.runtime.Platform; +import org.eclipse.wst.sse.core.preferences.CommonModelPreferenceNames; + +/** + * Additional preferences for new HTML Files generation + */ +public interface HTMLFilesPreferenceNames extends CommonModelPreferenceNames { + + static final String DEFAULT_SUFFIX = "defaultSuffix";//$NON-NLS-1$ + static final String HTML_SUFFIX = "html";//$NON-NLS-1$ + static final String GENERATE_DOCUMENT_TYPE = "generateDocumentType";//$NON-NLS-1$ + static final String GENERATE_GENERATOR = "generateGenerator";//$NON-NLS-1$ + // added this as a potential why to handle changing + // product names "up" the stack. Note, not declared final + // to avoid getting 'inlined' by compiler. + static IProduct product = Platform.getProduct(); + static String GENERATOR = product.getName(); +}
\ No newline at end of file diff --git a/bundles/org.eclipse.wst.html.core/src/org/eclipse/wst/html/core/HTMLFormatContraints.java b/bundles/org.eclipse.wst.html.core/src/org/eclipse/wst/html/core/HTMLFormatContraints.java new file mode 100644 index 0000000000..5346737757 --- /dev/null +++ b/bundles/org.eclipse.wst.html.core/src/org/eclipse/wst/html/core/HTMLFormatContraints.java @@ -0,0 +1,35 @@ +/******************************************************************************* + * Copyright (c) 2004 IBM Corporation and others. + * All rights reserved. This program and the accompanying materials + * are made available under the terms of the Eclipse Public License v1.0 + * which accompanies this distribution, and is available at + * http://www.eclipse.org/legal/epl-v10.html + * + * Contributors: + * IBM Corporation - initial API and implementation + *******************************************************************************/ +package org.eclipse.wst.html.core; + +import org.eclipse.wst.sse.core.format.IStructuredFormatContraints; + +/** + * @deprecated + * Please un-deprecate this if Page Designer thinks they are needed. + */ +public interface HTMLFormatContraints extends IStructuredFormatContraints { + /** + * @deprecated + * It's very hard to keep the available line width accurate. + * Sometimes a node wants to start on a new line, sometimes it doesn't. + * It's best for the node to figure out the available line width on the fly. + */ + int getAvailableLineWidth(); + + /** + * @deprecated + * It's very hard to keep the available line width accurate. + * Sometimes a node wants to start on a new line, sometimes it doesn't. + * It's best for the node to figure out the available line width on the fly. + */ + void setAvailableLineWidth(int availableLineWidth); +}
\ No newline at end of file diff --git a/bundles/org.eclipse.wst.html.core/src/org/eclipse/wst/html/core/PreferenceNames.java b/bundles/org.eclipse.wst.html.core/src/org/eclipse/wst/html/core/PreferenceNames.java new file mode 100644 index 0000000000..66466e4b24 --- /dev/null +++ b/bundles/org.eclipse.wst.html.core/src/org/eclipse/wst/html/core/PreferenceNames.java @@ -0,0 +1,35 @@ +/******************************************************************************* + * Copyright (c) 2004 IBM Corporation and others. + * All rights reserved. This program and the accompanying materials + * are made available under the terms of the Eclipse Public License v1.0 + * which accompanies this distribution, and is available at + * http://www.eclipse.org/legal/epl-v10.html + * + * Contributors: + * IBM Corporation - initial API and implementation + *******************************************************************************/ +package org.eclipse.wst.html.core; + + +public interface PreferenceNames { + + String TRUE = "true"; //$NON-NLS-1$ + String FALSE = "false"; //$NON-NLS-1$ + String YES = "yes"; //$NON-NLS-1$ + String NO = "no"; //$NON-NLS-1$ + + + String SETTINGS = "settings"; //$NON-NLS-1$ + + String TREEVIEW = "treeview"; //$NON-NLS-1$ + String DEFAULT_DEPTH = "defaultdepth"; //$NON-NLS-1$ + + String ASIS = "as-is"; //$NON-NLS-1$ + String LOWER = "lower"; //$NON-NLS-1$ + String UPPER = "upper"; //$NON-NLS-1$ + + String PREFERRED_CASE = "preferred-case"; //$NON-NLS-1$ + String TAGNAME = "tagname"; //$NON-NLS-1$ + String ATTRIBUTENAME = "attributename"; //$NON-NLS-1$ + +}
\ No newline at end of file diff --git a/bundles/org.eclipse.wst.html.core/src/org/eclipse/wst/html/core/cleanup/AbstractNodeCleanupHandler.java b/bundles/org.eclipse.wst.html.core/src/org/eclipse/wst/html/core/cleanup/AbstractNodeCleanupHandler.java new file mode 100644 index 0000000000..b16b86795a --- /dev/null +++ b/bundles/org.eclipse.wst.html.core/src/org/eclipse/wst/html/core/cleanup/AbstractNodeCleanupHandler.java @@ -0,0 +1,87 @@ +/******************************************************************************* + * Copyright (c) 2004 IBM Corporation and others. + * All rights reserved. This program and the accompanying materials + * are made available under the terms of the Eclipse Public License v1.0 + * which accompanies this distribution, and is available at + * http://www.eclipse.org/legal/epl-v10.html + * + * Contributors: + * IBM Corporation - initial API and implementation + *******************************************************************************/ +package org.eclipse.wst.html.core.cleanup; + +import org.eclipse.core.runtime.IProgressMonitor; +import org.eclipse.core.runtime.Preferences; +import org.eclipse.wst.html.core.HTMLCorePlugin; +import org.eclipse.wst.sse.core.cleanup.IStructuredCleanupHandler; +import org.eclipse.wst.sse.core.cleanup.IStructuredCleanupPreferences; +import org.eclipse.wst.sse.core.cleanup.StructuredCleanupPreferences; +import org.eclipse.wst.sse.core.events.StructuredDocumentEvent; +import org.eclipse.wst.sse.core.preferences.CommonModelPreferenceNames; +import org.eclipse.wst.sse.core.text.IStructuredDocument; +import org.eclipse.wst.xml.core.document.XMLModel; + +abstract class AbstractNodeCleanupHandler implements IStructuredCleanupHandler { + + protected IStructuredCleanupPreferences fCleanupPreferences = null; + protected IProgressMonitor fProgressMonitor = null; + + public void setCleanupPreferences(IStructuredCleanupPreferences cleanupPreferences) { + + fCleanupPreferences = cleanupPreferences; + } + + /** + * @see com.ibm.sed.partitionCleanup.CleanupHandler#getCleanupPreferences() + */ + public IStructuredCleanupPreferences getCleanupPreferences() { + if (fCleanupPreferences == null) { + fCleanupPreferences = new StructuredCleanupPreferences(); + + Preferences preferences = getModelPreferences(); + if (preferences != null) { + fCleanupPreferences.setTagNameCase(preferences.getInt(CommonModelPreferenceNames.CLEANUP_TAG_NAME_CASE)); + fCleanupPreferences.setAttrNameCase(preferences.getInt(CommonModelPreferenceNames.CLEANUP_ATTR_NAME_CASE)); + fCleanupPreferences.setCompressEmptyElementTags(preferences.getBoolean(CommonModelPreferenceNames.COMPRESS_EMPTY_ELEMENT_TAGS)); + fCleanupPreferences.setInsertRequiredAttrs(preferences.getBoolean(CommonModelPreferenceNames.INSERT_REQUIRED_ATTRS)); + fCleanupPreferences.setInsertMissingTags(preferences.getBoolean(CommonModelPreferenceNames.INSERT_MISSING_TAGS)); + fCleanupPreferences.setQuoteAttrValues(preferences.getBoolean(CommonModelPreferenceNames.QUOTE_ATTR_VALUES)); + fCleanupPreferences.setFormatSource(preferences.getBoolean(CommonModelPreferenceNames.FORMAT_SOURCE)); + fCleanupPreferences.setConvertEOLCodes(preferences.getBoolean(CommonModelPreferenceNames.CONVERT_EOL_CODES)); + fCleanupPreferences.setEOLCode(preferences.getString(CommonModelPreferenceNames.CLEANUP_EOL_CODE)); + } + } + + return fCleanupPreferences; + } + + /** + * @see com.ibm.sed.partitionCleanup.CleanupHandler#setProgressMonitor(org.eclipse.core.runtime.IProgressMonitor) + */ + public void setProgressMonitor(IProgressMonitor progressMonitor) { + + fProgressMonitor = progressMonitor; + } + + static protected StructuredDocumentEvent replaceSource(XMLModel model, Object requester, int offset, int length, String source) { + + StructuredDocumentEvent result = null; + if (model == null) + return result; + IStructuredDocument structuredDocument = model.getStructuredDocument(); + if (structuredDocument == null) + return result; + if (source == null) + source = new String(); + if (structuredDocument.containsReadOnly(offset, length)) + return result; + if (requester == null) { + requester = structuredDocument; + } + return structuredDocument.replaceText(requester, offset, length, source); + } + + protected Preferences getModelPreferences() { + return HTMLCorePlugin.getDefault().getPluginPreferences(); + } +}
\ No newline at end of file diff --git a/bundles/org.eclipse.wst.html.core/src/org/eclipse/wst/html/core/cleanup/CSSTextNodeCleanupHandler.java b/bundles/org.eclipse.wst.html.core/src/org/eclipse/wst/html/core/cleanup/CSSTextNodeCleanupHandler.java new file mode 100644 index 0000000000..491a8bd262 --- /dev/null +++ b/bundles/org.eclipse.wst.html.core/src/org/eclipse/wst/html/core/cleanup/CSSTextNodeCleanupHandler.java @@ -0,0 +1,86 @@ +/******************************************************************************* + * Copyright (c) 2004 IBM Corporation and others. + * All rights reserved. This program and the accompanying materials + * are made available under the terms of the Eclipse Public License v1.0 + * which accompanies this distribution, and is available at + * http://www.eclipse.org/legal/epl-v10.html + * + * Contributors: + * IBM Corporation - initial API and implementation + *******************************************************************************/ +package org.eclipse.wst.html.core.cleanup; + + + +import org.eclipse.wst.css.core.adapters.IStyleSheetAdapter; +import org.eclipse.wst.css.core.document.ICSSModel; +import org.eclipse.wst.css.core.document.ICSSNode; +import org.eclipse.wst.css.core.format.CSSSourceFormatter; +import org.eclipse.wst.sse.core.INodeAdapter; +import org.eclipse.wst.sse.core.INodeNotifier; +import org.eclipse.wst.sse.core.text.IStructuredDocument; +import org.eclipse.wst.xml.core.document.XMLModel; +import org.eclipse.wst.xml.core.document.XMLNode; +import org.w3c.dom.Node; + +// nakamori_TODO: check and remove + +public class CSSTextNodeCleanupHandler extends AbstractNodeCleanupHandler { + + public Node cleanup(Node node) { + if (node == null) + return node; + XMLModel model = ((XMLNode) node).getModel(); + if (model == null) + return node; + IStructuredDocument structuredDocument = model.getStructuredDocument(); + if (structuredDocument == null) + return node; + + String content = getCSSContent(node); + if (content == null) + return node; + + int offset = ((XMLNode) node).getStartOffset(); + int length = ((XMLNode) node).getEndOffset() - offset; + replaceSource(model, this, offset, length, content); + return (XMLNode) model.getIndexedRegion(offset); + } + + /** + */ + private String getCSSContent(Node text) { + ICSSModel model = getCSSModel(text); + if (model == null) + return null; + ICSSNode document = model.getDocument(); + if (document == null) + return null; + INodeNotifier notifier = (INodeNotifier) document; + INodeAdapter adapter = notifier.getAdapterFor(CSSSourceFormatter.class); + if (adapter == null) + return null; + CSSSourceFormatter formatter = (CSSSourceFormatter) adapter; + StringBuffer buffer = formatter.cleanup(document); + if (buffer == null) + return null; + return buffer.toString(); + } + + /** + */ + private ICSSModel getCSSModel(Node text) { + if (text == null) + return null; + INodeNotifier notifier = (INodeNotifier) text.getParentNode(); + if (notifier == null) + return null; + INodeAdapter adapter = notifier.getAdapterFor(IStyleSheetAdapter.class); + if (adapter == null) + return null; + if (!(adapter instanceof IStyleSheetAdapter)) + return null; + IStyleSheetAdapter styleAdapter = (IStyleSheetAdapter) adapter; + return styleAdapter.getModel(); + } +}
\ No newline at end of file diff --git a/bundles/org.eclipse.wst.html.core/src/org/eclipse/wst/html/core/cleanup/ElementNodeCleanupHandler.java b/bundles/org.eclipse.wst.html.core/src/org/eclipse/wst/html/core/cleanup/ElementNodeCleanupHandler.java new file mode 100644 index 0000000000..f006784b63 --- /dev/null +++ b/bundles/org.eclipse.wst.html.core/src/org/eclipse/wst/html/core/cleanup/ElementNodeCleanupHandler.java @@ -0,0 +1,635 @@ +/******************************************************************************* + * Copyright (c) 2004 IBM Corporation and others. + * All rights reserved. This program and the accompanying materials + * are made available under the terms of the Eclipse Public License v1.0 + * which accompanies this distribution, and is available at + * http://www.eclipse.org/legal/epl-v10.html + * + * Contributors: + * IBM Corporation - initial API and implementation + *******************************************************************************/ +package org.eclipse.wst.html.core.cleanup; + + + +import java.util.ArrayList; +import java.util.Iterator; +import java.util.List; +import java.util.Locale; + +import org.eclipse.jface.text.BadLocationException; +import org.eclipse.text.edits.InsertEdit; +import org.eclipse.text.edits.MultiTextEdit; +import org.eclipse.wst.common.contentmodel.CMAttributeDeclaration; +import org.eclipse.wst.common.contentmodel.CMElementDeclaration; +import org.eclipse.wst.common.contentmodel.CMNamedNodeMap; +import org.eclipse.wst.common.contentmodel.modelquery.ModelQuery; +import org.eclipse.wst.css.core.adapters.IStyleDeclarationAdapter; +import org.eclipse.wst.css.core.document.ICSSModel; +import org.eclipse.wst.css.core.document.ICSSNode; +import org.eclipse.wst.css.core.format.CSSSourceFormatter; +import org.eclipse.wst.sse.core.INodeAdapter; +import org.eclipse.wst.sse.core.INodeNotifier; +import org.eclipse.wst.sse.core.cleanup.IStructuredCleanupHandler; +import org.eclipse.wst.sse.core.exceptions.SourceEditingRuntimeException; +import org.eclipse.wst.sse.core.preferences.CommonModelPreferenceNames; +import org.eclipse.wst.sse.core.text.IStructuredDocument; +import org.eclipse.wst.sse.core.text.IStructuredDocumentRegion; +import org.eclipse.wst.sse.core.text.ITextRegion; +import org.eclipse.wst.sse.core.text.ITextRegionList; +import org.eclipse.wst.sse.core.util.StringUtils; +import org.eclipse.wst.xml.core.document.XMLAttr; +import org.eclipse.wst.xml.core.document.XMLDocument; +import org.eclipse.wst.xml.core.document.XMLElement; +import org.eclipse.wst.xml.core.document.XMLGenerator; +import org.eclipse.wst.xml.core.document.XMLModel; +import org.eclipse.wst.xml.core.document.XMLNode; +import org.eclipse.wst.xml.core.modelquery.ModelQueryUtil; +import org.eclipse.wst.xml.core.parser.XMLRegionContext; +import org.w3c.dom.Attr; +import org.w3c.dom.Document; +import org.w3c.dom.Element; +import org.w3c.dom.NamedNodeMap; +import org.w3c.dom.Node; + +// nakamori_TODO: check and remove CSS formatting + +public class ElementNodeCleanupHandler extends AbstractNodeCleanupHandler { + + /** Non-NLS strings */ + protected static final String START_TAG_OPEN = "<"; //$NON-NLS-1$ + protected static final String END_TAG_OPEN = "</"; //$NON-NLS-1$ + protected static final String TAG_CLOSE = ">"; //$NON-NLS-1$ + protected static final String EMPTY_TAG_CLOSE = "/>"; //$NON-NLS-1$ + protected static final String SINGLE_QUOTES = "''"; //$NON-NLS-1$ + protected static final String DOUBLE_QUOTES = "\"\""; //$NON-NLS-1$ + protected static final char SINGLE_QUOTE = '\''; //$NON-NLS-1$ + protected static final char DOUBLE_QUOTE = '\"'; //$NON-NLS-1$ + + public Node cleanup(Node node) { + XMLNode renamedNode = (XMLNode) cleanupChildren(node); + + // call quoteAttrValue() first so it will close any unclosed attr + // quoteAttrValue() will return the new start tag if there is a structure change + renamedNode = quoteAttrValue(renamedNode); + + // insert tag close if missing + // if node is not comment tag + // and not implicit tag + if (!((XMLElement) renamedNode).isCommentTag() && (renamedNode.getStartStructuredDocumentRegion() != null)) { + XMLModel structuredModel = renamedNode.getModel(); + + // save start offset before insertTagClose() + // or else renamedNode.getStartOffset() will be zero if renamedNode replaced by insertTagClose() + int startTagStartOffset = renamedNode.getStartOffset(); + + // for start tag + IStructuredDocumentRegion startTagStructuredDocumentRegion = renamedNode.getStartStructuredDocumentRegion(); + insertTagClose(structuredModel, startTagStructuredDocumentRegion); + + // update renamedNode and startTagStructuredDocumentRegion after insertTagClose() + renamedNode = (XMLNode) structuredModel.getIndexedRegion(startTagStartOffset); + startTagStructuredDocumentRegion = renamedNode.getStartStructuredDocumentRegion(); + + // for end tag + IStructuredDocumentRegion endTagStructuredDocumentRegion = renamedNode.getEndStructuredDocumentRegion(); + if (endTagStructuredDocumentRegion != startTagStructuredDocumentRegion) + insertTagClose(structuredModel, endTagStructuredDocumentRegion); + } + + // call insertMissingTags() next, it will generate implicit tags if there are any + // insertMissingTags() will return the new missing start tag if one is missing + // applyTagNameCase() will return the renamed node. + // The renamed/new node will be saved and returned to caller when all cleanup is done. + renamedNode = insertMissingTags(renamedNode); + renamedNode = insertRequiredAttrs(renamedNode); + renamedNode = applyTagNameCase(renamedNode); + applyAttrNameCase(renamedNode); + cleanupCSSAttrValue(renamedNode); + + return renamedNode; + } + + private boolean shouldIgnoreCase(XMLElement element) { + // case option can be applied to no namespace tags + return element.isGlobalTag(); + /* + ModelQueryAdapter mqadapter = (ModelQueryAdapter) element.getAdapterFor(ModelQueryAdapter.class); + ModelQuery mq = null; + CMNode nodedecl = null; + if (mqadapter != null) + mq = mqadapter.getModelQuery(); + if (mq != null) + nodedecl = mq.getCMNode(node); + // if a Node isn't recognized as HTML or is and cares about case, do not alter it + // if (nodedecl == null || (nodedecl instanceof HTMLCMNode && ((HTMLCMNode) nodedecl).shouldIgnoreCase())) + if (! nodedecl.supports(HTMLCMProperties.SHOULD_IGNORE_CASE)) return false; + return ((Boolean)cmnode.getProperty(HTMLCMProperties.SHOULD_IGNORE_CASE)).booleanValue(); + */ + } + + protected void applyAttrNameCase(XMLNode node) { + XMLElement element = (XMLElement) node; + if (element.isCommentTag()) + return; // do nothing + + int attrNameCase = CommonModelPreferenceNames.ASIS; + + if (shouldIgnoreCase(element)) + attrNameCase = getCleanupPreferences().getAttrNameCase(); + + NamedNodeMap attributes = node.getAttributes(); + int attributesLength = attributes.getLength(); + + for (int i = 0; i < attributesLength; i++) { + XMLNode eachAttr = (XMLNode) attributes.item(i); + String oldAttrName = eachAttr.getNodeName(); + String newAttrName = oldAttrName; + // 254961 - all HTML tag names and attribute names should be in English + // even for HTML files in other languages like Japanese or Turkish. + // English locale should be used to convert between uppercase and lowercase + // (otherwise "link" would be converted to "LÝNK" in Turkish, where '?' in "LÝNK" + // is the "I Overdot Capital" in Turkish). + if (attrNameCase == CommonModelPreferenceNames.LOWER) + newAttrName = oldAttrName.toLowerCase(Locale.US); + else if (attrNameCase == CommonModelPreferenceNames.UPPER) + newAttrName = oldAttrName.toUpperCase(Locale.US); + + if (newAttrName.compareTo(oldAttrName) != 0) { + int attrNameStartOffset = eachAttr.getStartOffset(); + int attrNameLength = oldAttrName.length(); + + XMLModel structuredModel = node.getModel(); + IStructuredDocument structuredDocument = structuredModel.getStructuredDocument(); + replaceSource(structuredModel, structuredDocument, attrNameStartOffset, attrNameLength, newAttrName); + } + } + } + + protected XMLNode applyTagNameCase(XMLNode node) { + XMLElement element = (XMLElement) node; + if (element.isCommentTag()) + return node; // do nothing + + int tagNameCase = CommonModelPreferenceNames.ASIS; + + if (shouldIgnoreCase(element)) + tagNameCase = getCleanupPreferences().getTagNameCase(); + + String oldTagName = node.getNodeName(); + String newTagName = oldTagName; + XMLNode newNode = node; + + // 254961 - all HTML tag names and attribute names should be in English + // even for HTML files in other languages like Japanese or Turkish. + // English locale should be used to convert between uppercase and lowercase + // (otherwise "link" would be converted to "LÝNK" in Turkish, where '?' in "LÝNK" + // is the "I Overdot Capital" in Turkish). + if (tagNameCase == CommonModelPreferenceNames.LOWER) + newTagName = oldTagName.toLowerCase(Locale.US); + else if (tagNameCase == CommonModelPreferenceNames.UPPER) + newTagName = oldTagName.toUpperCase(Locale.US); + + XMLModel structuredModel = node.getModel(); + IStructuredDocument structuredDocument = structuredModel.getStructuredDocument(); + + IStructuredDocumentRegion startTagStructuredDocumentRegion = node.getStartStructuredDocumentRegion(); + if (startTagStructuredDocumentRegion != null) { + ITextRegionList regions = startTagStructuredDocumentRegion.getRegions(); + if (regions != null && regions.size() > 0) { + ITextRegion startTagNameRegion = regions.get(1); + int startTagNameStartOffset = startTagStructuredDocumentRegion.getStartOffset(startTagNameRegion); + int startTagNameLength = startTagStructuredDocumentRegion.getTextEndOffset(startTagNameRegion) - startTagNameStartOffset; + + replaceSource(structuredModel, structuredDocument, startTagNameStartOffset, startTagNameLength, newTagName); + newNode = (XMLNode) structuredModel.getIndexedRegion(startTagNameStartOffset); // save new node + } + } + + IStructuredDocumentRegion endTagStructuredDocumentRegion = node.getEndStructuredDocumentRegion(); + if (endTagStructuredDocumentRegion != null) { + ITextRegionList regions = endTagStructuredDocumentRegion.getRegions(); + if (regions != null && regions.size() > 0) { + ITextRegion endTagNameRegion = regions.get(1); + int endTagNameStartOffset = endTagStructuredDocumentRegion.getStartOffset(endTagNameRegion); + int endTagNameLength = endTagStructuredDocumentRegion.getTextEndOffset(endTagNameRegion) - endTagNameStartOffset; + + if (startTagStructuredDocumentRegion != endTagStructuredDocumentRegion) + replaceSource(structuredModel, structuredDocument, endTagNameStartOffset, endTagNameLength, newTagName); + } + } + + return newNode; + } + + protected Node cleanupChildren(Node node) { + Node parentNode = node; + + if (node != null) { + Node childNode = node.getFirstChild(); + HTMLCleanupHandlerFactory factory = HTMLCleanupHandlerFactory.getInstance(); + while (childNode != null) { + // cleanup this child node + IStructuredCleanupHandler cleanupHandler = factory.createHandler(childNode, getCleanupPreferences()); + childNode = cleanupHandler.cleanup(childNode); + + // get new parent node + parentNode = (XMLNode) childNode.getParentNode(); + + // get next child node + childNode = (XMLNode) childNode.getNextSibling(); + } + } + + return parentNode; + } + + /** + */ + protected void cleanupCSSAttrValue(XMLNode node) { + if (node == null || node.getNodeType() != Node.ELEMENT_NODE) + return; + XMLElement element = (XMLElement) node; + if (!element.isGlobalTag()) + return; + + Attr attr = element.getAttributeNode("style"); //$NON-NLS-1$ + if (attr == null) + return; + String value = getCSSValue(attr); + if (value == null) + return; + String oldValue = ((XMLNode) attr).getValueSource(); + if (oldValue != null && value.equals(oldValue)) + return; + attr.setValue(value); + } + + /** + */ + private ICSSModel getCSSModel(Attr attr) { + if (attr == null) + return null; + INodeNotifier notifier = (INodeNotifier) attr.getOwnerElement(); + if (notifier == null) + return null; + INodeAdapter adapter = notifier.getAdapterFor(IStyleDeclarationAdapter.class); + if (adapter == null) + return null; + if (!(adapter instanceof IStyleDeclarationAdapter)) + return null; + IStyleDeclarationAdapter styleAdapter = (IStyleDeclarationAdapter) adapter; + return styleAdapter.getModel(); + } + + /** + */ + private String getCSSValue(Attr attr) { + ICSSModel model = getCSSModel(attr); + if (model == null) + return null; + ICSSNode document = model.getDocument(); + if (document == null) + return null; + INodeNotifier notifier = (INodeNotifier) document; + INodeAdapter adapter = notifier.getAdapterFor(CSSSourceFormatter.class); + if (adapter == null) + return null; + CSSSourceFormatter formatter = (CSSSourceFormatter) adapter; + StringBuffer buffer = formatter.cleanup(document); + if (buffer == null) + return null; + return buffer.toString(); + } + + private boolean isEmptyElement(XMLElement element) { + Document document = element.getOwnerDocument(); + if (document == null) + // undefined tag, return default + return false; + + ModelQuery modelQuery = ModelQueryUtil.getModelQuery(document); + if (modelQuery == null) + // undefined tag, return default + return false; + + CMElementDeclaration decl = modelQuery.getCMElementDeclaration(element); + if (decl == null) + // undefined tag, return default + return false; + + return (decl.getContentType() == CMElementDeclaration.EMPTY); + } + + protected XMLNode insertEndTag(XMLNode node) { + XMLElement element = (XMLElement) node; + + int startTagStartOffset = node.getStartOffset(); + XMLModel structuredModel = node.getModel(); + XMLNode newNode = null; + + if (element.isCommentTag()) { + // do nothing + } + else if (isEmptyElement(element)) { + IStructuredDocument structuredDocument = structuredModel.getStructuredDocument(); + IStructuredDocumentRegion startStructuredDocumentRegion = node.getStartStructuredDocumentRegion(); + ITextRegionList regions = startStructuredDocumentRegion.getRegions(); + ITextRegion lastRegion = regions.get(regions.size() - 1); + replaceSource(structuredModel, structuredDocument, startStructuredDocumentRegion.getStartOffset(lastRegion), lastRegion.getLength(), EMPTY_TAG_CLOSE); + + if (regions.size() > 1) { + ITextRegion regionBeforeTagClose = regions.get(regions.size() - 1 - 1); + + // insert a space separator before tag close if the previous region does not have extra spaces + if (regionBeforeTagClose.getTextLength() == regionBeforeTagClose.getLength()) + replaceSource(structuredModel, structuredDocument, startStructuredDocumentRegion.getStartOffset(lastRegion), 0, " "); //$NON-NLS-1$ + } + } + else { + String tagName = node.getNodeName(); + String endTag = END_TAG_OPEN.concat(tagName).concat(TAG_CLOSE); + + XMLNode lastChild = (XMLNode) node.getLastChild(); + int endTagStartOffset = 0; + if (lastChild != null) + // if this node has children, insert the end tag after the last child + endTagStartOffset = lastChild.getEndOffset(); + else + // if this node does not has children, insert the end tag after the start tag + endTagStartOffset = node.getEndOffset(); + + IStructuredDocument structuredDocument = structuredModel.getStructuredDocument(); + replaceSource(structuredModel, structuredDocument, endTagStartOffset, 0, endTag); + } + + newNode = (XMLNode) structuredModel.getIndexedRegion(startTagStartOffset); // save new node + + return newNode; + } + + protected XMLNode insertMissingTags(XMLNode node) { + boolean insertMissingTags = getCleanupPreferences().getInsertMissingTags(); + XMLNode newNode = node; + + if (insertMissingTags) { + IStructuredDocumentRegion startTagStructuredDocumentRegion = node.getStartStructuredDocumentRegion(); + if (startTagStructuredDocumentRegion == null) { + // implicit start tag; generate tag for it + newNode = insertStartTag(node); + startTagStructuredDocumentRegion = newNode.getStartStructuredDocumentRegion(); + } + + IStructuredDocumentRegion endTagStructuredDocumentRegion = newNode.getEndStructuredDocumentRegion(); + + ITextRegionList regionList = startTagStructuredDocumentRegion.getRegions(); + if (startTagStructuredDocumentRegion != null && regionList != null && regionList.get(regionList.size() - 1).getType() == XMLRegionContext.XML_EMPTY_TAG_CLOSE) { + + } + else { + if (startTagStructuredDocumentRegion == null) { + // start tag missing + if (isStartTagRequired(newNode)) + newNode = insertStartTag(newNode); + } + else if (endTagStructuredDocumentRegion == null) { + // end tag missing + if (isEndTagRequired(newNode)) + newNode = insertEndTag(newNode); + } + } + } + + return newNode; + } + + protected XMLNode insertStartTag(XMLNode node) { + XMLElement element = (XMLElement) node; + if (element.isCommentTag()) + return node; // do nothing + + XMLNode newNode = null; + + String tagName = node.getNodeName(); + String startTag = START_TAG_OPEN.concat(tagName).concat(TAG_CLOSE); + int startTagStartOffset = node.getStartOffset(); + + XMLModel structuredModel = node.getModel(); + IStructuredDocument structuredDocument = structuredModel.getStructuredDocument(); + replaceSource(structuredModel, structuredDocument, startTagStartOffset, 0, startTag); + newNode = (XMLNode) structuredModel.getIndexedRegion(startTagStartOffset); // save new node + + return newNode; + } + + protected void insertTagClose(XMLModel structuredModel, IStructuredDocumentRegion flatNode) { + if ((flatNode != null) && (flatNode.getRegions() != null)) { + ITextRegionList regionList = flatNode.getRegions(); + ITextRegion lastRegion = regionList.get(regionList.size() - 1); + if (lastRegion != null) { + String regionType = lastRegion.getType(); + if ((regionType != XMLRegionContext.XML_EMPTY_TAG_CLOSE) && (regionType != XMLRegionContext.XML_TAG_CLOSE)) { + IStructuredDocument structuredDocument = structuredModel.getStructuredDocument(); + + // insert ">" after lastRegion of flatNode + // as in "<a</a>" if flatNode is for start tag, or in "<a></a" if flatNode is for end tag + replaceSource(structuredModel, structuredDocument, flatNode.getTextEndOffset(lastRegion), 0, ">"); //$NON-NLS-1$ + } + } + } + } + + protected boolean isEndTagRequired(XMLNode node) { + if (node == null) + return false; + return node.isContainer(); + } + + /** + * The end tags of HTML EMPTY content type, such as IMG, + * and HTML undefined tags are parsed separately from the start tags. + * So inserting the missing start tag is useless and even harmful. + */ + protected boolean isStartTagRequired(XMLNode node) { + if (node == null) + return false; + return node.isContainer(); + } + + protected boolean isXMLType(XMLModel structuredModel) { + boolean result = false; + + if (structuredModel != null && structuredModel != null) { + XMLDocument document = structuredModel.getDocument(); + + if (document != null) + result = document.isXMLType(); + } + + return result; + } + + protected XMLNode quoteAttrValue(XMLNode node) { + XMLElement element = (XMLElement) node; + if (element.isCommentTag()) + return node; // do nothing + + boolean quoteAttrValues = getCleanupPreferences().getQuoteAttrValues(); + XMLNode newNode = node; + + if (quoteAttrValues) { + NamedNodeMap attributes = newNode.getAttributes(); + int attributesLength = attributes.getLength(); + XMLGenerator generator = node.getModel().getGenerator(); + + for (int i = 0; i < attributesLength; i++) { + attributes = newNode.getAttributes(); + attributesLength = attributes.getLength(); + XMLAttr eachAttr = (XMLAttr) attributes.item(i); + //ITextRegion oldAttrValueRegion = eachAttr.getValueRegion(); + String oldAttrValue = eachAttr.getValueRegionText(); + if (oldAttrValue == null) { + XMLModel structuredModel = node.getModel(); + if (isXMLType(structuredModel)) { + // TODO: Kit, please check. Is there any way to not rely on getting regions from attributes? + String newAttrValue = "=\"" + eachAttr.getNameRegionText() + "\""; //$NON-NLS-1$ //$NON-NLS-2$ + + IStructuredDocument structuredDocument = structuredModel.getStructuredDocument(); + replaceSource(structuredModel, structuredDocument, eachAttr.getNameRegionEndOffset(), 0, newAttrValue); + newNode = (XMLNode) structuredModel.getIndexedRegion(node.getStartOffset()); // save new node + } + } + else { + + char quote = StringUtils.isQuoted(oldAttrValue) ? oldAttrValue.charAt(0) : DOUBLE_QUOTE; + String newAttrValue = generator.generateAttrValue(eachAttr, quote); + + // There is a problem in StructuredDocumentRegionUtil.getAttrValue(ITextRegion) when the region is instanceof ContextRegion. + // Workaround for now... + if (oldAttrValue.length() == 1) { + char firstChar = oldAttrValue.charAt(0); + if (firstChar == SINGLE_QUOTE) + newAttrValue = SINGLE_QUOTES; + else if (firstChar == DOUBLE_QUOTE) + newAttrValue = DOUBLE_QUOTES; + } + + if (newAttrValue != null) { + if (newAttrValue.compareTo(oldAttrValue) != 0) { + int attrValueStartOffset = eachAttr.getValueRegionStartOffset(); + int attrValueLength = oldAttrValue.length(); + int startTagStartOffset = node.getStartOffset(); + + XMLModel structuredModel = node.getModel(); + IStructuredDocument structuredDocument = structuredModel.getStructuredDocument(); + replaceSource(structuredModel, structuredDocument, attrValueStartOffset, attrValueLength, newAttrValue); + newNode = (XMLNode) structuredModel.getIndexedRegion(startTagStartOffset); // save new node + } + } + } + } + } + + return newNode; + } + + private XMLNode insertRequiredAttrs(XMLNode node) { + boolean insertRequiredAttrs = getCleanupPreferences().getInsertRequiredAttrs(); + XMLNode newNode = node; + + if (insertRequiredAttrs) { + List requiredAttrs = getRequiredAttrs(newNode); + if (requiredAttrs.size() > 0) { + NamedNodeMap currentAttrs = node.getAttributes(); + List insertAttrs = new ArrayList(); + if (currentAttrs.getLength() == 0) + insertAttrs.addAll(requiredAttrs); + else { + for (int i = 0; i < requiredAttrs.size(); i++) { + String requiredAttrName = ((CMAttributeDeclaration) requiredAttrs.get(i)).getAttrName(); + boolean found = false; + for (int j = 0; j < currentAttrs.getLength(); j++) { + String currentAttrName = currentAttrs.item(j).getNodeName(); + if (requiredAttrName.compareToIgnoreCase(currentAttrName) == 0) { + found = true; + break; + } + } + if (!found) + insertAttrs.add(requiredAttrs.get(i)); + } + } + if (insertAttrs.size() > 0) { + IStructuredDocumentRegion startStructuredDocumentRegion = newNode.getStartStructuredDocumentRegion(); + int index = startStructuredDocumentRegion.getEndOffset(); + ITextRegion lastRegion = startStructuredDocumentRegion.getLastRegion(); + if (lastRegion.getType() == XMLRegionContext.XML_TAG_CLOSE) { + index--; + lastRegion = startStructuredDocumentRegion.getRegionAtCharacterOffset(index - 1); + } + else if (lastRegion.getType() == XMLRegionContext.XML_EMPTY_TAG_CLOSE) { + index = index - 2; + lastRegion = startStructuredDocumentRegion.getRegionAtCharacterOffset(index - 1); + } + MultiTextEdit multiTextEdit = new MultiTextEdit(); + try { + for (int i = insertAttrs.size() - 1; i >= 0; i--) { + CMAttributeDeclaration attrDecl = (CMAttributeDeclaration) insertAttrs.get(i); + String requiredAttributeName = attrDecl.getAttrName(); + String defaultValue = attrDecl.getDefaultValue(); + if (defaultValue == null) + defaultValue = ""; //$NON-NLS-1$ + String nameAndDefaultValue = " "; //$NON-NLS-1$ + if (i == 0 && lastRegion.getLength() > lastRegion.getTextLength()) + nameAndDefaultValue = ""; //$NON-NLS-1$ + nameAndDefaultValue += requiredAttributeName + "=\"" + defaultValue + "\""; //$NON-NLS-1$ //$NON-NLS-2$ + multiTextEdit.addChild(new InsertEdit(index, nameAndDefaultValue)); + // BUG3381: MultiTextEdit applies all child TextEdit's basing on offsets + // in the document before the first TextEdit, not after each + // child TextEdit. Therefore, do not need to advance the index. + //index += nameAndDefaultValue.length(); + } + multiTextEdit.apply(newNode.getStructuredDocument()); + } + catch (BadLocationException e) { + throw new SourceEditingRuntimeException(e); + } + } + } + } + + return newNode; + } + + + protected ModelQuery getModelQuery(Node node) { + if (node.getNodeType() == Node.DOCUMENT_NODE) { + return ModelQueryUtil.getModelQuery((Document) node); + } + else { + return ModelQueryUtil.getModelQuery(node.getOwnerDocument()); + } + } + + protected List getRequiredAttrs(Node node) { + List result = new ArrayList(); + + ModelQuery modelQuery = getModelQuery(node); + if (modelQuery != null) { + CMElementDeclaration elementDecl = modelQuery.getCMElementDeclaration((Element) node); + if (elementDecl != null) { + CMNamedNodeMap attrMap = elementDecl.getAttributes(); + Iterator it = attrMap.iterator(); + CMAttributeDeclaration attr = null; + while (it.hasNext()) { + attr = (CMAttributeDeclaration) it.next(); + if (attr.getUsage() == CMAttributeDeclaration.REQUIRED) { + result.add(attr); + } + } + } + } + + return result; + } +}
\ No newline at end of file diff --git a/bundles/org.eclipse.wst.html.core/src/org/eclipse/wst/html/core/cleanup/HTMLCleanupHandlerFactory.java b/bundles/org.eclipse.wst.html.core/src/org/eclipse/wst/html/core/cleanup/HTMLCleanupHandlerFactory.java new file mode 100644 index 0000000000..0935e7dd96 --- /dev/null +++ b/bundles/org.eclipse.wst.html.core/src/org/eclipse/wst/html/core/cleanup/HTMLCleanupHandlerFactory.java @@ -0,0 +1,119 @@ +/******************************************************************************* + * Copyright (c) 2004 IBM Corporation and others. + * All rights reserved. This program and the accompanying materials + * are made available under the terms of the Eclipse Public License v1.0 + * which accompanies this distribution, and is available at + * http://www.eclipse.org/legal/epl-v10.html + * + * Contributors: + * IBM Corporation - initial API and implementation + *******************************************************************************/ +package org.eclipse.wst.html.core.cleanup; + + + +import org.eclipse.wst.sse.core.cleanup.IStructuredCleanupHandler; +import org.eclipse.wst.sse.core.cleanup.IStructuredCleanupPreferences; +import org.eclipse.wst.sse.core.text.IStructuredDocumentRegion; +import org.eclipse.wst.xml.core.document.XMLNode; +import org.eclipse.wst.xml.core.jsp.model.parser.temp.XMLJSPRegionContexts; +import org.eclipse.wst.xml.core.parser.XMLRegionContext; +import org.w3c.dom.Node; + +// nakamori_TODO: check and remove CSS formatting + +class HTMLCleanupHandlerFactory { + + private static HTMLCleanupHandlerFactory fInstance = null; + + static synchronized HTMLCleanupHandlerFactory getInstance() { + if (fInstance == null) { + fInstance = new HTMLCleanupHandlerFactory(); + } + return fInstance; + } + + private HTMLCleanupHandlerFactory() { + super(); + } + + IStructuredCleanupHandler createHandler(Node node, IStructuredCleanupPreferences cleanupPreferences) { + short nodeType = node.getNodeType(); + IStructuredCleanupHandler handler = null; + switch (nodeType) { + case Node.ELEMENT_NODE : + { + if (isJSPTag(node)) + handler = new JSPElementNodeCleanupHandler(); + else + handler = new ElementNodeCleanupHandler(); + break; + } + case Node.TEXT_NODE : + { + if (isParentStyleTag(node)) + handler = new CSSTextNodeCleanupHandler(); + else + handler = new NodeCleanupHandler(); + break; + } + default : + { + handler = new NodeCleanupHandler(); + } + } + + handler.setCleanupPreferences(cleanupPreferences); + + return handler; + } + + private boolean isJSPTag(Node node) { + boolean result = false; + + if (node instanceof XMLNode) { + IStructuredDocumentRegion flatNode = ((XMLNode) node).getFirstStructuredDocumentRegion(); + // in some cases, the nodes exists, but hasn't been associated with + // a flatnode yet (the screen updates can be initiated on a different thread, + // so the request for a flatnode can come in before the node is fully formed. + // if the flatnode is null, we'll just allow the defaults to apply. + // (html adapter in this case). + if (flatNode != null) { + String flatNodeType = flatNode.getType(); + if ((flatNodeType == XMLJSPRegionContexts.JSP_CONTENT) || (flatNodeType == XMLJSPRegionContexts.JSP_EXPRESSION_OPEN) || (flatNodeType == XMLJSPRegionContexts.JSP_SCRIPTLET_OPEN) || (flatNodeType == XMLJSPRegionContexts.JSP_DECLARATION_OPEN) || (flatNodeType == XMLJSPRegionContexts.JSP_DIRECTIVE_CLOSE) || (flatNodeType == XMLJSPRegionContexts.JSP_DIRECTIVE_NAME) || (flatNodeType == XMLJSPRegionContexts.JSP_DIRECTIVE_OPEN) || (flatNodeType == XMLJSPRegionContexts.JSP_CLOSE)) { + result = true; + } + } + } + + return result; + } + + private boolean isParentStyleTag(Node node) { + if (node == null) + return false; + if (node.getNodeType() != Node.TEXT_NODE) + return false; + if (!(node instanceof XMLNode)) + return false; + IStructuredDocumentRegion flatNode = ((XMLNode) node).getFirstStructuredDocumentRegion(); + if (flatNode == null) + return false; + if (flatNode.getType() != XMLRegionContext.BLOCK_TEXT) + return false; + + // check if the parent is STYLE element + Node parent = node.getParentNode(); + if (parent == null) + return false; + if (parent.getNodeType() != Node.ELEMENT_NODE) + return false; + String name = parent.getNodeName(); + if (name == null) + return false; + if (!name.equalsIgnoreCase("STYLE"))//$NON-NLS-1$ + return false; + return true; + } + +}
\ No newline at end of file diff --git a/bundles/org.eclipse.wst.html.core/src/org/eclipse/wst/html/core/cleanup/HTMLCleanupProcessorImpl.java b/bundles/org.eclipse.wst.html.core/src/org/eclipse/wst/html/core/cleanup/HTMLCleanupProcessorImpl.java new file mode 100644 index 0000000000..3c7d6f700d --- /dev/null +++ b/bundles/org.eclipse.wst.html.core/src/org/eclipse/wst/html/core/cleanup/HTMLCleanupProcessorImpl.java @@ -0,0 +1,45 @@ +/******************************************************************************* + * Copyright (c) 2004 IBM Corporation and others. + * All rights reserved. This program and the accompanying materials + * are made available under the terms of the Eclipse Public License v1.0 + * which accompanies this distribution, and is available at + * http://www.eclipse.org/legal/epl-v10.html + * + * Contributors: + * IBM Corporation - initial API and implementation + *******************************************************************************/ +package org.eclipse.wst.html.core.cleanup; + +import org.eclipse.core.runtime.Preferences; +import org.eclipse.wst.common.encoding.content.IContentTypeIdentifier; +import org.eclipse.wst.html.core.HTMLCorePlugin; +import org.eclipse.wst.html.core.format.HTMLFormatProcessorImpl; +import org.eclipse.wst.sse.core.cleanup.IStructuredCleanupHandler; +import org.eclipse.wst.sse.core.format.IStructuredFormatProcessor; +import org.eclipse.wst.xml.core.cleanup.CleanupProcessorXML; +import org.w3c.dom.Node; + +public class HTMLCleanupProcessorImpl extends CleanupProcessorXML { + + /** + * @see com.ibm.sed.partitionCleanup.AbstractCleanupProcessorImpl#getContentType() + */ + protected String getContentType() { + return IContentTypeIdentifier.ContentTypeID_HTML; + } + + /** + * @see com.ibm.sed.partitionCleanup.AbstractCleanupProcessorImpl#getCleanupHandler(com.ibm.sed.model.xml.XMLNode) + */ + protected IStructuredCleanupHandler getCleanupHandler(Node node) { + return HTMLCleanupHandlerFactory.getInstance().createHandler(node, getCleanupPreferences()); + } + + protected IStructuredFormatProcessor getFormatProcessor() { + return new HTMLFormatProcessorImpl(); + } + + protected Preferences getModelPreferences() { + return HTMLCorePlugin.getDefault().getPluginPreferences(); + } +}
\ No newline at end of file diff --git a/bundles/org.eclipse.wst.html.core/src/org/eclipse/wst/html/core/cleanup/JSPElementNodeCleanupHandler.java b/bundles/org.eclipse.wst.html.core/src/org/eclipse/wst/html/core/cleanup/JSPElementNodeCleanupHandler.java new file mode 100644 index 0000000000..c4143ad35f --- /dev/null +++ b/bundles/org.eclipse.wst.html.core/src/org/eclipse/wst/html/core/cleanup/JSPElementNodeCleanupHandler.java @@ -0,0 +1,22 @@ +/******************************************************************************* + * Copyright (c) 2004 IBM Corporation and others. + * All rights reserved. This program and the accompanying materials + * are made available under the terms of the Eclipse Public License v1.0 + * which accompanies this distribution, and is available at + * http://www.eclipse.org/legal/epl-v10.html + * + * Contributors: + * IBM Corporation - initial API and implementation + *******************************************************************************/ +package org.eclipse.wst.html.core.cleanup; + + + +import org.w3c.dom.Node; + +public class JSPElementNodeCleanupHandler extends AbstractNodeCleanupHandler { + + public Node cleanup(Node node) { + return node; + } +}
\ No newline at end of file diff --git a/bundles/org.eclipse.wst.html.core/src/org/eclipse/wst/html/core/cleanup/NodeCleanupHandler.java b/bundles/org.eclipse.wst.html.core/src/org/eclipse/wst/html/core/cleanup/NodeCleanupHandler.java new file mode 100644 index 0000000000..1e9c7d265e --- /dev/null +++ b/bundles/org.eclipse.wst.html.core/src/org/eclipse/wst/html/core/cleanup/NodeCleanupHandler.java @@ -0,0 +1,22 @@ +/******************************************************************************* + * Copyright (c) 2004 IBM Corporation and others. + * All rights reserved. This program and the accompanying materials + * are made available under the terms of the Eclipse Public License v1.0 + * which accompanies this distribution, and is available at + * http://www.eclipse.org/legal/epl-v10.html + * + * Contributors: + * IBM Corporation - initial API and implementation + *******************************************************************************/ +package org.eclipse.wst.html.core.cleanup; + + + +import org.w3c.dom.Node; + +public class NodeCleanupHandler extends AbstractNodeCleanupHandler { + + public Node cleanup(Node node) { + return node; + } +}
\ No newline at end of file diff --git a/bundles/org.eclipse.wst.html.core/src/org/eclipse/wst/html/core/commentelement/handlers/CommentElementHandlerForSSI.java b/bundles/org.eclipse.wst.html.core/src/org/eclipse/wst/html/core/commentelement/handlers/CommentElementHandlerForSSI.java new file mode 100644 index 0000000000..f24b10800f --- /dev/null +++ b/bundles/org.eclipse.wst.html.core/src/org/eclipse/wst/html/core/commentelement/handlers/CommentElementHandlerForSSI.java @@ -0,0 +1,164 @@ +/******************************************************************************* + * Copyright (c) 2004 IBM Corporation and others. + * All rights reserved. This program and the accompanying materials + * are made available under the terms of the Eclipse Public License v1.0 + * which accompanies this distribution, and is available at + * http://www.eclipse.org/legal/epl-v10.html + * + * Contributors: + * IBM Corporation - initial API and implementation + *******************************************************************************/ +package org.eclipse.wst.html.core.commentelement.handlers; + + + +import org.eclipse.wst.common.contentmodel.CMDocument; +import org.eclipse.wst.common.contentmodel.CMNamedNodeMap; +import org.eclipse.wst.common.contentmodel.modelquery.ModelQuery; +import org.eclipse.wst.xml.core.commentelement.CommentElementHandler; +import org.eclipse.wst.xml.core.commentelement.util.CommentElementFactory; +import org.eclipse.wst.xml.core.commentelement.util.TagScanner; +import org.eclipse.wst.xml.core.document.XMLElement; +import org.eclipse.wst.xml.core.document.XMLGenerator; +import org.eclipse.wst.xml.core.modelquery.ModelQueryUtil; +import org.w3c.dom.Attr; +import org.w3c.dom.Document; +import org.w3c.dom.Element; +import org.w3c.dom.NamedNodeMap; + +/** + */ +public class CommentElementHandlerForSSI implements CommentElementHandler { + + /** + * @see com.ibm.sed.model.commentelement.CommentElementHandler#createElement(Document, String, boolean) + */ + public Element createElement(Document document, String data, boolean isJSPTag) { + ModelQuery modelQuery = ModelQueryUtil.getModelQuery(document); + if (modelQuery == null) { + return null; + } + CMDocument cm = modelQuery.getCorrespondingCMDocument(document); + if (cm == null) { + return null; + } + CMNamedNodeMap map = cm.getElements(); + if (map == null) { + return null; + } + + TagScanner scanner = new TagScanner(data, 1); + String name = scanner.nextName(); + if (name == null) { + return null; + } + StringBuffer buffer = new StringBuffer(name.length() + 4); + buffer.append(SSI_PREFIX); + buffer.append(':'); + buffer.append(name); + String tagName = buffer.toString(); + // check if valid (defined) SSI tag or not + if (map.getNamedItem(tagName) == null) { + return null; + } + + CommentElementFactory factory = new CommentElementFactory(document, isJSPTag, this); + Element element = factory.create(tagName, CommentElementFactory.IS_START); + + // set attributes + String attrName = scanner.nextName(); + while (attrName != null) { + String attrValue = scanner.nextValue(); + Attr attr = document.createAttribute(attrName); + if (attr != null) { + if (attrValue != null) + attr.setValue(attrValue); + element.setAttributeNode(attr); + } + attrName = scanner.nextName(); + } + return element; + } + + /** + * @see com.ibm.sed.model.commentelement.CommentElementHandler#generateStartTagContent(XMLElement) + */ + public String generateStartTagContent(XMLElement element) { + XMLGenerator generator = element.getModel().getGenerator(); + StringBuffer buffer = new StringBuffer(); + + buffer.append('#'); + buffer.append(element.getLocalName()); + + NamedNodeMap attributes = element.getAttributes(); + int length = attributes.getLength(); + for (int i = 0; i < length; i++) { + Attr attr = (Attr) attributes.item(i); + if (attr == null) { + continue; + } + buffer.append(' '); + String attrName = generator.generateAttrName(attr); + if (attrName != null) { + buffer.append(attrName); + } + String attrValue = generator.generateAttrValue(attr); + if (attrValue != null) { + // attr name only for HTML boolean and JSP + buffer.append('='); + buffer.append(attrValue); + } + } + + return buffer.toString(); + } + + /** + * @see com.ibm.sed.model.commentelement.CommentElementHandler#generateEndTagContent(XMLElement) + */ + public String generateEndTagContent(XMLElement element) { + return null; // always empty + } + + public boolean isEmpty() { + return true; + } + + /* (non-Javadoc) + * @see com.ibm.sed.model.commentelement.CommentElementHandler#isCommentElement(com.ibm.sed.model.xml.XMLElement) + */ + public boolean isCommentElement(XMLElement element) { + if (element == null) { + return false; + } + Document document = element.getOwnerDocument(); + ModelQuery modelQuery = ModelQueryUtil.getModelQuery(document); + if (modelQuery == null) { + return false; + } + CMDocument cm = modelQuery.getCorrespondingCMDocument(document); + if (cm == null) { + return false; + } + CMNamedNodeMap map = cm.getElements(); + if (map == null) { + return false; + } + String prefix = element.getPrefix(); + if (prefix == null || !prefix.equals(SSI_PREFIX)) { + return false; + } + String tagName = element.getTagName(); + if (tagName.length() <= 4) { + return false; + } + if (map.getNamedItem(tagName) == null) { + return false; + } + else { + return true; + } + } + + private static final String SSI_PREFIX = "ssi";//$NON-NLS-1$ +}
\ No newline at end of file diff --git a/bundles/org.eclipse.wst.html.core/src/org/eclipse/wst/html/core/contentmodel/AttributeCollection.java b/bundles/org.eclipse.wst.html.core/src/org/eclipse/wst/html/core/contentmodel/AttributeCollection.java new file mode 100644 index 0000000000..435e8ccc82 --- /dev/null +++ b/bundles/org.eclipse.wst.html.core/src/org/eclipse/wst/html/core/contentmodel/AttributeCollection.java @@ -0,0 +1,1295 @@ +/******************************************************************************* + * Copyright (c) 2004 IBM Corporation and others. + * All rights reserved. This program and the accompanying materials + * are made available under the terms of the Eclipse Public License v1.0 + * which accompanies this distribution, and is available at + * http://www.eclipse.org/legal/epl-v10.html + * + * Contributors: + * IBM Corporation - initial API and implementation + *******************************************************************************/ +package org.eclipse.wst.html.core.contentmodel; + + + +import java.util.Arrays; +import java.util.Iterator; + +import org.eclipse.wst.common.contentmodel.CMAttributeDeclaration; +import org.eclipse.wst.common.contentmodel.CMDataType; +import org.eclipse.wst.common.contentmodel.CMNode; +import org.eclipse.wst.html.core.HTML40Namespace; + +/** + * Factory for attribute declarations. + */ +final class AttributeCollection extends CMNamedNodeMapImpl implements HTML40Namespace { + + /** bodycolors. */ + private static final String[] BODYCOLORS = {ATTR_NAME_BGCOLOR, ATTR_NAME_TEXT, ATTR_NAME_LINK, ATTR_NAME_VLINK, HTML40Namespace.ATTR_NAME_ALINK}; + /** coreattrs. */ + private static final String[] CORE = {ATTR_NAME_ID, ATTR_NAME_CLASS, ATTR_NAME_STYLE, ATTR_NAME_TITLE}; + /** events. */ + private static final String[] EVENTS = {ATTR_NAME_ONCLICK, ATTR_NAME_ONDBLCLICK, ATTR_NAME_ONMOUSEDOWN, ATTR_NAME_ONMOUSEUP, ATTR_NAME_ONMOUSEOVER, ATTR_NAME_ONMOUSEMOVE, ATTR_NAME_ONMOUSEOUT, ATTR_NAME_ONKEYPRESS, ATTR_NAME_ONKEYDOWN, ATTR_NAME_ONKEYUP, ATTR_NAME_ONHELP}; + /** i18n. lang, dir */ + private static final String[] I18N = {ATTR_NAME_LANG, ATTR_NAME_DIR}; + /** cellhaligh. */ + private static final String[] CELLHALIGN = {ATTR_NAME_CHAR, ATTR_NAME_CHAROFF}; + + /** + * constructor. + */ + public AttributeCollection() { + super(); + } + + /** + * Create an attribute declaration. + * @return com.ibm.sed.contentmodel.html.HTMLAttrDeclImpl + * @param attrName java.lang.String + */ + private HTMLAttrDeclImpl create(String attrName) { + HTMLAttrDeclImpl attr = null; + HTMLCMDataTypeImpl atype = null; + + if (attrName.equalsIgnoreCase(ATTR_NAME_ABBR)) { + // (abbr %Text; #IMPLIED) + atype = new HTMLCMDataTypeImpl(HTMLCMDataType.TEXT); + attr = new HTMLAttrDeclImpl(ATTR_NAME_ABBR, atype, CMAttributeDeclaration.OPTIONAL); + + } + else if (attrName.equalsIgnoreCase(ATTR_NAME_ACCEPT)) { + // (accept %ContentTypes; #IMPLIED) + atype = new HTMLCMDataTypeImpl(HTMLCMDataType.CONTENT_TYPE); + attr = new HTMLAttrDeclImpl(ATTR_NAME_ACCEPT, atype, CMAttributeDeclaration.OPTIONAL); + + } + else if (attrName.equalsIgnoreCase(ATTR_NAME_ACCEPT_CHARSET)) { + // (accept-charset %Charsets;; #IMPLIED) + atype = new HTMLCMDataTypeImpl(HTMLCMDataType.CHARSETS); + attr = new HTMLAttrDeclImpl(ATTR_NAME_ACCEPT_CHARSET, atype, CMAttributeDeclaration.OPTIONAL); + + } + else if (attrName.equalsIgnoreCase(ATTR_NAME_ACTION)) { + // (action %URI #REQUIRED) + atype = new HTMLCMDataTypeImpl(CMDataType.URI); + attr = new HTMLAttrDeclImpl(ATTR_NAME_ACTION, atype, CMAttributeDeclaration.REQUIRED); + + } + else if (attrName.equalsIgnoreCase(ATTR_NAME_ARCHIVE)) { + // (archive CDATA #IMPLIED) + atype = new HTMLCMDataTypeImpl(CMDataType.CDATA); + attr = new HTMLAttrDeclImpl(ATTR_NAME_ARCHIVE, atype, CMAttributeDeclaration.OPTIONAL); + + } + else if (attrName.equalsIgnoreCase(ATTR_NAME_ACCESSKEY)) { + // (accesskey %Character; #IMPLIED) + atype = new HTMLCMDataTypeImpl(HTMLCMDataType.CHARACTER); + attr = new HTMLAttrDeclImpl(ATTR_NAME_ACCESSKEY, atype, CMAttributeDeclaration.OPTIONAL); + + } + else if (attrName.equalsIgnoreCase(ATTR_NAME_ALINK)) { + // (alink %Color; #IMPLIED) + atype = new HTMLCMDataTypeImpl(HTMLCMDataType.COLOR); + attr = new HTMLAttrDeclImpl(ATTR_NAME_ALINK, atype, CMAttributeDeclaration.OPTIONAL); + + } + else if (attrName.equalsIgnoreCase(ATTR_NAME_ALT)) { + // (alt %Text; #REQUIRED) + atype = new HTMLCMDataTypeImpl(HTMLCMDataType.TEXT); + attr = new HTMLAttrDeclImpl(ATTR_NAME_ALT, atype, CMAttributeDeclaration.REQUIRED); + + } + else if (attrName.equalsIgnoreCase(ATTR_NAME_AUTOSTART)) { + // (autostart (true|false) #IMPLIED) + atype = new HTMLCMDataTypeImpl(CMDataType.ENUM); + String[] values = {ATTR_VALUE_TRUE, ATTR_VALUE_FALSE}; + atype.setEnumValues(values); + attr = new HTMLAttrDeclImpl(ATTR_NAME_AUTOSTART, atype, CMAttributeDeclaration.OPTIONAL); + + } + else if (attrName.equalsIgnoreCase(ATTR_NAME_AUTOPLAY)) { + // (autoplay (true|false) #IMPLIED) + atype = new HTMLCMDataTypeImpl(CMDataType.ENUM); + String[] values = {ATTR_VALUE_TRUE, ATTR_VALUE_FALSE}; + atype.setEnumValues(values); + attr = new HTMLAttrDeclImpl(ATTR_NAME_AUTOPLAY, atype, CMAttributeDeclaration.OPTIONAL); + + } + else if (attrName.equalsIgnoreCase(ATTR_NAME_AUTOSIZE)) { + // (autosize (true|false) #IMPLIED) + atype = new HTMLCMDataTypeImpl(CMDataType.ENUM); + String[] values = {ATTR_VALUE_TRUE, ATTR_VALUE_FALSE}; + atype.setEnumValues(values); + attr = new HTMLAttrDeclImpl(ATTR_NAME_AUTOSIZE, atype, CMAttributeDeclaration.OPTIONAL); + + } + else if (attrName.equalsIgnoreCase(ATTR_NAME_AXIS)) { + // (axis CDATA #IMPLIED) + atype = new HTMLCMDataTypeImpl(CMDataType.CDATA); + attr = new HTMLAttrDeclImpl(ATTR_NAME_AXIS, atype, CMAttributeDeclaration.OPTIONAL); + + } + else if (attrName.equalsIgnoreCase(ATTR_NAME_BACKGROUND)) { + // (background %URI; #IMPLIED) + atype = new HTMLCMDataTypeImpl(CMDataType.URI); + attr = new HTMLAttrDeclImpl(ATTR_NAME_BACKGROUND, atype, CMAttributeDeclaration.OPTIONAL); + + } + else if (attrName.equalsIgnoreCase(ATTR_NAME_BEHAVIOR)) { + // (behavior (scroll|slide|alternate) scroll) + atype = new HTMLCMDataTypeImpl(CMDataType.ENUM); + String[] values = {ATTR_VALUE_SCROLL, ATTR_VALUE_SLIDE, ATTR_VALUE_ALTERNATE}; + atype.setEnumValues(values); + atype.setImpliedValue(CMDataType.IMPLIED_VALUE_DEFAULT, ATTR_VALUE_SCROLL); + attr = new HTMLAttrDeclImpl(ATTR_NAME_BEHAVIOR, atype, CMAttributeDeclaration.OPTIONAL); + + } + else if (attrName.equalsIgnoreCase(ATTR_NAME_BGCOLOR)) { + // (bgcolor %Color; #IMPLIED) + atype = new HTMLCMDataTypeImpl(HTMLCMDataType.COLOR); + attr = new HTMLAttrDeclImpl(ATTR_NAME_BGCOLOR, atype, CMAttributeDeclaration.OPTIONAL); + + } + else if (attrName.equalsIgnoreCase(ATTR_NAME_BORDER)) { + // (border %Pixels; #IMPLIED) + atype = new HTMLCMDataTypeImpl(HTMLCMDataType.PIXELS); + attr = new HTMLAttrDeclImpl(ATTR_NAME_BORDER, atype, CMAttributeDeclaration.OPTIONAL); + + } + else if (attrName.equalsIgnoreCase(ATTR_NAME_CELLSPACING)) { + // (cellspacing %Length; #IMPLIED) + atype = new HTMLCMDataTypeImpl(HTMLCMDataType.LENGTH); + attr = new HTMLAttrDeclImpl(ATTR_NAME_CELLSPACING, atype, CMAttributeDeclaration.OPTIONAL); + + } + else if (attrName.equalsIgnoreCase(ATTR_NAME_CELLPADDING)) { + // (cellpadding %Length; #IMPLIED) + atype = new HTMLCMDataTypeImpl(HTMLCMDataType.LENGTH); + attr = new HTMLAttrDeclImpl(ATTR_NAME_CELLPADDING, atype, CMAttributeDeclaration.OPTIONAL); + + } + else if (attrName.equalsIgnoreCase(ATTR_NAME_CGI)) { + // (cgi %URI; #IMPLIED) + atype = new HTMLCMDataTypeImpl(CMDataType.URI); + attr = new HTMLAttrDeclImpl(ATTR_NAME_CGI, atype, CMAttributeDeclaration.OPTIONAL); + + } + else if (attrName.equalsIgnoreCase(ATTR_NAME_CHAR)) { + // (char %Character; #IMPLIED) + atype = new HTMLCMDataTypeImpl(HTMLCMDataType.CHARACTER); + attr = new HTMLAttrDeclImpl(ATTR_NAME_CHAR, atype, CMAttributeDeclaration.OPTIONAL); + + } + else if (attrName.equalsIgnoreCase(ATTR_NAME_CHAROFF)) { + // (charoff %Length; #IMPLIED) + atype = new HTMLCMDataTypeImpl(HTMLCMDataType.LENGTH); + attr = new HTMLAttrDeclImpl(ATTR_NAME_CHAROFF, atype, CMAttributeDeclaration.OPTIONAL); + + } + else if (attrName.equalsIgnoreCase(ATTR_NAME_CHARSET)) { + // (charset %Charset; #IMPLIED) + atype = new HTMLCMDataTypeImpl(HTMLCMDataType.CHARSET); + attr = new HTMLAttrDeclImpl(ATTR_NAME_CHARSET, atype, CMAttributeDeclaration.OPTIONAL); + + } + else if (attrName.equalsIgnoreCase(ATTR_NAME_CITE)) { + // (cite %URI; #IMPLIED) + atype = new HTMLCMDataTypeImpl(CMDataType.URI); + attr = new HTMLAttrDeclImpl(ATTR_NAME_CITE, atype, CMAttributeDeclaration.OPTIONAL); + + } + else if (attrName.equalsIgnoreCase(ATTR_NAME_CLASS)) { + // (class CDATA #IMPLIED) + atype = new HTMLCMDataTypeImpl(CMDataType.CDATA); + attr = new HTMLAttrDeclImpl(ATTR_NAME_CLASS, atype, CMAttributeDeclaration.OPTIONAL); + + } + else if (attrName.equalsIgnoreCase(ATTR_NAME_CLASSID)) { + // (classid %URI #IMPLIED) + atype = new HTMLCMDataTypeImpl(CMDataType.URI); + attr = new HTMLAttrDeclImpl(ATTR_NAME_CLASSID, atype, CMAttributeDeclaration.OPTIONAL); + + } + else if (attrName.equalsIgnoreCase(ATTR_NAME_CMD)) { + // (cmd CDATA #IMPLIED) + atype = new HTMLCMDataTypeImpl(CMDataType.CDATA); + attr = new HTMLAttrDeclImpl(ATTR_NAME_CMD, atype, CMAttributeDeclaration.OPTIONAL); + + } + else if (attrName.equalsIgnoreCase(ATTR_NAME_CHECKED)) { + // (checked (checked) #IMPLIED) + atype = new HTMLCMDataTypeImpl(CMDataType.ENUM); + String[] values = {ATTR_NAME_CHECKED}; + atype.setEnumValues(values); + attr = new HTMLAttrDeclImpl(ATTR_NAME_CHECKED, atype, CMAttributeDeclaration.OPTIONAL); + + } + else if (attrName.equalsIgnoreCase(ATTR_NAME_CLEAR)) { + // (clear (left | all | right | none) none) + atype = new HTMLCMDataTypeImpl(CMDataType.ENUM); + String[] values = {ATTR_VALUE_LEFT, ATTR_VALUE_ALL, ATTR_VALUE_RIGHT, ATTR_VALUE_NONE}; + atype.setEnumValues(values); + atype.setImpliedValue(CMDataType.IMPLIED_VALUE_DEFAULT, ATTR_VALUE_NONE); + + attr = new HTMLAttrDeclImpl(ATTR_NAME_CLEAR, atype, CMAttributeDeclaration.OPTIONAL); + + } + else if (attrName.equalsIgnoreCase(ATTR_NAME_CODE)) { + // (code CDATA #IMPLIED) + atype = new HTMLCMDataTypeImpl(CMDataType.CDATA); + attr = new HTMLAttrDeclImpl(ATTR_NAME_CODE, atype, CMAttributeDeclaration.OPTIONAL); + + } + else if (attrName.equalsIgnoreCase(ATTR_NAME_CODEBASE)) { + // (codebase %URI; #IMPLIED) + atype = new HTMLCMDataTypeImpl(CMDataType.URI); + attr = new HTMLAttrDeclImpl(ATTR_NAME_CODEBASE, atype, CMAttributeDeclaration.OPTIONAL); + + } + else if (attrName.equalsIgnoreCase(ATTR_NAME_CODETYPE)) { + // (codetype %CotentType; #IMPLIED) + atype = new HTMLCMDataTypeImpl(HTMLCMDataType.CONTENT_TYPE); + attr = new HTMLAttrDeclImpl(ATTR_NAME_CODETYPE, atype, CMAttributeDeclaration.OPTIONAL); + + } + else if (attrName.equalsIgnoreCase(ATTR_NAME_COLOR)) { + // (color %Color; #IMPLIED) + atype = new HTMLCMDataTypeImpl(HTMLCMDataType.COLOR); + attr = new HTMLAttrDeclImpl(ATTR_NAME_COLOR, atype, CMAttributeDeclaration.OPTIONAL); + + } + else if (attrName.equalsIgnoreCase(ATTR_NAME_COMPACT)) { + // (compact (compact) #IMPLIED) + atype = new HTMLCMDataTypeImpl(CMDataType.ENUM); + String[] values = {ATTR_NAME_COMPACT}; + atype.setEnumValues(values); + attr = new HTMLAttrDeclImpl(ATTR_NAME_COMPACT, atype, CMAttributeDeclaration.OPTIONAL); + + } + else if (attrName.equalsIgnoreCase(ATTR_NAME_COLS)) { + // (cols NUMBER #REQUIRED) + atype = new HTMLCMDataTypeImpl(CMDataType.NUMBER); + attr = new HTMLAttrDeclImpl(ATTR_NAME_COLS, atype, CMAttributeDeclaration.REQUIRED); + + } + else if (attrName.equalsIgnoreCase(ATTR_NAME_COLSPAN)) { + // (colspan NUMBER 1) + atype = new HTMLCMDataTypeImpl(CMDataType.NUMBER); + atype.setImpliedValue(CMDataType.IMPLIED_VALUE_DEFAULT, ATTR_VALUE_1); + attr = new HTMLAttrDeclImpl(ATTR_NAME_COLSPAN, atype, CMAttributeDeclaration.OPTIONAL); + + } + else if (attrName.equalsIgnoreCase(ATTR_NAME_CONTENT)) { + // (content CDATA #REQUIRED) + atype = new HTMLCMDataTypeImpl(CMDataType.CDATA); + attr = new HTMLAttrDeclImpl(ATTR_NAME_CONTENT, atype, CMAttributeDeclaration.REQUIRED); + + } + else if (attrName.equalsIgnoreCase(ATTR_NAME_CONTROLLER)) { + // (controller (true|false) true) + atype = new HTMLCMDataTypeImpl(CMDataType.ENUM); + String[] values = {ATTR_VALUE_TRUE, ATTR_VALUE_FALSE}; + atype.setEnumValues(values); + atype.setImpliedValue(CMDataType.IMPLIED_VALUE_DEFAULT, ATTR_VALUE_TRUE); + attr = new HTMLAttrDeclImpl(ATTR_NAME_CONTROLLER, atype, CMAttributeDeclaration.OPTIONAL); + + } + else if (attrName.equalsIgnoreCase(ATTR_NAME_COORDS)) { + // (coords %Coords; #IMPLIED) + atype = new HTMLCMDataTypeImpl(HTMLCMDataType.COORDS); + attr = new HTMLAttrDeclImpl(ATTR_NAME_COORDS, atype, CMAttributeDeclaration.OPTIONAL); + + } + else if (attrName.equalsIgnoreCase(ATTR_NAME_DATA)) { + // (data %URI; #IMPLIED) + atype = new HTMLCMDataTypeImpl(CMDataType.URI); + attr = new HTMLAttrDeclImpl(ATTR_NAME_DATA, atype, CMAttributeDeclaration.OPTIONAL); + + } + else if (attrName.equalsIgnoreCase(ATTR_NAME_DATETIME)) { + // (datetime %Datetime; #IMPLIED) + atype = new HTMLCMDataTypeImpl(HTMLCMDataType.DATETIME); + attr = new HTMLAttrDeclImpl(ATTR_NAME_DATETIME, atype, CMAttributeDeclaration.OPTIONAL); + + } + else if (attrName.equalsIgnoreCase(ATTR_NAME_DATAPAGESIZE)) { + // (datapagesize CDATA #IMPLIED) + atype = new HTMLCMDataTypeImpl(CMDataType.CDATA); + attr = new HTMLAttrDeclImpl(ATTR_NAME_DATAPAGESIZE, atype, CMAttributeDeclaration.OPTIONAL); + + } + else if (attrName.equalsIgnoreCase(ATTR_NAME_DECLARE)) { + // (declare (declare) #IMPLIED) + atype = new HTMLCMDataTypeImpl(CMDataType.ENUM); + String[] values = {ATTR_NAME_DECLARE}; + atype.setEnumValues(values); + attr = new HTMLAttrDeclImpl(ATTR_NAME_DECLARE, atype, CMAttributeDeclaration.OPTIONAL); + + } + else if (attrName.equalsIgnoreCase(ATTR_NAME_DEFER)) { + // (defer (defer) #IMPLIED) + atype = new HTMLCMDataTypeImpl(CMDataType.ENUM); + String[] values = {ATTR_NAME_DEFER}; + atype.setEnumValues(values); + attr = new HTMLAttrDeclImpl(ATTR_NAME_DEFER, atype, CMAttributeDeclaration.OPTIONAL); + + } + else if (attrName.equalsIgnoreCase(ATTR_NAME_DIR)) { + // (dir (ltr|rtl) #IMPLIED) + atype = new HTMLCMDataTypeImpl(CMDataType.ENUM); + String[] values = {ATTR_VALUE_LTR, ATTR_VALUE_RTL}; + atype.setEnumValues(values); + attr = new HTMLAttrDeclImpl(ATTR_NAME_DIR, atype, CMAttributeDeclaration.OPTIONAL); + + } + else if (attrName.equalsIgnoreCase(ATTR_NAME_DIRECTION)) { + // (direction (left|right|up|down) left) + atype = new HTMLCMDataTypeImpl(CMDataType.ENUM); + String[] values = {ATTR_VALUE_LEFT, ATTR_VALUE_RIGHT, ATTR_VALUE_UP, ATTR_VALUE_DOWN}; + atype.setEnumValues(values); + attr = new HTMLAttrDeclImpl(ATTR_NAME_DIRECTION, atype, CMAttributeDeclaration.OPTIONAL); + + } + else if (attrName.equalsIgnoreCase(ATTR_NAME_DIRECTKEY)) { + // (directkey %Character; #IMPLIED) + atype = new HTMLCMDataTypeImpl(HTMLCMDataType.CHARACTER); + attr = new HTMLAttrDeclImpl(ATTR_NAME_DIRECTKEY, atype, CMAttributeDeclaration.OPTIONAL); + + } + else if (attrName.equalsIgnoreCase(ATTR_NAME_DISABLED)) { + // (disabled (disabled) #IMPLIED) + atype = new HTMLCMDataTypeImpl(CMDataType.ENUM); + // boolean attribute must have the same value as its name. + String[] values = {ATTR_NAME_DISABLED}; + atype.setEnumValues(values); + attr = new HTMLAttrDeclImpl(ATTR_NAME_DISABLED, atype, CMAttributeDeclaration.OPTIONAL); + + } + else if (attrName.equalsIgnoreCase(ATTR_NAME_ENCTYPE)) { + // (enctype %ContentType; "application/x-www-form-urlencoded") + atype = new HTMLCMDataTypeImpl(HTMLCMDataType.CONTENT_TYPE); + atype.setImpliedValue(CMDataType.IMPLIED_VALUE_DEFAULT, ATTR_VALUE_WWW_FORM_URLENCODED); + attr = new HTMLAttrDeclImpl(ATTR_NAME_ENCTYPE, atype, CMAttributeDeclaration.OPTIONAL); + + } + else if (attrName.equalsIgnoreCase(ATTR_NAME_ERRMSG)) { + // (errmsg CDATA #IMPLIED) + atype = new HTMLCMDataTypeImpl(CMDataType.CDATA); + attr = new HTMLAttrDeclImpl(ATTR_NAME_ERRMSG, atype, CMAttributeDeclaration.OPTIONAL); + + } + else if (attrName.equalsIgnoreCase(ATTR_NAME_EVENT)) { + // (event CDATA #IMPLIED) + atype = new HTMLCMDataTypeImpl(CMDataType.CDATA); + attr = new HTMLAttrDeclImpl(ATTR_NAME_EVENT, atype, CMAttributeDeclaration.OPTIONAL); + + } + else if (attrName.equalsIgnoreCase(ATTR_NAME_FACE)) { + // (face CDATA #IMPLIED) + atype = new HTMLCMDataTypeImpl(CMDataType.CDATA); + attr = new HTMLAttrDeclImpl(ATTR_NAME_FACE, atype, CMAttributeDeclaration.OPTIONAL); + + } + else if (attrName.equalsIgnoreCase(ATTR_NAME_FILE)) { + // (file %URI; #IMPLIED) + atype = new HTMLCMDataTypeImpl(CMDataType.URI); + attr = new HTMLAttrDeclImpl(ATTR_NAME_FILE, atype, CMAttributeDeclaration.OPTIONAL); + + } + else if (attrName.equalsIgnoreCase(ATTR_NAME_FOR)) { + // (for %URI; #IMPLIED) + atype = new HTMLCMDataTypeImpl(CMDataType.URI); + attr = new HTMLAttrDeclImpl(ATTR_NAME_FOR, atype, CMAttributeDeclaration.OPTIONAL); + + } + else if (attrName.equalsIgnoreCase(ATTR_NAME_FRAME)) { + // (frame %TFrame; #IMPLIED) + // %TFrame; is (void|above|below|hsides|lhs|rhs|vsides|box|border). + atype = new HTMLCMDataTypeImpl(CMDataType.ENUM); + String[] values = {ATTR_VALUE_VOID, ATTR_VALUE_ABOVE, ATTR_VALUE_BELOW, ATTR_VALUE_HSIDES, ATTR_VALUE_LHS, ATTR_VALUE_RHS, ATTR_VALUE_VSIDES, ATTR_VALUE_BOX, ATTR_VALUE_BORDER}; + atype.setEnumValues(values); + attr = new HTMLAttrDeclImpl(ATTR_NAME_FRAME, atype, CMAttributeDeclaration.OPTIONAL); + + } + else if (attrName.equalsIgnoreCase(ATTR_NAME_FRAMEBORDER)) { + // (frameborder (1|0) 1) + atype = new HTMLCMDataTypeImpl(CMDataType.ENUM); + String[] values = {ATTR_VALUE_1, ATTR_VALUE_0}; + atype.setEnumValues(values); + atype.setImpliedValue(CMDataType.IMPLIED_VALUE_DEFAULT, ATTR_VALUE_1); + attr = new HTMLAttrDeclImpl(ATTR_NAME_FRAMEBORDER, atype, CMAttributeDeclaration.OPTIONAL); + + //<<D215684 + } + else if (attrName.equalsIgnoreCase(ATTR_NAME_FRAMESPACING)) { + // (framespacing CDATA; #IMPLIED) + atype = new HTMLCMDataTypeImpl(CMDataType.CDATA); + attr = new HTMLAttrDeclImpl(ATTR_NAME_FRAMESPACING, atype, CMAttributeDeclaration.OPTIONAL); + //D215684 + } + else if (attrName.equalsIgnoreCase(ATTR_NAME_HEADERS)) { + // (HEADERS IDREFS; #IMPLIED) + atype = new HTMLCMDataTypeImpl(HTMLCMDataType.IDREFS); + attr = new HTMLAttrDeclImpl(ATTR_NAME_HEADERS, atype, CMAttributeDeclaration.OPTIONAL); + + } + else if (attrName.equalsIgnoreCase(ATTR_NAME_HEIGHT)) { + // (height %Length; #IMPLIED) + atype = new HTMLCMDataTypeImpl(HTMLCMDataType.LENGTH); + attr = new HTMLAttrDeclImpl(ATTR_NAME_HEIGHT, atype, CMAttributeDeclaration.OPTIONAL); + + } + else if (attrName.equalsIgnoreCase(ATTR_NAME_HIDDEN)) { + // (hidden CDATA #IMPLIED) + atype = new HTMLCMDataTypeImpl(CMDataType.CDATA); + attr = new HTMLAttrDeclImpl(ATTR_NAME_HIDDEN, atype, CMAttributeDeclaration.OPTIONAL); + + } + else if (attrName.equalsIgnoreCase(ATTR_NAME_HREF)) { + // (href %URI; #IMPLIED) + atype = new HTMLCMDataTypeImpl(CMDataType.URI); + attr = new HTMLAttrDeclImpl(ATTR_NAME_HREF, atype, CMAttributeDeclaration.OPTIONAL); + + } + else if (attrName.equalsIgnoreCase(ATTR_NAME_HREFLANG)) { + // (hreflang %LanguageCode; #IMPLIED) + atype = new HTMLCMDataTypeImpl(HTMLCMDataType.LANGUAGE_CODE); + attr = new HTMLAttrDeclImpl(ATTR_NAME_HREFLANG, atype, CMAttributeDeclaration.OPTIONAL); + + } + else if (attrName.equalsIgnoreCase(ATTR_NAME_HSPACE)) { + // (hspace %Pixels; #IMPLIED) + atype = new HTMLCMDataTypeImpl(HTMLCMDataType.PIXELS); + attr = new HTMLAttrDeclImpl(ATTR_NAME_HSPACE, atype, CMAttributeDeclaration.OPTIONAL); + + } + else if (attrName.equalsIgnoreCase(ATTR_NAME_HTTP_EQUIV)) { + // (http-equiv NAME #IMPLIED) + atype = new HTMLCMDataTypeImpl(HTMLCMDataType.NAME); + attr = new HTMLAttrDeclImpl(ATTR_NAME_HTTP_EQUIV, atype, CMAttributeDeclaration.OPTIONAL); + + } + else if (attrName.equalsIgnoreCase(ATTR_NAME_ID)) { + // (id ID #IMPLIED) + atype = new HTMLCMDataTypeImpl(CMDataType.ID); + attr = new HTMLAttrDeclImpl(ATTR_NAME_ID, atype, CMAttributeDeclaration.OPTIONAL); + + } + else if (attrName.equalsIgnoreCase(ATTR_NAME_ISMAP)) { + // (ismap (ismap) #IMPLIED) + atype = new HTMLCMDataTypeImpl(CMDataType.ENUM); + String[] values = {ATTR_NAME_ISMAP}; + atype.setEnumValues(values); + attr = new HTMLAttrDeclImpl(ATTR_NAME_ISMAP, atype, CMAttributeDeclaration.OPTIONAL); + + } + else if (attrName.equalsIgnoreCase(ATTR_NAME_ISTYLE)) { + // (istyle CDATA #IMPLIED) + atype = new HTMLCMDataTypeImpl(CMDataType.CDATA); + attr = new HTMLAttrDeclImpl(ATTR_NAME_ISTYLE, atype, CMAttributeDeclaration.OPTIONAL); + + } + else if (attrName.equalsIgnoreCase(ATTR_NAME_LABEL)) { + // (label %Text; #IMPLIED) + atype = new HTMLCMDataTypeImpl(HTMLCMDataType.TEXT); + attr = new HTMLAttrDeclImpl(ATTR_NAME_LABEL, atype, CMAttributeDeclaration.OPTIONAL); + + } + else if (attrName.equalsIgnoreCase(ATTR_NAME_LANG)) { + // (lang %LanguageCode; #IMPLIED) + atype = new HTMLCMDataTypeImpl(HTMLCMDataType.LANGUAGE_CODE); + attr = new HTMLAttrDeclImpl(ATTR_NAME_LANG, atype, CMAttributeDeclaration.OPTIONAL); + + } + else if (attrName.equalsIgnoreCase(ATTR_NAME_LANGUAGE)) { + // (language %CDATA; #IMPLIED) + atype = new HTMLCMDataTypeImpl(CMDataType.CDATA); + attr = new HTMLAttrDeclImpl(ATTR_NAME_LANGUAGE, atype, CMAttributeDeclaration.OPTIONAL); + + } + else if (attrName.equalsIgnoreCase(ATTR_NAME_LINK)) { + // (link %Color; #IMPLIED) + atype = new HTMLCMDataTypeImpl(HTMLCMDataType.COLOR); + attr = new HTMLAttrDeclImpl(ATTR_NAME_LINK, atype, CMAttributeDeclaration.OPTIONAL); + + } + else if (attrName.equalsIgnoreCase(ATTR_NAME_LONGDESC)) { + // (longdesc %URI; #IMPLIED) + atype = new HTMLCMDataTypeImpl(CMDataType.URI); + attr = new HTMLAttrDeclImpl(ATTR_NAME_LONGDESC, atype, CMAttributeDeclaration.OPTIONAL); + + } + else if (attrName.equalsIgnoreCase(ATTR_NAME_LOOP)) { + // (loop CDATA #IMPLIED) + atype = new HTMLCMDataTypeImpl(CMDataType.CDATA); + attr = new HTMLAttrDeclImpl(ATTR_NAME_LOOP, atype, CMAttributeDeclaration.OPTIONAL); + + } + else if (attrName.equalsIgnoreCase(ATTR_NAME_MACRO)) { + // (macro CDATA #IMPLIED) + atype = new HTMLCMDataTypeImpl(CMDataType.CDATA); + attr = new HTMLAttrDeclImpl(ATTR_NAME_MACRO, atype, CMAttributeDeclaration.OPTIONAL); + + } + else if (attrName.equalsIgnoreCase(ATTR_NAME_MAPFILE)) { + // (mapfile %URI; #IMPLIED) + atype = new HTMLCMDataTypeImpl(CMDataType.URI); + attr = new HTMLAttrDeclImpl(ATTR_NAME_MAPFILE, atype, CMAttributeDeclaration.OPTIONAL); + + } + else if (attrName.equalsIgnoreCase(ATTR_NAME_MARGINWIDTH)) { + // (marginwidth %Pixels; #IMPLIED) + atype = new HTMLCMDataTypeImpl(HTMLCMDataType.PIXELS); + attr = new HTMLAttrDeclImpl(ATTR_NAME_MARGINWIDTH, atype, CMAttributeDeclaration.OPTIONAL); + + } + else if (attrName.equalsIgnoreCase(ATTR_NAME_MARGINHEIGHT)) { + // (marginheight %Pixels; #IMPLIED) + atype = new HTMLCMDataTypeImpl(HTMLCMDataType.PIXELS); + attr = new HTMLAttrDeclImpl(ATTR_NAME_MARGINHEIGHT, atype, CMAttributeDeclaration.OPTIONAL); + + } + else if (attrName.equalsIgnoreCase(ATTR_NAME_MAXLENGTH)) { + // (maxlength NUMBER #IMPLIED) + atype = new HTMLCMDataTypeImpl(CMDataType.NUMBER); + attr = new HTMLAttrDeclImpl(ATTR_NAME_MAXLENGTH, atype, CMAttributeDeclaration.OPTIONAL); + + } + else if (attrName.equalsIgnoreCase(ATTR_NAME_MAYSCRIPT)) { + // (mayscript (mayscript) #IMPLIED) + atype = new HTMLCMDataTypeImpl(CMDataType.ENUM); + String[] values = {ATTR_NAME_MAYSCRIPT}; + atype.setEnumValues(values); + attr = new HTMLAttrDeclImpl(ATTR_NAME_MAYSCRIPT, atype, CMAttributeDeclaration.OPTIONAL); + + } + else if (attrName.equalsIgnoreCase(ATTR_NAME_MEDIA)) { + // (media %MediaDesc; #IMPLIED) + atype = new HTMLCMDataTypeImpl(HTMLCMDataType.MEDIA_DESC); + attr = new HTMLAttrDeclImpl(ATTR_NAME_MEDIA, atype, CMAttributeDeclaration.OPTIONAL); + + } + else if (attrName.equalsIgnoreCase(ATTR_NAME_METHOD)) { + // (method (GET|POST) GET) + atype = new HTMLCMDataTypeImpl(CMDataType.ENUM); + String[] values = {ATTR_VALUE_GET, ATTR_VALUE_POST}; + atype.setEnumValues(values); + atype.setImpliedValue(CMDataType.IMPLIED_VALUE_DEFAULT, ATTR_VALUE_GET); + attr = new HTMLAttrDeclImpl(ATTR_NAME_METHOD, atype, CMAttributeDeclaration.OPTIONAL); + + } + else if (attrName.equalsIgnoreCase(ATTR_NAME_MULTIPLE)) { + // (multiple (multiple) #IMPLIED) + atype = new HTMLCMDataTypeImpl(CMDataType.ENUM); + String[] values = {ATTR_NAME_MULTIPLE}; + atype.setEnumValues(values); + attr = new HTMLAttrDeclImpl(ATTR_NAME_MULTIPLE, atype, CMAttributeDeclaration.OPTIONAL); + + } + else if (attrName.equalsIgnoreCase(ATTR_NAME_NAME)) { + // (name CDATA #IMPLIED) + atype = new HTMLCMDataTypeImpl(CMDataType.CDATA); + attr = new HTMLAttrDeclImpl(ATTR_NAME_NAME, atype, CMAttributeDeclaration.OPTIONAL); + + } + else if (attrName.equalsIgnoreCase(ATTR_NAME_NOHREF)) { + // (nohref (nohref) #IMPLIED) + atype = new HTMLCMDataTypeImpl(CMDataType.ENUM); + String[] values = {ATTR_NAME_NOHREF}; + atype.setEnumValues(values); + attr = new HTMLAttrDeclImpl(ATTR_NAME_NOHREF, atype, CMAttributeDeclaration.OPTIONAL); + + } + else if (attrName.equalsIgnoreCase(ATTR_NAME_NORESIZE)) { + // (noresize (noresize) #IMPLIED) + atype = new HTMLCMDataTypeImpl(CMDataType.ENUM); + String[] values = {ATTR_NAME_NORESIZE}; + atype.setEnumValues(values); + attr = new HTMLAttrDeclImpl(ATTR_NAME_NORESIZE, atype, CMAttributeDeclaration.OPTIONAL); + + } + else if (attrName.equalsIgnoreCase(ATTR_NAME_NOSHADE)) { + // (noshade (noshade) #IMPLIED) + atype = new HTMLCMDataTypeImpl(CMDataType.ENUM); + String[] values = {ATTR_NAME_NOSHADE}; + atype.setEnumValues(values); + attr = new HTMLAttrDeclImpl(ATTR_NAME_NOSHADE, atype, CMAttributeDeclaration.OPTIONAL); + + } + else if (attrName.equalsIgnoreCase(ATTR_NAME_NOWRAP)) { + // (nowrap (nowrap) #IMPLIED) + atype = new HTMLCMDataTypeImpl(CMDataType.ENUM); + String[] values = {ATTR_NAME_NOWRAP}; + atype.setEnumValues(values); + attr = new HTMLAttrDeclImpl(ATTR_NAME_NOWRAP, atype, CMAttributeDeclaration.OPTIONAL); + + } + else if (attrName.equalsIgnoreCase(ATTR_NAME_OBJECT)) { + // (object CDATA #IMPLIED) + atype = new HTMLCMDataTypeImpl(CMDataType.ENUM); + String[] values = {ATTR_NAME_OBJECT}; + atype.setEnumValues(values); + attr = new HTMLAttrDeclImpl(ATTR_NAME_OBJECT, atype, CMAttributeDeclaration.OPTIONAL); + + } + else if (attrName.equalsIgnoreCase(ATTR_NAME_ONBLUR)) { + // (onblur %Script; #IMPLIED) + atype = new HTMLCMDataTypeImpl(HTMLCMDataType.SCRIPT); + attr = new HTMLAttrDeclImpl(ATTR_NAME_ONBLUR, atype, CMAttributeDeclaration.OPTIONAL); + + } + else if (attrName.equalsIgnoreCase(ATTR_NAME_ONCLICK)) { + // (onclick %Script; #IMPLIED) + atype = new HTMLCMDataTypeImpl(HTMLCMDataType.SCRIPT); + attr = new HTMLAttrDeclImpl(ATTR_NAME_ONCLICK, atype, CMAttributeDeclaration.OPTIONAL); + + } + else if (attrName.equalsIgnoreCase(ATTR_NAME_ONCHANGE)) { + // (onchange %Script; #IMPLIED) + atype = new HTMLCMDataTypeImpl(HTMLCMDataType.SCRIPT); + attr = new HTMLAttrDeclImpl(ATTR_NAME_ONCHANGE, atype, CMAttributeDeclaration.OPTIONAL); + + } + else if (attrName.equalsIgnoreCase(ATTR_NAME_ONDBLCLICK)) { + // (ondblclick %Script; #IMPLIED) + atype = new HTMLCMDataTypeImpl(HTMLCMDataType.SCRIPT); + attr = new HTMLAttrDeclImpl(ATTR_NAME_ONDBLCLICK, atype, CMAttributeDeclaration.OPTIONAL); + + } + else if (attrName.equalsIgnoreCase(ATTR_NAME_ONFOCUS)) { + // (onfocus %Script; #IMPLIED) + atype = new HTMLCMDataTypeImpl(HTMLCMDataType.SCRIPT); + attr = new HTMLAttrDeclImpl(ATTR_NAME_ONFOCUS, atype, CMAttributeDeclaration.OPTIONAL); + + } + else if (attrName.equalsIgnoreCase(ATTR_NAME_ONHELP)) { + // (onhelp %Script; #IMPLIED) + atype = new HTMLCMDataTypeImpl(HTMLCMDataType.SCRIPT); + attr = new HTMLAttrDeclImpl(ATTR_NAME_ONHELP, atype, CMAttributeDeclaration.OPTIONAL); + + } + else if (attrName.equalsIgnoreCase(ATTR_NAME_ONKEYPRESS)) { + // (onkeypress %Script; #IMPLIED) + atype = new HTMLCMDataTypeImpl(HTMLCMDataType.SCRIPT); + attr = new HTMLAttrDeclImpl(ATTR_NAME_ONKEYPRESS, atype, CMAttributeDeclaration.OPTIONAL); + + } + else if (attrName.equalsIgnoreCase(ATTR_NAME_ONKEYDOWN)) { + // (onkeydown %Script; #IMPLIED) + atype = new HTMLCMDataTypeImpl(HTMLCMDataType.SCRIPT); + attr = new HTMLAttrDeclImpl(ATTR_NAME_ONKEYDOWN, atype, CMAttributeDeclaration.OPTIONAL); + + } + else if (attrName.equalsIgnoreCase(ATTR_NAME_ONKEYUP)) { + // (onkyeup %Script; #IMPLIED) + atype = new HTMLCMDataTypeImpl(HTMLCMDataType.SCRIPT); + attr = new HTMLAttrDeclImpl(ATTR_NAME_ONKEYUP, atype, CMAttributeDeclaration.OPTIONAL); + + } + else if (attrName.equalsIgnoreCase(ATTR_NAME_ONLOAD)) { + // (onload %Script; #IMPLIED) + atype = new HTMLCMDataTypeImpl(HTMLCMDataType.SCRIPT); + attr = new HTMLAttrDeclImpl(ATTR_NAME_ONLOAD, atype, CMAttributeDeclaration.OPTIONAL); + + } + else if (attrName.equalsIgnoreCase(ATTR_NAME_ONMOUSEDOWN)) { + // (onmousedown %Script; #IMPLIED) + atype = new HTMLCMDataTypeImpl(HTMLCMDataType.SCRIPT); + attr = new HTMLAttrDeclImpl(ATTR_NAME_ONMOUSEDOWN, atype, CMAttributeDeclaration.OPTIONAL); + + } + else if (attrName.equalsIgnoreCase(ATTR_NAME_ONMOUSEUP)) { + // (onmouseup %Script; #IMPLIED) + atype = new HTMLCMDataTypeImpl(HTMLCMDataType.SCRIPT); + attr = new HTMLAttrDeclImpl(ATTR_NAME_ONMOUSEUP, atype, CMAttributeDeclaration.OPTIONAL); + + } + else if (attrName.equalsIgnoreCase(ATTR_NAME_ONMOUSEOVER)) { + // (onmouseover %Script; #IMPLIED) + atype = new HTMLCMDataTypeImpl(HTMLCMDataType.SCRIPT); + attr = new HTMLAttrDeclImpl(ATTR_NAME_ONMOUSEOVER, atype, CMAttributeDeclaration.OPTIONAL); + + } + else if (attrName.equalsIgnoreCase(ATTR_NAME_ONMOUSEMOVE)) { + // (onmousemove %Script; #IMPLIED) + atype = new HTMLCMDataTypeImpl(HTMLCMDataType.SCRIPT); + attr = new HTMLAttrDeclImpl(ATTR_NAME_ONMOUSEMOVE, atype, CMAttributeDeclaration.OPTIONAL); + + } + else if (attrName.equalsIgnoreCase(ATTR_NAME_ONMOUSEOUT)) { + // (onmouseout %Script; #IMPLIED) + atype = new HTMLCMDataTypeImpl(HTMLCMDataType.SCRIPT); + attr = new HTMLAttrDeclImpl(ATTR_NAME_ONMOUSEOUT, atype, CMAttributeDeclaration.OPTIONAL); + + } + else if (attrName.equalsIgnoreCase(ATTR_NAME_ONRESET)) { + // (onreset %Script; #IMPLIED) + atype = new HTMLCMDataTypeImpl(HTMLCMDataType.SCRIPT); + attr = new HTMLAttrDeclImpl(ATTR_NAME_ONRESET, atype, CMAttributeDeclaration.OPTIONAL); + + } + else if (attrName.equalsIgnoreCase(ATTR_NAME_ONSELECT)) { + // (onselect %Script; #IMPLIED) + atype = new HTMLCMDataTypeImpl(HTMLCMDataType.SCRIPT); + attr = new HTMLAttrDeclImpl(ATTR_NAME_ONSELECT, atype, CMAttributeDeclaration.OPTIONAL); + + } + else if (attrName.equalsIgnoreCase(ATTR_NAME_ONSUBMIT)) { + // (onsubmit %Script; #IMPLIED) + atype = new HTMLCMDataTypeImpl(HTMLCMDataType.SCRIPT); + attr = new HTMLAttrDeclImpl(ATTR_NAME_ONSUBMIT, atype, CMAttributeDeclaration.OPTIONAL); + + } + else if (attrName.equalsIgnoreCase(ATTR_NAME_ONUNLOAD)) { + // (onunload %Script; #IMPLIED) + atype = new HTMLCMDataTypeImpl(HTMLCMDataType.SCRIPT); + attr = new HTMLAttrDeclImpl(ATTR_NAME_ONUNLOAD, atype, CMAttributeDeclaration.OPTIONAL); + + } + else if (attrName.equalsIgnoreCase(ATTR_NAME_PALETTE)) { + // (palette CDATA; #IMPLIED) + atype = new HTMLCMDataTypeImpl(CMDataType.CDATA); + attr = new HTMLAttrDeclImpl(ATTR_NAME_PALETTE, atype, CMAttributeDeclaration.OPTIONAL); + + } + else if (attrName.equalsIgnoreCase(ATTR_NAME_PANEL)) { + // (panel CDATA; #IMPLIED) + atype = new HTMLCMDataTypeImpl(CMDataType.CDATA); + attr = new HTMLAttrDeclImpl(ATTR_NAME_PANEL, atype, CMAttributeDeclaration.OPTIONAL); + + } + else if (attrName.equalsIgnoreCase(ATTR_NAME_PLAYCOUNT)) { + // (playcount NUMBER; #IMPLIED) + atype = new HTMLCMDataTypeImpl(CMDataType.NUMBER); + attr = new HTMLAttrDeclImpl(ATTR_NAME_PLAYCOUNT, atype, CMAttributeDeclaration.OPTIONAL); + + } + else if (attrName.equalsIgnoreCase(ATTR_NAME_PROFILE)) { + // (profile %URI; #IMPLIED) + atype = new HTMLCMDataTypeImpl(CMDataType.URI); + attr = new HTMLAttrDeclImpl(ATTR_NAME_PROFILE, atype, CMAttributeDeclaration.OPTIONAL); + + } + else if (attrName.equalsIgnoreCase(ATTR_NAME_PROMPT)) { + // (prompt %Text; #IMPLIED) + atype = new HTMLCMDataTypeImpl(HTMLCMDataType.TEXT); + attr = new HTMLAttrDeclImpl(ATTR_NAME_PROMPT, atype, CMAttributeDeclaration.OPTIONAL); + + } + else if (attrName.equalsIgnoreCase(ATTR_NAME_READONLY)) { + // (readonly (readonly) #IMPLIED) + atype = new HTMLCMDataTypeImpl(CMDataType.ENUM); + String[] values = {ATTR_NAME_READONLY}; + atype.setEnumValues(values); + attr = new HTMLAttrDeclImpl(ATTR_NAME_READONLY, atype, CMAttributeDeclaration.OPTIONAL); + + } + else if (attrName.equalsIgnoreCase(ATTR_NAME_REPEAT)) { + // (repeat CDATA #IMPLIED) + atype = new HTMLCMDataTypeImpl(CMDataType.CDATA); + attr = new HTMLAttrDeclImpl(ATTR_NAME_REPEAT, atype, CMAttributeDeclaration.OPTIONAL); + + } + else if (attrName.equalsIgnoreCase(ATTR_NAME_REL)) { + // (rel %LinkTypes; #IMPLIED) + atype = new HTMLCMDataTypeImpl(HTMLCMDataType.LINK_TYPES); + attr = new HTMLAttrDeclImpl(ATTR_NAME_REL, atype, CMAttributeDeclaration.OPTIONAL); + + } + else if (attrName.equalsIgnoreCase(ATTR_NAME_REV)) { + // (rev %LinkTypes; #IMPLIED) + atype = new HTMLCMDataTypeImpl(HTMLCMDataType.LINK_TYPES); + attr = new HTMLAttrDeclImpl(ATTR_NAME_REV, atype, CMAttributeDeclaration.OPTIONAL); + + } + else if (attrName.equalsIgnoreCase(ATTR_NAME_ROWS)) { + // (rows NUMBER #REQUIRED) + atype = new HTMLCMDataTypeImpl(CMDataType.NUMBER); + attr = new HTMLAttrDeclImpl(ATTR_NAME_ROWS, atype, CMAttributeDeclaration.REQUIRED); + + } + else if (attrName.equalsIgnoreCase(ATTR_NAME_ROWSPAN)) { + // (rowspan NUMBER 1) + atype = new HTMLCMDataTypeImpl(CMDataType.NUMBER); + atype.setImpliedValue(CMDataType.IMPLIED_VALUE_DEFAULT, ATTR_VALUE_1); + attr = new HTMLAttrDeclImpl(ATTR_NAME_ROWSPAN, atype, CMAttributeDeclaration.OPTIONAL); + + } + else if (attrName.equalsIgnoreCase(ATTR_NAME_RULES)) { + // (rules %TRules; #IMPLIED) + // %TRules; is (none | groups | rows | cols | all). + atype = new HTMLCMDataTypeImpl(CMDataType.ENUM); + String[] values = {ATTR_VALUE_NONE, ATTR_VALUE_GROUPS, ATTR_VALUE_ROWS, ATTR_VALUE_COLS, ATTR_VALUE_ALL}; + atype.setEnumValues(values); + attr = new HTMLAttrDeclImpl(ATTR_NAME_RULES, atype, CMAttributeDeclaration.OPTIONAL); + + } + else if (attrName.equalsIgnoreCase(ATTR_NAME_SCALE)) { + // (scale CDATA #IMPLIED) + atype = new HTMLCMDataTypeImpl(CMDataType.CDATA); + attr = new HTMLAttrDeclImpl(ATTR_NAME_SCALE, atype, CMAttributeDeclaration.OPTIONAL); + + } + else if (attrName.equalsIgnoreCase(ATTR_NAME_SCHEME)) { + // (scheme CDATA #IMPLIED) + atype = new HTMLCMDataTypeImpl(CMDataType.CDATA); + attr = new HTMLAttrDeclImpl(ATTR_NAME_SCHEME, atype, CMAttributeDeclaration.OPTIONAL); + + } + else if (attrName.equalsIgnoreCase(ATTR_NAME_SELECTED)) { + // (selected (selected) #IMPLIED) + atype = new HTMLCMDataTypeImpl(CMDataType.ENUM); + String[] values = {ATTR_NAME_SELECTED}; + atype.setEnumValues(values); + attr = new HTMLAttrDeclImpl(ATTR_NAME_SELECTED, atype, CMAttributeDeclaration.OPTIONAL); + + } + else if (attrName.equalsIgnoreCase(ATTR_NAME_SCOPE)) { + // (SCOPE %Scope; #IMPLIED) + // %Scope; is (row|col|rowgroup|colgroup) + atype = new HTMLCMDataTypeImpl(CMDataType.ENUM); + String[] values = {ATTR_VALUE_ROW, ATTR_VALUE_COL, ATTR_VALUE_ROWGROUP, ATTR_VALUE_COLGROUP}; + atype.setEnumValues(values); + attr = new HTMLAttrDeclImpl(ATTR_NAME_SCOPE, atype, CMAttributeDeclaration.OPTIONAL); + + } + else if (attrName.equalsIgnoreCase(ATTR_NAME_SCROLLAMOUNT)) { + // (scrollamount NUMBER #IMPLIED) + atype = new HTMLCMDataTypeImpl(CMDataType.NUMBER); + attr = new HTMLAttrDeclImpl(ATTR_NAME_SCROLLAMOUNT, atype, CMAttributeDeclaration.OPTIONAL); + + } + else if (attrName.equalsIgnoreCase(ATTR_NAME_SCROLLDELAY)) { + // (scrolldelay NUMBER #IMPLIED) + atype = new HTMLCMDataTypeImpl(CMDataType.NUMBER); + attr = new HTMLAttrDeclImpl(ATTR_NAME_SCROLLDELAY, atype, CMAttributeDeclaration.OPTIONAL); + + } + else if (attrName.equalsIgnoreCase(ATTR_NAME_SCROLLING)) { + // (scrolling (yes|no|auto) auto) + atype = new HTMLCMDataTypeImpl(CMDataType.ENUM); + String[] values = {ATTR_VALUE_YES, ATTR_VALUE_NO, ATTR_VALUE_AUTO}; + atype.setEnumValues(values); + atype.setImpliedValue(CMDataType.IMPLIED_VALUE_DEFAULT, ATTR_VALUE_AUTO); + attr = new HTMLAttrDeclImpl(ATTR_NAME_SCROLLING, atype, CMAttributeDeclaration.OPTIONAL); + + } + else if (attrName.equalsIgnoreCase(ATTR_NAME_SHAPE)) { + // (shape %Shape; rect): %Shape; is (rect|circle|poly|default). + atype = new HTMLCMDataTypeImpl(CMDataType.ENUM); + String[] values = {ATTR_VALUE_RECT, ATTR_VALUE_CIRCLE, ATTR_VALUE_POLY, ATTR_VALUE_DEFAULT}; + atype.setEnumValues(values); + atype.setImpliedValue(CMDataType.IMPLIED_VALUE_DEFAULT, ATTR_VALUE_RECT); + attr = new HTMLAttrDeclImpl(ATTR_NAME_SHAPE, atype, CMAttributeDeclaration.OPTIONAL); + + } + else if (attrName.equalsIgnoreCase(ATTR_NAME_SHOWCONTROLS)) { + // (showcontrols (true|false) #IMPLIED) + atype = new HTMLCMDataTypeImpl(CMDataType.ENUM); + String[] values = {ATTR_VALUE_TRUE, ATTR_VALUE_FALSE}; + atype.setEnumValues(values); + attr = new HTMLAttrDeclImpl(ATTR_NAME_SHOWCONTROLS, atype, CMAttributeDeclaration.OPTIONAL); + + } + else if (attrName.equalsIgnoreCase(ATTR_NAME_SIZE)) { + // (size %Pixels; #IMPLIED) + atype = new HTMLCMDataTypeImpl(HTMLCMDataType.PIXELS); + attr = new HTMLAttrDeclImpl(ATTR_NAME_SIZE, atype, CMAttributeDeclaration.OPTIONAL); + + } + else if (attrName.equalsIgnoreCase(ATTR_NAME_SIZEFMT)) { + // (sizefmt CDATA #IMPLIED) + atype = new HTMLCMDataTypeImpl(CMDataType.CDATA); + attr = new HTMLAttrDeclImpl(ATTR_NAME_SIZEFMT, atype, CMAttributeDeclaration.OPTIONAL); + + } + else if (attrName.equalsIgnoreCase(ATTR_NAME_SPAN)) { + // (span NUMBER 1) + atype = new HTMLCMDataTypeImpl(CMDataType.NUMBER); + atype.setImpliedValue(CMDataType.IMPLIED_VALUE_DEFAULT, ATTR_VALUE_1); + attr = new HTMLAttrDeclImpl(ATTR_NAME_SPAN, atype, CMAttributeDeclaration.OPTIONAL); + + } + else if (attrName.equalsIgnoreCase(ATTR_NAME_SRC)) { + // (src %URI; #IMPLIED) + // NOTE: "src" attributes are defined in several elements. + // The definition of IMG is different from others. + // So, it should be locally defined. + atype = new HTMLCMDataTypeImpl(CMDataType.URI); + attr = new HTMLAttrDeclImpl(ATTR_NAME_SRC, atype, CMAttributeDeclaration.OPTIONAL); + + } + else if (attrName.equalsIgnoreCase(ATTR_NAME_START)) { + // (start NUMBER #IMPLIED) + atype = new HTMLCMDataTypeImpl(CMDataType.NUMBER); + attr = new HTMLAttrDeclImpl(ATTR_NAME_START, atype, CMAttributeDeclaration.OPTIONAL); + + } + else if (attrName.equalsIgnoreCase(ATTR_NAME_STANDBY)) { + // (standby %Text; #IMPLIED) + atype = new HTMLCMDataTypeImpl(HTMLCMDataType.TEXT); + attr = new HTMLAttrDeclImpl(ATTR_NAME_STANDBY, atype, CMAttributeDeclaration.OPTIONAL); + + } + else if (attrName.equalsIgnoreCase(ATTR_NAME_STYLE)) { + // (style %StyleSheet; #IMPLIED) + atype = new HTMLCMDataTypeImpl(HTMLCMDataType.STYLE_SHEET); + attr = new HTMLAttrDeclImpl(ATTR_NAME_STYLE, atype, CMAttributeDeclaration.OPTIONAL); + + } + else if (attrName.equalsIgnoreCase(ATTR_NAME_SUMMARY)) { + // (summary %Text; #IMPLIED) + atype = new HTMLCMDataTypeImpl(HTMLCMDataType.TEXT); + attr = new HTMLAttrDeclImpl(ATTR_NAME_SUMMARY, atype, CMAttributeDeclaration.OPTIONAL); + + } + else if (attrName.equalsIgnoreCase(ATTR_NAME_TABINDEX)) { + // (tabindex NUMBER #IMPLIED) + atype = new HTMLCMDataTypeImpl(CMDataType.NUMBER); + attr = new HTMLAttrDeclImpl(ATTR_NAME_TABINDEX, atype, CMAttributeDeclaration.OPTIONAL); + + } + else if (attrName.equalsIgnoreCase(ATTR_NAME_TARGET)) { + // (target %FrameTarget; #IMPLIED) + atype = new HTMLCMDataTypeImpl(HTMLCMDataType.FRAME_TARGET); + attr = new HTMLAttrDeclImpl(ATTR_NAME_TARGET, atype, CMAttributeDeclaration.OPTIONAL); + + } + else if (attrName.equalsIgnoreCase(ATTR_NAME_TEXT)) { + // (text CDATA #IMPLIED) + atype = new HTMLCMDataTypeImpl(CMDataType.CDATA); + attr = new HTMLAttrDeclImpl(ATTR_NAME_TEXT, atype, CMAttributeDeclaration.OPTIONAL); + + } + else if (attrName.equalsIgnoreCase(ATTR_NAME_TEXTFOCUS)) { + // (textfocus CDATA #IMPLIED) + atype = new HTMLCMDataTypeImpl(CMDataType.CDATA); + attr = new HTMLAttrDeclImpl(ATTR_NAME_TEXTFOCUS, atype, CMAttributeDeclaration.OPTIONAL); + + } + else if (attrName.equalsIgnoreCase(ATTR_NAME_TITLE)) { + // (title %Text; #IMPLIED) + atype = new HTMLCMDataTypeImpl(HTMLCMDataType.TEXT); + attr = new HTMLAttrDeclImpl(ATTR_NAME_TITLE, atype, CMAttributeDeclaration.OPTIONAL); + + } + else if (attrName.equalsIgnoreCase(ATTR_NAME_TIMEFMT)) { + // (timefmt CDATA #IMPLIED) + atype = new HTMLCMDataTypeImpl(CMDataType.CDATA); + attr = new HTMLAttrDeclImpl(ATTR_NAME_TIMEFMT, atype, CMAttributeDeclaration.OPTIONAL); + + } + else if (attrName.equalsIgnoreCase(ATTR_NAME_TRUESPEED)) { + // (truespeed (truespeed) #IMPLIED) + atype = new HTMLCMDataTypeImpl(CMDataType.ENUM); + String[] values = {ATTR_NAME_TRUESPEED}; + atype.setEnumValues(values); + attr = new HTMLAttrDeclImpl(ATTR_NAME_TRUESPEED, atype, CMAttributeDeclaration.OPTIONAL); + + } + else if (attrName.equalsIgnoreCase(ATTR_NAME_TYPE)) { + // (type %CotentType; #IMPLIED) + atype = new HTMLCMDataTypeImpl(HTMLCMDataType.CONTENT_TYPE); + attr = new HTMLAttrDeclImpl(ATTR_NAME_TYPE, atype, CMAttributeDeclaration.OPTIONAL); + + } + else if (attrName.equalsIgnoreCase(ATTR_NAME_USEMAP)) { + // (usemap %URI; #IMPLIED) + atype = new HTMLCMDataTypeImpl(CMDataType.URI); + attr = new HTMLAttrDeclImpl(ATTR_NAME_USEMAP, atype, CMAttributeDeclaration.OPTIONAL); + + } + else if (attrName.equalsIgnoreCase(ATTR_NAME_VALIGN)) { + // (valign (top|middle|bottom|baseline) #IMPLIED) + atype = new HTMLCMDataTypeImpl(CMDataType.ENUM); + String[] values = {ATTR_VALUE_TOP, ATTR_VALUE_MIDDLE, ATTR_VALUE_BOTTOM, ATTR_VALUE_BASELINE}; + atype.setEnumValues(values); + attr = new HTMLAttrDeclImpl(ATTR_NAME_VALIGN, atype, CMAttributeDeclaration.OPTIONAL); + + } + else if (attrName.equalsIgnoreCase(ATTR_NAME_VALUE)) { + // (value CDATA #IMPLIED) + atype = new HTMLCMDataTypeImpl(CMDataType.CDATA); + attr = new HTMLAttrDeclImpl(ATTR_NAME_VALUE, atype, CMAttributeDeclaration.OPTIONAL); + + } + else if (attrName.equalsIgnoreCase(ATTR_NAME_VALUETYPE)) { + // (valuetype (DATA|REF|OBJECT) DATA) + atype = new HTMLCMDataTypeImpl(CMDataType.ENUM); + String[] values = {ATTR_VALUE_DATA, ATTR_VALUE_REF, ATTR_VALUE_OBJECT}; + atype.setEnumValues(values); + atype.setImpliedValue(CMDataType.IMPLIED_VALUE_DEFAULT, ATTR_VALUE_DATA); + attr = new HTMLAttrDeclImpl(ATTR_NAME_VALUETYPE, atype, CMAttributeDeclaration.OPTIONAL); + + } + else if (attrName.equalsIgnoreCase(ATTR_NAME_VAR)) { + // (var CDATA #IMPLIED) + atype = new HTMLCMDataTypeImpl(CMDataType.CDATA); + attr = new HTMLAttrDeclImpl(ATTR_NAME_VAR, atype, CMAttributeDeclaration.OPTIONAL); + + } + else if (attrName.equalsIgnoreCase(ATTR_NAME_VERSION)) { + // (version CDATA #FIXED '%HTML.Version;) + atype = new HTMLCMDataTypeImpl(CMDataType.CDATA); + atype.setImpliedValue(CMDataType.IMPLIED_VALUE_FIXED, ATTR_VALUE_VERSION_TRANSITIONAL); + attr = new HTMLAttrDeclImpl(ATTR_NAME_VERSION, atype, CMAttributeDeclaration.FIXED); + + } + else if (attrName.equalsIgnoreCase(ATTR_NAME_VIRTUAL)) { + // (virtual %URI; #IMPLIED) + atype = new HTMLCMDataTypeImpl(CMDataType.URI); + attr = new HTMLAttrDeclImpl(ATTR_NAME_VIRTUAL, atype, CMAttributeDeclaration.OPTIONAL); + + } + else if (attrName.equalsIgnoreCase(ATTR_NAME_VLINK)) { + // (vlink %Color; #IMPLIED) + atype = new HTMLCMDataTypeImpl(HTMLCMDataType.COLOR); + attr = new HTMLAttrDeclImpl(ATTR_NAME_VLINK, atype, CMAttributeDeclaration.OPTIONAL); + + } + else if (attrName.equalsIgnoreCase(ATTR_NAME_VOLUME)) { + // (volume CDATA #IMPLIED) + atype = new HTMLCMDataTypeImpl(CMDataType.CDATA); + attr = new HTMLAttrDeclImpl(ATTR_NAME_VOLUME, atype, CMAttributeDeclaration.OPTIONAL); + + } + else if (attrName.equalsIgnoreCase(ATTR_NAME_WIDTH)) { + // (width %Length; #IMPLIED) + atype = new HTMLCMDataTypeImpl(HTMLCMDataType.LENGTH); + attr = new HTMLAttrDeclImpl(ATTR_NAME_WIDTH, atype, CMAttributeDeclaration.OPTIONAL); + + } + else if (attrName.equalsIgnoreCase(ATTR_NAME_VSPACE)) { + // (vspace %Pixels; #IMPLIED) + atype = new HTMLCMDataTypeImpl(HTMLCMDataType.PIXELS); + attr = new HTMLAttrDeclImpl(ATTR_NAME_VSPACE, atype, CMAttributeDeclaration.OPTIONAL); + + // <<D205514 + } + else if (attrName.equalsIgnoreCase(ATTR_NAME_TOPMARGIN)) { + // (topmargin, CDATA, #IMPLIED) + atype = new HTMLCMDataTypeImpl(CMDataType.CDATA); + attr = new HTMLAttrDeclImpl(ATTR_NAME_TOPMARGIN, atype, CMAttributeDeclaration.OPTIONAL); + + } + else if (attrName.equalsIgnoreCase(ATTR_NAME_BOTTOMMARGIN)) { + // (bottommargin, CDATA, #IMPLIED) + atype = new HTMLCMDataTypeImpl(CMDataType.CDATA); + attr = new HTMLAttrDeclImpl(ATTR_NAME_BOTTOMMARGIN, atype, CMAttributeDeclaration.OPTIONAL); + + } + else if (attrName.equalsIgnoreCase(ATTR_NAME_LEFTMARGIN)) { + // (leftmargin, CDATA, #IMPLIED) + atype = new HTMLCMDataTypeImpl(CMDataType.CDATA); + attr = new HTMLAttrDeclImpl(ATTR_NAME_LEFTMARGIN, atype, CMAttributeDeclaration.OPTIONAL); + + } + else if (attrName.equalsIgnoreCase(ATTR_NAME_RIGHTMARGIN)) { + // (rightmargin, CDATA, #IMPLIED) + atype = new HTMLCMDataTypeImpl(CMDataType.CDATA); + attr = new HTMLAttrDeclImpl(ATTR_NAME_RIGHTMARGIN, atype, CMAttributeDeclaration.OPTIONAL); + + } + else if (attrName.equalsIgnoreCase(ATTR_NAME_BORDERCOLOR)) { + // (bordercolor, %Color; #IMPLIED) + atype = new HTMLCMDataTypeImpl(HTMLCMDataType.COLOR); + attr = new HTMLAttrDeclImpl(ATTR_NAME_BORDERCOLOR, atype, CMAttributeDeclaration.OPTIONAL); + // D205514 + + } + else { + // unknown attribute; maybe error. + // should warn. + attr = null; + } + + return attr; + } + + /** + * Get align attribute which has %CAlign; as values.. + * At this time (4/19/2001), it is identical to %LAlign;. + * @param attributes com.ibm.sed.contentmodel.html.CMNamedNodeMapImpl + */ + public static final HTMLAttrDeclImpl createAlignForCaption() { + // align (local) + HTMLCMDataTypeImpl atype = new HTMLCMDataTypeImpl(CMDataType.ENUM); + // set enum values + String[] values = {ATTR_VALUE_TOP, ATTR_VALUE_BOTTOM, ATTR_VALUE_LEFT, ATTR_VALUE_RIGHT}; + atype.setEnumValues(values); + + HTMLAttrDeclImpl attr = new HTMLAttrDeclImpl(ATTR_NAME_ALIGN, atype, CMAttributeDeclaration.OPTIONAL); + return attr; + } + + /** + * Get align attribute which has %IAlign; as values.. + * @param attributes com.ibm.sed.contentmodel.html.CMNamedNodeMapImpl + */ + public static final HTMLAttrDeclImpl createAlignForImage() { + // align (local) + HTMLCMDataTypeImpl atype = new HTMLCMDataTypeImpl(CMDataType.ENUM); + // set enum values + String[] values = {ATTR_VALUE_TOP, ATTR_VALUE_MIDDLE, ATTR_VALUE_BOTTOM, ATTR_VALUE_LEFT, ATTR_VALUE_RIGHT}; + atype.setEnumValues(values); + + HTMLAttrDeclImpl attr = new HTMLAttrDeclImpl(ATTR_NAME_ALIGN, atype, CMAttributeDeclaration.OPTIONAL); + return attr; + } + + /** + * Get align attribute which has %LAlign; as values.. + * @param attributes com.ibm.sed.contentmodel.html.CMNamedNodeMapImpl + */ + public static final HTMLAttrDeclImpl createAlignForLegend() { + // align (local) + HTMLCMDataTypeImpl atype = new HTMLCMDataTypeImpl(CMDataType.ENUM); + // set enum values + String[] values = {ATTR_VALUE_TOP, ATTR_VALUE_BOTTOM, ATTR_VALUE_LEFT, ATTR_VALUE_RIGHT}; + atype.setEnumValues(values); + + HTMLAttrDeclImpl attr = new HTMLAttrDeclImpl(ATTR_NAME_ALIGN, atype, CMAttributeDeclaration.OPTIONAL); + return attr; + } + + /** + * Create an attribute declaration for <code>align</code> + * in several elements, like <code>P</code>, <code>DIV</code>. + * The values are different from attributes those have the same name + * in other elements (<code>IMG</code> and <code>TABLE</code>). + * So, it can't treat as global attributes. + * <strong>NOTE: These attribute declaration has + * no owner CMDocument instance.</strong> + * @return com.ibm.sed.contentmodel.html.HTMLAttrDeclImpl + */ + public static final HTMLAttrDeclImpl createAlignForParagraph() { + HTMLCMDataTypeImpl atype = new HTMLCMDataTypeImpl(CMDataType.ENUM); + // set enum values: left|center|right|justify + String[] values = {ATTR_VALUE_LEFT, ATTR_VALUE_CENTER, ATTR_VALUE_RIGHT, ATTR_VALUE_JUSTIFY}; + atype.setEnumValues(values); + + HTMLAttrDeclImpl attr = new HTMLAttrDeclImpl(ATTR_NAME_ALIGN, atype, CMAttributeDeclaration.OPTIONAL); + return attr; + } + + /** + * Get %attrs; declarations. + * %attrs; consists of %coreattrs;, %i18n, and %events;. + * @param attributes com.ibm.sed.contentmodel.html.CMNamedNodeMapImpl + */ + public void getAttrs(CMNamedNodeMapImpl declarations) { + // %coreattrs; + Iterator names = Arrays.asList(CORE).iterator(); + getDeclarations(declarations, names); + // %i18n; + names = Arrays.asList(I18N).iterator(); + getDeclarations(declarations, names); + // %events; + names = Arrays.asList(EVENTS).iterator(); + getDeclarations(declarations, names); + } + + /** + * Get %bodycolors; declarations. + * @param attributes com.ibm.sed.contentmodel.html.CMNamedNodeMapImpl + */ + public void getBodycolors(CMNamedNodeMapImpl declarations) { + Iterator names = Arrays.asList(BODYCOLORS).iterator(); + getDeclarations(declarations, names); + } + + /** + * Get %cellhalign; declarations. + * %cellhaligh; consists of: + * - (align (left|center|right|justify|char) #IMPLIED) + * - (char %Character; #IMPLIED) + * - (charoff %Length; #IMPLIED) + * @param attributes com.ibm.sed.contentmodel.html.CMNamedNodeMapImpl + */ + public void getCellhalign(CMNamedNodeMapImpl declarations) { + // (align (left|center|right|justify|char) #IMPLIED) should be defined + // locally. + HTMLCMDataTypeImpl atype = new HTMLCMDataTypeImpl(CMDataType.ENUM); + // set enum values + String[] values = {ATTR_VALUE_LEFT, ATTR_VALUE_CENTER, ATTR_VALUE_RIGHT, ATTR_VALUE_JUSTIFY, ATTR_VALUE_CHAR}; + atype.setEnumValues(values); + + HTMLAttrDeclImpl attr = new HTMLAttrDeclImpl(ATTR_NAME_ALIGN, atype, CMAttributeDeclaration.OPTIONAL); + declarations.putNamedItem(HTML40Namespace.ATTR_NAME_ALIGN, attr); + + // the rest. + Iterator names = Arrays.asList(CELLHALIGN).iterator(); + getDeclarations(declarations, names); + } + + /** + * Get %cellvalign; declarations. + * %cellhaligh; is: + * - (valign (top|middle|bottom|baseline) #IMPLIED) + * @param attributes com.ibm.sed.contentmodel.html.CMNamedNodeMapImpl + */ + public void getCellvalign(CMNamedNodeMapImpl declarations) { + HTMLAttributeDeclaration dec = getDeclaration(HTML40Namespace.ATTR_NAME_VALIGN); + if (dec != null) + declarations.putNamedItem(HTML40Namespace.ATTR_NAME_VALIGN, dec); + } + + /** + * Get %coreattrs; declarations. + * @param attributes com.ibm.sed.contentmodel.html.CMNamedNodeMapImpl + */ + public void getCore(CMNamedNodeMapImpl declarations) { + Iterator names = Arrays.asList(CORE).iterator(); + getDeclarations(declarations, names); + } + + /** + * Get a global attribute declaration. + * @return com.ibm.sed.contentmodel.html.HTMLAttrributeDeclaration + * @param attrName java.lang.String + */ + public HTMLAttributeDeclaration getDeclaration(String attrName) { + CMNode cmnode = getNamedItem(attrName); + if (cmnode != null) + return (HTMLAttributeDeclaration) cmnode; // already exists. + + HTMLAttrDeclImpl dec = create(attrName); + if (dec != null) + putNamedItem(attrName, dec); + + return dec; + } + + /** + * Get declarations which are specified by names. + * @param declarations com.ibm.sed.contentmodel.html.CMNamedNodeMapImpl + * @param names java.util.Iterator + */ + public void getDeclarations(CMNamedNodeMapImpl declarations, Iterator names) { + while (names.hasNext()) { + String attrName = (String) names.next(); + HTMLAttributeDeclaration dec = getDeclaration(attrName); + if (dec != null) + declarations.putNamedItem(attrName, dec); + } + } + + /** + * Get %events; declarations. + * @param attributes com.ibm.sed.contentmodel.html.CMNamedNodeMapImpl + */ + public void getEvents(CMNamedNodeMapImpl declarations) { + Iterator names = Arrays.asList(EVENTS).iterator(); + getDeclarations(declarations, names); + } + + /** + * Get %i18n; declarations. + * @param attributes com.ibm.sed.contentmodel.html.CMNamedNodeMapImpl + */ + public void getI18n(CMNamedNodeMapImpl declarations) { + Iterator names = Arrays.asList(I18N).iterator(); + getDeclarations(declarations, names); + } +}
\ No newline at end of file diff --git a/bundles/org.eclipse.wst.html.core/src/org/eclipse/wst/html/core/contentmodel/CMContentImpl.java b/bundles/org.eclipse.wst.html.core/src/org/eclipse/wst/html/core/contentmodel/CMContentImpl.java new file mode 100644 index 0000000000..20341fb6aa --- /dev/null +++ b/bundles/org.eclipse.wst.html.core/src/org/eclipse/wst/html/core/contentmodel/CMContentImpl.java @@ -0,0 +1,58 @@ +/******************************************************************************* + * Copyright (c) 2004 IBM Corporation and others. + * All rights reserved. This program and the accompanying materials + * are made available under the terms of the Eclipse Public License v1.0 + * which accompanies this distribution, and is available at + * http://www.eclipse.org/legal/epl-v10.html + * + * Contributors: + * IBM Corporation - initial API and implementation + *******************************************************************************/ +package org.eclipse.wst.html.core.contentmodel; + +import org.eclipse.wst.common.contentmodel.CMContent; + + + +/** + * Implementation of CMContent for HTML CM. + */ +abstract class CMContentImpl extends CMNodeImpl implements CMContent { + + public static final int UNBOUNDED = -1; + /** -1: it's UNBOUNDED. */ + private int maxOccur = UNBOUNDED; + /** 0: it's OPTIONAL, 1, it's REQUIRED. */ + private int minOccur = 0; + + /** + * The primary consturctor. + * Use this one for usual cases.<br> + */ + public CMContentImpl(String name, int min, int max) { + super(name); + minOccur = min; + maxOccur = max; + } + + /** + * getMaxOccur method + * @return int + * + * If -1, it's UNBOUNDED. + */ + public int getMaxOccur() { + return maxOccur; + } + + /** + * getMinOccur method + * @return int + * + * If 0, it's OPTIONAL. + * If 1, it's REQUIRED. + */ + public int getMinOccur() { + return minOccur; + } +}
\ No newline at end of file diff --git a/bundles/org.eclipse.wst.html.core/src/org/eclipse/wst/html/core/contentmodel/CMGroupImpl.java b/bundles/org.eclipse.wst.html.core/src/org/eclipse/wst/html/core/contentmodel/CMGroupImpl.java new file mode 100644 index 0000000000..cbbe37f4df --- /dev/null +++ b/bundles/org.eclipse.wst.html.core/src/org/eclipse/wst/html/core/contentmodel/CMGroupImpl.java @@ -0,0 +1,83 @@ +/******************************************************************************* + * Copyright (c) 2004 IBM Corporation and others. + * All rights reserved. This program and the accompanying materials + * are made available under the terms of the Eclipse Public License v1.0 + * which accompanies this distribution, and is available at + * http://www.eclipse.org/legal/epl-v10.html + * + * Contributors: + * IBM Corporation - initial API and implementation + *******************************************************************************/ +package org.eclipse.wst.html.core.contentmodel; + + + +import org.eclipse.wst.common.contentmodel.CMGroup; +import org.eclipse.wst.common.contentmodel.CMNode; +import org.eclipse.wst.common.contentmodel.CMNodeList; + +/** + */ +class CMGroupImpl extends CMContentImpl implements CMGroup { + + private int operator = CMGroup.SEQUENCE; + private CMNodeListImpl children = null; + + /** + * CMGroupImpl constructor comment. + */ + public CMGroupImpl(int op, int minOccur, int maxOccur) { + super(null, minOccur, maxOccur); + switch (op) { + case CMGroup.ALL : + case CMGroup.CHOICE : + case CMGroup.SEQUENCE : + operator = op; + break; + default : + // should warn. + break; + } + } + + /** + * @return org.eclipse.wst.common.contentmodel.CMNode + * @param org.eclipse.wst.common.contentmodel.CMNode + */ + protected CMNode appendChild(CMNode child) { + if (child == null) + return null; + if (children == null) + children = new CMNodeListImpl(); + return children.appendNode(child); + } + + /** + * @return org.eclipse.wst.common.contentmodel.CMNodeList + */ + public CMNodeList getChildNodes() { + return children; + } + + /** + * getNodeType method + * @return int + * + * Returns one of : + * ELEMENT_DECLARATION, ATTRIBUTE_DECLARATION, GROUP, ENTITY_DECLARATION. + */ + public int getNodeType() { + return CMNode.GROUP; + } + + /** + * getOperation method + * @return int + * + * Returns one of : + * ALONE (a), SEQUENCE (a,b), CHOICE (a|b), ALL (a&b). + */ + public int getOperator() { + return operator; + } +}
\ No newline at end of file diff --git a/bundles/org.eclipse.wst.html.core/src/org/eclipse/wst/html/core/contentmodel/CMNamedNodeMapImpl.java b/bundles/org.eclipse.wst.html.core/src/org/eclipse/wst/html/core/contentmodel/CMNamedNodeMapImpl.java new file mode 100644 index 0000000000..ac775f61df --- /dev/null +++ b/bundles/org.eclipse.wst.html.core/src/org/eclipse/wst/html/core/contentmodel/CMNamedNodeMapImpl.java @@ -0,0 +1,99 @@ +/******************************************************************************* + * Copyright (c) 2004 IBM Corporation and others. + * All rights reserved. This program and the accompanying materials + * are made available under the terms of the Eclipse Public License v1.0 + * which accompanies this distribution, and is available at + * http://www.eclipse.org/legal/epl-v10.html + * + * Contributors: + * IBM Corporation - initial API and implementation + *******************************************************************************/ +package org.eclipse.wst.html.core.contentmodel; + + + +import java.util.Hashtable; +import java.util.Iterator; + +import org.eclipse.wst.common.contentmodel.CMNamedNodeMap; +import org.eclipse.wst.common.contentmodel.CMNode; + +/** + * An implementation of the CMNamedNodeMap interface. + * This class is intented to be used as a container of attribute declarations. + * If someone wants to use this class for other purpose, he must pay attention + * to the fact that this class is tolerant of the key name case. That is, this + * class does not distinguish "name", "NAME", and "Name" as a key name. + */ +class CMNamedNodeMapImpl implements CMNamedNodeMap { + + private Hashtable items = null; + + /** + */ + public CMNamedNodeMapImpl() { + super(); + items = new Hashtable(); + } + + /** + * getLength method + * @return int + */ + public int getLength() { + return items.size(); + } + + /** + * getNamedItem method + * @return CMNode <code>null</code> for unknown keys. + * @param name java.lang.String + */ + public CMNode getNamedItem(String name) { + String cookedName = makeCanonicalForm(name); + if (!items.containsKey(cookedName)) + return null; + return (CMNode) items.get(cookedName); + } + + /** + * item method + * @return CMNode + * @param index int + */ + public CMNode item(int index) { + Iterator iter = iterator(); + while (iter.hasNext()) { + CMNode node = (CMNode) iter.next(); + if (--index < 0) + return node; + } + return null; + } + + /** + * @return java.util.Iterator + */ + public Iterator iterator() { + return items.values().iterator(); + } + + /** + * @return java.lang.String + * @param rawForm java.lang.String + */ + private String makeCanonicalForm(String rawForm) { + return rawForm.toUpperCase(); + } + + /** + * @param key java.lang.String + * @param item java.lang.String + */ + void putNamedItem(String name, CMNode item) { + String cookedName = makeCanonicalForm(name); + if (items.containsKey(cookedName)) + return; // already registered. + items.put(cookedName, item); + } +}
\ No newline at end of file diff --git a/bundles/org.eclipse.wst.html.core/src/org/eclipse/wst/html/core/contentmodel/CMNamespaceImpl.java b/bundles/org.eclipse.wst.html.core/src/org/eclipse/wst/html/core/contentmodel/CMNamespaceImpl.java new file mode 100644 index 0000000000..f24a601225 --- /dev/null +++ b/bundles/org.eclipse.wst.html.core/src/org/eclipse/wst/html/core/contentmodel/CMNamespaceImpl.java @@ -0,0 +1,59 @@ +/******************************************************************************* + * Copyright (c) 2004 IBM Corporation and others. + * All rights reserved. This program and the accompanying materials + * are made available under the terms of the Eclipse Public License v1.0 + * which accompanies this distribution, and is available at + * http://www.eclipse.org/legal/epl-v10.html + * + * Contributors: + * IBM Corporation - initial API and implementation + *******************************************************************************/ +package org.eclipse.wst.html.core.contentmodel; + + + +import org.eclipse.wst.common.contentmodel.CMNamespace; +import org.eclipse.wst.common.contentmodel.CMNode; + +/** + * CMNamespace implementation. + */ +class CMNamespaceImpl extends CMNodeImpl implements CMNamespace { + + private java.lang.String prefix = null; + + /** + * CMNamespaceImpl constructor comment. + */ + public CMNamespaceImpl(String uri, String pfx) { + super(uri); + prefix = pfx; + } + + /** + * getNodeType method + * @return int + * + * Returns one of : + * + */ + public int getNodeType() { + return CMNode.NAME_SPACE; + } + + /** + * getPrefix method + * @return java.lang.String + */ + public String getPrefix() { + return prefix; + } + + /** + * getURI method + * @return java.lang.String + */ + public String getURI() { + return getNodeName(); + } +}
\ No newline at end of file diff --git a/bundles/org.eclipse.wst.html.core/src/org/eclipse/wst/html/core/contentmodel/CMNodeImpl.java b/bundles/org.eclipse.wst.html.core/src/org/eclipse/wst/html/core/contentmodel/CMNodeImpl.java new file mode 100644 index 0000000000..9c45f16e0e --- /dev/null +++ b/bundles/org.eclipse.wst.html.core/src/org/eclipse/wst/html/core/contentmodel/CMNodeImpl.java @@ -0,0 +1,65 @@ +/******************************************************************************* + * Copyright (c) 2004 IBM Corporation and others. + * All rights reserved. This program and the accompanying materials + * are made available under the terms of the Eclipse Public License v1.0 + * which accompanies this distribution, and is available at + * http://www.eclipse.org/legal/epl-v10.html + * + * Contributors: + * IBM Corporation - initial API and implementation + *******************************************************************************/ +package org.eclipse.wst.html.core.contentmodel; + +import org.eclipse.wst.common.contentmodel.CMNode; +import org.eclipse.wst.html.core.HTMLCMProperties; + + + +/** + */ +abstract class CMNodeImpl implements CMNode { + + private java.lang.String name = null; + + /** + * CMNodeImpl constructor comment. + */ + public CMNodeImpl(String nm) { + super(); + name = nm; + } + + /** + * getNodeName method + * @return java.lang.String + */ + public String getNodeName() { + return name; + } + + /** + * getProperty method + * @return java.lang.Object + * + * Returns the object property desciped by the propertyName + * + */ + public Object getProperty(String propertyName) { + if (propertyName.equals(HTMLCMProperties.IS_XHTML)) + return new Boolean(false); + return null; + } + + /** + * supports method + * @return boolean + * + * Returns true if the CMNode supports a specified property + * + */ + public boolean supports(String propertyName) { + if (propertyName.equals(HTMLCMProperties.IS_XHTML)) + return true; + return false; + } +}
\ No newline at end of file diff --git a/bundles/org.eclipse.wst.html.core/src/org/eclipse/wst/html/core/contentmodel/CMNodeListImpl.java b/bundles/org.eclipse.wst.html.core/src/org/eclipse/wst/html/core/contentmodel/CMNodeListImpl.java new file mode 100644 index 0000000000..a821fc51b9 --- /dev/null +++ b/bundles/org.eclipse.wst.html.core/src/org/eclipse/wst/html/core/contentmodel/CMNodeListImpl.java @@ -0,0 +1,62 @@ +/******************************************************************************* + * Copyright (c) 2004 IBM Corporation and others. + * All rights reserved. This program and the accompanying materials + * are made available under the terms of the Eclipse Public License v1.0 + * which accompanies this distribution, and is available at + * http://www.eclipse.org/legal/epl-v10.html + * + * Contributors: + * IBM Corporation - initial API and implementation + *******************************************************************************/ +package org.eclipse.wst.html.core.contentmodel; + + + +import org.eclipse.wst.common.contentmodel.CMNode; +import org.eclipse.wst.common.contentmodel.CMNodeList; + +/** + * Analog of dom.NodeList for CM. + * So, the implementation is very similar to + * {@link com.ibm.sed.model.xml.NodeListImpl}.<br> + */ +class CMNodeListImpl implements CMNodeList { + + private java.util.Vector nodes = null; + + /** + * CMNodeListImpl constructor comment. + */ + public CMNodeListImpl() { + super(); + nodes = new java.util.Vector(); + } + + /** + * @return org.eclipse.wst.common.contentmodel.CMNode + * @param node org.eclipse.wst.common.contentmodel.CMNode + */ + protected CMNode appendNode(CMNode node) { + nodes.addElement(node); + return node; + } + + /** + * getLength method + * @return int + */ + public int getLength() { + return nodes.size(); + } + + /** + * item method + * @return CMNode + * @param index int + */ + public CMNode item(int index) { + if (index < 0 || index >= nodes.size()) + return null; + return (CMNode) nodes.elementAt(index); + } +}
\ No newline at end of file diff --git a/bundles/org.eclipse.wst.html.core/src/org/eclipse/wst/html/core/contentmodel/ComplexTypeDefinition.java b/bundles/org.eclipse.wst.html.core/src/org/eclipse/wst/html/core/contentmodel/ComplexTypeDefinition.java new file mode 100644 index 0000000000..8ddb7732e2 --- /dev/null +++ b/bundles/org.eclipse.wst.html.core/src/org/eclipse/wst/html/core/contentmodel/ComplexTypeDefinition.java @@ -0,0 +1,76 @@ +/******************************************************************************* + * Copyright (c) 2004 IBM Corporation and others. + * All rights reserved. This program and the accompanying materials + * are made available under the terms of the Eclipse Public License v1.0 + * which accompanies this distribution, and is available at + * http://www.eclipse.org/legal/epl-v10.html + * + * Contributors: + * IBM Corporation - initial API and implementation + *******************************************************************************/ +package org.eclipse.wst.html.core.contentmodel; + + + +import org.eclipse.wst.common.contentmodel.CMGroup; + +/** + * This class is intended to represent a complex type definition + * in XML Schema.<br> + */ +abstract class ComplexTypeDefinition { + + protected CMGroupImpl content = null; + protected ElementCollection collection = null; + protected String primaryCandidateName = null; + + /** + * ComplexTypeDefinition constructor comment. + */ + public ComplexTypeDefinition(ElementCollection elementCollection) { + super(); + collection = elementCollection; + createContent(); + } + + /** + * Create an actual content model. + * This method should be called once and only once in the constructor.<br> + */ + protected abstract void createContent(); + + /** + * @return org.eclipse.wst.common.contentmodel.CMGroup + */ + public CMGroup getContent() { + return content; + } + + /** + * @return int; Should be one of ANY, EMPTY, ELEMENT, MIXED, PCDATA, CDATA, + * those are defined in CMElementDeclaration. + */ + /* NOTE: Do we need LOGICAL type? + * -- 3/7/2001 + */ + public abstract int getContentType(); + + /** + * Get content hint. + * @return com.ibm.sed.contentmodel.html.HTMLElementDeclaration + */ + public HTMLElementDeclaration getPrimaryCandidate() { + if (primaryCandidateName == null) + return null; + return (HTMLElementDeclaration) collection.getNamedItem(primaryCandidateName); + } + + /** + * Name of complex type definition. + * Each singleton must know its own name. + * All names should be defined in + * {@link <code>ComplexTypeDefinitionFactory</code>} as constants.<br> + * @return java.lang.String + */ + public abstract String getTypeName(); +}
\ No newline at end of file diff --git a/bundles/org.eclipse.wst.html.core/src/org/eclipse/wst/html/core/contentmodel/ComplexTypeDefinitionFactory.java b/bundles/org.eclipse.wst.html.core/src/org/eclipse/wst/html/core/contentmodel/ComplexTypeDefinitionFactory.java new file mode 100644 index 0000000000..ecf6f04002 --- /dev/null +++ b/bundles/org.eclipse.wst.html.core/src/org/eclipse/wst/html/core/contentmodel/ComplexTypeDefinitionFactory.java @@ -0,0 +1,185 @@ +/******************************************************************************* + * Copyright (c) 2004 IBM Corporation and others. + * All rights reserved. This program and the accompanying materials + * are made available under the terms of the Eclipse Public License v1.0 + * which accompanies this distribution, and is available at + * http://www.eclipse.org/legal/epl-v10.html + * + * Contributors: + * IBM Corporation - initial API and implementation + *******************************************************************************/ +package org.eclipse.wst.html.core.contentmodel; + + + +/** + * Factory of ComplexTypeDefinition. + */ +final class ComplexTypeDefinitionFactory { + + private static ComplexTypeDefinitionFactory instance = null; + private java.util.Hashtable definitions = null; + // constants for complex type name + /** for ADDRESS. */ + public final static String CTYPE_ADDRESS = "CTYPE_ADDRESS";//$NON-NLS-1$ + /** CDATA content. No ComplexTypeDefinition instance shuld be created. */ + public final static String CTYPE_CDATA = "CTYPE_CDATA";//$NON-NLS-1$ + /** col group content. COL* */ + public final static String CTYPE_COLUMN_GROUP = "CTYPE_COLUMN_GROUP";//$NON-NLS-1$ + /** for DL. */ + public final static String CTYPE_DEFINITION_LIST = "CTYPE_DEFINITION_LIST";//$NON-NLS-1$ + /** for EMBED. */ + public final static String CTYPE_EMBED = "CTYPE_EMBED";//$NON-NLS-1$ + /** empty content. No ComplexTypeDefinition instance should be created. */ + public final static String CTYPE_EMPTY = "CTYPE_EMPTY";//$NON-NLS-1$ + /** for FIELDSET. */ + public final static String CTYPE_FIELDSET = "CTYPE_FIELDSET";//$NON-NLS-1$ + /** for FRAMESET. */ + public final static String CTYPE_FRAMESET = "CTYPE_FRAMESET";//$NON-NLS-1$ + /** flow content. (%flow;)* */ + public final static String CTYPE_FLOW_CONTAINER = "CTYPE_FLOW_CONTAINER";//$NON-NLS-1$ + /** html content. HEAD, (FRAMESET|BODY) */ + public final static String CTYPE_HTML = "CTYPE_HTML";//$NON-NLS-1$ + /** head content. TITLE & ISINDEX? & BASE? */ + public final static String CTYPE_HEAD = "CTYPE_HEAD";//$NON-NLS-1$ + /** inline content. (%inline;)* */ + public final static String CTYPE_INLINE_CONTAINER = "CTYPE_INLINE_CONTAINER";//$NON-NLS-1$ + /** list item container. (LI)+ */ + public final static String CTYPE_LI_CONTAINER = "CTYPE_LI_CONTAINER";//$NON-NLS-1$ + /** for MAP. */ + public final static String CTYPE_MAP = "CTYPE_MAP";//$NON-NLS-1$ + /** noframes content. */ + public final static String CTYPE_NOFRAMES_CONTENT = "CTYPE_NOFRAMES_CONTENT";//$NON-NLS-1$ + /** for OPTGROUP. */ + public final static String CTYPE_OPTION_CONTAINER = "CTYPE_OPTION_CONTAINER";//$NON-NLS-1$ + /** param container. For OBJECT/APPLET. */ + public final static String CTYPE_PARAM_CONTAINER = "CTYPE_PARAM_CONTAINER";//$NON-NLS-1$ + /** PCDATA content. No ComplexTypeDefinition instance shuld be created. */ + public final static String CTYPE_PCDATA = "CTYPE_PCDATA";//$NON-NLS-1$ + /** for SELECT. */ + public final static String CTYPE_SELECT = "CTYPE_SELECT";//$NON-NLS-1$ + /** table content. CAPTION?, (COL*|COLGROUP*), THEAD?, TFOOT?, TBODY+ */ + public final static String CTYPE_TABLE = "CTYPE_TABLE";//$NON-NLS-1$ + /** table cell contaier. (TH|TD)+ */ + public final static String CTYPE_TCELL_CONTAINER = "CTYPE_TCELL_CONTAINER";//$NON-NLS-1$ + /** table record container. (TR)+ */ + public final static String CTYPE_TR_CONTAINER = "CTYPE_TR_CONTAINER";//$NON-NLS-1$ + + /** + * ComplexTypeDefinitionFactory constructor comment. + */ + private ComplexTypeDefinitionFactory() { + super(); + definitions = new java.util.Hashtable(); + } + + /** + * Factory method for ComplexTypeDefinition. + * Each instance created in this method must be registered into + * the map with its name. + * @return com.ibm.sed.contentmodel.html.ComplexTypeDefinition + * @param definitionName java.lang.String + * @param elementCollection ElementCollection + */ + public ComplexTypeDefinition createTypeDefinition(String definitionName, ElementCollection elementCollection) { + if (definitions.containsKey(definitionName)) { + return (ComplexTypeDefinition) definitions.get(definitionName); + } + + ComplexTypeDefinition def = null; + if (definitionName == CTYPE_ADDRESS) { + def = new CtdAddress(elementCollection); + + } + else if (definitionName == CTYPE_COLUMN_GROUP) { + def = new CtdColumnGroup(elementCollection); + + } + else if (definitionName == CTYPE_DEFINITION_LIST) { + def = new CtdDl(elementCollection); + + } + else if (definitionName == CTYPE_EMBED) { + def = new CtdEmbed(elementCollection); + + } + else if (definitionName == CTYPE_FIELDSET) { + def = new CtdFieldset(elementCollection); + + } + else if (definitionName == CTYPE_FLOW_CONTAINER) { + def = new CtdFlowContainer(elementCollection); + + } + else if (definitionName == CTYPE_FRAMESET) { + def = new CtdFrameset(elementCollection); + + } + else if (definitionName == CTYPE_HEAD) { + def = new CtdHead(elementCollection); + + } + else if (definitionName == CTYPE_HTML) { + def = new CtdHtml(elementCollection); + + } + else if (definitionName == CTYPE_INLINE_CONTAINER) { + def = new CtdInlineContainer(elementCollection); + + } + else if (definitionName == CTYPE_LI_CONTAINER) { + def = new CtdLiContainer(elementCollection); + + } + else if (definitionName == CTYPE_MAP) { + def = new CtdMap(elementCollection); + + } + else if (definitionName == CTYPE_NOFRAMES_CONTENT) { + def = new CtdNoframesContent(elementCollection); + + } + else if (definitionName == CTYPE_OPTION_CONTAINER) { + def = new CtdOptionContainer(elementCollection); + + } + else if (definitionName == CTYPE_PARAM_CONTAINER) { + def = new CtdParamContainer(elementCollection); + + } + else if (definitionName == CTYPE_SELECT) { + def = new CtdSelect(elementCollection); + + } + else if (definitionName == CTYPE_TABLE) { + def = new CtdTable(elementCollection); + + } + else if (definitionName == CTYPE_TCELL_CONTAINER) { + def = new CtdTableCellContainer(elementCollection); + + } + else if (definitionName == CTYPE_TR_CONTAINER) { + def = new CtdTrContainer(elementCollection); + + } + else { + def = null; + } + if (def == null) + return null; // fail to create. + definitions.put(definitionName, def); + return def; + } + + /** + * For singleton.<br> + * @return com.ibm.sed.contentmodel.html.ComplexTypeDefinitionFactory + */ + public synchronized static ComplexTypeDefinitionFactory getInstance() { + if (instance != null) + return instance; + instance = new ComplexTypeDefinitionFactory(); + return instance; + } +}
\ No newline at end of file diff --git a/bundles/org.eclipse.wst.html.core/src/org/eclipse/wst/html/core/contentmodel/CtdAddress.java b/bundles/org.eclipse.wst.html.core/src/org/eclipse/wst/html/core/contentmodel/CtdAddress.java new file mode 100644 index 0000000000..a524a1cd73 --- /dev/null +++ b/bundles/org.eclipse.wst.html.core/src/org/eclipse/wst/html/core/contentmodel/CtdAddress.java @@ -0,0 +1,71 @@ +/******************************************************************************* + * Copyright (c) 2004 IBM Corporation and others. + * All rights reserved. This program and the accompanying materials + * are made available under the terms of the Eclipse Public License v1.0 + * which accompanies this distribution, and is available at + * http://www.eclipse.org/legal/epl-v10.html + * + * Contributors: + * IBM Corporation - initial API and implementation + *******************************************************************************/ +package org.eclipse.wst.html.core.contentmodel; + + + +import org.eclipse.wst.common.contentmodel.CMElementDeclaration; +import org.eclipse.wst.common.contentmodel.CMGroup; +import org.eclipse.wst.common.contentmodel.CMNode; +import org.eclipse.wst.html.core.HTML40Namespace; + +/** + * for ADDRESS. + */ +final class CtdAddress extends ComplexTypeDefinition { + + /** + * @param elementCollection ElementCollection + */ + public CtdAddress(ElementCollection elementCollection) { + super(elementCollection); + } + + /** + * ((%inline) | P)*. + */ + protected void createContent() { + if (content != null) + return; // already created. + if (collection == null) + return; + + // ( | )* + content = new CMGroupImpl(CMGroup.CHOICE, 0, CMContentImpl.UNBOUNDED); + // (%inline) + CMGroupImpl inlines = new CMGroupImpl(CMGroup.CHOICE, 1, 1); + if (inlines == null) + return; + collection.getInline(inlines); + content.appendChild(inlines); + // P + CMNode p = collection.getNamedItem(HTML40Namespace.ElementName.P); + if (p != null) + content.appendChild(p); + } + + /** + * ((%inline) | P)*. + * Because %inline; contains #PCDATA, the type is MIXED. + * @return int; Should be one of ANY, EMPTY, ELEMENT, MIXED, PCDATA, CDATA, + * those are defined in CMElementDeclaration. + */ + public int getContentType() { + return CMElementDeclaration.MIXED; + } + + /** + * @return java.lang.String + */ + public String getTypeName() { + return ComplexTypeDefinitionFactory.CTYPE_ADDRESS; + } +}
\ No newline at end of file diff --git a/bundles/org.eclipse.wst.html.core/src/org/eclipse/wst/html/core/contentmodel/CtdColumnGroup.java b/bundles/org.eclipse.wst.html.core/src/org/eclipse/wst/html/core/contentmodel/CtdColumnGroup.java new file mode 100644 index 0000000000..f3b8e5585a --- /dev/null +++ b/bundles/org.eclipse.wst.html.core/src/org/eclipse/wst/html/core/contentmodel/CtdColumnGroup.java @@ -0,0 +1,69 @@ +/******************************************************************************* + * Copyright (c) 2004 IBM Corporation and others. + * All rights reserved. This program and the accompanying materials + * are made available under the terms of the Eclipse Public License v1.0 + * which accompanies this distribution, and is available at + * http://www.eclipse.org/legal/epl-v10.html + * + * Contributors: + * IBM Corporation - initial API and implementation + *******************************************************************************/ +package org.eclipse.wst.html.core.contentmodel; + + + +import org.eclipse.wst.common.contentmodel.CMElementDeclaration; +import org.eclipse.wst.common.contentmodel.CMGroup; +import org.eclipse.wst.common.contentmodel.CMNode; +import org.eclipse.wst.html.core.HTML40Namespace; + +/** + * COL group. + * (COL)* + */ +final class CtdColumnGroup extends ComplexTypeDefinition { + + /** + * @param elementCollection ElementCollection + */ + public CtdColumnGroup(ElementCollection elementCollection) { + super(elementCollection); + } + + /** + * (COL)* + */ + protected void createContent() { + if (content != null) + return; // already created. + if (collection == null) + return; + + // ( )* + content = new CMGroupImpl(CMGroup.SEQUENCE, 0, CMContentImpl.UNBOUNDED); + // COL + CMNode dec = collection.getNamedItem(HTML40Namespace.ElementName.COL); + if (dec != null) + content.appendChild(dec); + } + + /** + * (COL)* + * @return int; Should be one of ANY, EMPTY, ELEMENT, MIXED, PCDATA, CDATA, + * those are defined in CMElementDeclaration. + */ + public int getContentType() { + return CMElementDeclaration.ELEMENT; + } + + /** + * Name of complex type definition. + * Each singleton must know its own name. + * All names should be defined in + * {@link <code>ComplexTypeDefinitionFactory</code>} as constants.<br> + * @return java.lang.String + */ + public String getTypeName() { + return ComplexTypeDefinitionFactory.CTYPE_COLUMN_GROUP; + } +}
\ No newline at end of file diff --git a/bundles/org.eclipse.wst.html.core/src/org/eclipse/wst/html/core/contentmodel/CtdDl.java b/bundles/org.eclipse.wst.html.core/src/org/eclipse/wst/html/core/contentmodel/CtdDl.java new file mode 100644 index 0000000000..abd3dd42ab --- /dev/null +++ b/bundles/org.eclipse.wst.html.core/src/org/eclipse/wst/html/core/contentmodel/CtdDl.java @@ -0,0 +1,69 @@ +/******************************************************************************* + * Copyright (c) 2004 IBM Corporation and others. + * All rights reserved. This program and the accompanying materials + * are made available under the terms of the Eclipse Public License v1.0 + * which accompanies this distribution, and is available at + * http://www.eclipse.org/legal/epl-v10.html + * + * Contributors: + * IBM Corporation - initial API and implementation + *******************************************************************************/ +package org.eclipse.wst.html.core.contentmodel; + + + +import org.eclipse.wst.common.contentmodel.CMElementDeclaration; +import org.eclipse.wst.common.contentmodel.CMGroup; +import org.eclipse.wst.common.contentmodel.CMNode; +import org.eclipse.wst.html.core.HTML40Namespace; + +/** + * for DL. + */ +final class CtdDl extends ComplexTypeDefinition { + + /** + * @param elementCollection ElementCollection + */ + public CtdDl(ElementCollection elementCollection) { + super(elementCollection); + primaryCandidateName = HTML40Namespace.ElementName.DT; + } + + /** + * (DT | DD)+ + */ + protected void createContent() { + if (content != null) + return; // already created. + if (collection == null) + return; + + // ( | )+ + content = new CMGroupImpl(CMGroup.CHOICE, 1, CMContentImpl.UNBOUNDED); + // DT + CMNode dec = collection.getNamedItem(HTML40Namespace.ElementName.DT); + if (dec != null) + content.appendChild(dec); + // DD + dec = collection.getNamedItem(HTML40Namespace.ElementName.DD); + if (dec != null) + content.appendChild(dec); + } + + /** + * (DT | DD)+. + * @return int; Should be one of ANY, EMPTY, ELEMENT, MIXED, PCDATA, CDATA, + * those are defined in CMElementDeclaration. + */ + public int getContentType() { + return CMElementDeclaration.ELEMENT; + } + + /** + * @return java.lang.String + */ + public String getTypeName() { + return ComplexTypeDefinitionFactory.CTYPE_DEFINITION_LIST; + } +}
\ No newline at end of file diff --git a/bundles/org.eclipse.wst.html.core/src/org/eclipse/wst/html/core/contentmodel/CtdEmbed.java b/bundles/org.eclipse.wst.html.core/src/org/eclipse/wst/html/core/contentmodel/CtdEmbed.java new file mode 100644 index 0000000000..f5abdd5bcb --- /dev/null +++ b/bundles/org.eclipse.wst.html.core/src/org/eclipse/wst/html/core/contentmodel/CtdEmbed.java @@ -0,0 +1,65 @@ +/******************************************************************************* + * Copyright (c) 2004 IBM Corporation and others. + * All rights reserved. This program and the accompanying materials + * are made available under the terms of the Eclipse Public License v1.0 + * which accompanies this distribution, and is available at + * http://www.eclipse.org/legal/epl-v10.html + * + * Contributors: + * IBM Corporation - initial API and implementation + *******************************************************************************/ +package org.eclipse.wst.html.core.contentmodel; + + + +import org.eclipse.wst.common.contentmodel.CMElementDeclaration; +import org.eclipse.wst.common.contentmodel.CMGroup; +import org.eclipse.wst.common.contentmodel.CMNode; +import org.eclipse.wst.html.core.HTML40Namespace; + +/** + * for EMBED. + */ +final class CtdEmbed extends ComplexTypeDefinition { + + /** + * @param elementCollection ElementCollection + */ + public CtdEmbed(ElementCollection elementCollection) { + super(elementCollection); + primaryCandidateName = HTML40Namespace.ElementName.NOEMBED; + } + + /** + * (NOEMBED). + */ + protected void createContent() { + if (content != null) + return; // already created. + if (collection == null) + return; + + // ( ) + content = new CMGroupImpl(CMGroup.SEQUENCE, 1, 1); + // NOEMBED + CMNode noembed = collection.getNamedItem(HTML40Namespace.ElementName.NOEMBED); + if (noembed != null) + content.appendChild(noembed); + } + + /** + * (NOEMBED). + * @return int; Should be one of ANY, EMPTY, ELEMENT, MIXED, PCDATA, CDATA, + * those are defined in CMElementDeclaration. + */ + public int getContentType() { + return CMElementDeclaration.ELEMENT; + } + + /** + * @return java.lang.String + */ + public String getTypeName() { + return ComplexTypeDefinitionFactory.CTYPE_EMBED; + } +}
\ No newline at end of file diff --git a/bundles/org.eclipse.wst.html.core/src/org/eclipse/wst/html/core/contentmodel/CtdFieldset.java b/bundles/org.eclipse.wst.html.core/src/org/eclipse/wst/html/core/contentmodel/CtdFieldset.java new file mode 100644 index 0000000000..e54e8f5e65 --- /dev/null +++ b/bundles/org.eclipse.wst.html.core/src/org/eclipse/wst/html/core/contentmodel/CtdFieldset.java @@ -0,0 +1,74 @@ +/******************************************************************************* + * Copyright (c) 2004 IBM Corporation and others. + * All rights reserved. This program and the accompanying materials + * are made available under the terms of the Eclipse Public License v1.0 + * which accompanies this distribution, and is available at + * http://www.eclipse.org/legal/epl-v10.html + * + * Contributors: + * IBM Corporation - initial API and implementation + *******************************************************************************/ +package org.eclipse.wst.html.core.contentmodel; + + + +import org.eclipse.wst.common.contentmodel.CMElementDeclaration; +import org.eclipse.wst.common.contentmodel.CMGroup; +import org.eclipse.wst.common.contentmodel.CMNode; +import org.eclipse.wst.html.core.HTML40Namespace; + +/** + * for FIELDSET. + */ +final class CtdFieldset extends ComplexTypeDefinition { + + /** + * @param elementCollection ElementCollection + */ + public CtdFieldset(ElementCollection elementCollection) { + super(elementCollection); + primaryCandidateName = HTML40Namespace.ElementName.LEGEND; + } + + /** + * (#PCDATA, LEGEND, (%flow;)*) + */ + protected void createContent() { + if (content != null) + return; // already created. + if (collection == null) + return; + + // ( , , ) + content = new CMGroupImpl(CMGroup.SEQUENCE, 1, 1); + // #PCDATA + // ...?? + + // LEGEND + CMNode dec = collection.getNamedItem(HTML40Namespace.ElementName.LEGEND); + if (dec != null) + content.appendChild(dec); + // (%flow;)* + CMGroupImpl flows = new CMGroupImpl(CMGroup.CHOICE, 0, CMContentImpl.UNBOUNDED); + if (flows == null) + return; + collection.getFlow(flows); + content.appendChild(flows); + } + + /** + * (#PCDATA, LEGEND, (%flow;)*) + * @return int; Should be one of ANY, EMPTY, ELEMENT, MIXED, PCDATA, CDATA, + * those are defined in CMElementDeclaration. + */ + public int getContentType() { + return CMElementDeclaration.MIXED; + } + + /** + * @return java.lang.String + */ + public String getTypeName() { + return ComplexTypeDefinitionFactory.CTYPE_FIELDSET; + } +}
\ No newline at end of file diff --git a/bundles/org.eclipse.wst.html.core/src/org/eclipse/wst/html/core/contentmodel/CtdFlowContainer.java b/bundles/org.eclipse.wst.html.core/src/org/eclipse/wst/html/core/contentmodel/CtdFlowContainer.java new file mode 100644 index 0000000000..7b202bea5c --- /dev/null +++ b/bundles/org.eclipse.wst.html.core/src/org/eclipse/wst/html/core/contentmodel/CtdFlowContainer.java @@ -0,0 +1,55 @@ +/******************************************************************************* + * Copyright (c) 2004 IBM Corporation and others. + * All rights reserved. This program and the accompanying materials + * are made available under the terms of the Eclipse Public License v1.0 + * which accompanies this distribution, and is available at + * http://www.eclipse.org/legal/epl-v10.html + * + * Contributors: + * IBM Corporation - initial API and implementation + *******************************************************************************/ +package org.eclipse.wst.html.core.contentmodel; + + + +import org.eclipse.wst.common.contentmodel.CMElementDeclaration; +import org.eclipse.wst.common.contentmodel.CMGroup; + +/** + * Complex type definition for containers of <code>%flow;</code>. + */ +final class CtdFlowContainer extends ComplexTypeDefinition { + + /** + */ + public CtdFlowContainer(ElementCollection elementCollection) { + super(elementCollection); + } + + /** + * (%flow;)* + */ + protected void createContent() { + if (content != null) + return; // already created. + if (collection == null) + return; + + content = new CMGroupImpl(CMGroup.CHOICE, 0, CMContentImpl.UNBOUNDED); + collection.getFlow(content); + } + + /** + * @see com.ibm.sed.contentmodel.html.ComplexTypeDefinition + */ + public int getContentType() { + return CMElementDeclaration.MIXED; + } + + /** + * @see com.ibm.sed.contentmodel.html.ComplexTypeDefinition + */ + public String getTypeName() { + return ComplexTypeDefinitionFactory.CTYPE_FLOW_CONTAINER; + } +}
\ No newline at end of file diff --git a/bundles/org.eclipse.wst.html.core/src/org/eclipse/wst/html/core/contentmodel/CtdFrameset.java b/bundles/org.eclipse.wst.html.core/src/org/eclipse/wst/html/core/contentmodel/CtdFrameset.java new file mode 100644 index 0000000000..759d983ad4 --- /dev/null +++ b/bundles/org.eclipse.wst.html.core/src/org/eclipse/wst/html/core/contentmodel/CtdFrameset.java @@ -0,0 +1,93 @@ +/******************************************************************************* + * Copyright (c) 2004 IBM Corporation and others. + * All rights reserved. This program and the accompanying materials + * are made available under the terms of the Eclipse Public License v1.0 + * which accompanies this distribution, and is available at + * http://www.eclipse.org/legal/epl-v10.html + * + * Contributors: + * IBM Corporation - initial API and implementation + *******************************************************************************/ +package org.eclipse.wst.html.core.contentmodel; + + + +import org.eclipse.wst.common.contentmodel.CMElementDeclaration; +import org.eclipse.wst.common.contentmodel.CMGroup; +import org.eclipse.wst.common.contentmodel.CMNode; +import org.eclipse.wst.html.core.HTML40Namespace; + +/** + * for FRAMESET. + * ((FRAMESET | FRAME)+ & NOFRAMES?) + */ +final class CtdFrameset extends ComplexTypeDefinition { + + /** + * @param elementCollection ElementCollection + */ + public CtdFrameset(ElementCollection elementCollection) { + super(elementCollection); + primaryCandidateName = HTML40Namespace.ElementName.FRAME; + } + + /** + * ((FRAMESET | FRAME)+ & NOFRAMES?). + * --> ((FRAMESET | FRAME)+ & (NOFRAMES)?) + */ + protected void createContent() { + if (content != null) + return; // already created. + if (collection == null) + return; + + // ( & ) + content = new CMGroupImpl(CMGroup.ALL, 1, 1); + + // ( | )+ + CMGroupImpl group = new CMGroupImpl(CMGroup.CHOICE, 1, CMContentImpl.UNBOUNDED); + if (group == null) + return; + content.appendChild(group); + + // FRAMESET + CMNode dec = collection.getNamedItem(HTML40Namespace.ElementName.FRAMESET); + if (dec != null) + group.appendChild(dec); + // FRAME + dec = collection.getNamedItem(HTML40Namespace.ElementName.FRAME); + if (dec != null) + group.appendChild(dec); + + // ( )? + group = new CMGroupImpl(CMGroup.SEQUENCE, 0, 1); + if (group == null) + return; + content.appendChild(group); + + // NOFRAMES + dec = collection.getNamedItem(HTML40Namespace.ElementName.NOFRAMES); + if (dec != null) + group.appendChild(dec); + } + + /** + * ((FRAMESET | FRAME)+ & NOFRAMES?) + * @return int; Should be one of ANY, EMPTY, ELEMENT, MIXED, PCDATA, CDATA, + * those are defined in CMElementDeclaration. + */ + public int getContentType() { + return CMElementDeclaration.ELEMENT; + } + + /** + * Name of complex type definition. + * Each singleton must know its own name. + * All names should be defined in + * {@link <code>ComplexTypeDefinitionFactory</code>} as constants.<br> + * @return java.lang.String + */ + public String getTypeName() { + return ComplexTypeDefinitionFactory.CTYPE_FRAMESET; + } +}
\ No newline at end of file diff --git a/bundles/org.eclipse.wst.html.core/src/org/eclipse/wst/html/core/contentmodel/CtdHead.java b/bundles/org.eclipse.wst.html.core/src/org/eclipse/wst/html/core/contentmodel/CtdHead.java new file mode 100644 index 0000000000..684241edd8 --- /dev/null +++ b/bundles/org.eclipse.wst.html.core/src/org/eclipse/wst/html/core/contentmodel/CtdHead.java @@ -0,0 +1,176 @@ +/******************************************************************************* + * Copyright (c) 2004 IBM Corporation and others. + * All rights reserved. This program and the accompanying materials + * are made available under the terms of the Eclipse Public License v1.0 + * which accompanies this distribution, and is available at + * http://www.eclipse.org/legal/epl-v10.html + * + * Contributors: + * IBM Corporation - initial API and implementation + *******************************************************************************/ +package org.eclipse.wst.html.core.contentmodel; + + + +import java.util.Arrays; + +import org.eclipse.wst.common.contentmodel.CMElementDeclaration; +import org.eclipse.wst.common.contentmodel.CMGroup; +import org.eclipse.wst.common.contentmodel.CMNode; +import org.eclipse.wst.html.core.HTML40Namespace; + +/** + * Complex type definition for the head content. + * Content Model: (TITLE & ISINDEX? & BASE?) + */ +final class CtdHead extends ComplexTypeDefinition { + + /** + */ + public CtdHead(ElementCollection elementCollection) { + super(elementCollection); + primaryCandidateName = HTML40Namespace.ElementName.TITLE; + } + + /** + * for HEAD. + * To avoid using inclusion, the content model comes from the XHTML 1.0. + * + * (%head.misc;, ((title, %head.misc;, (base, %head.misc;)?) | (base, %head.misc;, (title, %head.misc;)))) + * And %head.misc; is: + * (script|style|meta|link|object|isindex)* + * + * 0: (%head.misc, A) + * A: (B | C) + * B: (title, %head.misc;, D) + * C: (base, %head.misc;, E) + * D: (base, %head.misc;)? + * E: (title, %head.misc;) + */ + protected void createContent() { + if (content != null) + return; // already created. + if (collection == null) + return; + + // At 1st, create %head.misc; content. + // %head.misc; + // ( | )* + CMGroupImpl misc = new CMGroupImpl(CMGroup.CHOICE, 0, CMContentImpl.UNBOUNDED); + if (misc == null) + return; + String[] names = {HTML40Namespace.ElementName.SCRIPT, HTML40Namespace.ElementName.STYLE, HTML40Namespace.ElementName.META, HTML40Namespace.ElementName.LINK, HTML40Namespace.ElementName.OBJECT, HTML40Namespace.ElementName.ISINDEX}; + collection.getDeclarations(misc, Arrays.asList(names).iterator()); + // 2nd, get a title + CMNode title = collection.getNamedItem(HTML40Namespace.ElementName.TITLE); + // 3rd, get a base + CMNode base = collection.getNamedItem(HTML40Namespace.ElementName.BASE); + if (title == null || base == null) + return; + + // Top level content is a sequence of %head.misc; and A. + // 0: (%head.misc;, A) + // create a sequence + content = new CMGroupImpl(CMGroup.SEQUENCE, 1, 1); + if (content == null) + return; + // append %head.misc; + content.appendChild(misc); + // create A and append it to the top level. + { + // A is a choice of B and C. + // A: (B | C) + // create a choice + CMGroupImpl gA = new CMGroupImpl(CMGroup.CHOICE, 1, 1); + if (gA == null) + return; + // append A to the top level. + content.appendChild(gA); + + // create B and append it to A + { + // B is a sequence of title, %head.misc;, and D. + // B: (title, %head.misc;, D) + // create a sequence + CMGroupImpl gB = new CMGroupImpl(CMGroup.SEQUENCE, 1, 1); + if (gB == null) + return; + // append B to A. + gA.appendChild(gB); + + // append title to B + gB.appendChild(title); + // append %head.misc; to B + gB.appendChild(misc); + // create D and append it to B. + { + // D is a sequence of base, %head.misc;. + // D: (base, %head.misc;)? + // create a sequence + CMGroupImpl gD = new CMGroupImpl(CMGroup.SEQUENCE, 0, 1); + if (gD == null) + return; + // append D to B. + gB.appendChild(gD); + + // append base to D + gD.appendChild(base); + // append %head.misc; to D. + gD.appendChild(misc); + } + } + // create C and append it to A + { + // C is a sequence of base, %head.misc;, and E + // C: (base, %head.misc;, E) + // create a sequence + CMGroupImpl gC = new CMGroupImpl(CMGroup.SEQUENCE, 1, 1); + if (gC == null) + return; + // append C to A. + gA.appendChild(gC); + + // append base to C + gC.appendChild(base); + // append %head.misc; to C + gC.appendChild(misc); + + // create E and append it to C. + { + // E is a sequence of title and %head.misc;. + // E: (title, %head.misc;) + // create a sequence + CMGroupImpl gE = new CMGroupImpl(CMGroup.SEQUENCE, 1, 1); + if (gE == null) + return; + // append E to C. + gC.appendChild(gE); + + // append title to E + gE.appendChild(title); + // append %head.misc; to E. + gE.appendChild(misc); + } + } + } + } + + /** + * Element content.<br> + * @see com.ibm.sed.contentmodel.html.ComplexTypeDefinition + */ + public int getContentType() { + return CMElementDeclaration.ELEMENT; + } + + /** + * Name of complex type definition. + * Each singleton must know its own name. + * All names should be defined in + * {@link <code>ComplexTypeDefinitionFactory</code>} as constants.<br> + * @return java.lang.String + */ + public String getTypeName() { + return ComplexTypeDefinitionFactory.CTYPE_HEAD; + } +}
\ No newline at end of file diff --git a/bundles/org.eclipse.wst.html.core/src/org/eclipse/wst/html/core/contentmodel/CtdHtml.java b/bundles/org.eclipse.wst.html.core/src/org/eclipse/wst/html/core/contentmodel/CtdHtml.java new file mode 100644 index 0000000000..b13ba6bd42 --- /dev/null +++ b/bundles/org.eclipse.wst.html.core/src/org/eclipse/wst/html/core/contentmodel/CtdHtml.java @@ -0,0 +1,80 @@ +/******************************************************************************* + * Copyright (c) 2004 IBM Corporation and others. + * All rights reserved. This program and the accompanying materials + * are made available under the terms of the Eclipse Public License v1.0 + * which accompanies this distribution, and is available at + * http://www.eclipse.org/legal/epl-v10.html + * + * Contributors: + * IBM Corporation - initial API and implementation + *******************************************************************************/ +package org.eclipse.wst.html.core.contentmodel; + + + +import java.util.Arrays; + +import org.eclipse.wst.common.contentmodel.CMElementDeclaration; +import org.eclipse.wst.common.contentmodel.CMGroup; +import org.eclipse.wst.common.contentmodel.CMNode; +import org.eclipse.wst.html.core.HTML40Namespace; + +/** + * Complex type definition for <code>HTML</code>.<br> + * Content Model: + * HEAD, (FRAMESET|BODY)<br> + */ +final class CtdHtml extends ComplexTypeDefinition { + + /** + */ + public CtdHtml(ElementCollection elementCollection) { + super(elementCollection); + primaryCandidateName = HTML40Namespace.ElementName.HEAD; + } + + /** + * (%html.content;). + * %html.content; is HEAD, (FRAMESET | BODY). + * @see com.ibm.sed.contentmodel.html.ComplexTypeDefinition + */ + protected void createContent() { + if (content != null) + return; // already created. + if (collection == null) + return; + + // ( ) + content = new CMGroupImpl(CMGroup.SEQUENCE, 1, 1); + if (content == null) + return; + + // HEAD + CMNode edec = collection.getNamedItem(HTML40Namespace.ElementName.HEAD); + if (edec != null) + content.appendChild(edec); + + // ( | ) + CMGroupImpl group = new CMGroupImpl(CMGroup.CHOICE, 1, 1); + content.appendChild(group); + + // FRAMESET, BODY + String[] names = {HTML40Namespace.ElementName.FRAMESET, HTML40Namespace.ElementName.BODY}; + collection.getDeclarations(group, Arrays.asList(names).iterator()); + } + + /** + * Element content. + * @see com.ibm.sed.contentmodel.html.ComplexTypeDefinition + */ + public int getContentType() { + return CMElementDeclaration.ELEMENT; + } + + /** + * @see com.ibm.sed.contentmodel.html.ComplexTypeDefinition + */ + public String getTypeName() { + return ComplexTypeDefinitionFactory.CTYPE_HTML; + } +}
\ No newline at end of file diff --git a/bundles/org.eclipse.wst.html.core/src/org/eclipse/wst/html/core/contentmodel/CtdInlineContainer.java b/bundles/org.eclipse.wst.html.core/src/org/eclipse/wst/html/core/contentmodel/CtdInlineContainer.java new file mode 100644 index 0000000000..09ee6b80fa --- /dev/null +++ b/bundles/org.eclipse.wst.html.core/src/org/eclipse/wst/html/core/contentmodel/CtdInlineContainer.java @@ -0,0 +1,56 @@ +/******************************************************************************* + * Copyright (c) 2004 IBM Corporation and others. + * All rights reserved. This program and the accompanying materials + * are made available under the terms of the Eclipse Public License v1.0 + * which accompanies this distribution, and is available at + * http://www.eclipse.org/legal/epl-v10.html + * + * Contributors: + * IBM Corporation - initial API and implementation + *******************************************************************************/ +package org.eclipse.wst.html.core.contentmodel; + + + +import org.eclipse.wst.common.contentmodel.CMElementDeclaration; +import org.eclipse.wst.common.contentmodel.CMGroup; + +/** + * Complex type definition for (%inline;)*. + */ +final class CtdInlineContainer extends ComplexTypeDefinition { + + /** + * @param elementCollection ElementCollection + */ + public CtdInlineContainer(ElementCollection elementCollection) { + super(elementCollection); + } + + /** + * (%inline)*. + */ + protected void createContent() { + if (content != null) + return; // already created. + if (collection == null) + return; + + content = new CMGroupImpl(CMGroup.CHOICE, 0, CMContentImpl.UNBOUNDED); + collection.getInline(content); + } + + /** + * @see com.ibm.sed.contentmodel.html.ComplexTypeDefinition + */ + public int getContentType() { + return CMElementDeclaration.MIXED; + } + + /** + * @see com.ibm.sed.contentmodel.html.ComplexTypeDefinition + */ + public String getTypeName() { + return ComplexTypeDefinitionFactory.CTYPE_INLINE_CONTAINER; + } +}
\ No newline at end of file diff --git a/bundles/org.eclipse.wst.html.core/src/org/eclipse/wst/html/core/contentmodel/CtdLiContainer.java b/bundles/org.eclipse.wst.html.core/src/org/eclipse/wst/html/core/contentmodel/CtdLiContainer.java new file mode 100644 index 0000000000..4f56f0d569 --- /dev/null +++ b/bundles/org.eclipse.wst.html.core/src/org/eclipse/wst/html/core/contentmodel/CtdLiContainer.java @@ -0,0 +1,69 @@ +/******************************************************************************* + * Copyright (c) 2004 IBM Corporation and others. + * All rights reserved. This program and the accompanying materials + * are made available under the terms of the Eclipse Public License v1.0 + * which accompanies this distribution, and is available at + * http://www.eclipse.org/legal/epl-v10.html + * + * Contributors: + * IBM Corporation - initial API and implementation + *******************************************************************************/ +package org.eclipse.wst.html.core.contentmodel; + + + +import org.eclipse.wst.common.contentmodel.CMElementDeclaration; +import org.eclipse.wst.common.contentmodel.CMGroup; +import org.eclipse.wst.common.contentmodel.CMNode; +import org.eclipse.wst.html.core.HTML40Namespace; + +/** + * List item container. + * (LI)+ + */ +final class CtdLiContainer extends ComplexTypeDefinition { + + /** + * @param elemenCollection ElementCollection + */ + public CtdLiContainer(ElementCollection elementCollection) { + super(elementCollection); + primaryCandidateName = HTML40Namespace.ElementName.LI; + } + + /** + * (LI)+. + */ + protected void createContent() { + if (content != null) + return; // already created. + if (collection == null) + return; + + // (LI)+ + content = new CMGroupImpl(CMGroup.SEQUENCE, 1, CMContentImpl.UNBOUNDED); + CMNode li = collection.getNamedItem(HTML40Namespace.ElementName.LI); + if (li != null) + content.appendChild(li); + } + + /** + * ELEMENT content.<br> + * @return int; Should be one of ANY, EMPTY, ELEMENT, MIXED, PCDATA, CDATA, + * those are defined in CMElementDeclaration. + */ + public int getContentType() { + return CMElementDeclaration.ELEMENT; + } + + /** + * Name of complex type definition. + * Each singleton must know its own name. + * All names should be defined in + * {@link <code>ComplexTypeDefinitionFactory</code>} as constants.<br> + * @return java.lang.String + */ + public String getTypeName() { + return ComplexTypeDefinitionFactory.CTYPE_LI_CONTAINER; + } +}
\ No newline at end of file diff --git a/bundles/org.eclipse.wst.html.core/src/org/eclipse/wst/html/core/contentmodel/CtdMap.java b/bundles/org.eclipse.wst.html.core/src/org/eclipse/wst/html/core/contentmodel/CtdMap.java new file mode 100644 index 0000000000..ac295ec012 --- /dev/null +++ b/bundles/org.eclipse.wst.html.core/src/org/eclipse/wst/html/core/contentmodel/CtdMap.java @@ -0,0 +1,72 @@ +/******************************************************************************* + * Copyright (c) 2004 IBM Corporation and others. + * All rights reserved. This program and the accompanying materials + * are made available under the terms of the Eclipse Public License v1.0 + * which accompanies this distribution, and is available at + * http://www.eclipse.org/legal/epl-v10.html + * + * Contributors: + * IBM Corporation - initial API and implementation + *******************************************************************************/ +package org.eclipse.wst.html.core.contentmodel; + + + +import org.eclipse.wst.common.contentmodel.CMElementDeclaration; +import org.eclipse.wst.common.contentmodel.CMGroup; +import org.eclipse.wst.common.contentmodel.CMNode; +import org.eclipse.wst.html.core.HTML40Namespace; + +/** + * for MAP. + */ +final class CtdMap extends ComplexTypeDefinition { + + /** + * @param elementCollection ElementCollection + */ + public CtdMap(ElementCollection elementCollection) { + super(elementCollection); + primaryCandidateName = HTML40Namespace.ElementName.AREA; + } + + /** + * ((%block;) | AREA)+. + */ + protected void createContent() { + if (content != null) + return; // already created. + if (collection == null) + return; + + // ( | )+ + content = new CMGroupImpl(CMGroup.CHOICE, 1, CMContentImpl.UNBOUNDED); + // (%block;) + CMGroupImpl blocks = new CMGroupImpl(CMGroup.CHOICE, 1, 1); + if (blocks == null) + return; + collection.getBlock(blocks); + content.appendChild(blocks); + // AREA + CMNode area = collection.getNamedItem(HTML40Namespace.ElementName.AREA); + if (area != null) + content.appendChild(area); + } + + /** + * ((%block;) | AREA)+. + * Because %block; consists of elements only, the type is ELEMENT. + * @return int; Should be one of ANY, EMPTY, ELEMENT, MIXED, PCDATA, CDATA, + * those are defined in CMElementDeclaration. + */ + public int getContentType() { + return CMElementDeclaration.ELEMENT; + } + + /** + * @return java.lang.String + */ + public String getTypeName() { + return ComplexTypeDefinitionFactory.CTYPE_MAP; + } +}
\ No newline at end of file diff --git a/bundles/org.eclipse.wst.html.core/src/org/eclipse/wst/html/core/contentmodel/CtdNoframesContent.java b/bundles/org.eclipse.wst.html.core/src/org/eclipse/wst/html/core/contentmodel/CtdNoframesContent.java new file mode 100644 index 0000000000..4f220a33ab --- /dev/null +++ b/bundles/org.eclipse.wst.html.core/src/org/eclipse/wst/html/core/contentmodel/CtdNoframesContent.java @@ -0,0 +1,65 @@ +/******************************************************************************* + * Copyright (c) 2004 IBM Corporation and others. + * All rights reserved. This program and the accompanying materials + * are made available under the terms of the Eclipse Public License v1.0 + * which accompanies this distribution, and is available at + * http://www.eclipse.org/legal/epl-v10.html + * + * Contributors: + * IBM Corporation - initial API and implementation + *******************************************************************************/ +package org.eclipse.wst.html.core.contentmodel; + + + +import org.eclipse.wst.common.contentmodel.CMElementDeclaration; +import org.eclipse.wst.common.contentmodel.CMGroup; +import org.eclipse.wst.common.contentmodel.CMNode; +import org.eclipse.wst.html.core.HTML40Namespace; + +/** + * for NOFRAMES. + */ +final class CtdNoframesContent extends ComplexTypeDefinition { + + /** + * @param elementCollection ElementCollection + */ + public CtdNoframesContent(ElementCollection elementCollection) { + super(elementCollection); + primaryCandidateName = HTML40Namespace.ElementName.BODY; + } + + /** + * (BODY). + */ + protected void createContent() { + if (content != null) + return; // already created. + if (collection == null) + return; + + // ( ) + content = new CMGroupImpl(CMGroup.SEQUENCE, 1, 1); + // BODY + CMNode dec = collection.getNamedItem(HTML40Namespace.ElementName.BODY); + if (dec != null) + content.appendChild(dec); + } + + /** + * (BODY) + * @return int; Should be one of ANY, EMPTY, ELEMENT, MIXED, PCDATA, CDATA, + * those are defined in CMElementDeclaration. + */ + public int getContentType() { + return CMElementDeclaration.ELEMENT; + } + + /** + * @return java.lang.String + */ + public String getTypeName() { + return ComplexTypeDefinitionFactory.CTYPE_NOFRAMES_CONTENT; + } +}
\ No newline at end of file diff --git a/bundles/org.eclipse.wst.html.core/src/org/eclipse/wst/html/core/contentmodel/CtdOptionContainer.java b/bundles/org.eclipse.wst.html.core/src/org/eclipse/wst/html/core/contentmodel/CtdOptionContainer.java new file mode 100644 index 0000000000..05237b3694 --- /dev/null +++ b/bundles/org.eclipse.wst.html.core/src/org/eclipse/wst/html/core/contentmodel/CtdOptionContainer.java @@ -0,0 +1,70 @@ +/******************************************************************************* + * Copyright (c) 2004 IBM Corporation and others. + * All rights reserved. This program and the accompanying materials + * are made available under the terms of the Eclipse Public License v1.0 + * which accompanies this distribution, and is available at + * http://www.eclipse.org/legal/epl-v10.html + * + * Contributors: + * IBM Corporation - initial API and implementation + *******************************************************************************/ +package org.eclipse.wst.html.core.contentmodel; + + + +import org.eclipse.wst.common.contentmodel.CMElementDeclaration; +import org.eclipse.wst.common.contentmodel.CMGroup; +import org.eclipse.wst.common.contentmodel.CMNode; +import org.eclipse.wst.html.core.HTML40Namespace; + +/** + * OPTION container. + * (OPTION)+ + */ +final class CtdOptionContainer extends ComplexTypeDefinition { + + /** + * @param elementCollection ElementCollection + */ + public CtdOptionContainer(ElementCollection elementCollection) { + super(elementCollection); + primaryCandidateName = HTML40Namespace.ElementName.OPTION; + } + + /** + * (OPTION)+. + */ + protected void createContent() { + if (content != null) + return; // already created. + if (collection == null) + return; + + // ( )+ + content = new CMGroupImpl(CMGroup.SEQUENCE, 1, CMContentImpl.UNBOUNDED); + // OPTION + CMNode dec = collection.getNamedItem(HTML40Namespace.ElementName.OPTION); + if (dec != null) + content.appendChild(dec); + } + + /** + * (OPTION)+ + * @return int; Should be one of ANY, EMPTY, ELEMENT, MIXED, PCDATA, CDATA, + * those are defined in CMElementDeclaration. + */ + public int getContentType() { + return CMElementDeclaration.ELEMENT; + } + + /** + * Name of complex type definition. + * Each singleton must know its own name. + * All names should be defined in + * {@link <code>ComplexTypeDefinitionFactory</code>} as constants.<br> + * @return java.lang.String + */ + public String getTypeName() { + return ComplexTypeDefinitionFactory.CTYPE_OPTION_CONTAINER; + } +}
\ No newline at end of file diff --git a/bundles/org.eclipse.wst.html.core/src/org/eclipse/wst/html/core/contentmodel/CtdParamContainer.java b/bundles/org.eclipse.wst.html.core/src/org/eclipse/wst/html/core/contentmodel/CtdParamContainer.java new file mode 100644 index 0000000000..587ec35c0d --- /dev/null +++ b/bundles/org.eclipse.wst.html.core/src/org/eclipse/wst/html/core/contentmodel/CtdParamContainer.java @@ -0,0 +1,71 @@ +/******************************************************************************* + * Copyright (c) 2004 IBM Corporation and others. + * All rights reserved. This program and the accompanying materials + * are made available under the terms of the Eclipse Public License v1.0 + * which accompanies this distribution, and is available at + * http://www.eclipse.org/legal/epl-v10.html + * + * Contributors: + * IBM Corporation - initial API and implementation + *******************************************************************************/ +package org.eclipse.wst.html.core.contentmodel; + + + +import org.eclipse.wst.common.contentmodel.CMElementDeclaration; +import org.eclipse.wst.common.contentmodel.CMGroup; +import org.eclipse.wst.common.contentmodel.CMNode; +import org.eclipse.wst.html.core.HTML40Namespace; + +/** + * PARAM container. For OBJECT and APPLET. + */ +final class CtdParamContainer extends ComplexTypeDefinition { + + /** + * @param elementCollection ElementCollection + */ + public CtdParamContainer(ElementCollection elementCollection) { + super(elementCollection); + } + + /** + * (PARAM | %flow;)*. + */ + protected void createContent() { + if (content != null) + return; // already created. + if (collection == null) + return; + + // ( | )* + content = new CMGroupImpl(CMGroup.CHOICE, 0, CMContentImpl.UNBOUNDED); + // PARAM + CMNode param = collection.getNamedItem(HTML40Namespace.ElementName.PARAM); + if (param != null) + content.appendChild(param); + // %flow; + CMGroupImpl flows = new CMGroupImpl(CMGroup.CHOICE, 1, 1); + if (flows == null) + return; + collection.getInline(flows); + content.appendChild(flows); + } + + /** + * (PARAM | %flow;)*. + * Because %flow; contains #PCDATA, the type is MIXED. + * @return int; Should be one of ANY, EMPTY, ELEMENT, MIXED, PCDATA, CDATA, + * those are defined in CMElementDeclaration. + */ + public int getContentType() { + return CMElementDeclaration.MIXED; + } + + /** + * @return java.lang.String + */ + public String getTypeName() { + return ComplexTypeDefinitionFactory.CTYPE_PARAM_CONTAINER; + } +}
\ No newline at end of file diff --git a/bundles/org.eclipse.wst.html.core/src/org/eclipse/wst/html/core/contentmodel/CtdSelect.java b/bundles/org.eclipse.wst.html.core/src/org/eclipse/wst/html/core/contentmodel/CtdSelect.java new file mode 100644 index 0000000000..7f03f22a4f --- /dev/null +++ b/bundles/org.eclipse.wst.html.core/src/org/eclipse/wst/html/core/contentmodel/CtdSelect.java @@ -0,0 +1,69 @@ +/******************************************************************************* + * Copyright (c) 2004 IBM Corporation and others. + * All rights reserved. This program and the accompanying materials + * are made available under the terms of the Eclipse Public License v1.0 + * which accompanies this distribution, and is available at + * http://www.eclipse.org/legal/epl-v10.html + * + * Contributors: + * IBM Corporation - initial API and implementation + *******************************************************************************/ +package org.eclipse.wst.html.core.contentmodel; + + + +import org.eclipse.wst.common.contentmodel.CMElementDeclaration; +import org.eclipse.wst.common.contentmodel.CMGroup; +import org.eclipse.wst.common.contentmodel.CMNode; +import org.eclipse.wst.html.core.HTML40Namespace; + +/** + * for SELECT. + */ +final class CtdSelect extends ComplexTypeDefinition { + + /** + * @param elementCollection ElementCollection + */ + public CtdSelect(ElementCollection elementCollection) { + super(elementCollection); + primaryCandidateName = HTML40Namespace.ElementName.OPTION; + } + + /** + * (OPTGROUP | OPTION)+. + */ + protected void createContent() { + if (content != null) + return; // already created. + if (collection == null) + return; + + // ( | )+ + content = new CMGroupImpl(CMGroup.CHOICE, 1, CMContentImpl.UNBOUNDED); + // OPTGROUP + CMNode dec = collection.getNamedItem(HTML40Namespace.ElementName.OPTGROUP); + if (dec != null) + content.appendChild(dec); + // OPTION + dec = collection.getNamedItem(HTML40Namespace.ElementName.OPTION); + if (dec != null) + content.appendChild(dec); + } + + /** + * (OPTGROUP | OPTION)+. + * @return int; Should be one of ANY, EMPTY, ELEMENT, MIXED, PCDATA, CDATA, + * those are defined in CMElementDeclaration. + */ + public int getContentType() { + return CMElementDeclaration.ELEMENT; + } + + /** + * @return java.lang.String + */ + public String getTypeName() { + return ComplexTypeDefinitionFactory.CTYPE_SELECT; + } +}
\ No newline at end of file diff --git a/bundles/org.eclipse.wst.html.core/src/org/eclipse/wst/html/core/contentmodel/CtdTable.java b/bundles/org.eclipse.wst.html.core/src/org/eclipse/wst/html/core/contentmodel/CtdTable.java new file mode 100644 index 0000000000..1e5f4b0c11 --- /dev/null +++ b/bundles/org.eclipse.wst.html.core/src/org/eclipse/wst/html/core/contentmodel/CtdTable.java @@ -0,0 +1,128 @@ +/******************************************************************************* + * Copyright (c) 2004 IBM Corporation and others. + * All rights reserved. This program and the accompanying materials + * are made available under the terms of the Eclipse Public License v1.0 + * which accompanies this distribution, and is available at + * http://www.eclipse.org/legal/epl-v10.html + * + * Contributors: + * IBM Corporation - initial API and implementation + *******************************************************************************/ +package org.eclipse.wst.html.core.contentmodel; + + + +import org.eclipse.wst.common.contentmodel.CMElementDeclaration; +import org.eclipse.wst.common.contentmodel.CMGroup; +import org.eclipse.wst.common.contentmodel.CMNode; +import org.eclipse.wst.html.core.HTML40Namespace; + +/** + * for TABLE. + * (CAPTION?, (COL*|COLGROUP*), THEAD?, TFOOT?, TBODY+) + */ +final class CtdTable extends ComplexTypeDefinition { + + /** + * @param elementCollection ElementCollection + */ + public CtdTable(ElementCollection elementCollection) { + super(elementCollection); + primaryCandidateName = HTML40Namespace.ElementName.TBODY; + } + + /** + * (CAPTION?, (COL*|COLGROUP*), THEAD?, TFOOT?, TBODY+) + * --> ((CAPTION)?, ((COL)* | (COLGROUP)*), (THEAD)?, (TFOOT)?, (TBODY)+) + */ + protected void createContent() { + if (content != null) + return; // already created. + if (collection == null) + return; + + // ( , , , ,) + content = new CMGroupImpl(CMGroup.SEQUENCE, 1, 1); + + // (CAPTION)? + // ( )? + CMGroupImpl wrap = new CMGroupImpl(CMGroup.SEQUENCE, 0, 1); + if (wrap == null) + return; + content.appendChild(wrap); + // CAPTION + CMNode dec = collection.getNamedItem(HTML40Namespace.ElementName.CAPTION); + if (dec != null) + wrap.appendChild(dec); + + // ((COL)* | (COLGROUP)*) + // ( | ) + CMGroupImpl group = new CMGroupImpl(CMGroup.CHOICE, 1, 1); + if (group == null) + return; + content.appendChild(group); + // (COL)* + wrap = new CMGroupImpl(CMGroup.SEQUENCE, 0, CMContentImpl.UNBOUNDED); + if (wrap == null) + return; + group.appendChild(wrap); + dec = collection.getNamedItem(HTML40Namespace.ElementName.COL); + if (dec != null) + wrap.appendChild(dec); + // (COLGROUP)* + wrap = new CMGroupImpl(CMGroup.SEQUENCE, 0, CMContentImpl.UNBOUNDED); + if (wrap == null) + return; + group.appendChild(wrap); + dec = collection.getNamedItem(HTML40Namespace.ElementName.COLGROUP); + if (dec != null) + wrap.appendChild(dec); + + // (THEAD)? + wrap = new CMGroupImpl(CMGroup.SEQUENCE, 0, 1); + if (wrap == null) + return; + content.appendChild(wrap); + dec = collection.getNamedItem(HTML40Namespace.ElementName.THEAD); + if (dec != null) + wrap.appendChild(dec); + + // (TFOOT)? + wrap = new CMGroupImpl(CMGroup.SEQUENCE, 0, 1); + if (wrap == null) + return; + content.appendChild(wrap); + dec = collection.getNamedItem(HTML40Namespace.ElementName.TFOOT); + if (dec != null) + wrap.appendChild(dec); + + // (TBODY)+ + wrap = new CMGroupImpl(CMGroup.SEQUENCE, 1, CMContentImpl.UNBOUNDED); + if (wrap == null) + return; + content.appendChild(wrap); + dec = collection.getNamedItem(HTML40Namespace.ElementName.TBODY); + if (dec != null) + wrap.appendChild(dec); + } + + /** + * ((FRAMESET | FRAME)+ & NOFRAMES?) + * @return int; Should be one of ANY, EMPTY, ELEMENT, MIXED, PCDATA, CDATA, + * those are defined in CMElementDeclaration. + */ + public int getContentType() { + return CMElementDeclaration.ELEMENT; + } + + /** + * Name of complex type definition. + * Each singleton must know its own name. + * All names should be defined in + * {@link <code>ComplexTypeDefinitionFactory</code>} as constants.<br> + * @return java.lang.String + */ + public String getTypeName() { + return ComplexTypeDefinitionFactory.CTYPE_TABLE; + } +}
\ No newline at end of file diff --git a/bundles/org.eclipse.wst.html.core/src/org/eclipse/wst/html/core/contentmodel/CtdTableCellContainer.java b/bundles/org.eclipse.wst.html.core/src/org/eclipse/wst/html/core/contentmodel/CtdTableCellContainer.java new file mode 100644 index 0000000000..39221ff0bd --- /dev/null +++ b/bundles/org.eclipse.wst.html.core/src/org/eclipse/wst/html/core/contentmodel/CtdTableCellContainer.java @@ -0,0 +1,74 @@ +/******************************************************************************* + * Copyright (c) 2004 IBM Corporation and others. + * All rights reserved. This program and the accompanying materials + * are made available under the terms of the Eclipse Public License v1.0 + * which accompanies this distribution, and is available at + * http://www.eclipse.org/legal/epl-v10.html + * + * Contributors: + * IBM Corporation - initial API and implementation + *******************************************************************************/ +package org.eclipse.wst.html.core.contentmodel; + + + +import org.eclipse.wst.common.contentmodel.CMElementDeclaration; +import org.eclipse.wst.common.contentmodel.CMGroup; +import org.eclipse.wst.common.contentmodel.CMNode; +import org.eclipse.wst.html.core.HTML40Namespace; + +/** + * Table cell container. + * (TH | TD)+ + */ +final class CtdTableCellContainer extends ComplexTypeDefinition { + + /** + * @param elementCollection ElementCollection + */ + public CtdTableCellContainer(ElementCollection elementCollection) { + super(elementCollection); + primaryCandidateName = HTML40Namespace.ElementName.TD; + } + + /** + * (TH | TD)+. + */ + protected void createContent() { + if (content != null) + return; // already created. + if (collection == null) + return; + + // ( )+ + content = new CMGroupImpl(CMGroup.CHOICE, 1, CMContentImpl.UNBOUNDED); + // TH + CMNode dec = collection.getNamedItem(HTML40Namespace.ElementName.TH); + if (dec != null) + content.appendChild(dec); + // TD + dec = collection.getNamedItem(HTML40Namespace.ElementName.TD); + if (dec != null) + content.appendChild(dec); + } + + /** + * (TH | TD)+ + * @return int; Should be one of ANY, EMPTY, ELEMENT, MIXED, PCDATA, CDATA, + * those are defined in CMElementDeclaration. + */ + public int getContentType() { + return CMElementDeclaration.ELEMENT; + } + + /** + * Name of complex type definition. + * Each singleton must know its own name. + * All names should be defined in + * {@link <code>ComplexTypeDefinitionFactory</code>} as constants.<br> + * @return java.lang.String + */ + public String getTypeName() { + return ComplexTypeDefinitionFactory.CTYPE_TCELL_CONTAINER; + } +}
\ No newline at end of file diff --git a/bundles/org.eclipse.wst.html.core/src/org/eclipse/wst/html/core/contentmodel/CtdTrContainer.java b/bundles/org.eclipse.wst.html.core/src/org/eclipse/wst/html/core/contentmodel/CtdTrContainer.java new file mode 100644 index 0000000000..4a494bd8d2 --- /dev/null +++ b/bundles/org.eclipse.wst.html.core/src/org/eclipse/wst/html/core/contentmodel/CtdTrContainer.java @@ -0,0 +1,69 @@ +/******************************************************************************* + * Copyright (c) 2004 IBM Corporation and others. + * All rights reserved. This program and the accompanying materials + * are made available under the terms of the Eclipse Public License v1.0 + * which accompanies this distribution, and is available at + * http://www.eclipse.org/legal/epl-v10.html + * + * Contributors: + * IBM Corporation - initial API and implementation + *******************************************************************************/ +package org.eclipse.wst.html.core.contentmodel; + + + +import org.eclipse.wst.common.contentmodel.CMElementDeclaration; +import org.eclipse.wst.common.contentmodel.CMGroup; +import org.eclipse.wst.common.contentmodel.CMNode; +import org.eclipse.wst.html.core.HTML40Namespace; + +/** + * Table record container. + * (TR)+ + */ +final class CtdTrContainer extends ComplexTypeDefinition { + + /** + * @param elementCollection ElementCollection + */ + public CtdTrContainer(ElementCollection elementCollection) { + super(elementCollection); + primaryCandidateName = HTML40Namespace.ElementName.TR; + } + + /** + * (TR)+. + */ + protected void createContent() { + if (content != null) + return; // already created. + if (collection == null) + return; + + // (TR)+ + content = new CMGroupImpl(CMGroup.SEQUENCE, 1, CMContentImpl.UNBOUNDED); + CMNode tr = collection.getNamedItem(HTML40Namespace.ElementName.TR); + if (tr != null) + content.appendChild(tr); + } + + /** + * ELEMENT content.<br> + * @return int; Should be one of ANY, EMPTY, ELEMENT, MIXED, PCDATA, CDATA, + * those are defined in CMElementDeclaration. + */ + public int getContentType() { + return CMElementDeclaration.ELEMENT; + } + + /** + * Name of complex type definition. + * Each singleton must know its own name. + * All names should be defined in + * {@link <code>ComplexTypeDefinitionFactory</code>} as constants.<br> + * @return java.lang.String + */ + public String getTypeName() { + return ComplexTypeDefinitionFactory.CTYPE_TR_CONTAINER; + } +}
\ No newline at end of file diff --git a/bundles/org.eclipse.wst.html.core/src/org/eclipse/wst/html/core/contentmodel/DeclCollection.java b/bundles/org.eclipse.wst.html.core/src/org/eclipse/wst/html/core/contentmodel/DeclCollection.java new file mode 100644 index 0000000000..c9449fd6bf --- /dev/null +++ b/bundles/org.eclipse.wst.html.core/src/org/eclipse/wst/html/core/contentmodel/DeclCollection.java @@ -0,0 +1,238 @@ +/******************************************************************************* + * Copyright (c) 2004 IBM Corporation and others. + * All rights reserved. This program and the accompanying materials + * are made available under the terms of the Eclipse Public License v1.0 + * which accompanies this distribution, and is available at + * http://www.eclipse.org/legal/epl-v10.html + * + * Contributors: + * IBM Corporation - initial API and implementation + *******************************************************************************/ +package org.eclipse.wst.html.core.contentmodel; + + + +import java.util.HashMap; +import java.util.Iterator; + +import org.eclipse.wst.common.contentmodel.CMNamedNodeMap; +import org.eclipse.wst.common.contentmodel.CMNode; + +/** + */ +abstract class DeclCollection implements CMNamedNodeMap { + + + protected class DualMap { + public DualMap() { + super(); + } + + public DualMap(Object[] objects) { + super(); + initialize(objects); + } + + public int size() { + return table.length; + } + + public Object getValue(int key) { + if (!isValidIndex(key)) + return null; + return table[key]; + } + + public int getKey(Object value) { + Integer keyObj = (Integer) map.get(value); + if (keyObj == null) + return ID_UNKNOWN; + return keyObj.intValue(); + } + + protected void initialize(Object[] objects) { + if (objects == null) + return; + table = objects; + map = new HashMap(); + for (int key = 0; key < objects.length; key++) { + Object value = table[key]; + map.put(value, new Integer(key)); + } + } + + private Object[] table = null; + private HashMap map = null; + + private boolean isValidIndex(int index) { + return index >= 0 && index < table.length; + } + } + + protected class TolerantStringDualMap extends DualMap { + public TolerantStringDualMap(String[] names) { + super(); + Object[] objects = new Object[names.length]; + for (int i = 0; i < names.length; i++) { + objects[i] = makeCanonicalForm(names[i]); + } + initialize(objects); + } + + public int getKey(Object value) { + try { + String name = (String) value; + return super.getKey(makeCanonicalForm(name)); + } + catch (ClassCastException e) { + return ID_UNKNOWN; + } + } + + private String makeCanonicalForm(String raw) { + return raw.toUpperCase(); + } + } + + private class DeclIterator implements Iterator { + public DeclIterator() { + maxid = fDecls.length - 1; + } + + public boolean hasNext() { + return id < maxid; + } + + public Object next() { + if (!hasNext()) + return null; + return item(++id); + } + + public void remove() { /* nothing should be done. */ + } + + private int id = -1; + private int maxid = -1; + } + + CMNode[] fDecls = null; + protected final static boolean STRICT_CASE = false; + protected final static boolean TOLERANT_CASE = true; + protected final static int ID_UNKNOWN = -1; + private DualMap fMap = null; + + /** + */ + public DeclCollection(String[] names, boolean tolerant) { + super(); + fDecls = new CMNode[names.length]; + if (tolerant) { + fMap = new TolerantStringDualMap(names); + } + else { + fMap = new DualMap(names); + } + } + + /** + * @return org.eclipse.wst.common.contentmodel.CMNode + * @param id int + */ + protected abstract CMNode create(String name); + + /** + */ + public CMNamedNodeMap getDeclarations(String[] names) { + CMNamedNodeMapImpl map = new CMNamedNodeMapImpl(); + for (int i = 0; i < names.length; i++) { + String name = names[i]; + CMNode node = getNamedItem(name); + if (node == null) + continue; + map.putNamedItem(name, node); + } + return map; + } + + /** + * @param declarations com.ibm.sed.contentmodel.html.CMGroupImpl + * @param names java.util.Iterator + */ + public void getDeclarations(CMGroupImpl group, Iterator names) { + while (names.hasNext()) { + String entityName = (String) names.next(); + CMNode dec = getNamedItem(entityName); + if (dec != null) + group.appendChild(dec); + } + } + + /** + * Map name to id. + * @return int + * @param name java.lang.String + */ + protected int getID(String name) { + return fMap.getKey(name); + } + + /** + * getLength method + * @return int + */ + public int getLength() { + return fDecls.length; + } + + /** + * @return java.lang.String + * @param id int + */ + protected String getName(int id) { + return (String) fMap.getValue(id); + } + + /** + * getNamedItem method + * @return CMNode + * @param name java.lang.String + */ + public CMNode getNamedItem(String name) { + int id = getID(name); + if (!isValidID(id)) + return null; + return item(id); + } + + /** + * @return boolean + * @param id int + */ + private boolean isValidID(int id) { + return id >= 0 && id < fDecls.length; + } + + /** + * item method + * @return CMNode + * @param index int + */ + public CMNode item(int index) { + if (!isValidID(index)) + return null; + CMNode decl = fDecls[index]; + if (decl != null) + return decl; // already exist. + + decl = create(getName(index)); + fDecls[index] = decl; + return decl; + } + + /** + */ + public Iterator iterator() { + return new DeclIterator(); + } +}
\ No newline at end of file diff --git a/bundles/org.eclipse.wst.html.core/src/org/eclipse/wst/html/core/contentmodel/ElementCollection.java b/bundles/org.eclipse.wst.html.core/src/org/eclipse/wst/html/core/contentmodel/ElementCollection.java new file mode 100644 index 0000000000..26da0269b2 --- /dev/null +++ b/bundles/org.eclipse.wst.html.core/src/org/eclipse/wst/html/core/contentmodel/ElementCollection.java @@ -0,0 +1,886 @@ +/******************************************************************************* + * Copyright (c) 2004 IBM Corporation and others. + * All rights reserved. This program and the accompanying materials + * are made available under the terms of the Eclipse Public License v1.0 + * which accompanies this distribution, and is available at + * http://www.eclipse.org/legal/epl-v10.html + * + * Contributors: + * IBM Corporation - initial API and implementation + *******************************************************************************/ +package org.eclipse.wst.html.core.contentmodel; + + + +import java.lang.reflect.Field; +import java.util.Arrays; +import java.util.Collection; +import java.util.Vector; + +import org.eclipse.wst.common.contentmodel.CMNode; + +/** + * Factory for element declarations. + */ +final class ElementCollection extends DeclCollection implements org.eclipse.wst.html.core.HTML40Namespace.ElementName { + + + // Element IDs + private static class Ids { + public static final int ID_A = 0; + public static final int ID_ABBR = 1; + public static final int ID_ACRONYM = 2; + public static final int ID_ADDRESS = 3; + public static final int ID_APPLET = 4; + public static final int ID_AREA = 5; + public static final int ID_B = 6; + public static final int ID_BASE = 7; + public static final int ID_BASEFONT = 8; + public static final int ID_BDO = 9; + public static final int ID_BIG = 10; + public static final int ID_BLINK = 11; + public static final int ID_BLOCKQUOTE = 12; + public static final int ID_BODY = 13; + public static final int ID_BR = 14; + public static final int ID_BUTTON = 15; + public static final int ID_CAPTION = 16; + public static final int ID_CENTER = 17; + public static final int ID_CITE = 18; + public static final int ID_CODE = 19; + public static final int ID_COL = 20; + public static final int ID_COLGROUP = 21; + public static final int ID_DD = 22; + public static final int ID_DEL = 23; + public static final int ID_DFN = 24; + public static final int ID_DIR = 25; + public static final int ID_DIV = 26; + public static final int ID_DL = 27; + public static final int ID_DT = 28; + public static final int ID_EM = 29; + public static final int ID_EMBED = 30; + public static final int ID_FIELDSET = 31; + public static final int ID_FONT = 32; + public static final int ID_FORM = 33; + public static final int ID_FRAME = 34; + public static final int ID_FRAMESET = 35; + public static final int ID_H1 = 36; + public static final int ID_H2 = 37; + public static final int ID_H3 = 38; + public static final int ID_H4 = 39; + public static final int ID_H5 = 40; + public static final int ID_H6 = 41; + public static final int ID_HEAD = 42; + public static final int ID_HR = 43; + public static final int ID_HTML = 44; + public static final int ID_I = 45; + public static final int ID_IFRAME = 46; + public static final int ID_IMG = 47; + public static final int ID_INPUT = 48; + public static final int ID_INS = 49; + public static final int ID_ISINDEX = 50; + public static final int ID_KBD = 51; + public static final int ID_LABEL = 52; + public static final int ID_LEGEND = 53; + public static final int ID_LI = 54; + public static final int ID_LINK = 55; + public static final int ID_MAP = 56; + public static final int ID_MENU = 57; + public static final int ID_META = 58; + public static final int ID_NOEMBED = 59; + public static final int ID_NOFRAMES = 60; + public static final int ID_NOSCRIPT = 61; + public static final int ID_OBJECT = 62; + public static final int ID_OL = 63; + public static final int ID_OPTGROUP = 64; + public static final int ID_OPTION = 65; + public static final int ID_P = 66; + public static final int ID_PARAM = 67; + public static final int ID_PRE = 68; + public static final int ID_Q = 69; + public static final int ID_S = 70; + public static final int ID_SAMP = 71; + public static final int ID_SCRIPT = 72; + public static final int ID_SELECT = 73; + public static final int ID_SMALL = 74; + public static final int ID_SPAN = 75; + public static final int ID_STRIKE = 76; + public static final int ID_STRONG = 77; + public static final int ID_STYLE = 78; + public static final int ID_SUB = 79; + public static final int ID_SUP = 80; + public static final int ID_TABLE = 81; + public static final int ID_TBODY = 82; + public static final int ID_TD = 83; + public static final int ID_TEXTAREA = 84; + public static final int ID_TFOOT = 85; + public static final int ID_TH = 86; + public static final int ID_THEAD = 87; + public static final int ID_TITLE = 88; + public static final int ID_TR = 89; + public static final int ID_TT = 90; + public static final int ID_U = 91; + public static final int ID_UL = 92; + public static final int ID_VAR = 93; + public static final int ID_MARQUEE = 94; + public static final int ID_SSI_CONFIG = 95; + public static final int ID_SSI_ECHO = 96; + public static final int ID_SSI_EXEC = 97; + public static final int ID_SSI_FSIZE = 98; + public static final int ID_SSI_FLASTMOD = 99; + public static final int ID_SSI_INCLUDE = 100; + public static final int ID_SSI_PRINTENV = 101; + public static final int ID_SSI_SET = 102; + // <<D205513 + public static final int ID_BGSOUND = 103; + public static final int ID_NOBR = 104; + public static final int ID_WBR = 105; + + // D205513 + + public static int getNumOfIds() { + if (numofids != -1) + return numofids; + + // NOTE: If the reflection is too slow, this method should + // just return the literal value, like 105. + // -- 5/25/2001 + Class clazz = Ids.class; + Field[] fields = clazz.getFields(); + numofids = 0; + for (int i = 0; i < fields.length; i++) { + String name = fields[i].getName(); + if (name.startsWith("ID_"))//$NON-NLS-1$ + numofids++; + } + return numofids; + } + + // chache the result of the reflection. + private static int numofids = -1; + } + + /** %fontstyle;. TT | I | B | U | S | STRIKE | BIG | SMALL | BLINK */ + private static final String[] FONTSTYLE = {TT, I, B, U, S, STRIKE, BIG, SMALL, BLINK}; + /** %formctl;. INPUT | SELECT | TEXTAREA | LABEL | BUTTON */ + private static final String[] FORMCTL = {INPUT, SELECT, TEXTAREA, LABEL, BUTTON}; + /** %phrase;. + * EM | STRONG | DFN | CODE | SAMP | KBD | VAR | CITE | ABBR | ACRONYM + */ + private static final String[] PHRASE = {EM, STRONG, DFN, CODE, SAMP, KBD, VAR, CITE, ABBR, ACRONYM}; + /** %special;. + * A | IMG | APPLET | OBJECT | FONT | BASEFONT | BR | SCRIPT | + * MAP | Q | SUB | SUP | SPAN | BDO | IFRAME | EMBED | MARQUEE | + * D2W | SUBMIT + * WBR | NOBR | BGSOUND + */ + private static final String[] SPECIAL = {A, IMG, APPLET, OBJECT, FONT, BASEFONT, BR, WBR, // D205513 + SCRIPT, MAP, Q, SUB, SUP, SPAN, BDO, IFRAME, EMBED, BGSOUND, // D205513 + MARQUEE, NOBR // D205513 + }; + /** %heading;. H[1-6] */ + private static final String[] HEADING = {H1, H2, H3, H4, H5, H6}; + /** %list;. UL | OL | DIR | MENU */ + private static final String[] LIST = {UL, OL, DIR, MENU}; + /** %preformatted;. PRE */ + private static final String[] PREFORMATTED = {PRE}; + private AttributeCollection attributeCollection = null; + private static String[] fNames = null; + + static { + fNames = new String[Ids.getNumOfIds()]; + fNames[Ids.ID_A] = A; + fNames[Ids.ID_ABBR] = ABBR; + fNames[Ids.ID_ACRONYM] = ACRONYM; + fNames[Ids.ID_ADDRESS] = ADDRESS; + fNames[Ids.ID_APPLET] = APPLET; + fNames[Ids.ID_AREA] = AREA; + fNames[Ids.ID_B] = B; + fNames[Ids.ID_BASE] = BASE; + fNames[Ids.ID_BASEFONT] = BASEFONT; + fNames[Ids.ID_BDO] = BDO; + fNames[Ids.ID_BIG] = BIG; + fNames[Ids.ID_BLINK] = BLINK; + fNames[Ids.ID_BLOCKQUOTE] = BLOCKQUOTE; + fNames[Ids.ID_BODY] = BODY; + fNames[Ids.ID_BR] = BR; + fNames[Ids.ID_BUTTON] = BUTTON; + fNames[Ids.ID_CAPTION] = CAPTION; + fNames[Ids.ID_CENTER] = CENTER; + fNames[Ids.ID_CITE] = CITE; + fNames[Ids.ID_CODE] = CODE; + fNames[Ids.ID_COL] = COL; + fNames[Ids.ID_COLGROUP] = COLGROUP; + fNames[Ids.ID_DD] = DD; + fNames[Ids.ID_DEL] = DEL; + fNames[Ids.ID_DFN] = DFN; + fNames[Ids.ID_DIR] = DIR; + fNames[Ids.ID_DIV] = DIV; + fNames[Ids.ID_DL] = DL; + fNames[Ids.ID_DT] = DT; + fNames[Ids.ID_EM] = EM; + fNames[Ids.ID_EMBED] = EMBED; + fNames[Ids.ID_FIELDSET] = FIELDSET; + fNames[Ids.ID_FONT] = FONT; + fNames[Ids.ID_FORM] = FORM; + fNames[Ids.ID_FRAME] = FRAME; + fNames[Ids.ID_FRAMESET] = FRAMESET; + fNames[Ids.ID_H1] = H1; + fNames[Ids.ID_H2] = H2; + fNames[Ids.ID_H3] = H3; + fNames[Ids.ID_H4] = H4; + fNames[Ids.ID_H5] = H5; + fNames[Ids.ID_H6] = H6; + fNames[Ids.ID_HEAD] = HEAD; + fNames[Ids.ID_HR] = HR; + fNames[Ids.ID_HTML] = HTML; + fNames[Ids.ID_I] = I; + fNames[Ids.ID_IFRAME] = IFRAME; + fNames[Ids.ID_IMG] = IMG; + fNames[Ids.ID_INPUT] = INPUT; + fNames[Ids.ID_INS] = INS; + fNames[Ids.ID_ISINDEX] = ISINDEX; + fNames[Ids.ID_KBD] = KBD; + fNames[Ids.ID_LABEL] = LABEL; + fNames[Ids.ID_LEGEND] = LEGEND; + fNames[Ids.ID_LI] = LI; + fNames[Ids.ID_LINK] = LINK; + fNames[Ids.ID_MAP] = MAP; + fNames[Ids.ID_MENU] = MENU; + fNames[Ids.ID_META] = META; + fNames[Ids.ID_NOEMBED] = NOEMBED; + fNames[Ids.ID_NOFRAMES] = NOFRAMES; + fNames[Ids.ID_NOSCRIPT] = NOSCRIPT; + fNames[Ids.ID_OBJECT] = OBJECT; + fNames[Ids.ID_OL] = OL; + fNames[Ids.ID_OPTGROUP] = OPTGROUP; + fNames[Ids.ID_OPTION] = OPTION; + fNames[Ids.ID_P] = P; + fNames[Ids.ID_PARAM] = PARAM; + fNames[Ids.ID_PRE] = PRE; + fNames[Ids.ID_Q] = Q; + fNames[Ids.ID_S] = S; + fNames[Ids.ID_SAMP] = SAMP; + fNames[Ids.ID_SCRIPT] = SCRIPT; + fNames[Ids.ID_SELECT] = SELECT; + fNames[Ids.ID_SMALL] = SMALL; + fNames[Ids.ID_SPAN] = SPAN; + fNames[Ids.ID_STRIKE] = STRIKE; + fNames[Ids.ID_STRONG] = STRONG; + fNames[Ids.ID_STYLE] = STYLE; + fNames[Ids.ID_SUB] = SUB; + fNames[Ids.ID_SUP] = SUP; + fNames[Ids.ID_TABLE] = TABLE; + fNames[Ids.ID_TBODY] = TBODY; + fNames[Ids.ID_TD] = TD; + fNames[Ids.ID_TEXTAREA] = TEXTAREA; + fNames[Ids.ID_TFOOT] = TFOOT; + fNames[Ids.ID_TH] = TH; + fNames[Ids.ID_THEAD] = THEAD; + fNames[Ids.ID_TITLE] = TITLE; + fNames[Ids.ID_TR] = TR; + fNames[Ids.ID_TT] = TT; + fNames[Ids.ID_U] = U; + fNames[Ids.ID_UL] = UL; + fNames[Ids.ID_VAR] = VAR; + fNames[Ids.ID_MARQUEE] = MARQUEE; + fNames[Ids.ID_SSI_CONFIG] = SSI_CONFIG; + fNames[Ids.ID_SSI_ECHO] = SSI_ECHO; + fNames[Ids.ID_SSI_EXEC] = SSI_EXEC; + fNames[Ids.ID_SSI_FSIZE] = SSI_FSIZE; + fNames[Ids.ID_SSI_FLASTMOD] = SSI_FLASTMOD; + fNames[Ids.ID_SSI_INCLUDE] = SSI_INCLUDE; + fNames[Ids.ID_SSI_PRINTENV] = SSI_PRINTENV; + fNames[Ids.ID_SSI_SET] = SSI_SET; + fNames[Ids.ID_BGSOUND] = BGSOUND; + fNames[Ids.ID_NOBR] = NOBR; + fNames[Ids.ID_WBR] = WBR; + } + + /** + */ + public ElementCollection(AttributeCollection collection) { + super(fNames, TOLERANT_CASE); + attributeCollection = collection; + } + + /** + * Actually creates HTMLElementDeclaration instance. + * @return HTMLElementDeclaration + */ + protected CMNode create(String elementName) { + HTMLElemDeclImpl edec = null; + + if (elementName.equalsIgnoreCase(A)) { + edec = new HedA(this); + } + else if (elementName.equalsIgnoreCase(ABBR)) { + edec = new HedPhrase(ABBR, this); + + } + else if (elementName.equalsIgnoreCase(ACRONYM)) { + edec = new HedPhrase(ACRONYM, this); + + } + else if (elementName.equalsIgnoreCase(ADDRESS)) { + edec = new HedADDRESS(this); + + } + else if (elementName.equalsIgnoreCase(APPLET)) { + edec = new HedAPPLET(this); + + } + else if (elementName.equalsIgnoreCase(AREA)) { + edec = new HedAREA(this); + + } + else if (elementName.equalsIgnoreCase(B)) { + edec = new HedFontStyle(B, this); + + } + else if (elementName.equalsIgnoreCase(BASE)) { + edec = new HedBASE(this); + + } + else if (elementName.equalsIgnoreCase(BASEFONT)) { + edec = new HedBASEFONT(this); + + } + else if (elementName.equalsIgnoreCase(BDO)) { + edec = new HedBDO(this); + + } + else if (elementName.equalsIgnoreCase(BIG)) { + edec = new HedFontStyle(BIG, this); + + } + else if (elementName.equalsIgnoreCase(BLINK)) { + edec = new HedFontStyle(BLINK, this); + + } + else if (elementName.equalsIgnoreCase(BLOCKQUOTE)) { + edec = new HedBLOCKQUOTE(this); + + } + else if (elementName.equalsIgnoreCase(BODY)) { + edec = new HedBODY(this); + + } + else if (elementName.equalsIgnoreCase(BR)) { + edec = new HedBR(this); + + } + else if (elementName.equalsIgnoreCase(BUTTON)) { + edec = new HedBUTTON(this); + + } + else if (elementName.equalsIgnoreCase(CAPTION)) { + edec = new HedCAPTION(this); + + } + else if (elementName.equalsIgnoreCase(CENTER)) { + edec = new HedCENTER(this); + + } + else if (elementName.equalsIgnoreCase(CITE)) { + edec = new HedPhrase(CITE, this); + + } + else if (elementName.equalsIgnoreCase(CODE)) { + edec = new HedPhrase(CODE, this); + + } + else if (elementName.equalsIgnoreCase(COL)) { + edec = new HedCOL(this); + + } + else if (elementName.equalsIgnoreCase(COLGROUP)) { + edec = new HedCOLGROUP(this); + + } + else if (elementName.equalsIgnoreCase(DD)) { + edec = new HedDD(this); + + } + else if (elementName.equalsIgnoreCase(DEL)) { + edec = new HedMarkChanges(DEL, this); + + } + else if (elementName.equalsIgnoreCase(DFN)) { + edec = new HedPhrase(DFN, this); + + } + else if (elementName.equalsIgnoreCase(DIR)) { + edec = new HedMENU(DIR, this); + + } + else if (elementName.equalsIgnoreCase(DIV)) { + edec = new HedDIV(this); + + } + else if (elementName.equalsIgnoreCase(DL)) { + edec = new HedDL(this); + + } + else if (elementName.equalsIgnoreCase(DT)) { + edec = new HedDT(this); + + } + else if (elementName.equalsIgnoreCase(EM)) { + edec = new HedPhrase(EM, this); + + } + else if (elementName.equalsIgnoreCase(EMBED)) { + edec = new HedEMBED(this); + + } + else if (elementName.equalsIgnoreCase(FIELDSET)) { + edec = new HedFIELDSET(this); + + } + else if (elementName.equalsIgnoreCase(FONT)) { + edec = new HedFONT(this); + + } + else if (elementName.equalsIgnoreCase(FORM)) { + edec = new HedFORM(this); + + } + else if (elementName.equalsIgnoreCase(FRAME)) { + edec = new HedFRAME(this); + + } + else if (elementName.equalsIgnoreCase(FRAMESET)) { + edec = new HedFRAMESET(this); + + } + else if (elementName.equalsIgnoreCase(H1)) { + edec = new HedHeading(H1, this); + + } + else if (elementName.equalsIgnoreCase(H2)) { + edec = new HedHeading(H2, this); + + } + else if (elementName.equalsIgnoreCase(H3)) { + edec = new HedHeading(H3, this); + + } + else if (elementName.equalsIgnoreCase(H4)) { + edec = new HedHeading(H4, this); + + } + else if (elementName.equalsIgnoreCase(H5)) { + edec = new HedHeading(H5, this); + + } + else if (elementName.equalsIgnoreCase(H6)) { + edec = new HedHeading(H6, this); + + } + else if (elementName.equalsIgnoreCase(HEAD)) { + edec = new HedHEAD(this); + + } + else if (elementName.equalsIgnoreCase(HR)) { + edec = new HedHR(this); + + } + else if (elementName.equalsIgnoreCase(HTML)) { + edec = new HedHTML(this); + + } + else if (elementName.equalsIgnoreCase(I)) { + edec = new HedFontStyle(I, this); + + } + else if (elementName.equalsIgnoreCase(IFRAME)) { + edec = new HedIFRAME(this); + + } + else if (elementName.equalsIgnoreCase(IMG)) { + edec = new HedIMG(this); + + } + else if (elementName.equalsIgnoreCase(INPUT)) { + edec = new HedINPUT(this); + + } + else if (elementName.equalsIgnoreCase(INS)) { + edec = new HedMarkChanges(INS, this); + + } + else if (elementName.equalsIgnoreCase(ISINDEX)) { + edec = new HedISINDEX(this); + + } + else if (elementName.equalsIgnoreCase(KBD)) { + edec = new HedPhrase(KBD, this); + + } + else if (elementName.equalsIgnoreCase(LABEL)) { + edec = new HedLABEL(this); + + } + else if (elementName.equalsIgnoreCase(LEGEND)) { + edec = new HedLEGEND(this); + + } + else if (elementName.equalsIgnoreCase(LI)) { + edec = new HedLI(this); + + } + else if (elementName.equalsIgnoreCase(LINK)) { + edec = new HedLINK(this); + + } + else if (elementName.equalsIgnoreCase(MAP)) { + edec = new HedMAP(this); + + } + else if (elementName.equalsIgnoreCase(MARQUEE)) { + edec = new HedMARQUEE(this); + + } + else if (elementName.equalsIgnoreCase(MENU)) { + edec = new HedMENU(MENU, this); + + } + else if (elementName.equalsIgnoreCase(META)) { + edec = new HedMETA(this); + + } + else if (elementName.equalsIgnoreCase(NOEMBED)) { + edec = new HedNOEMBED(this); + + } + else if (elementName.equalsIgnoreCase(NOFRAMES)) { + edec = new HedNOFRAMES(this); + + } + else if (elementName.equalsIgnoreCase(NOSCRIPT)) { + edec = new HedNOSCRIPT(this); + + } + else if (elementName.equalsIgnoreCase(OBJECT)) { + edec = new HedOBJECT(this); + + } + else if (elementName.equalsIgnoreCase(OL)) { + edec = new HedOL(this); + + } + else if (elementName.equalsIgnoreCase(OPTGROUP)) { + edec = new HedOPTGROUP(this); + + } + else if (elementName.equalsIgnoreCase(OPTION)) { + edec = new HedOPTION(this); + + } + else if (elementName.equalsIgnoreCase(P)) { + edec = new HedP(this); + + } + else if (elementName.equalsIgnoreCase(PARAM)) { + edec = new HedPARAM(this); + + } + else if (elementName.equalsIgnoreCase(PRE)) { + edec = new HedPRE(this); + + } + else if (elementName.equalsIgnoreCase(Q)) { + edec = new HedQ(this); + + } + else if (elementName.equalsIgnoreCase(S)) { + edec = new HedFontStyle(S, this); + + } + else if (elementName.equalsIgnoreCase(SAMP)) { + edec = new HedPhrase(SAMP, this); + + } + else if (elementName.equalsIgnoreCase(SCRIPT)) { + edec = new HedSCRIPT(this); + + } + else if (elementName.equalsIgnoreCase(SELECT)) { + edec = new HedSELECT(this); + + } + else if (elementName.equalsIgnoreCase(SMALL)) { + edec = new HedFontStyle(SMALL, this); + + } + else if (elementName.equalsIgnoreCase(SPAN)) { + edec = new HedSPAN(this); + + } + else if (elementName.equalsIgnoreCase(STRIKE)) { + edec = new HedFontStyle(STRIKE, this); + + } + else if (elementName.equalsIgnoreCase(STRONG)) { + edec = new HedPhrase(STRONG, this); + + } + else if (elementName.equalsIgnoreCase(STYLE)) { + edec = new HedSTYLE(this); + + } + else if (elementName.equalsIgnoreCase(SUB)) { + edec = new HedScripts(SUB, this); + + } + else if (elementName.equalsIgnoreCase(SUP)) { + edec = new HedScripts(SUP, this); + + } + else if (elementName.equalsIgnoreCase(TABLE)) { + edec = new HedTABLE(this); + + } + else if (elementName.equalsIgnoreCase(TBODY)) { + edec = new HedTableBody(TBODY, this); + + } + else if (elementName.equalsIgnoreCase(TD)) { + edec = new HedTableCell(TD, this); + + } + else if (elementName.equalsIgnoreCase(TEXTAREA)) { + edec = new HedTEXTAREA(this); + + } + else if (elementName.equalsIgnoreCase(TFOOT)) { + edec = new HedTableBody(TFOOT, this); + + } + else if (elementName.equalsIgnoreCase(TH)) { + edec = new HedTableCell(TH, this); + + } + else if (elementName.equalsIgnoreCase(THEAD)) { + edec = new HedTableBody(THEAD, this); + + } + else if (elementName.equalsIgnoreCase(TITLE)) { + edec = new HedTITLE(this); + + } + else if (elementName.equalsIgnoreCase(TR)) { + edec = new HedTR(this); + + } + else if (elementName.equalsIgnoreCase(TT)) { + edec = new HedFontStyle(TT, this); + + } + else if (elementName.equalsIgnoreCase(U)) { + edec = new HedFontStyle(U, this); + + } + else if (elementName.equalsIgnoreCase(UL)) { + edec = new HedUL(this); + + } + else if (elementName.equalsIgnoreCase(VAR)) { + edec = new HedPhrase(VAR, this); + + } + else if (elementName.equalsIgnoreCase(SSI_CONFIG)) { + edec = new HedSSIConfig(this); + + } + else if (elementName.equalsIgnoreCase(SSI_ECHO)) { + edec = new HedSSIEcho(this); + + } + else if (elementName.equalsIgnoreCase(SSI_EXEC)) { + edec = new HedSSIExec(this); + + } + else if (elementName.equalsIgnoreCase(SSI_FSIZE)) { + edec = new HedSSIFsize(this); + + } + else if (elementName.equalsIgnoreCase(SSI_FLASTMOD)) { + edec = new HedSSIFlastmod(this); + + } + else if (elementName.equalsIgnoreCase(SSI_INCLUDE)) { + edec = new HedSSIInclude(this); + + } + else if (elementName.equalsIgnoreCase(SSI_PRINTENV)) { + edec = new HedSSIPrintenv(this); + + } + else if (elementName.equalsIgnoreCase(SSI_SET)) { + edec = new HedSSISet(this); + + } + else if (elementName.equalsIgnoreCase(BGSOUND)) { + edec = new HedBGSOUND(this); + + } + else if (elementName.equalsIgnoreCase(NOBR)) { + edec = new HedNOBR(this); + + } + else if (elementName.equalsIgnoreCase(WBR)) { + edec = new HedWBR(this); + + } // unknown + else { + // NOTE: We don't define the UNKNOWN element declaration. + // <code>null</code> for a declaration is a sign of + // the target element is unknown. + // -- 3/9/2001 + edec = null; + } + return edec; + } + + /** + * @return com.ibm.sed.contentmodel.html.AttributeCollection + */ + public AttributeCollection getAttributeCollection() { + return attributeCollection; + } + + /** + */ + public final Collection getNamesOfBlock() { + // P, DL, DIV, CENTER, NOSCRIPT, NOFRAMES, BLOCKQUOTE, FORM, ISINDEX, HR, + // TABLE, FIELDSET, ADDRESS + String[] blockMisc = {P, DL, DIV, CENTER, NOSCRIPT, NOFRAMES, BLOCKQUOTE, FORM, ISINDEX, HR, TABLE, FIELDSET, ADDRESS}; + Vector names = new Vector(Arrays.asList(blockMisc)); + // %heading; + names.addAll(Arrays.asList(HEADING)); + // %list; + names.addAll(Arrays.asList(LIST)); + // %preformatted; + names.addAll(Arrays.asList(PREFORMATTED)); + + return names; + } + + /** + * %block;. + * %block; is: + * P | %heading; | %list; | %preformatted; | DL | DIV | CENTER | + * NOSCRIPT | NOFRAMES | BLOCKQUOTE | FORM | ISINDEX | HR | + * TABLE | FIELDSET | ADDRESS.<br> + * @param group CMGroupImpl Return values. + */ + public final void getBlock(CMGroupImpl group) { + if (group == null) + return; + getDeclarations(group, getNamesOfBlock().iterator()); + } + + /** + * Create element declarations and store them + * into a <code>CMGroupImpl</code> instance. + * @param group CMGroupImpl Return values. + */ + public final void getFlow(CMGroupImpl group) { + if (group == null) + return; + getBlock(group); + getInline(group); + } + + /** + * Create element declarations and store them into a <code>CMGroupImpl</code> + * instance.<br> + * @param group CMGroupImpl Return values. + */ + public final void getFontstyle(CMGroupImpl group) { + if (group == null) + return; + getDeclarations(group, Arrays.asList(FONTSTYLE).iterator()); + } + + /** + * Create element declarations and store them into a <code>CMGroupImpl</code> + * instance.<br> + * @param group CMGroupImpl Return values. + */ + public final void getFormctrl(CMGroupImpl group) { + if (group == null) + return; + getDeclarations(group, Arrays.asList(FORMCTL).iterator()); + } + + /** + * %heading;. + * @param group CMGroupImpl Return values. + */ + public final void getHeading(CMGroupImpl group) { + if (group == null) + return; + + getDeclarations(group, Arrays.asList(HEADING).iterator()); + } + + /** + * Create element declarations and store them + * into a <code>CMGroupImpl</code> instance. + * @param group CMGroupImpl Return values. + */ + public final void getInline(CMGroupImpl group) { + if (group == null) + return; + getFontstyle(group); + getPhrase(group); + getSpecial(group); + getFormctrl(group); + } + + /** + * %list;. + * @param group CMGroupImpl Return values. + */ + public final void getList(CMGroupImpl group) { + if (group == null) + return; + + getDeclarations(group, Arrays.asList(LIST).iterator()); + } + + /** + * Create element declarations and store them into a <code>CMGroupImpl</code> + * instance.<br> + * @param group CMGroupImpl Return values. + */ + public final void getPhrase(CMGroupImpl group) { + if (group == null) + return; + getDeclarations(group, Arrays.asList(PHRASE).iterator()); + } + + /** + * %preformatted; + * @param group CMGroupImpl Return values. + */ + public final void getPreformatted(CMGroupImpl group) { + if (group == null) + return; + + getDeclarations(group, Arrays.asList(PREFORMATTED).iterator()); + } + + /** + * Create element declarations and store them into a <code>CMGroupImpl</code> + * instance.<br> + * @param group CMGroupImpl Return values. + */ + public final void getSpecial(CMGroupImpl group) { + if (group == null) + return; + getDeclarations(group, Arrays.asList(SPECIAL).iterator()); + } +}
\ No newline at end of file diff --git a/bundles/org.eclipse.wst.html.core/src/org/eclipse/wst/html/core/contentmodel/EntityCollection.java b/bundles/org.eclipse.wst.html.core/src/org/eclipse/wst/html/core/contentmodel/EntityCollection.java new file mode 100644 index 0000000000..dfecba9e08 --- /dev/null +++ b/bundles/org.eclipse.wst.html.core/src/org/eclipse/wst/html/core/contentmodel/EntityCollection.java @@ -0,0 +1,837 @@ +/******************************************************************************* + * Copyright (c) 2004 IBM Corporation and others. + * All rights reserved. This program and the accompanying materials + * are made available under the terms of the Eclipse Public License v1.0 + * which accompanies this distribution, and is available at + * http://www.eclipse.org/legal/epl-v10.html + * + * Contributors: + * IBM Corporation - initial API and implementation + *******************************************************************************/ +package org.eclipse.wst.html.core.contentmodel; + + + +import java.lang.reflect.Field; + +import org.eclipse.wst.common.contentmodel.CMNode; + +/** + * Factory for entity declarations. + */ +final class EntityCollection extends DeclCollection implements org.eclipse.wst.html.core.HTML40Namespace.EntityName { + + + private static class Ids { + public static final int ID_AACUTE_L = 0; + public static final int ID_AACUTE_U = 1; + public static final int ID_ACIRC_L = 2; + public static final int ID_ACIRC_U = 3; + public static final int ID_ACUTE = 4; + public static final int ID_AELIG_L = 5; + public static final int ID_AELIG_U = 6; + public static final int ID_AGRAVE_L = 7; + public static final int ID_AGRAVE_U = 8; + public static final int ID_ALEFSYM = 9; + public static final int ID_ALPHA_L = 10; + public static final int ID_ALPHA_U = 11; + public static final int ID_AMP = 12; + public static final int ID_AND = 13; + public static final int ID_ANG = 14; + public static final int ID_ARING_L = 15; + public static final int ID_ARING_U = 16; + public static final int ID_ASYMP = 17; + public static final int ID_ATILDE_L = 18; + public static final int ID_ATILDE_U = 19; + public static final int ID_AUML_L = 20; + public static final int ID_AUML_U = 21; + public static final int ID_BDQUO = 22; + public static final int ID_BETA_L = 23; + public static final int ID_BETA_U = 24; + public static final int ID_BRVBAR = 25; + public static final int ID_BULL = 26; + public static final int ID_CAP = 27; + public static final int ID_CCEDIL_L = 28; + public static final int ID_CCEDIL_U = 29; + public static final int ID_CEDIL = 30; + public static final int ID_CENT = 31; + public static final int ID_CHI_L = 32; + public static final int ID_CHI_U = 33; + public static final int ID_CIRC = 34; + public static final int ID_CLUBS = 35; + public static final int ID_CONG = 36; + public static final int ID_COPY = 37; + public static final int ID_CRARR = 38; + public static final int ID_CUP = 39; + public static final int ID_CURREN = 40; + public static final int ID_DAGGER_L = 41; + public static final int ID_DAGGER_U = 42; + public static final int ID_DARR_L = 43; + public static final int ID_DARR_U = 44; + public static final int ID_DEG = 45; + public static final int ID_DELTA_L = 46; + public static final int ID_DELTA_U = 47; + public static final int ID_DIAMS = 48; + public static final int ID_DIVIDE = 49; + public static final int ID_EACUTE_L = 50; + public static final int ID_EACUTE_U = 51; + public static final int ID_ECIRC_L = 52; + public static final int ID_ECIRC_U = 53; + public static final int ID_EGRAVE_L = 54; + public static final int ID_EGRAVE_U = 55; + public static final int ID_EMPTY = 56; + public static final int ID_EMSP = 57; + public static final int ID_ENSP = 58; + public static final int ID_EPSILON_L = 59; + public static final int ID_EPSILON_U = 60; + public static final int ID_EQUIV = 61; + public static final int ID_ETA_L = 62; + public static final int ID_ETA_U = 63; + public static final int ID_ETH_L = 64; + public static final int ID_ETH_U = 65; + public static final int ID_EUML_L = 66; + public static final int ID_EUML_U = 67; + public static final int ID_EURO = 68; + public static final int ID_EXIST = 69; + public static final int ID_FNOF = 70; + public static final int ID_FORALL = 71; + public static final int ID_FRAC12 = 72; + public static final int ID_FRAC14 = 73; + public static final int ID_FRAC34 = 74; + public static final int ID_FRASL = 75; + public static final int ID_GAMMA_L = 76; + public static final int ID_GAMMA_U = 77; + public static final int ID_GE = 78; + public static final int ID_GT = 79; + public static final int ID_HARR_L = 80; + public static final int ID_HARR_U = 81; + public static final int ID_HEARTS = 82; + public static final int ID_HELLIP = 83; + public static final int ID_IACUTE_L = 84; + public static final int ID_IACUTE_U = 85; + public static final int ID_ICIRC_L = 86; + public static final int ID_ICIRC_U = 87; + public static final int ID_IEXCL = 88; + public static final int ID_IGRAVE_L = 89; + public static final int ID_IGRAVE_U = 90; + public static final int ID_IMAGE = 91; + public static final int ID_INFIN = 92; + public static final int ID_INT = 93; + public static final int ID_IOTA_L = 94; + public static final int ID_IOTA_U = 95; + public static final int ID_IQUEST = 96; + public static final int ID_ISIN = 97; + public static final int ID_IUML_L = 98; + public static final int ID_IUML_U = 99; + public static final int ID_KAPPA_L = 100; + public static final int ID_KAPPA_U = 101; + public static final int ID_LAMBDA_L = 102; + public static final int ID_LAMBDA_U = 103; + public static final int ID_LANG = 104; + public static final int ID_LAQUO = 105; + public static final int ID_LARR_L = 106; + public static final int ID_LARR_U = 107; + public static final int ID_LCEIL = 108; + public static final int ID_LDQUO = 109; + public static final int ID_LE = 110; + public static final int ID_LFLOOR = 111; + public static final int ID_LOWAST = 112; + public static final int ID_LOZ = 113; + public static final int ID_LRM = 114; + public static final int ID_LSAQUO = 115; + public static final int ID_LSQUO = 116; + public static final int ID_LT = 117; + public static final int ID_MACR = 118; + public static final int ID_MDASH = 119; + public static final int ID_MICRO = 120; + public static final int ID_MIDDOT = 121; + public static final int ID_MINUS = 122; + public static final int ID_MU_L = 123; + public static final int ID_MU_U = 124; + public static final int ID_NABLA = 125; + public static final int ID_NBSP = 126; + public static final int ID_NDASH = 127; + public static final int ID_NE = 128; + public static final int ID_NI = 129; + public static final int ID_NOT = 130; + public static final int ID_NOTIN = 131; + public static final int ID_NSUB = 132; + public static final int ID_NTILDE_L = 133; + public static final int ID_NTILDE_U = 134; + public static final int ID_NU_L = 135; + public static final int ID_NU_U = 136; + public static final int ID_OACUTE_L = 137; + public static final int ID_OACUTE_U = 138; + public static final int ID_OCIRC_L = 139; + public static final int ID_OCIRC_U = 140; + public static final int ID_OELIG_L = 141; + public static final int ID_OELIG_U = 142; + public static final int ID_OGRAVE_L = 143; + public static final int ID_OGRAVE_U = 144; + public static final int ID_OLINE = 145; + public static final int ID_OMEGA_L = 146; + public static final int ID_OMEGA_U = 147; + public static final int ID_OMICRON_L = 148; + public static final int ID_OMICRON_U = 149; + public static final int ID_OPLUS = 150; + public static final int ID_OR = 151; + public static final int ID_ORDF = 152; + public static final int ID_ORDM = 153; + public static final int ID_OSLASH_L = 154; + public static final int ID_OSLASH_U = 155; + public static final int ID_OTILDE_L = 156; + public static final int ID_OTILDE_U = 157; + public static final int ID_OTIMES = 158; + public static final int ID_OUML_L = 159; + public static final int ID_OUML_U = 160; + public static final int ID_PARA = 161; + public static final int ID_PART = 162; + public static final int ID_PERMIL = 163; + public static final int ID_PERP = 164; + public static final int ID_PHI_L = 165; + public static final int ID_PHI_U = 166; + public static final int ID_PIV = 167; + public static final int ID_PI_L = 168; + public static final int ID_PI_U = 169; + public static final int ID_PLUSMN = 170; + public static final int ID_POUND = 171; + public static final int ID_PRIME_L = 172; + public static final int ID_PRIME_U = 173; + public static final int ID_PROD = 174; + public static final int ID_PROP = 175; + public static final int ID_PSI_L = 176; + public static final int ID_PSI_U = 177; + public static final int ID_QUOT = 178; + public static final int ID_RADIC = 179; + public static final int ID_RANG = 180; + public static final int ID_RAQUO = 181; + public static final int ID_RARR_L = 182; + public static final int ID_RARR_U = 183; + public static final int ID_RCEIL = 184; + public static final int ID_RDQUO = 185; + public static final int ID_REAL = 186; + public static final int ID_REG = 187; + public static final int ID_RFLOOR = 188; + public static final int ID_RHO_L = 189; + public static final int ID_RHO_U = 190; + public static final int ID_RLM = 191; + public static final int ID_RSAQUO = 192; + public static final int ID_RSQUO = 193; + public static final int ID_SBQUO = 194; + public static final int ID_SCARON_L = 195; + public static final int ID_SCARON_U = 196; + public static final int ID_SDOT = 197; + public static final int ID_SECT = 198; + public static final int ID_SHY = 199; + public static final int ID_SIGMAF = 200; + public static final int ID_SIGMA_L = 201; + public static final int ID_SIGMA_U = 202; + public static final int ID_SIM = 203; + public static final int ID_SPADES = 204; + public static final int ID_SUB = 205; + public static final int ID_SUBE = 206; + public static final int ID_SUM = 207; + public static final int ID_SUP = 208; + public static final int ID_SUP1 = 209; + public static final int ID_SUP2 = 210; + public static final int ID_SUP3 = 211; + public static final int ID_SUPE = 212; + public static final int ID_SZLIG = 213; + public static final int ID_TAU_L = 214; + public static final int ID_TAU_U = 215; + public static final int ID_THERE4 = 216; + public static final int ID_THETASYM = 217; + public static final int ID_THETA_L = 218; + public static final int ID_THETA_U = 219; + public static final int ID_THINSP = 220; + public static final int ID_THORN_L = 221; + public static final int ID_THORN_U = 222; + public static final int ID_TILDE = 223; + public static final int ID_TIMES = 224; + public static final int ID_TRADE = 225; + public static final int ID_UACUTE_L = 226; + public static final int ID_UACUTE_U = 227; + public static final int ID_UARR_L = 228; + public static final int ID_UARR_U = 229; + public static final int ID_UCIRC_L = 230; + public static final int ID_UCIRC_U = 231; + public static final int ID_UGRAVE_L = 232; + public static final int ID_UGRAVE_U = 233; + public static final int ID_UML = 234; + public static final int ID_UPSIH = 235; + public static final int ID_UPSILON_L = 236; + public static final int ID_UPSILON_U = 237; + public static final int ID_UUML_L = 238; + public static final int ID_UUML_U = 239; + public static final int ID_WEIERP = 240; + public static final int ID_XI_L = 241; + public static final int ID_XI_U = 242; + public static final int ID_YACUTE_L = 243; + public static final int ID_YACUTE_U = 244; + public static final int ID_YEN = 245; + public static final int ID_YUML_L = 246; + public static final int ID_YUML_U = 247; + public static final int ID_ZETA_L = 248; + public static final int ID_ZETA_U = 249; + public static final int ID_ZWJ = 250; + public static final int ID_ZWNJ = 251; + + public static int getNumOfIds() { + if (numofids != -1) + return numofids; + + // NOTE: If the reflection is too slow, this method should + // just return the literal value, like 252. + // -- 5/24/2001 + Class clazz = Ids.class; + Field[] fields = clazz.getFields(); + numofids = 0; + for (int i = 0; i < fields.length; i++) { + String name = fields[i].getName(); + if (name.startsWith("ID_"))//$NON-NLS-1$ + numofids++; + } + return numofids; + } + + // chache the result of the reflection. + private static int numofids = -1; + } + + private static String[] names = null; + + static { + names = new String[Ids.getNumOfIds()]; + names[Ids.ID_AACUTE_L] = AACUTE_L; + names[Ids.ID_AACUTE_U] = AACUTE_U; + names[Ids.ID_ACIRC_L] = ACIRC_L; + names[Ids.ID_ACIRC_U] = ACIRC_U; + names[Ids.ID_ACUTE] = ACUTE; + names[Ids.ID_AELIG_L] = AELIG_L; + names[Ids.ID_AELIG_U] = AELIG_U; + names[Ids.ID_AGRAVE_L] = AGRAVE_L; + names[Ids.ID_AGRAVE_U] = AGRAVE_U; + names[Ids.ID_ALEFSYM] = ALEFSYM; + names[Ids.ID_ALPHA_L] = ALPHA_L; + names[Ids.ID_ALPHA_U] = ALPHA_U; + names[Ids.ID_AMP] = AMP; + names[Ids.ID_AND] = AND; + names[Ids.ID_ANG] = ANG; + names[Ids.ID_ARING_L] = ARING_L; + names[Ids.ID_ARING_U] = ARING_U; + names[Ids.ID_ASYMP] = ASYMP; + names[Ids.ID_ATILDE_L] = ATILDE_L; + names[Ids.ID_ATILDE_U] = ATILDE_U; + names[Ids.ID_AUML_L] = AUML_L; + names[Ids.ID_AUML_U] = AUML_U; + names[Ids.ID_BDQUO] = BDQUO; + names[Ids.ID_BETA_L] = BETA_L; + names[Ids.ID_BETA_U] = BETA_U; + names[Ids.ID_BRVBAR] = BRVBAR; + names[Ids.ID_BULL] = BULL; + names[Ids.ID_CAP] = CAP; + names[Ids.ID_CCEDIL_L] = CCEDIL_L; + names[Ids.ID_CCEDIL_U] = CCEDIL_U; + names[Ids.ID_CEDIL] = CEDIL; + names[Ids.ID_CENT] = CENT; + names[Ids.ID_CHI_L] = CHI_L; + names[Ids.ID_CHI_U] = CHI_U; + names[Ids.ID_CIRC] = CIRC; + names[Ids.ID_CLUBS] = CLUBS; + names[Ids.ID_CONG] = CONG; + names[Ids.ID_COPY] = COPY; + names[Ids.ID_CRARR] = CRARR; + names[Ids.ID_CUP] = CUP; + names[Ids.ID_CURREN] = CURREN; + names[Ids.ID_DAGGER_L] = DAGGER_L; + names[Ids.ID_DAGGER_U] = DAGGER_U; + names[Ids.ID_DARR_L] = DARR_L; + names[Ids.ID_DARR_U] = DARR_U; + names[Ids.ID_DEG] = DEG; + names[Ids.ID_DELTA_L] = DELTA_L; + names[Ids.ID_DELTA_U] = DELTA_U; + names[Ids.ID_DIAMS] = DIAMS; + names[Ids.ID_DIVIDE] = DIVIDE; + names[Ids.ID_EACUTE_L] = EACUTE_L; + names[Ids.ID_EACUTE_U] = EACUTE_U; + names[Ids.ID_ECIRC_L] = ECIRC_L; + names[Ids.ID_ECIRC_U] = ECIRC_U; + names[Ids.ID_EGRAVE_L] = EGRAVE_L; + names[Ids.ID_EGRAVE_U] = EGRAVE_U; + names[Ids.ID_EMPTY] = EMPTY; + names[Ids.ID_EMSP] = EMSP; + names[Ids.ID_ENSP] = ENSP; + names[Ids.ID_EPSILON_L] = EPSILON_L; + names[Ids.ID_EPSILON_U] = EPSILON_U; + names[Ids.ID_EQUIV] = EQUIV; + names[Ids.ID_ETA_L] = ETA_L; + names[Ids.ID_ETA_U] = ETA_U; + names[Ids.ID_ETH_L] = ETH_L; + names[Ids.ID_ETH_U] = ETH_U; + names[Ids.ID_EUML_L] = EUML_L; + names[Ids.ID_EUML_U] = EUML_U; + names[Ids.ID_EURO] = EURO; + names[Ids.ID_EXIST] = EXIST; + names[Ids.ID_FNOF] = FNOF; + names[Ids.ID_FORALL] = FORALL; + names[Ids.ID_FRAC12] = FRAC12; + names[Ids.ID_FRAC14] = FRAC14; + names[Ids.ID_FRAC34] = FRAC34; + names[Ids.ID_FRASL] = FRASL; + names[Ids.ID_GAMMA_L] = GAMMA_L; + names[Ids.ID_GAMMA_U] = GAMMA_U; + names[Ids.ID_GE] = GE; + names[Ids.ID_GT] = GT; + names[Ids.ID_HARR_L] = HARR_L; + names[Ids.ID_HARR_U] = HARR_U; + names[Ids.ID_HEARTS] = HEARTS; + names[Ids.ID_HELLIP] = HELLIP; + names[Ids.ID_IACUTE_L] = IACUTE_L; + names[Ids.ID_IACUTE_U] = IACUTE_U; + names[Ids.ID_ICIRC_L] = ICIRC_L; + names[Ids.ID_ICIRC_U] = ICIRC_U; + names[Ids.ID_IEXCL] = IEXCL; + names[Ids.ID_IGRAVE_L] = IGRAVE_L; + names[Ids.ID_IGRAVE_U] = IGRAVE_U; + names[Ids.ID_IMAGE] = IMAGE; + names[Ids.ID_INFIN] = INFIN; + names[Ids.ID_INT] = INT; + names[Ids.ID_IOTA_L] = IOTA_L; + names[Ids.ID_IOTA_U] = IOTA_U; + names[Ids.ID_IQUEST] = IQUEST; + names[Ids.ID_ISIN] = ISIN; + names[Ids.ID_IUML_L] = IUML_L; + names[Ids.ID_IUML_U] = IUML_U; + names[Ids.ID_KAPPA_L] = KAPPA_L; + names[Ids.ID_KAPPA_U] = KAPPA_U; + names[Ids.ID_LAMBDA_L] = LAMBDA_L; + names[Ids.ID_LAMBDA_U] = LAMBDA_U; + names[Ids.ID_LANG] = LANG; + names[Ids.ID_LAQUO] = LAQUO; + names[Ids.ID_LARR_L] = LARR_L; + names[Ids.ID_LARR_U] = LARR_U; + names[Ids.ID_LCEIL] = LCEIL; + names[Ids.ID_LDQUO] = LDQUO; + names[Ids.ID_LE] = LE; + names[Ids.ID_LFLOOR] = LFLOOR; + names[Ids.ID_LOWAST] = LOWAST; + names[Ids.ID_LOZ] = LOZ; + names[Ids.ID_LRM] = LRM; + names[Ids.ID_LSAQUO] = LSAQUO; + names[Ids.ID_LSQUO] = LSQUO; + names[Ids.ID_LT] = LT; + names[Ids.ID_MACR] = MACR; + names[Ids.ID_MDASH] = MDASH; + names[Ids.ID_MICRO] = MICRO; + names[Ids.ID_MIDDOT] = MIDDOT; + names[Ids.ID_MINUS] = MINUS; + names[Ids.ID_MU_L] = MU_L; + names[Ids.ID_MU_U] = MU_U; + names[Ids.ID_NABLA] = NABLA; + names[Ids.ID_NBSP] = NBSP; + names[Ids.ID_NDASH] = NDASH; + names[Ids.ID_NE] = NE; + names[Ids.ID_NI] = NI; + names[Ids.ID_NOT] = NOT; + names[Ids.ID_NOTIN] = NOTIN; + names[Ids.ID_NSUB] = NSUB; + names[Ids.ID_NTILDE_L] = NTILDE_L; + names[Ids.ID_NTILDE_U] = NTILDE_U; + names[Ids.ID_NU_L] = NU_L; + names[Ids.ID_NU_U] = NU_U; + names[Ids.ID_OACUTE_L] = OACUTE_L; + names[Ids.ID_OACUTE_U] = OACUTE_U; + names[Ids.ID_OCIRC_L] = OCIRC_L; + names[Ids.ID_OCIRC_U] = OCIRC_U; + names[Ids.ID_OELIG_L] = OELIG_L; + names[Ids.ID_OELIG_U] = OELIG_U; + names[Ids.ID_OGRAVE_L] = OGRAVE_L; + names[Ids.ID_OGRAVE_U] = OGRAVE_U; + names[Ids.ID_OLINE] = OLINE; + names[Ids.ID_OMEGA_L] = OMEGA_L; + names[Ids.ID_OMEGA_U] = OMEGA_U; + names[Ids.ID_OMICRON_L] = OMICRON_L; + names[Ids.ID_OMICRON_U] = OMICRON_U; + names[Ids.ID_OPLUS] = OPLUS; + names[Ids.ID_OR] = OR; + names[Ids.ID_ORDF] = ORDF; + names[Ids.ID_ORDM] = ORDM; + names[Ids.ID_OSLASH_L] = OSLASH_L; + names[Ids.ID_OSLASH_U] = OSLASH_U; + names[Ids.ID_OTILDE_L] = OTILDE_L; + names[Ids.ID_OTILDE_U] = OTILDE_U; + names[Ids.ID_OTIMES] = OTIMES; + names[Ids.ID_OUML_L] = OUML_L; + names[Ids.ID_OUML_U] = OUML_U; + names[Ids.ID_PARA] = PARA; + names[Ids.ID_PART] = PART; + names[Ids.ID_PERMIL] = PERMIL; + names[Ids.ID_PERP] = PERP; + names[Ids.ID_PHI_L] = PHI_L; + names[Ids.ID_PHI_U] = PHI_U; + names[Ids.ID_PIV] = PIV; + names[Ids.ID_PI_L] = PI_L; + names[Ids.ID_PI_U] = PI_U; + names[Ids.ID_PLUSMN] = PLUSMN; + names[Ids.ID_POUND] = POUND; + names[Ids.ID_PRIME_L] = PRIME_L; + names[Ids.ID_PRIME_U] = PRIME_U; + names[Ids.ID_PROD] = PROD; + names[Ids.ID_PROP] = PROP; + names[Ids.ID_PSI_L] = PSI_L; + names[Ids.ID_PSI_U] = PSI_U; + names[Ids.ID_QUOT] = QUOT; + names[Ids.ID_RADIC] = RADIC; + names[Ids.ID_RANG] = RANG; + names[Ids.ID_RAQUO] = RAQUO; + names[Ids.ID_RARR_L] = RARR_L; + names[Ids.ID_RARR_U] = RARR_U; + names[Ids.ID_RCEIL] = RCEIL; + names[Ids.ID_RDQUO] = RDQUO; + names[Ids.ID_REAL] = REAL; + names[Ids.ID_REG] = REG; + names[Ids.ID_RFLOOR] = RFLOOR; + names[Ids.ID_RHO_L] = RHO_L; + names[Ids.ID_RHO_U] = RHO_U; + names[Ids.ID_RLM] = RLM; + names[Ids.ID_RSAQUO] = RSAQUO; + names[Ids.ID_RSQUO] = RSQUO; + names[Ids.ID_SBQUO] = SBQUO; + names[Ids.ID_SCARON_L] = SCARON_L; + names[Ids.ID_SCARON_U] = SCARON_U; + names[Ids.ID_SDOT] = SDOT; + names[Ids.ID_SECT] = SECT; + names[Ids.ID_SHY] = SHY; + names[Ids.ID_SIGMAF] = SIGMAF; + names[Ids.ID_SIGMA_L] = SIGMA_L; + names[Ids.ID_SIGMA_U] = SIGMA_U; + names[Ids.ID_SIM] = SIM; + names[Ids.ID_SPADES] = SPADES; + names[Ids.ID_SUB] = SUB; + names[Ids.ID_SUBE] = SUBE; + names[Ids.ID_SUM] = SUM; + names[Ids.ID_SUP] = SUP; + names[Ids.ID_SUP1] = SUP1; + names[Ids.ID_SUP2] = SUP2; + names[Ids.ID_SUP3] = SUP3; + names[Ids.ID_SUPE] = SUPE; + names[Ids.ID_SZLIG] = SZLIG; + names[Ids.ID_TAU_L] = TAU_L; + names[Ids.ID_TAU_U] = TAU_U; + names[Ids.ID_THERE4] = THERE4; + names[Ids.ID_THETASYM] = THETASYM; + names[Ids.ID_THETA_L] = THETA_L; + names[Ids.ID_THETA_U] = THETA_U; + names[Ids.ID_THINSP] = THINSP; + names[Ids.ID_THORN_L] = THORN_L; + names[Ids.ID_THORN_U] = THORN_U; + names[Ids.ID_TILDE] = TILDE; + names[Ids.ID_TIMES] = TIMES; + names[Ids.ID_TRADE] = TRADE; + names[Ids.ID_UACUTE_L] = UACUTE_L; + names[Ids.ID_UACUTE_U] = UACUTE_U; + names[Ids.ID_UARR_L] = UARR_L; + names[Ids.ID_UARR_U] = UARR_U; + names[Ids.ID_UCIRC_L] = UCIRC_L; + names[Ids.ID_UCIRC_U] = UCIRC_U; + names[Ids.ID_UGRAVE_L] = UGRAVE_L; + names[Ids.ID_UGRAVE_U] = UGRAVE_U; + names[Ids.ID_UML] = UML; + names[Ids.ID_UPSIH] = UPSIH; + names[Ids.ID_UPSILON_L] = UPSILON_L; + names[Ids.ID_UPSILON_U] = UPSILON_U; + names[Ids.ID_UUML_L] = UUML_L; + names[Ids.ID_UUML_U] = UUML_U; + names[Ids.ID_WEIERP] = WEIERP; + names[Ids.ID_XI_L] = XI_L; + names[Ids.ID_XI_U] = XI_U; + names[Ids.ID_YACUTE_L] = YACUTE_L; + names[Ids.ID_YACUTE_U] = YACUTE_U; + names[Ids.ID_YEN] = YEN; + names[Ids.ID_YUML_L] = YUML_L; + names[Ids.ID_YUML_U] = YUML_U; + names[Ids.ID_ZETA_L] = ZETA_L; + names[Ids.ID_ZETA_U] = ZETA_U; + names[Ids.ID_ZWJ] = ZWJ; + names[Ids.ID_ZWNJ] = ZWNJ; + } + private static char[] values = null; + + static { + values = new char[Ids.getNumOfIds()]; + values[Ids.ID_AACUTE_L] = 225; + values[Ids.ID_AACUTE_U] = 193; + values[Ids.ID_ACIRC_L] = 226; + values[Ids.ID_ACIRC_U] = 194; + values[Ids.ID_ACUTE] = 180; + values[Ids.ID_AELIG_L] = 230; + values[Ids.ID_AELIG_U] = 198; + values[Ids.ID_AGRAVE_L] = 224; + values[Ids.ID_AGRAVE_U] = 192; + values[Ids.ID_ALEFSYM] = 8501; + values[Ids.ID_ALPHA_L] = 945; + values[Ids.ID_ALPHA_U] = 913; + values[Ids.ID_AMP] = 38; + values[Ids.ID_AND] = 8743; + values[Ids.ID_ANG] = 8736; + values[Ids.ID_ARING_L] = 229; + values[Ids.ID_ARING_U] = 197; + values[Ids.ID_ASYMP] = 8776; + values[Ids.ID_ATILDE_L] = 227; + values[Ids.ID_ATILDE_U] = 195; + values[Ids.ID_AUML_L] = 228; + values[Ids.ID_AUML_U] = 196; + values[Ids.ID_BDQUO] = 8222; + values[Ids.ID_BETA_L] = 946; + values[Ids.ID_BETA_U] = 914; + values[Ids.ID_BRVBAR] = 166; + values[Ids.ID_BULL] = 8226; + values[Ids.ID_CAP] = 8745; + values[Ids.ID_CCEDIL_L] = 231; + values[Ids.ID_CCEDIL_U] = 199; + values[Ids.ID_CEDIL] = 184; + values[Ids.ID_CENT] = 162; + values[Ids.ID_CHI_L] = 967; + values[Ids.ID_CHI_U] = 935; + values[Ids.ID_CIRC] = 710; + values[Ids.ID_CLUBS] = 9827; + values[Ids.ID_CONG] = 8773; + values[Ids.ID_COPY] = 169; + values[Ids.ID_CRARR] = 8629; + values[Ids.ID_CUP] = 8746; + values[Ids.ID_CURREN] = 164; + values[Ids.ID_DAGGER_L] = 8224; + values[Ids.ID_DAGGER_U] = 8225; + values[Ids.ID_DARR_L] = 8595; + values[Ids.ID_DARR_U] = 8659; + values[Ids.ID_DEG] = 176; + values[Ids.ID_DELTA_L] = 948; + values[Ids.ID_DELTA_U] = 916; + values[Ids.ID_DIAMS] = 9830; + values[Ids.ID_DIVIDE] = 247; + values[Ids.ID_EACUTE_L] = 233; + values[Ids.ID_EACUTE_U] = 201; + values[Ids.ID_ECIRC_L] = 234; + values[Ids.ID_ECIRC_U] = 202; + values[Ids.ID_EGRAVE_L] = 232; + values[Ids.ID_EGRAVE_U] = 200; + values[Ids.ID_EMPTY] = 8709; + values[Ids.ID_EMSP] = 8195; + values[Ids.ID_ENSP] = 8194; + values[Ids.ID_EPSILON_L] = 949; + values[Ids.ID_EPSILON_U] = 917; + values[Ids.ID_EQUIV] = 8801; + values[Ids.ID_ETA_L] = 951; + values[Ids.ID_ETA_U] = 919; + values[Ids.ID_ETH_L] = 240; + values[Ids.ID_ETH_U] = 208; + values[Ids.ID_EUML_L] = 235; + values[Ids.ID_EUML_U] = 203; + values[Ids.ID_EURO] = 8364; + values[Ids.ID_EXIST] = 8707; + values[Ids.ID_FNOF] = 402; + values[Ids.ID_FORALL] = 8704; + values[Ids.ID_FRAC12] = 189; + values[Ids.ID_FRAC14] = 188; + values[Ids.ID_FRAC34] = 190; + values[Ids.ID_FRASL] = 8260; + values[Ids.ID_GAMMA_L] = 947; + values[Ids.ID_GAMMA_U] = 915; + values[Ids.ID_GE] = 8805; + values[Ids.ID_GT] = 62; + values[Ids.ID_HARR_L] = 8596; + values[Ids.ID_HARR_U] = 8660; + values[Ids.ID_HEARTS] = 9829; + values[Ids.ID_HELLIP] = 8230; + values[Ids.ID_IACUTE_L] = 237; + values[Ids.ID_IACUTE_U] = 205; + values[Ids.ID_ICIRC_L] = 238; + values[Ids.ID_ICIRC_U] = 206; + values[Ids.ID_IEXCL] = 161; + values[Ids.ID_IGRAVE_L] = 236; + values[Ids.ID_IGRAVE_U] = 204; + values[Ids.ID_IMAGE] = 8465; + values[Ids.ID_INFIN] = 8734; + values[Ids.ID_INT] = 8747; + values[Ids.ID_IOTA_L] = 953; + values[Ids.ID_IOTA_U] = 921; + values[Ids.ID_IQUEST] = 191; + values[Ids.ID_ISIN] = 8712; + values[Ids.ID_IUML_L] = 239; + values[Ids.ID_IUML_U] = 207; + values[Ids.ID_KAPPA_L] = 954; + values[Ids.ID_KAPPA_U] = 922; + values[Ids.ID_LAMBDA_L] = 955; + values[Ids.ID_LAMBDA_U] = 923; + values[Ids.ID_LANG] = 9001; + values[Ids.ID_LAQUO] = 171; + values[Ids.ID_LARR_L] = 8592; + values[Ids.ID_LARR_U] = 8656; + values[Ids.ID_LCEIL] = 8968; + values[Ids.ID_LDQUO] = 8220; + values[Ids.ID_LE] = 8804; + values[Ids.ID_LFLOOR] = 8970; + values[Ids.ID_LOWAST] = 8727; + values[Ids.ID_LOZ] = 9674; + values[Ids.ID_LRM] = 8206; + values[Ids.ID_LSAQUO] = 8249; + values[Ids.ID_LSQUO] = 8216; + values[Ids.ID_LT] = 60; + values[Ids.ID_MACR] = 175; + values[Ids.ID_MDASH] = 8212; + values[Ids.ID_MICRO] = 181; + values[Ids.ID_MIDDOT] = 183; + values[Ids.ID_MINUS] = 8722; + values[Ids.ID_MU_L] = 956; + values[Ids.ID_MU_U] = 924; + values[Ids.ID_NABLA] = 8711; + values[Ids.ID_NBSP] = 160; + values[Ids.ID_NDASH] = 8211; + values[Ids.ID_NE] = 8800; + values[Ids.ID_NI] = 8715; + values[Ids.ID_NOT] = 172; + values[Ids.ID_NOTIN] = 8713; + values[Ids.ID_NSUB] = 8836; + values[Ids.ID_NTILDE_L] = 241; + values[Ids.ID_NTILDE_U] = 209; + values[Ids.ID_NU_L] = 957; + values[Ids.ID_NU_U] = 925; + values[Ids.ID_OACUTE_L] = 243; + values[Ids.ID_OACUTE_U] = 211; + values[Ids.ID_OCIRC_L] = 244; + values[Ids.ID_OCIRC_U] = 212; + values[Ids.ID_OELIG_L] = 339; + values[Ids.ID_OELIG_U] = 338; + values[Ids.ID_OGRAVE_L] = 242; + values[Ids.ID_OGRAVE_U] = 210; + values[Ids.ID_OLINE] = 8254; + values[Ids.ID_OMEGA_L] = 969; + values[Ids.ID_OMEGA_U] = 937; + values[Ids.ID_OMICRON_L] = 959; + values[Ids.ID_OMICRON_U] = 927; + values[Ids.ID_OPLUS] = 8853; + values[Ids.ID_OR] = 8744; + values[Ids.ID_ORDF] = 170; + values[Ids.ID_ORDM] = 186; + values[Ids.ID_OSLASH_L] = 248; + values[Ids.ID_OSLASH_U] = 216; + values[Ids.ID_OTILDE_L] = 245; + values[Ids.ID_OTILDE_U] = 213; + values[Ids.ID_OTIMES] = 8855; + values[Ids.ID_OUML_L] = 246; + values[Ids.ID_OUML_U] = 214; + values[Ids.ID_PARA] = 182; + values[Ids.ID_PART] = 8706; + values[Ids.ID_PERMIL] = 8240; + values[Ids.ID_PERP] = 8869; + values[Ids.ID_PHI_L] = 966; + values[Ids.ID_PHI_U] = 934; + values[Ids.ID_PIV] = 982; + values[Ids.ID_PI_L] = 960; + values[Ids.ID_PI_U] = 928; + values[Ids.ID_PLUSMN] = 177; + values[Ids.ID_POUND] = 163; + values[Ids.ID_PRIME_L] = 8242; + values[Ids.ID_PRIME_U] = 8243; + values[Ids.ID_PROD] = 8719; + values[Ids.ID_PROP] = 8733; + values[Ids.ID_PSI_L] = 968; + values[Ids.ID_PSI_U] = 936; + values[Ids.ID_QUOT] = 34; + values[Ids.ID_RADIC] = 8730; + values[Ids.ID_RANG] = 9002; + values[Ids.ID_RAQUO] = 187; + values[Ids.ID_RARR_L] = 8594; + values[Ids.ID_RARR_U] = 8658; + values[Ids.ID_RCEIL] = 8969; + values[Ids.ID_RDQUO] = 8221; + values[Ids.ID_REAL] = 8476; + values[Ids.ID_REG] = 174; + values[Ids.ID_RFLOOR] = 8971; + values[Ids.ID_RHO_L] = 961; + values[Ids.ID_RHO_U] = 929; + values[Ids.ID_RLM] = 8207; + values[Ids.ID_RSAQUO] = 8250; + values[Ids.ID_RSQUO] = 8217; + values[Ids.ID_SBQUO] = 8218; + values[Ids.ID_SCARON_L] = 353; + values[Ids.ID_SCARON_U] = 352; + values[Ids.ID_SDOT] = 8901; + values[Ids.ID_SECT] = 167; + values[Ids.ID_SHY] = 173; + values[Ids.ID_SIGMAF] = 962; + values[Ids.ID_SIGMA_L] = 963; + values[Ids.ID_SIGMA_U] = 931; + values[Ids.ID_SIM] = 8764; + values[Ids.ID_SPADES] = 9824; + values[Ids.ID_SUB] = 8834; + values[Ids.ID_SUBE] = 8838; + values[Ids.ID_SUM] = 8721; + values[Ids.ID_SUP] = 8835; + values[Ids.ID_SUP1] = 185; + values[Ids.ID_SUP2] = 178; + values[Ids.ID_SUP3] = 179; + values[Ids.ID_SUPE] = 8839; + values[Ids.ID_SZLIG] = 223; + values[Ids.ID_TAU_L] = 964; + values[Ids.ID_TAU_U] = 932; + values[Ids.ID_THERE4] = 8756; + values[Ids.ID_THETASYM] = 977; + values[Ids.ID_THETA_L] = 952; + values[Ids.ID_THETA_U] = 920; + values[Ids.ID_THINSP] = 8201; + values[Ids.ID_THORN_L] = 254; + values[Ids.ID_THORN_U] = 222; + values[Ids.ID_TILDE] = 732; + values[Ids.ID_TIMES] = 215; + values[Ids.ID_TRADE] = 8482; + values[Ids.ID_UACUTE_L] = 250; + values[Ids.ID_UACUTE_U] = 218; + values[Ids.ID_UARR_L] = 8593; + values[Ids.ID_UARR_U] = 8657; + values[Ids.ID_UCIRC_L] = 251; + values[Ids.ID_UCIRC_U] = 219; + values[Ids.ID_UGRAVE_L] = 249; + values[Ids.ID_UGRAVE_U] = 217; + values[Ids.ID_UML] = 168; + values[Ids.ID_UPSIH] = 978; + values[Ids.ID_UPSILON_L] = 965; + values[Ids.ID_UPSILON_U] = 933; + values[Ids.ID_UUML_L] = 252; + values[Ids.ID_UUML_U] = 220; + values[Ids.ID_WEIERP] = 8472; + values[Ids.ID_XI_L] = 958; + values[Ids.ID_XI_U] = 926; + values[Ids.ID_YACUTE_L] = 253; + values[Ids.ID_YACUTE_U] = 221; + values[Ids.ID_YEN] = 165; + values[Ids.ID_YUML_L] = 255; + values[Ids.ID_YUML_U] = 376; + values[Ids.ID_ZETA_L] = 950; + values[Ids.ID_ZETA_U] = 918; + values[Ids.ID_ZWJ] = 8205; + values[Ids.ID_ZWNJ] = 8204; + } + + /** + */ + public EntityCollection() { + super(names, STRICT_CASE); + } + + /** + * Create an entity declaration. + * @return org.eclipse.wst.common.contentmodel.CMNode + * @param attrName java.lang.String + */ + protected CMNode create(String entityName) { + int id = getID(entityName); + if (id == ID_UNKNOWN) + return null; + + String value = String.valueOf(values[id]); + HTMLEntityDeclImpl dec = new HTMLEntityDeclImpl(entityName, value); + + return dec; + } +}
\ No newline at end of file diff --git a/bundles/org.eclipse.wst.html.core/src/org/eclipse/wst/html/core/contentmodel/HCMDocImpl.java b/bundles/org.eclipse.wst.html.core/src/org/eclipse/wst/html/core/contentmodel/HCMDocImpl.java new file mode 100644 index 0000000000..7357b90fec --- /dev/null +++ b/bundles/org.eclipse.wst.html.core/src/org/eclipse/wst/html/core/contentmodel/HCMDocImpl.java @@ -0,0 +1,93 @@ +/******************************************************************************* + * Copyright (c) 2004 IBM Corporation and others. + * All rights reserved. This program and the accompanying materials + * are made available under the terms of the Eclipse Public License v1.0 + * which accompanies this distribution, and is available at + * http://www.eclipse.org/legal/epl-v10.html + * + * Contributors: + * IBM Corporation - initial API and implementation + *******************************************************************************/ +package org.eclipse.wst.html.core.contentmodel; + + + +import org.eclipse.wst.common.contentmodel.CMDocument; +import org.eclipse.wst.common.contentmodel.CMNamedNodeMap; +import org.eclipse.wst.common.contentmodel.CMNamespace; +import org.eclipse.wst.common.contentmodel.CMNode; + +/** + * CMDocument implementation for the HTML. + */ +class HCMDocImpl extends CMNodeImpl implements HTMLCMDocument { + + /** Namespace for all names of elements, entities and attributes. */ + private CMNamespaceImpl namespace = null; + private ElementCollection elements = null; + private EntityCollection entities = null; + private AttributeCollection attributes = null; + + /** + */ + public HCMDocImpl(String docTypeName, CMNamespaceImpl targetNamespace) { + super(docTypeName); + namespace = targetNamespace; + attributes = new AttributeCollection(); + elements = new ElementCollection(attributes); + entities = new EntityCollection(); + } + + /** + * @return com.ibm.sed.contentmodel.html.AttributeCollection + */ + AttributeCollection getAttributes() { + return attributes; + } + + /** + * @see com.ibm.sed.contentmodel.html.HTMLCMDocument + */ + public HTMLElementDeclaration getElementDeclaration(String elementName) { + if (elements == null) + return null; + return (HTMLElementDeclaration) elements.getNamedItem(elementName); + } + + /** + * @see CMDocument + */ + public CMNamedNodeMap getElements() { + return elements; + } + + /** + * @see CMDocument + */ + public CMNamedNodeMap getEntities() { + return entities; + } + + /** + * @see com.ibm.sed.contentmodel.html.HTMLCMDocument + */ + public HTMLEntityDeclaration getEntityDeclaration(String entityName) { + if (entities == null) + return null; + return (HTMLEntityDeclaration) entities.getNamedItem(entityName); + } + + /** + * @see CMDocument + */ + public CMNamespace getNamespace() { + return namespace; + } + + /** + * @see CMNode + */ + public int getNodeType() { + return CMNode.DOCUMENT; + } +}
\ No newline at end of file diff --git a/bundles/org.eclipse.wst.html.core/src/org/eclipse/wst/html/core/contentmodel/HTMLAttrDeclImpl.java b/bundles/org.eclipse.wst.html.core/src/org/eclipse/wst/html/core/contentmodel/HTMLAttrDeclImpl.java new file mode 100644 index 0000000000..f9311ac852 --- /dev/null +++ b/bundles/org.eclipse.wst.html.core/src/org/eclipse/wst/html/core/contentmodel/HTMLAttrDeclImpl.java @@ -0,0 +1,122 @@ +/******************************************************************************* + * Copyright (c) 2004 IBM Corporation and others. + * All rights reserved. This program and the accompanying materials + * are made available under the terms of the Eclipse Public License v1.0 + * which accompanies this distribution, and is available at + * http://www.eclipse.org/legal/epl-v10.html + * + * Contributors: + * IBM Corporation - initial API and implementation + *******************************************************************************/ +package org.eclipse.wst.html.core.contentmodel; + + + +import java.util.Arrays; +import java.util.Enumeration; +import java.util.Vector; + +import org.eclipse.wst.common.contentmodel.CMDataType; +import org.eclipse.wst.common.contentmodel.CMNode; +import org.eclipse.wst.html.core.HTMLCMProperties; + +/** + * Implementation class of {@link <code>HTMLAttributeDeclaration</code>} interface.<br> + */ +class HTMLAttrDeclImpl extends CMNodeImpl implements HTMLAttributeDeclaration { + + private HTMLCMDataTypeImpl type = null; + private int usage = 0; + + /** + */ + public HTMLAttrDeclImpl(String attrName, HTMLCMDataTypeImpl valueType, int valueUsage) { + super(attrName); + this.type = valueType; + + switch (valueUsage) { + case OPTIONAL : + case REQUIRED : + case FIXED : + case PROHIBITED : + this.usage = valueUsage; + break; + default : + // should warn... + this.usage = OPTIONAL; // fall back + break; + } + } + + /** + * getAttrName method + * @return java.lang.String + */ + public String getAttrName() { + return getNodeName(); + } + + /** + * getAttrType method + * @return CMDataType + */ + public CMDataType getAttrType() { + return type; + } + + /** + * @deprecated by superinterface + */ + public String getDefaultValue() { + if (type.getImpliedValueKind() != CMDataType.IMPLIED_VALUE_DEFAULT) + return null; + return type.getImpliedValue(); + } + + /** + * @deprecated by superinterface + */ + public Enumeration getEnumAttr() { + Vector v = new Vector(Arrays.asList(type.getEnumeratedValues())); + return v.elements(); + } + + /** + * getNodeType method + * @return int + * + * Returns one of : + * ELEMENT_DECLARATION, ATTRIBUTE_DECLARATION, GROUP, ENTITY_DECLARATION. + */ + public int getNodeType() { + return CMNode.ATTRIBUTE_DECLARATION; + } + + /** + * @return int + */ + public int getUsage() { + return usage; + } + + /** + */ + public boolean supports(String propertyName) { + if (propertyName.equals(HTMLCMProperties.SHOULD_IGNORE_CASE)) + return true; + else if (propertyName.equals(HTMLCMProperties.IS_SCRIPTABLE)) + return true; + return super.supports(propertyName); + } + + /** + */ + public Object getProperty(String propertyName) { + if (propertyName.equals(HTMLCMProperties.SHOULD_IGNORE_CASE)) + return new Boolean(true); + else if (propertyName.equals(HTMLCMProperties.IS_SCRIPTABLE)) { + return getAttrType().getDataTypeName() == HTMLCMDataType.SCRIPT ? new Boolean(true) : new Boolean(false); + } + return super.getProperty(propertyName); + } +}
\ No newline at end of file diff --git a/bundles/org.eclipse.wst.html.core/src/org/eclipse/wst/html/core/contentmodel/HTMLAttributeDeclaration.java b/bundles/org.eclipse.wst.html.core/src/org/eclipse/wst/html/core/contentmodel/HTMLAttributeDeclaration.java new file mode 100644 index 0000000000..5ea976a264 --- /dev/null +++ b/bundles/org.eclipse.wst.html.core/src/org/eclipse/wst/html/core/contentmodel/HTMLAttributeDeclaration.java @@ -0,0 +1,24 @@ +/******************************************************************************* + * Copyright (c) 2004 IBM Corporation and others. + * All rights reserved. This program and the accompanying materials + * are made available under the terms of the Eclipse Public License v1.0 + * which accompanies this distribution, and is available at + * http://www.eclipse.org/legal/epl-v10.html + * + * Contributors: + * IBM Corporation - initial API and implementation + *******************************************************************************/ +package org.eclipse.wst.html.core.contentmodel; + +import org.eclipse.wst.common.contentmodel.CMAttributeDeclaration; + + + +/** + * This interface is intended to be a public interface which has + * interfaces defined in both of {@link <code>CMAttributeDeclaration</code>} + * and {@link <code>HTMLCMNode</code>}.<br> + */ +public interface HTMLAttributeDeclaration extends CMAttributeDeclaration { + +}
\ No newline at end of file diff --git a/bundles/org.eclipse.wst.html.core/src/org/eclipse/wst/html/core/contentmodel/HTMLCMDataType.java b/bundles/org.eclipse.wst.html.core/src/org/eclipse/wst/html/core/contentmodel/HTMLCMDataType.java new file mode 100644 index 0000000000..fe0e16eee8 --- /dev/null +++ b/bundles/org.eclipse.wst.html.core/src/org/eclipse/wst/html/core/contentmodel/HTMLCMDataType.java @@ -0,0 +1,66 @@ +/******************************************************************************* + * Copyright (c) 2004 IBM Corporation and others. + * All rights reserved. This program and the accompanying materials + * are made available under the terms of the Eclipse Public License v1.0 + * which accompanies this distribution, and is available at + * http://www.eclipse.org/legal/epl-v10.html + * + * Contributors: + * IBM Corporation - initial API and implementation + *******************************************************************************/ +package org.eclipse.wst.html.core.contentmodel; + + + +import org.eclipse.wst.common.contentmodel.CMDataType; + +/** + * HTML extension for data types. + */ +public interface HTMLCMDataType extends CMDataType { + + /** Boolean; it should be defined in CMDataType. */ + public static final String BOOLEAN = "BOOLEAN"; //$NON-NLS-1$ + public static final String COLOR = "COLOR"; //$NON-NLS-1$ + public static final String EVENT = "EVENT"; //$NON-NLS-1$ + public static final String IDREFS = "IDREFS"; //$NON-NLS-1$ + /** Name; it should be defined in CMDataType. */ + public static final String NAME = "NAME"; //$NON-NLS-1$ + // Following types are just aliases. + /** %Character; == CDATA */ + public static final String CHARACTER = CMDataType.CDATA; + /** %Charset; == CDATA */ + public static final String CHARSET = CMDataType.CDATA; + /** %Charsets; == CDATA */ + public static final String CHARSETS = CMDataType.CDATA; + /** %ContentType; == CDATA */ + public static final String CONTENT_TYPE = CMDataType.CDATA; + /** %Coords; == CDATA */ + public static final String COORDS = CMDataType.CDATA; + /** %Datetime; == CDATA */ + public static final String DATETIME = CMDataType.CDATA; + /** %FrameTarget; == CDATA */ + public static final String FRAME_TARGET = CMDataType.CDATA; + /** %LanguageCode; == NAME */ + public static final String LANGUAGE_CODE = NAME; + /** %Length; == CDATA */ + public static final String LENGTH = CMDataType.CDATA; + /** %LinkTypes; == CDATA */ + public static final String LINK_TYPES = CMDataType.CDATA; + /** %LIStyle; == CDATA */ + public static final String LI_STYLE = CMDataType.CDATA; + /** %MediaDesc; == CDATA */ + public static final String MEDIA_DESC = CMDataType.CDATA; + /** %MultiLength; == CDATA */ + public static final String MULTI_LENGTH = CMDataType.CDATA; + /** %OLStyle; == CDATA */ + public static final String OL_STYLE = CMDataType.CDATA; + /** %Pixles; == CDATA */ + public static final String PIXELS = CMDataType.CDATA; + /** %Script; == EVENT */ + public static final String SCRIPT = EVENT; + /** %StyleSheet; == EVENT */ + public static final String STYLE_SHEET = CMDataType.CDATA; + /** %Text; == CDATA */ + public static final String TEXT = CMDataType.CDATA; +}
\ No newline at end of file diff --git a/bundles/org.eclipse.wst.html.core/src/org/eclipse/wst/html/core/contentmodel/HTMLCMDataTypeImpl.java b/bundles/org.eclipse.wst.html.core/src/org/eclipse/wst/html/core/contentmodel/HTMLCMDataTypeImpl.java new file mode 100644 index 0000000000..d0674787de --- /dev/null +++ b/bundles/org.eclipse.wst.html.core/src/org/eclipse/wst/html/core/contentmodel/HTMLCMDataTypeImpl.java @@ -0,0 +1,125 @@ +/******************************************************************************* + * Copyright (c) 2004 IBM Corporation and others. + * All rights reserved. This program and the accompanying materials + * are made available under the terms of the Eclipse Public License v1.0 + * which accompanies this distribution, and is available at + * http://www.eclipse.org/legal/epl-v10.html + * + * Contributors: + * IBM Corporation - initial API and implementation + *******************************************************************************/ +package org.eclipse.wst.html.core.contentmodel; + +import org.eclipse.wst.common.contentmodel.CMNode; + + + +/** + */ +class HTMLCMDataTypeImpl extends CMNodeImpl implements HTMLCMDataType { + + private int impliedValueKind = IMPLIED_VALUE_NONE; + private String impliedValue = null; + private final static String[] emptyArray = new String[0]; + private String[] enumValues = emptyArray; + private String instanceValue = null; + + /** + * HTMLCMDataTypeImpl constructor comment. + * @param nm java.lang.String + */ + public HTMLCMDataTypeImpl(String typeName) { + super(typeName); + } + + /** + * HTMLCMDataTypeImpl constructor comment. + * @param nm java.lang.String + */ + public HTMLCMDataTypeImpl(String typeName, String instanceValue) { + super(typeName); + this.instanceValue = instanceValue; + } + + /** + * getTypeName method + * @return java.lang.String + * + * This method returns a suitable default value that can be used when an instance of the data type is created. + * This returns null of a suitable default is not available. + */ + public String generateInstanceValue() { + return instanceValue; + } + + /** + * @see org.eclipse.wst.common.contentmodel.CMDataType + */ + public String getDataTypeName() { + return getNodeName(); + } + + /** + * getTypeName method + * @return java.lang.String[] + * + */ + public String[] getEnumeratedValues() { + return enumValues; + } + + /** + * getTypeName method + * @return java.lang.String + * + * Returns the implied value or null if none exists. + */ + public String getImpliedValue() { + return impliedValue; + } + + /** + * getImpliedValueKind method + * @return int + * + * Returns one of : + * IMPLIED_VALUE_NONE, IMPLIED_VALUE_FIXED, IMPLIED_VALUE_DEFAULT. + */ + public int getImpliedValueKind() { + return impliedValueKind; + } + + /** + * @see org.eclipse.wst.common.contentmodel.CMNode + */ + public int getNodeType() { + return CMNode.DATA_TYPE; + } + + /** + */ + void setEnumValues(String[] values) { + enumValues = new String[values.length]; + for (int i = 0; i < values.length; i++) { + enumValues[i] = values[i]; + } + } + + /** + * package scope. + */ + void setImpliedValue(int kind, String value) { + switch (kind) { + case IMPLIED_VALUE_FIXED : + case IMPLIED_VALUE_DEFAULT : + impliedValueKind = kind; + impliedValue = value; + break; + case IMPLIED_VALUE_NONE : + default : + impliedValueKind = IMPLIED_VALUE_NONE; + impliedValue = null; // maybe a null string? + break; + } + } +}
\ No newline at end of file diff --git a/bundles/org.eclipse.wst.html.core/src/org/eclipse/wst/html/core/contentmodel/HTMLCMDocument.java b/bundles/org.eclipse.wst.html.core/src/org/eclipse/wst/html/core/contentmodel/HTMLCMDocument.java new file mode 100644 index 0000000000..46177cc52b --- /dev/null +++ b/bundles/org.eclipse.wst.html.core/src/org/eclipse/wst/html/core/contentmodel/HTMLCMDocument.java @@ -0,0 +1,37 @@ +/******************************************************************************* + * Copyright (c) 2004 IBM Corporation and others. + * All rights reserved. This program and the accompanying materials + * are made available under the terms of the Eclipse Public License v1.0 + * which accompanies this distribution, and is available at + * http://www.eclipse.org/legal/epl-v10.html + * + * Contributors: + * IBM Corporation - initial API and implementation + *******************************************************************************/ +package org.eclipse.wst.html.core.contentmodel; + +import org.eclipse.wst.common.contentmodel.CMDocument; + + + +/** + * HTML extension for CMDocument. + * This interface provides some short hand methods to get declarations + * by a name. + */ +public interface HTMLCMDocument extends CMDocument { + + /** + * A short hand method to get a element declaration for a HTML element.<br> + * @return com.ibm.sed.contentmodel.html.HTMLElementDeclaration + * @param elementName java.lang.String + */ + HTMLElementDeclaration getElementDeclaration(String elementName); + + /** + * A short hand method to get a entity declaration of HTML documents.<br> + * @return com.ibm.sed.contentmodel.html.HTMLEntityDeclaration + * @param entityName java.lang.String + */ + HTMLEntityDeclaration getEntityDeclaration(String entityName); +}
\ No newline at end of file diff --git a/bundles/org.eclipse.wst.html.core/src/org/eclipse/wst/html/core/contentmodel/HTMLCMDocumentFactory.java b/bundles/org.eclipse.wst.html.core/src/org/eclipse/wst/html/core/contentmodel/HTMLCMDocumentFactory.java new file mode 100644 index 0000000000..4e7ea65f39 --- /dev/null +++ b/bundles/org.eclipse.wst.html.core/src/org/eclipse/wst/html/core/contentmodel/HTMLCMDocumentFactory.java @@ -0,0 +1,60 @@ +/******************************************************************************* + * Copyright (c) 2004 IBM Corporation and others. + * All rights reserved. This program and the accompanying materials + * are made available under the terms of the Eclipse Public License v1.0 + * which accompanies this distribution, and is available at + * http://www.eclipse.org/legal/epl-v10.html + * + * Contributors: + * IBM Corporation - initial API and implementation + *******************************************************************************/ +package org.eclipse.wst.html.core.contentmodel; + + + +import java.util.Hashtable; + +import org.eclipse.wst.common.contentmodel.CMDocument; +import org.eclipse.wst.html.core.HTML40Namespace; +import org.eclipse.wst.html.core.contentmodel.chtml.CHCMDocImpl; +import org.eclipse.wst.sse.core.contentmodel.CMDocType; + +/** + * INodeAdapter factory for HTML and JSP documents. + */ +public final class HTMLCMDocumentFactory { + + private static Hashtable cmdocs = new Hashtable(); + + static { + CMNamespaceImpl h40ns = new CMNamespaceImpl(HTML40Namespace.HTML40_URI, HTML40Namespace.HTML40_TAG_PREFIX); + CMNamespaceImpl j11ns = new CMNamespaceImpl(JSP11Namespace.JSP11_URI, JSP11Namespace.JSP_TAG_PREFIX); + + HCMDocImpl html40doc = new HCMDocImpl(CMDocType.HTML_DOC_TYPE, h40ns); + CHCMDocImpl chtmldoc = new CHCMDocImpl(CMDocType.CHTML_DOC_TYPE, h40ns); + JCMDocImpl jsp11doc = new JCMDocImpl(CMDocType.JSP11_DOC_TYPE, j11ns); + + cmdocs.put(CMDocType.HTML_DOC_TYPE, html40doc); + cmdocs.put(CMDocType.CHTML_DOC_TYPE, chtmldoc); + cmdocs.put(CMDocType.JSP11_DOC_TYPE, jsp11doc); + } + + /** + * HTMLCMAdapterFactory constructor. + */ + private HTMLCMDocumentFactory() { + super(); + } + + /** + * @return org.eclipse.wst.common.contentmodel.CMDocument + * @param cmtype java.lang.String + */ + public static CMDocument getCMDocument(String cmtype) { + Object obj = cmdocs.get(cmtype); + if (obj == null) + return null; + + return (CMDocument) obj; + } +}
\ No newline at end of file diff --git a/bundles/org.eclipse.wst.html.core/src/org/eclipse/wst/html/core/contentmodel/HTMLCMNode.java b/bundles/org.eclipse.wst.html.core/src/org/eclipse/wst/html/core/contentmodel/HTMLCMNode.java new file mode 100644 index 0000000000..f7a783d145 --- /dev/null +++ b/bundles/org.eclipse.wst.html.core/src/org/eclipse/wst/html/core/contentmodel/HTMLCMNode.java @@ -0,0 +1,32 @@ +/******************************************************************************* + * Copyright (c) 2004 IBM Corporation and others. + * All rights reserved. This program and the accompanying materials + * are made available under the terms of the Eclipse Public License v1.0 + * which accompanies this distribution, and is available at + * http://www.eclipse.org/legal/epl-v10.html + * + * Contributors: + * IBM Corporation - initial API and implementation + *******************************************************************************/ +package org.eclipse.wst.html.core.contentmodel; + + +/** + * In HTML Documents, name and value of an attribute/element/entity + * should be treated ignoring theirs case. However, in XML documents, + * they should be distinguished with sensitiveness of their case. + * CMNode is basically designed to represent DTDs or Schemas for XML + * documents. So, it doesn't have interfaces to retrieve such information. + * However, declarations in the HTML CM should provide such information. + * This intermediate interface is intended to provide whether ignore cases + * or not.<br> + */ +interface HTMLCMNode extends org.eclipse.wst.common.contentmodel.CMNode { + + /** + * Returns <code>true</code>, if declaration is for HTML attribute/element/entity. + * Otherwise, returns <code>false</code>. + * @return boolean + */ + boolean shouldIgnoreCase(); +}
\ No newline at end of file diff --git a/bundles/org.eclipse.wst.html.core/src/org/eclipse/wst/html/core/contentmodel/HTMLElemDeclImpl.java b/bundles/org.eclipse.wst.html.core/src/org/eclipse/wst/html/core/contentmodel/HTMLElemDeclImpl.java new file mode 100644 index 0000000000..6814cbe164 --- /dev/null +++ b/bundles/org.eclipse.wst.html.core/src/org/eclipse/wst/html/core/contentmodel/HTMLElemDeclImpl.java @@ -0,0 +1,377 @@ +/******************************************************************************* + * Copyright (c) 2004 IBM Corporation and others. + * All rights reserved. This program and the accompanying materials + * are made available under the terms of the Eclipse Public License v1.0 + * which accompanies this distribution, and is available at + * http://www.eclipse.org/legal/epl-v10.html + * + * Contributors: + * IBM Corporation - initial API and implementation + *******************************************************************************/ +package org.eclipse.wst.html.core.contentmodel; + + + +import java.util.Iterator; + +import org.eclipse.wst.common.contentmodel.CMContent; +import org.eclipse.wst.common.contentmodel.CMDataType; +import org.eclipse.wst.common.contentmodel.CMElementDeclaration; +import org.eclipse.wst.common.contentmodel.CMNamedNodeMap; +import org.eclipse.wst.common.contentmodel.CMNode; +import org.eclipse.wst.html.core.HTMLCMProperties; + +/** + * Base class for all Hed???? classes. + */ +abstract class HTMLElemDeclImpl extends CMContentImpl implements HTMLElementDeclaration, HTMLPropertyDeclaration { + + // DTD + protected CMNamedNodeMapImpl attributes = null; + protected String typeDefinitionName = ComplexTypeDefinitionFactory.CTYPE_EMPTY; + /** Never access this field directly. Instead, use getComplexTypeDefinition method. */ + private ComplexTypeDefinition typeDefinition = null; + protected CMGroupImpl inclusion = null; + protected CMGroupImpl exclusion = null; + // advanced information + protected CMNamedNodeMap prohibitedAncestors = null; + protected int correctionType = CORRECT_NONE; + protected int formatType = FORMAT_HTML; + protected int layoutType = LAYOUT_NONE; + protected int omitType = OMIT_NONE; + protected boolean keepSpaces = false; + protected boolean indentChild = false; + protected ElementCollection elementCollection = null; + protected AttributeCollection attributeCollection = null; + protected final static CMNamedNodeMap EMPTY_MAP = new CMNamedNodeMap() { + public int getLength() { + return 0; + } + + public CMNode getNamedItem(String name) { + return null; + } + + public CMNode item(int index) { + return null; + } + + public Iterator iterator() { + return new Iterator() { + public boolean hasNext() { + return false; + } + + public Object next() { + return null; + } + + public void remove() { + } + }; + } + }; + + /** + * HTMLElemDeclImpl constructor. + * In the HTML DTD, an element declaration has no specification + * for its occurrence. Occurrence is specifed in content model, like + * <code>(LI)+</code>. To avoid confusion (and complexity), + * occurrence of an element declaration is always 1 (it means, min = 1 and + * max = 1). Instead, occurrence of CMGroup represents actual occurrence + * of the content. + * <br> + * @param name java.lang.String + */ + public HTMLElemDeclImpl(String elementName, ElementCollection collection) { + super(elementName, 1, 1); + elementCollection = collection; + attributeCollection = collection.getAttributeCollection(); + } + + /** + */ + protected abstract void createAttributeDeclarations(); + + /** + * + * @return com.ibm.sed.contentmodel.html.ComplexTypeDefinition + */ + private ComplexTypeDefinition createComplexTypeDefinition() { + if (typeDefinitionName.equals(ComplexTypeDefinitionFactory.CTYPE_CDATA) || typeDefinitionName.equals(ComplexTypeDefinitionFactory.CTYPE_EMPTY) || typeDefinitionName.equals(ComplexTypeDefinitionFactory.CTYPE_PCDATA)) + return null; + + ComplexTypeDefinitionFactory factory = ComplexTypeDefinitionFactory.getInstance(); + if (factory == null) + return null; // fatal error. + + ComplexTypeDefinition def = factory.createTypeDefinition(typeDefinitionName, elementCollection); + return def; + } + + /** + * Get an attribute declaration. + * <br> + * @see com.ibm.sed.contentmodel.html.HTMLElementDeclaration + */ + public HTMLAttributeDeclaration getAttributeDeclaration(String attrName) { + if (attributes == null) { + createAttributeDeclarations(); + if (attributes == null) + return null; // fail to create + } + + CMNode cmnode = attributes.getNamedItem(attrName); + if (cmnode == null) { + return null; + } + else { + return (HTMLAttributeDeclaration) cmnode; // already exists. + } + } + + /** + * @see org.eclipse.wst.common.contentmodel.CMElementDeclaration + */ + public CMNamedNodeMap getAttributes() { + if (attributes == null) + createAttributeDeclarations(); // lazy eval. + return attributes; + } + + /** + * Get an instance of complex type definition. + * @return com.ibm.sed.contentmodel.html.ComplexTypeDefinition + */ + private ComplexTypeDefinition getComplexTypeDefinition() { + if (typeDefinition == null) + typeDefinition = createComplexTypeDefinition(); + return typeDefinition; + } + + /** + * Content.<br> + * Element declarations which type is EMPTY or CDATA (maybe PCDATA) + * <strong>MUST</strong> override this method and always return null. + * This default implementation always tries to create a complex type definition + * instance and access to it. + * <br> + * @see org.eclipse.wst.common.contentmodel.CMElementDeclaration + */ + public CMContent getContent() { + ComplexTypeDefinition def = getComplexTypeDefinition(); // lazy eval. + return (def != null) ? def.getContent() : null; + } + + /** + * Content type.<br> + * Element declarations which type is EMPTY or CDATA (maybe PCDATA) + * <strong>MUST</strong> override this method and return an appropriate type. + * This default implementation always tries to create a complex type definition + * instance and access to it. + * <br> + * @see org.eclipse.wst.common.contentmodel.CMElementDeclaration + */ + public int getContentType() { + ComplexTypeDefinition def = getComplexTypeDefinition(); // lazy eval. + return (def != null) ? def.getContentType() : CMElementDeclaration.CDATA; + } + + /** + * @see HTMLElementDeclaration#getCorrectionType + */ + public int getCorrectionType() { + return correctionType; + } + + /** + * HTML element doesn't have any data type. So, this method always + * returns <code>null</code>.<br> + * @see org.eclipse.wst.common.contentmodel.CMElementDeclaration + */ + public CMDataType getDataType() { + return null; + } + + /** + * @see org.eclipse.wst.common.contentmodel.CMElementDeclaration + */ + public String getElementName() { + return getNodeName(); + } + + /** + * Exclusion. + * Almost elements don't have a exclusion. + * Only classes those have exclusion should override this method. + * <br> + * @see com.ibm.sed.contentmodel.html.HTMLElementDeclaration + */ + public CMContent getExclusion() { + return null; + } + + /** + * Default format type is <code>FORMAT_HTML</code>.<br> + */ + public int getFormatType() { + return formatType; + } + + /** + * Inclusion. + * Almost elements don't have a inclusion. + * Only classes those have inclusion should override this method. + * <br> + * @see com.ibm.sed.contentmodel.html.HTMLElementDeclaration + */ + public CMContent getInclusion() { + return null; + } + + /** + */ + public int getLayoutType() { + return layoutType; + } + + /** + * Line break hint is strongly related to layout type. + * Indeed, in the C++DOM, it is determined from layout type only. + * So, this implementation, as the default implementation for all declarations, + * also determines from layout type only.<br> + * @return int + */ + public int getLineBreakHint() { + switch (getLayoutType()) { + case HTMLElementDeclaration.LAYOUT_BLOCK : + return HTMLElementDeclaration.BREAK_BEFORE_START_AND_AFTER_END; + case HTMLElementDeclaration.LAYOUT_BREAK : + return HTMLElementDeclaration.BREAK_AFTER_START; + case HTMLElementDeclaration.LAYOUT_HIDDEN : + return HTMLElementDeclaration.BREAK_BEFORE_START_AND_AFTER_END; + default : + return HTMLElementDeclaration.BREAK_NONE; + } + } + + /** + * No HTML element has local elements. So, this method always + * returns an empty map. + * @see org.eclipse.wst.common.contentmodel.CMElementDeclaration + */ + public CMNamedNodeMap getLocalElements() { + return EMPTY_MAP; + } + + /** + * @see org.eclipse.wst.common.contentmodel.CMNode + */ + public int getNodeType() { + return CMNode.ELEMENT_DECLARATION; + } + + /** + */ + public int getOmitType() { + return omitType; + } + + /** + */ + public CMNamedNodeMap getProhibitedAncestors() { + return EMPTY_MAP; + } + + /** + */ + public boolean supports(String propertyName) { + if (propertyName.equals(HTMLCMProperties.SHOULD_IGNORE_CASE)) { + return true; + } + else if (propertyName.equals(HTMLCMProperties.CONTENT_HINT)) { + ComplexTypeDefinition def = getComplexTypeDefinition(); + return (def != null); + } + else { + PropertyProvider pp = PropertyProviderFactory.getProvider(propertyName); + if (pp == null) + return false; + return pp.supports(this); + } + + } + + /** + */ + public Object getProperty(String propertyName) { + if (propertyName.equals(HTMLCMProperties.SHOULD_IGNORE_CASE)) { + return new Boolean(true); + } + else if (propertyName.equals(HTMLCMProperties.CONTENT_HINT)) { + ComplexTypeDefinition def = getComplexTypeDefinition(); + return (def != null) ? def.getPrimaryCandidate() : null; + } + else { + PropertyProvider pp = PropertyProviderFactory.getProvider(propertyName); + if (pp == null) + return null; + return pp.get(this); + } + } + + /** + * Return element names which terminates this element.<br> + * @return java.util.Iterator + */ + protected Iterator getTerminators() { + return null; + } + + /** + * return true when the element is a JSP element. + */ + public boolean isJSP() { + return false; + } + + /** + * In some elements, such as APPLET, a source generator should indent child + * elements that their parents. That is, a source generator should generate + * source of APPLET and PARAMS like this: + * <PRE> + * <APPLET ...> + * <PARAM ... > + * <PARAM ... > + * </APPLET> + * <PRE> + * @return boolean + */ + public boolean shouldIndentChildSource() { + return indentChild; + } + + /** + * Most of elements can compact spaces in their child text nodes. + * Some special elements should keep them in their source. + * @return boolean + */ + public boolean shouldKeepSpaces() { + return keepSpaces; + } + + /** + * @return boolean + */ + public boolean shouldTerminateAt(HTMLElementDeclaration nextElement) { + Iterator i = getTerminators(); + if (i == null) + return false; + String nextName = nextElement.getElementName(); + while (i.hasNext()) { + if (nextName.equals(i.next())) + return true; + } + return false; + } +}
\ No newline at end of file diff --git a/bundles/org.eclipse.wst.html.core/src/org/eclipse/wst/html/core/contentmodel/HTMLElementDeclaration.java b/bundles/org.eclipse.wst.html.core/src/org/eclipse/wst/html/core/contentmodel/HTMLElementDeclaration.java new file mode 100644 index 0000000000..99e673578b --- /dev/null +++ b/bundles/org.eclipse.wst.html.core/src/org/eclipse/wst/html/core/contentmodel/HTMLElementDeclaration.java @@ -0,0 +1,81 @@ +/******************************************************************************* + * Copyright (c) 2004 IBM Corporation and others. + * All rights reserved. This program and the accompanying materials + * are made available under the terms of the Eclipse Public License v1.0 + * which accompanies this distribution, and is available at + * http://www.eclipse.org/legal/epl-v10.html + * + * Contributors: + * IBM Corporation - initial API and implementation + *******************************************************************************/ +package org.eclipse.wst.html.core.contentmodel; + + + +import org.eclipse.wst.common.contentmodel.CMElementDeclaration; + +/** + * This interface is intended to be a public interface which has + * interfaces defined in both of {@link <code>CMElementDeclaration</code>} + * and {@link <code>HTMLCMNode</code>}.<br> + * In addition to this, some interfaces are added to this interface, + * those are specially to HTML elements.<br> + */ +public interface HTMLElementDeclaration extends CMElementDeclaration { + + /** Tag ommission; Not ommisible. */ + int OMIT_NONE = 0; + /** Tag ommission; Both tags are ommisible. */ + int OMIT_BOTH = 1; + /** Tag ommission; The end tag is ommisible. */ + int OMIT_END = 2; + /** Tag ommission; The end tag is ommitted when created. */ + int OMIT_END_DEFAULT = 3; + /** Tag ommission; The end tag must be omitted. */ + int OMIT_END_MUST = 4; + /** Line Break; No break. */ + int BREAK_NONE = 10; + /** Line Break; Break after the start tag. */ + int BREAK_AFTER_START = 11; + /** Line Break; Break both before the start tagn and after the end tag. */ + int BREAK_BEFORE_START_AND_AFTER_END = 12; + /* Layout */ + /** initial value; the value should never returns to client programs. */ + int LAYOUT_NONE = 100; + int LAYOUT_BLOCK = 101; + int LAYOUT_WRAP = 102; + /** No wrap object; like IMG, APPLET,... */ + int LAYOUT_OBJECT = 103; + /** BR */ + int LAYOUT_BREAK = 104; + /** Hidden object; like HTML or HEAD */ + int LAYOUT_HIDDEN = 105; + /* Correction */ + /** Correct; No correct. */ + int CORRECT_NONE = 1000; + /** Correct; Meaningless when the content is empty. */ + int CORRECT_EMPTY = 1001; + /** Correct; Meaningless when no attribut is set. */ + int CORRECT_NEUTRAL = 1002; + /** Correct; Meaningless when same element is nested. */ + int CORRECT_DUPLICATED = 1003; + /** Format; HTML */ + int FORMAT_HTML = 10000; + /** Format; SSI */ + int FORMAT_SSI = 10001; + /** Format; JSP script */ + int FORMAT_JSP_SCRIPT = 10002; + /** Format; JSP directive */ + int FORMAT_JSP_DIRECTIVE = 10003; + /** Format; XML */ + int FORMAT_XML = 10004; + /** Format; MW */ + int FORMAT_MW = 10005; + + /** + * A short hand method to get an attribute declaration of a HTML element. + * @return com.ibm.sed.contentmodel.html.HTMLAttributeDeclaration + * @param attrName java.lang.String + */ + HTMLAttributeDeclaration getAttributeDeclaration(String attrName); +}
\ No newline at end of file diff --git a/bundles/org.eclipse.wst.html.core/src/org/eclipse/wst/html/core/contentmodel/HTMLEntityDeclImpl.java b/bundles/org.eclipse.wst.html.core/src/org/eclipse/wst/html/core/contentmodel/HTMLEntityDeclImpl.java new file mode 100644 index 0000000000..3ec7fdb7dc --- /dev/null +++ b/bundles/org.eclipse.wst.html.core/src/org/eclipse/wst/html/core/contentmodel/HTMLEntityDeclImpl.java @@ -0,0 +1,76 @@ +/******************************************************************************* + * Copyright (c) 2004 IBM Corporation and others. + * All rights reserved. This program and the accompanying materials + * are made available under the terms of the Eclipse Public License v1.0 + * which accompanies this distribution, and is available at + * http://www.eclipse.org/legal/epl-v10.html + * + * Contributors: + * IBM Corporation - initial API and implementation + *******************************************************************************/ +package org.eclipse.wst.html.core.contentmodel; + +import org.eclipse.wst.common.contentmodel.CMNode; +import org.eclipse.wst.html.core.HTMLCMProperties; + + + +/** + */ +class HTMLEntityDeclImpl extends CMNodeImpl implements HTMLEntityDeclaration { + + private java.lang.String value = null; + + /** + * CMEntityDeclImpl constructor comment. + * @param entityName java.lang.String; Entity name. + * @param entityValue java.lang.String; Value string. + */ + public HTMLEntityDeclImpl(String entityName, String entityValue) { + super(entityName); + value = entityValue; + } + + /** + * getName method + * @return java.lang.String + */ + public String getName() { + return getNodeName(); + } + + /** + * Get CMNode type.<br> + * @return int; Always return ENTITY_DECLARATION. + */ + public int getNodeType() { + return CMNode.ENTITY_DECLARATION; + } + + /** + * getValue method + * @return java.lang.String + */ + public String getValue() { + return value; + } + + /** + */ + public boolean supports(String propertyName) { + if (propertyName.equals(HTMLCMProperties.SHOULD_IGNORE_CASE)) + return true; + return super.supports(propertyName); + } + + /** + * Entities in HTML documents are always treated with ignoring cases. + * Because no special entities are defined in JSP 1.0, this method + * can always return <code>true</code>.<br> + */ + public Object getProperty(String propertyName) { + if (propertyName.equals(HTMLCMProperties.SHOULD_IGNORE_CASE)) + return new Boolean(true); + return super.getProperty(propertyName); + } +}
\ No newline at end of file diff --git a/bundles/org.eclipse.wst.html.core/src/org/eclipse/wst/html/core/contentmodel/HTMLEntityDeclaration.java b/bundles/org.eclipse.wst.html.core/src/org/eclipse/wst/html/core/contentmodel/HTMLEntityDeclaration.java new file mode 100644 index 0000000000..b1b10148f6 --- /dev/null +++ b/bundles/org.eclipse.wst.html.core/src/org/eclipse/wst/html/core/contentmodel/HTMLEntityDeclaration.java @@ -0,0 +1,22 @@ +/******************************************************************************* + * Copyright (c) 2004 IBM Corporation and others. + * All rights reserved. This program and the accompanying materials + * are made available under the terms of the Eclipse Public License v1.0 + * which accompanies this distribution, and is available at + * http://www.eclipse.org/legal/epl-v10.html + * + * Contributors: + * IBM Corporation - initial API and implementation + *******************************************************************************/ +package org.eclipse.wst.html.core.contentmodel; + + + +/** + * This interface is intended to be a public interface which has + * interfaces defined in both of {@link <code>CMEntityDeclaration</code>} + * and {@link <code>HTMLCMNode</code>}.<br> + */ +public interface HTMLEntityDeclaration extends org.eclipse.wst.common.contentmodel.CMEntityDeclaration { + +}
\ No newline at end of file diff --git a/bundles/org.eclipse.wst.html.core/src/org/eclipse/wst/html/core/contentmodel/HTMLPropertyDeclaration.java b/bundles/org.eclipse.wst.html.core/src/org/eclipse/wst/html/core/contentmodel/HTMLPropertyDeclaration.java new file mode 100644 index 0000000000..9ff07f645f --- /dev/null +++ b/bundles/org.eclipse.wst.html.core/src/org/eclipse/wst/html/core/contentmodel/HTMLPropertyDeclaration.java @@ -0,0 +1,105 @@ +/******************************************************************************* + * Copyright (c) 2004 IBM Corporation and others. + * All rights reserved. This program and the accompanying materials + * are made available under the terms of the Eclipse Public License v1.0 + * which accompanies this distribution, and is available at + * http://www.eclipse.org/legal/epl-v10.html + * + * Contributors: + * IBM Corporation - initial API and implementation + *******************************************************************************/ +package org.eclipse.wst.html.core.contentmodel; + +import org.eclipse.wst.common.contentmodel.CMContent; +import org.eclipse.wst.common.contentmodel.CMNamedNodeMap; + +/** + * This interface is commonly used in declaration implementation, and internal use. + * Use getProperty() method for public use. + */ +public interface HTMLPropertyDeclaration { + /** + * To determin the type, look up the following keywords in C++DOM/DTDParser.cpp: + * <ul> + * <li>CORRECT_DUPLICATED - <code>GROUP_NODUP</code></li> + * <li>CORRECT_EMPTY - <code>GROUP_COMPACT</code></li> + * <li>CORRECT_NEUTRAL - <code>GROUP_NEUTRAL</code></li> + * <li>CORRECT_NONE - <code>(N/A)</code></li> + * </ul> + * @return int + */ + int getCorrectionType(); + /** + * Get the list of declarations those should be excluded from the content.<br> + * @return org.eclipse.wst.common.contentmodel.CMContent + */ + CMContent getExclusion(); + /** + * To determin the type, see the following files in the C++DOM: + * ElementType.cpp - ElementType#setGroup(). + * Element.cpp - Element#getStartTag(). + * @return int + */ + int getFormatType(); + /** + * Get the list of declarations those should be included into the content.<br> + * @return org.eclipse.wst.common.contentmodel.CMContent + */ + CMContent getInclusion(); + /** + * To determin the type, look up the following keywords in C++DOM/DTDParser.cpp: + * <ul> + * <li>LAYOUT_BLOCK - <code>GROUP_BLOCK</code></li> + * <li>LAYOUT_BREAK - <code>GROUP_BREAK</code></li> + * <li>LAYOUT_HIDDEN - <code>GROUP_HIDDEN</code></li> + * <li>LAYOUT_NONE - <code>(N/A)</code></li> + * <li>LAYOUT_OBJECT - <code>GROUP_NOWRAP</code></li> + * <li>LAYOUT_WRAP - <code>(N/A)</code></li> + * </ul> + * @return int + */ + int getLayoutType(); + /** + * To determine the type, see <code>Element::isBreakingBeforeElement()</code> + * and <code>Element::isBreakingAfterElement()</code> defined in C++DOM/Element.cpp.<br> + * @return int + */ + int getLineBreakHint(); + /** + * To determine the type, Check the HTML DTD. + * And look up <code>GROUP_NOEND</code> in C++DOM/DTDParser.cpp.<br> + * @return int + */ + int getOmitType(); + /** + * @return org.eclipse.wst.common.contentmodel.CMNamedNodeMap + */ + CMNamedNodeMap getProhibitedAncestors(); + /** + * return true when the element is a JSP element. + */ + boolean isJSP(); + /** + * @return boolean + */ + boolean shouldIndentChildSource(); + /** + * Some elements should keep spaces in its child text nodes. + * For example, PRE and TEXTAREA. This method returns true, + * if a target element is one of such elements. + * @return boolean + */ + boolean shouldKeepSpaces(); + /** + * Returns <code>true</code>, if <code>nextElement</code> terminates + * the current element. + * Some elements like <code>P</code> terminates other <code>P</code>. + * That is, when <code><P></code> appears at the next to <code>P</code>, + * which end tags is omitted, it represents not only the beginning of the + * new <code>P</code> element but also the end of the previous <code>P</code>. + * <br> + * See the C++DOM/HTMLParser#_terminate(Element*) method. + * @param nextElement com.ibm.sed.contentmodel.html.HTMLElementDeclaration + */ + boolean shouldTerminateAt(HTMLElementDeclaration nextElement); +} diff --git a/bundles/org.eclipse.wst.html.core/src/org/eclipse/wst/html/core/contentmodel/HedA.java b/bundles/org.eclipse.wst.html.core/src/org/eclipse/wst/html/core/contentmodel/HedA.java new file mode 100644 index 0000000000..84cb78bffe --- /dev/null +++ b/bundles/org.eclipse.wst.html.core/src/org/eclipse/wst/html/core/contentmodel/HedA.java @@ -0,0 +1,100 @@ +/******************************************************************************* + * Copyright (c) 2004 IBM Corporation and others. + * All rights reserved. This program and the accompanying materials + * are made available under the terms of the Eclipse Public License v1.0 + * which accompanies this distribution, and is available at + * http://www.eclipse.org/legal/epl-v10.html + * + * Contributors: + * IBM Corporation - initial API and implementation + *******************************************************************************/ +package org.eclipse.wst.html.core.contentmodel; + + + +import java.util.Arrays; + +import org.eclipse.wst.common.contentmodel.CMContent; +import org.eclipse.wst.common.contentmodel.CMGroup; +import org.eclipse.wst.common.contentmodel.CMNamedNodeMap; +import org.eclipse.wst.common.contentmodel.CMNode; +import org.eclipse.wst.html.core.HTML40Namespace; + +/** + * A. + */ +final class HedA extends HedInlineContainer { + + /** + */ + public HedA(ElementCollection collection) { + super(HTML40Namespace.ElementName.A, collection); + // CORRECT_EMPTY - GROUP_COMPACT + correctionType = CORRECT_EMPTY; + } + + /** + * %attrs; + * (charset %Charset; #IMPLIED) + * (type %ContentType; #IMPLIED) + * (name CDATA #IMPLIED) + * (href %URI; #IMPLIED) + * (hreflang %LanguageCode; #IMPLIED) + * (target %FrameTarget; #IMPLIED) + * (rel %LinkTypes; #IMPLIED) + * (rev %LinkTypes; #IMPLIED) + * (accesskey %Character; #IMPLIED) + * (directkey %Character; #IMPLIED) + * (shape %Shape; rect) + * (coords %Coords; #IMPLIED) + * (tabindex NUMBER #IMPLIED) + * (onfocus %Script; #IMPLIED) + * (onblur %Script; #IMPLIED) + */ + protected void createAttributeDeclarations() { + if (attributes != null) + return; // already created. + if (attributeCollection == null) + return; // fatal + + attributes = new CMNamedNodeMapImpl(); + + // %attrs; + attributeCollection.getAttrs(attributes); + + String[] names = {HTML40Namespace.ATTR_NAME_CHARSET, HTML40Namespace.ATTR_NAME_TYPE, HTML40Namespace.ATTR_NAME_NAME, HTML40Namespace.ATTR_NAME_HREF, HTML40Namespace.ATTR_NAME_HREFLANG, HTML40Namespace.ATTR_NAME_TARGET, HTML40Namespace.ATTR_NAME_REL, HTML40Namespace.ATTR_NAME_REV, HTML40Namespace.ATTR_NAME_ACCESSKEY, HTML40Namespace.ATTR_NAME_DIRECTKEY, HTML40Namespace.ATTR_NAME_SHAPE, HTML40Namespace.ATTR_NAME_COORDS, HTML40Namespace.ATTR_NAME_TABINDEX, HTML40Namespace.ATTR_NAME_ONFOCUS, HTML40Namespace.ATTR_NAME_ONBLUR}; + attributeCollection.getDeclarations(attributes, Arrays.asList(names).iterator()); + } + + /** + * Exclusion. + * <code>A</code> has the exclusion. + * It is <code>A</code> itself. + * @see com.ibm.sed.contentmodel.html.HTMLElementDeclaration + */ + public CMContent getExclusion() { + if (exclusion != null) + return exclusion; // already created. + if (elementCollection == null) + return null; + + exclusion = new CMGroupImpl(CMGroup.CHOICE, 1, 1); + CMNode a = elementCollection.getNamedItem(HTML40Namespace.ElementName.A); + if (a != null) + exclusion.appendChild(a); + + return exclusion; + } + + /** + */ + public CMNamedNodeMap getProhibitedAncestors() { + if (prohibitedAncestors != null) + return prohibitedAncestors; + + String[] names = {HTML40Namespace.ElementName.A, HTML40Namespace.ElementName.BUTTON}; + prohibitedAncestors = elementCollection.getDeclarations(names); + + return prohibitedAncestors; + } +}
\ No newline at end of file diff --git a/bundles/org.eclipse.wst.html.core/src/org/eclipse/wst/html/core/contentmodel/HedADDRESS.java b/bundles/org.eclipse.wst.html.core/src/org/eclipse/wst/html/core/contentmodel/HedADDRESS.java new file mode 100644 index 0000000000..3fb721c0e7 --- /dev/null +++ b/bundles/org.eclipse.wst.html.core/src/org/eclipse/wst/html/core/contentmodel/HedADDRESS.java @@ -0,0 +1,58 @@ +/******************************************************************************* + * Copyright (c) 2004 IBM Corporation and others. + * All rights reserved. This program and the accompanying materials + * are made available under the terms of the Eclipse Public License v1.0 + * which accompanies this distribution, and is available at + * http://www.eclipse.org/legal/epl-v10.html + * + * Contributors: + * IBM Corporation - initial API and implementation + *******************************************************************************/ +package org.eclipse.wst.html.core.contentmodel; + + + +import org.eclipse.wst.common.contentmodel.CMNamedNodeMap; +import org.eclipse.wst.html.core.HTML40Namespace; + +/** + * ADDRESS. + */ +final class HedADDRESS extends HTMLElemDeclImpl { + + /** + */ + public HedADDRESS(ElementCollection collection) { + super(HTML40Namespace.ElementName.ADDRESS, collection); + typeDefinitionName = ComplexTypeDefinitionFactory.CTYPE_ADDRESS; + correctionType = CORRECT_EMPTY; + layoutType = LAYOUT_BLOCK; + } + + /** + * %attrs; + */ + protected void createAttributeDeclarations() { + if (attributes != null) + return; // already created. + if (attributeCollection == null) + return; // fatal + + attributes = new CMNamedNodeMapImpl(); + + // %attrs; + attributeCollection.getAttrs(attributes); + } + + /** + */ + public CMNamedNodeMap getProhibitedAncestors() { + if (prohibitedAncestors != null) + return prohibitedAncestors; + + String[] names = {HTML40Namespace.ElementName.DIR, HTML40Namespace.ElementName.MENU}; + prohibitedAncestors = elementCollection.getDeclarations(names); + + return prohibitedAncestors; + } +}
\ No newline at end of file diff --git a/bundles/org.eclipse.wst.html.core/src/org/eclipse/wst/html/core/contentmodel/HedAPPLET.java b/bundles/org.eclipse.wst.html.core/src/org/eclipse/wst/html/core/contentmodel/HedAPPLET.java new file mode 100644 index 0000000000..48c420ef1f --- /dev/null +++ b/bundles/org.eclipse.wst.html.core/src/org/eclipse/wst/html/core/contentmodel/HedAPPLET.java @@ -0,0 +1,68 @@ +/******************************************************************************* + * Copyright (c) 2004 IBM Corporation and others. + * All rights reserved. This program and the accompanying materials + * are made available under the terms of the Eclipse Public License v1.0 + * which accompanies this distribution, and is available at + * http://www.eclipse.org/legal/epl-v10.html + * + * Contributors: + * IBM Corporation - initial API and implementation + *******************************************************************************/ +package org.eclipse.wst.html.core.contentmodel; + + + +import java.util.Arrays; + +import org.eclipse.wst.html.core.HTML40Namespace; + + +/** + * APPLET. + */ +final class HedAPPLET extends HTMLElemDeclImpl { + + /** + */ + public HedAPPLET(ElementCollection collection) { + super(HTML40Namespace.ElementName.APPLET, collection); + typeDefinitionName = ComplexTypeDefinitionFactory.CTYPE_PARAM_CONTAINER; + layoutType = LAYOUT_OBJECT; + indentChild = true; + } + + /** + * %coreattrs; + * (codebase %URI; #IMPLIED) + * (archive CDATA #IMPLIED) + * (code CDATA #IMPLIED) + * (object CDATA #IMPLIED) + * (alt %Text; #IMPLIED) ... should be defined locally. + * (name CDATA #IMPLIED) + * (width %Length; #REQUIRED) + * (height %Length; #REQUIRED) + * (align %IAlign; #IMPLIED) + * (hspace %Pixels; #IMPLIED) + * (vspace %Pixels; #IMPLIED) + * (mayscript (mayscript) #IMPLIED) + */ + protected void createAttributeDeclarations() { + if (attributes != null) + return; // already created. + if (attributeCollection == null) + return; // fatal + + attributes = new CMNamedNodeMapImpl(); + + // %coreattrs; + attributeCollection.getCore(attributes); + + String[] names = {HTML40Namespace.ATTR_NAME_CODEBASE, HTML40Namespace.ATTR_NAME_ARCHIVE, HTML40Namespace.ATTR_NAME_CODE, HTML40Namespace.ATTR_NAME_OBJECT, HTML40Namespace.ATTR_NAME_ALT, HTML40Namespace.ATTR_NAME_NAME, HTML40Namespace.ATTR_NAME_WIDTH, HTML40Namespace.ATTR_NAME_HEIGHT, HTML40Namespace.ATTR_NAME_HSPACE, HTML40Namespace.ATTR_NAME_VSPACE, HTML40Namespace.ATTR_NAME_MAYSCRIPT}; + attributeCollection.getDeclarations(attributes, Arrays.asList(names).iterator()); + + // %align; ... should be defined locally. + HTMLAttrDeclImpl attr = AttributeCollection.createAlignForImage(); + if (attr != null) + attributes.putNamedItem(HTML40Namespace.ATTR_NAME_ALIGN, attr); + } +}
\ No newline at end of file diff --git a/bundles/org.eclipse.wst.html.core/src/org/eclipse/wst/html/core/contentmodel/HedAREA.java b/bundles/org.eclipse.wst.html.core/src/org/eclipse/wst/html/core/contentmodel/HedAREA.java new file mode 100644 index 0000000000..7014b587ad --- /dev/null +++ b/bundles/org.eclipse.wst.html.core/src/org/eclipse/wst/html/core/contentmodel/HedAREA.java @@ -0,0 +1,61 @@ +/******************************************************************************* + * Copyright (c) 2004 IBM Corporation and others. + * All rights reserved. This program and the accompanying materials + * are made available under the terms of the Eclipse Public License v1.0 + * which accompanies this distribution, and is available at + * http://www.eclipse.org/legal/epl-v10.html + * + * Contributors: + * IBM Corporation - initial API and implementation + *******************************************************************************/ +package org.eclipse.wst.html.core.contentmodel; + + + +import java.util.Arrays; + +import org.eclipse.wst.html.core.HTML40Namespace; + + +/** + * AREA. + */ +final class HedAREA extends HedEmpty { + + /** + */ + public HedAREA(ElementCollection collection) { + super(HTML40Namespace.ElementName.AREA, collection); + // LAYOUT_HIDDEN. + // Because, AREA is GROUP_HIDDEN in the C++DOM/DTDParser.cpp. + layoutType = LAYOUT_HIDDEN; + } + + /** + * AREA. + * %attrs; + * (shape %Shape; rect) + * (coords %Coords; #IMPLIED) + * (href %URI; #IMPLIED) + * (target %FrameTarget; #IMPLIED) + * (nohref (nohref) #IMPLIED) + * (alt %Text; #REQUIRED) + * (tabindex NUMBER #IMPLIED) + * (accesskey %Character; #IMPLIED) + * (onfocus %Script; #IMPLIED) + * (onblur %Script; #IMPLIED) + */ + protected void createAttributeDeclarations() { + if (attributes != null) + return; // already created. + if (attributeCollection == null) + return; // fatal + attributes = new CMNamedNodeMapImpl(); + + // %attrs; + attributeCollection.getAttrs(attributes); + + String[] names = {HTML40Namespace.ATTR_NAME_SHAPE, HTML40Namespace.ATTR_NAME_COORDS, HTML40Namespace.ATTR_NAME_HREF, HTML40Namespace.ATTR_NAME_TARGET, HTML40Namespace.ATTR_NAME_NOHREF, HTML40Namespace.ATTR_NAME_ALT, HTML40Namespace.ATTR_NAME_TABINDEX, HTML40Namespace.ATTR_NAME_ACCESSKEY, HTML40Namespace.ATTR_NAME_ONFOCUS, HTML40Namespace.ATTR_NAME_ONBLUR}; + attributeCollection.getDeclarations(attributes, Arrays.asList(names).iterator()); + } +}
\ No newline at end of file diff --git a/bundles/org.eclipse.wst.html.core/src/org/eclipse/wst/html/core/contentmodel/HedBASE.java b/bundles/org.eclipse.wst.html.core/src/org/eclipse/wst/html/core/contentmodel/HedBASE.java new file mode 100644 index 0000000000..4b388cc7d8 --- /dev/null +++ b/bundles/org.eclipse.wst.html.core/src/org/eclipse/wst/html/core/contentmodel/HedBASE.java @@ -0,0 +1,50 @@ +/******************************************************************************* + * Copyright (c) 2004 IBM Corporation and others. + * All rights reserved. This program and the accompanying materials + * are made available under the terms of the Eclipse Public License v1.0 + * which accompanies this distribution, and is available at + * http://www.eclipse.org/legal/epl-v10.html + * + * Contributors: + * IBM Corporation - initial API and implementation + *******************************************************************************/ +package org.eclipse.wst.html.core.contentmodel; + + + +import java.util.Arrays; + +import org.eclipse.wst.html.core.HTML40Namespace; + + +/** + * BASE. + */ +final class HedBASE extends HedEmpty { + + /** + */ + public HedBASE(ElementCollection collection) { + super(HTML40Namespace.ElementName.BASE, collection); + // LAYOUT_HIDDEN. + // Because, BASE is GROUP_HIDDEN in the C++DOM/DTDParser.cpp. + layoutType = LAYOUT_HIDDEN; + } + + /** + * BASE. + * (href %URI; #IMPLIED) + * (target %FrameTarget; #IMPLIED) + */ + protected void createAttributeDeclarations() { + if (attributes != null) + return; // already created. + if (attributeCollection == null) + return; // fatal + + attributes = new CMNamedNodeMapImpl(); + + String[] names = {HTML40Namespace.ATTR_NAME_HREF, HTML40Namespace.ATTR_NAME_TARGET}; + attributeCollection.getDeclarations(attributes, Arrays.asList(names).iterator()); + } +}
\ No newline at end of file diff --git a/bundles/org.eclipse.wst.html.core/src/org/eclipse/wst/html/core/contentmodel/HedBASEFONT.java b/bundles/org.eclipse.wst.html.core/src/org/eclipse/wst/html/core/contentmodel/HedBASEFONT.java new file mode 100644 index 0000000000..da1536fc63 --- /dev/null +++ b/bundles/org.eclipse.wst.html.core/src/org/eclipse/wst/html/core/contentmodel/HedBASEFONT.java @@ -0,0 +1,57 @@ +/******************************************************************************* + * Copyright (c) 2004 IBM Corporation and others. + * All rights reserved. This program and the accompanying materials + * are made available under the terms of the Eclipse Public License v1.0 + * which accompanies this distribution, and is available at + * http://www.eclipse.org/legal/epl-v10.html + * + * Contributors: + * IBM Corporation - initial API and implementation + *******************************************************************************/ +package org.eclipse.wst.html.core.contentmodel; + + + +import java.util.Arrays; + +import org.eclipse.wst.common.contentmodel.CMAttributeDeclaration; +import org.eclipse.wst.common.contentmodel.CMDataType; +import org.eclipse.wst.html.core.HTML40Namespace; + +/** + * BASEFONT. + */ +final class HedBASEFONT extends HedEmpty { + + /** + */ + public HedBASEFONT(ElementCollection collection) { + super(HTML40Namespace.ElementName.BASEFONT, collection); + // LAYOUT_OBJECT - GROUP_NOWRAP. + layoutType = LAYOUT_OBJECT; + } + + /** + * BASEFONT. + * (id ID #IMPLIED) + * (size CDATA #REQUIRED) ... should be localy defined. + * (color %Color; #IMPLIED) + * (face CDATA #IMPLIED) + */ + protected void createAttributeDeclarations() { + if (attributes != null) + return; // already created. + if (attributeCollection == null) + return; // fatal + + attributes = new CMNamedNodeMapImpl(); + + String[] names = {HTML40Namespace.ATTR_NAME_ID, HTML40Namespace.ATTR_NAME_COLOR, HTML40Namespace.ATTR_NAME_FACE}; + attributeCollection.getDeclarations(attributes, Arrays.asList(names).iterator()); + + // (size CDATA #REQUIRED) ... should be localy defined. + HTMLCMDataTypeImpl atype = new HTMLCMDataTypeImpl(CMDataType.CDATA); + HTMLAttrDeclImpl attr = new HTMLAttrDeclImpl(HTML40Namespace.ATTR_NAME_SIZE, atype, CMAttributeDeclaration.REQUIRED); + attributes.putNamedItem(HTML40Namespace.ATTR_NAME_SIZE, attr); + } +}
\ No newline at end of file diff --git a/bundles/org.eclipse.wst.html.core/src/org/eclipse/wst/html/core/contentmodel/HedBDO.java b/bundles/org.eclipse.wst.html.core/src/org/eclipse/wst/html/core/contentmodel/HedBDO.java new file mode 100644 index 0000000000..3cde33173e --- /dev/null +++ b/bundles/org.eclipse.wst.html.core/src/org/eclipse/wst/html/core/contentmodel/HedBDO.java @@ -0,0 +1,61 @@ +/******************************************************************************* + * Copyright (c) 2004 IBM Corporation and others. + * All rights reserved. This program and the accompanying materials + * are made available under the terms of the Eclipse Public License v1.0 + * which accompanies this distribution, and is available at + * http://www.eclipse.org/legal/epl-v10.html + * + * Contributors: + * IBM Corporation - initial API and implementation + *******************************************************************************/ +package org.eclipse.wst.html.core.contentmodel; + + + +import java.util.Arrays; + +import org.eclipse.wst.common.contentmodel.CMAttributeDeclaration; +import org.eclipse.wst.common.contentmodel.CMDataType; +import org.eclipse.wst.html.core.HTML40Namespace; + +/** + * BDO. + */ +final class HedBDO extends HedInlineContainer { + + /** + */ + public HedBDO(ElementCollection collection) { + super(HTML40Namespace.ElementName.BDO, collection); + // CORRECT_EMPTY - GROUP_COMPACT + correctionType = CORRECT_EMPTY; + } + + /** + * %coreattrs; + * (lang %LanguageCode; #IMPLIED) + * (dir (ltr|rtl) #REQUIRED) ... should be defined locally. + */ + protected void createAttributeDeclarations() { + if (attributes != null) + return; // already created. + if (attributeCollection == null) + return; // fatal + + attributes = new CMNamedNodeMapImpl(); + + // %coreattrs; + attributeCollection.getCore(attributes); + + String[] names = {HTML40Namespace.ATTR_NAME_LANG}; + attributeCollection.getDeclarations(attributes, Arrays.asList(names).iterator()); + + // (dir (ltr|rtl) #REQUIRED) ... should be defined locally. + HTMLCMDataTypeImpl atype = new HTMLCMDataTypeImpl(CMDataType.ENUM); + String[] values = {HTML40Namespace.ATTR_VALUE_LTR, HTML40Namespace.ATTR_VALUE_RTL}; + atype.setEnumValues(values); + + HTMLAttrDeclImpl attr = new HTMLAttrDeclImpl(HTML40Namespace.ATTR_NAME_DIR, atype, CMAttributeDeclaration.REQUIRED); + attributes.putNamedItem(HTML40Namespace.ATTR_NAME_DIR, attr); + } +}
\ No newline at end of file diff --git a/bundles/org.eclipse.wst.html.core/src/org/eclipse/wst/html/core/contentmodel/HedBGSOUND.java b/bundles/org.eclipse.wst.html.core/src/org/eclipse/wst/html/core/contentmodel/HedBGSOUND.java new file mode 100644 index 0000000000..baa939ff26 --- /dev/null +++ b/bundles/org.eclipse.wst.html.core/src/org/eclipse/wst/html/core/contentmodel/HedBGSOUND.java @@ -0,0 +1,47 @@ +/******************************************************************************* + * Copyright (c) 2004 IBM Corporation and others. + * All rights reserved. This program and the accompanying materials + * are made available under the terms of the Eclipse Public License v1.0 + * which accompanies this distribution, and is available at + * http://www.eclipse.org/legal/epl-v10.html + * + * Contributors: + * IBM Corporation - initial API and implementation + *******************************************************************************/ +package org.eclipse.wst.html.core.contentmodel; + +import org.eclipse.wst.common.contentmodel.CMAttributeDeclaration; +import org.eclipse.wst.common.contentmodel.CMDataType; +import org.eclipse.wst.html.core.HTML40Namespace; + + + +final class HedBGSOUND extends HedEmpty { + + public HedBGSOUND(ElementCollection collection) { + super(HTML40Namespace.ElementName.BGSOUND, collection); + layoutType = LAYOUT_OBJECT; + } + + /** + * (src, CDATA, #IMPLIED) + * (loop, CDATA, #IMPLIED) + */ + protected void createAttributeDeclarations() { + if (attributes != null) + return; + if (attributeCollection == null) + return; // fatal + attributes = new CMNamedNodeMapImpl(); + // src + HTMLAttributeDeclaration attr = attributeCollection.getDeclaration(HTML40Namespace.ATTR_NAME_SRC); + if (attr != null) + attributes.putNamedItem(HTML40Namespace.ATTR_NAME_SRC, attr); + // loop + HTMLCMDataTypeImpl atype = new HTMLCMDataTypeImpl(CMDataType.CDATA); + atype.setImpliedValue(CMDataType.IMPLIED_VALUE_DEFAULT, HTML40Namespace.ATTR_VALUE_INFINITE); + attr = new HTMLAttrDeclImpl(HTML40Namespace.ATTR_NAME_LOOP, atype, CMAttributeDeclaration.OPTIONAL); + if (attr != null) + attributes.putNamedItem(HTML40Namespace.ATTR_NAME_LOOP, attr); + } +}
\ No newline at end of file diff --git a/bundles/org.eclipse.wst.html.core/src/org/eclipse/wst/html/core/contentmodel/HedBLOCKQUOTE.java b/bundles/org.eclipse.wst.html.core/src/org/eclipse/wst/html/core/contentmodel/HedBLOCKQUOTE.java new file mode 100644 index 0000000000..dc0fed2697 --- /dev/null +++ b/bundles/org.eclipse.wst.html.core/src/org/eclipse/wst/html/core/contentmodel/HedBLOCKQUOTE.java @@ -0,0 +1,63 @@ +/******************************************************************************* + * Copyright (c) 2004 IBM Corporation and others. + * All rights reserved. This program and the accompanying materials + * are made available under the terms of the Eclipse Public License v1.0 + * which accompanies this distribution, and is available at + * http://www.eclipse.org/legal/epl-v10.html + * + * Contributors: + * IBM Corporation - initial API and implementation + *******************************************************************************/ +package org.eclipse.wst.html.core.contentmodel; + + + +import java.util.Arrays; + +import org.eclipse.wst.common.contentmodel.CMNamedNodeMap; +import org.eclipse.wst.html.core.HTML40Namespace; + +/** + * BLOCKQUOTE. + */ +final class HedBLOCKQUOTE extends HedFlowContainer { + + /** + */ + public HedBLOCKQUOTE(ElementCollection collection) { + super(HTML40Namespace.ElementName.BLOCKQUOTE, collection); + correctionType = CORRECT_EMPTY; + layoutType = LAYOUT_BLOCK; + } + + /** + * %attrs; + * (cite %URI; #IMPLIED) + */ + protected void createAttributeDeclarations() { + if (attributes != null) + return; // already created. + if (attributeCollection == null) + return; // fatal + + attributes = new CMNamedNodeMapImpl(); + + // %attrs; + attributeCollection.getAttrs(attributes); + + String[] names = {HTML40Namespace.ATTR_NAME_CITE}; + attributeCollection.getDeclarations(attributes, Arrays.asList(names).iterator()); + } + + /** + */ + public CMNamedNodeMap getProhibitedAncestors() { + if (prohibitedAncestors != null) + return prohibitedAncestors; + + String[] names = {HTML40Namespace.ElementName.DIR, HTML40Namespace.ElementName.MENU}; + prohibitedAncestors = elementCollection.getDeclarations(names); + + return prohibitedAncestors; + } +}
\ No newline at end of file diff --git a/bundles/org.eclipse.wst.html.core/src/org/eclipse/wst/html/core/contentmodel/HedBODY.java b/bundles/org.eclipse.wst.html.core/src/org/eclipse/wst/html/core/contentmodel/HedBODY.java new file mode 100644 index 0000000000..fdd5b98e20 --- /dev/null +++ b/bundles/org.eclipse.wst.html.core/src/org/eclipse/wst/html/core/contentmodel/HedBODY.java @@ -0,0 +1,96 @@ +/******************************************************************************* + * Copyright (c) 2004 IBM Corporation and others. + * All rights reserved. This program and the accompanying materials + * are made available under the terms of the Eclipse Public License v1.0 + * which accompanies this distribution, and is available at + * http://www.eclipse.org/legal/epl-v10.html + * + * Contributors: + * IBM Corporation - initial API and implementation + *******************************************************************************/ +package org.eclipse.wst.html.core.contentmodel; + + + +import java.util.Arrays; +import java.util.Iterator; + +import org.eclipse.wst.common.contentmodel.CMContent; +import org.eclipse.wst.common.contentmodel.CMGroup; +import org.eclipse.wst.html.core.HTML40Namespace; + +/** + * BODY. + */ +final class HedBODY extends HedFlowContainer { + + private static String[] terminators = {HTML40Namespace.ElementName.HEAD, HTML40Namespace.ElementName.BODY, HTML40Namespace.ElementName.FRAMESET, HTML40Namespace.ElementName.HTML}; + + /** + */ + public HedBODY(ElementCollection collection) { + super(HTML40Namespace.ElementName.BODY, collection); + layoutType = LAYOUT_BLOCK; + omitType = OMIT_BOTH; + } + + /** + * %attrs; + * %bodycolors; + * (onload %Script; #IMPLIED) + * (onunload %Script; #IMPLIED) + * (background %URI; #IMPLIED) + * (marginwidth %Pixels; #IMPLIED) ... D205514 + * (marginheight %Pixels; #IMPLIED) .. D205514 + * (topmargin, CDATA, #IMPLIED) ...... D205514 + * (bottommargin, CDATA, #IMPLIED) ... D205514 + * (leftmargin, CDATA, #IMPLIED) ..... D205514 + * (rightmargin, CDATA, #IMPLIED) .... D205514 + */ + protected void createAttributeDeclarations() { + if (attributes != null) + return; // already created. + if (attributeCollection == null) + return; // fatal + + attributes = new CMNamedNodeMapImpl(); + + // %attrs; + attributeCollection.getAttrs(attributes); + // %bodycolors; + attributeCollection.getBodycolors(attributes); + + String[] names = {HTML40Namespace.ATTR_NAME_ONLOAD, HTML40Namespace.ATTR_NAME_ONUNLOAD, HTML40Namespace.ATTR_NAME_BACKGROUND, + // <<D205514 + HTML40Namespace.ATTR_NAME_MARGINWIDTH, HTML40Namespace.ATTR_NAME_MARGINHEIGHT, HTML40Namespace.ATTR_NAME_TOPMARGIN, HTML40Namespace.ATTR_NAME_BOTTOMMARGIN, HTML40Namespace.ATTR_NAME_LEFTMARGIN, HTML40Namespace.ATTR_NAME_RIGHTMARGIN + // D205514 + }; + attributeCollection.getDeclarations(attributes, Arrays.asList(names).iterator()); + } + + /** + * Inclusion. + * "Lazy eval."<br> + * @return org.eclipse.wst.common.contentmodel.CMContent + */ + public CMContent getInclusion() { + if (inclusion != null) + return inclusion; // already created. + if (elementCollection == null) + return null; + + // (INS|DEL) + inclusion = new CMGroupImpl(CMGroup.CHOICE, 1, 1); + String[] names = {HTML40Namespace.ElementName.INS, HTML40Namespace.ElementName.DEL}; + elementCollection.getDeclarations(inclusion, Arrays.asList(names).iterator()); + return inclusion; + } + + /** + * BODY has terminators. + * @return java.util.Iterator + */ + protected Iterator getTerminators() { + return Arrays.asList(terminators).iterator(); + } +}
\ No newline at end of file diff --git a/bundles/org.eclipse.wst.html.core/src/org/eclipse/wst/html/core/contentmodel/HedBR.java b/bundles/org.eclipse.wst.html.core/src/org/eclipse/wst/html/core/contentmodel/HedBR.java new file mode 100644 index 0000000000..d6adcb067a --- /dev/null +++ b/bundles/org.eclipse.wst.html.core/src/org/eclipse/wst/html/core/contentmodel/HedBR.java @@ -0,0 +1,51 @@ +/******************************************************************************* + * Copyright (c) 2004 IBM Corporation and others. + * All rights reserved. This program and the accompanying materials + * are made available under the terms of the Eclipse Public License v1.0 + * which accompanies this distribution, and is available at + * http://www.eclipse.org/legal/epl-v10.html + * + * Contributors: + * IBM Corporation - initial API and implementation + *******************************************************************************/ +package org.eclipse.wst.html.core.contentmodel; + +import org.eclipse.wst.html.core.HTML40Namespace; + + + +/** + * BR. + */ +final class HedBR extends HedEmpty { + + /** + */ + public HedBR(ElementCollection collection) { + super(HTML40Namespace.ElementName.BR, collection); + // LAYOUT_BREAK. + // Because, BR is GROUP_BREAK in the C++DOM/DTDParser.cpp. + layoutType = LAYOUT_BREAK; + } + + /** + * BR. + * %coreattrs; + * (clear (left | all | right | none) none) + */ + protected void createAttributeDeclarations() { + if (attributes != null) + return; // already created. + if (attributeCollection == null) + return; // fatal + + attributes = new CMNamedNodeMapImpl(); + + // %coreattrs; + attributeCollection.getCore(attributes); + // clear + HTMLAttributeDeclaration attr = attributeCollection.getDeclaration(HTML40Namespace.ATTR_NAME_CLEAR); + if (attr != null) + attributes.putNamedItem(HTML40Namespace.ATTR_NAME_CLEAR, attr); + } +}
\ No newline at end of file diff --git a/bundles/org.eclipse.wst.html.core/src/org/eclipse/wst/html/core/contentmodel/HedBUTTON.java b/bundles/org.eclipse.wst.html.core/src/org/eclipse/wst/html/core/contentmodel/HedBUTTON.java new file mode 100644 index 0000000000..7360060415 --- /dev/null +++ b/bundles/org.eclipse.wst.html.core/src/org/eclipse/wst/html/core/contentmodel/HedBUTTON.java @@ -0,0 +1,102 @@ +/******************************************************************************* + * Copyright (c) 2004 IBM Corporation and others. + * All rights reserved. This program and the accompanying materials + * are made available under the terms of the Eclipse Public License v1.0 + * which accompanies this distribution, and is available at + * http://www.eclipse.org/legal/epl-v10.html + * + * Contributors: + * IBM Corporation - initial API and implementation + *******************************************************************************/ +package org.eclipse.wst.html.core.contentmodel; + + + +import java.util.Arrays; + +import org.eclipse.wst.common.contentmodel.CMAttributeDeclaration; +import org.eclipse.wst.common.contentmodel.CMContent; +import org.eclipse.wst.common.contentmodel.CMDataType; +import org.eclipse.wst.common.contentmodel.CMGroup; +import org.eclipse.wst.common.contentmodel.CMNamedNodeMap; +import org.eclipse.wst.html.core.HTML40Namespace; + +/** + * BUTTON. + */ +final class HedBUTTON extends HedFlowContainer { + + /** + */ + public HedBUTTON(ElementCollection collection) { + super(HTML40Namespace.ElementName.BUTTON, collection); + layoutType = LAYOUT_BLOCK; + } + + /** + * %attrs; + * %reserved; ... empty. + * (name CDATA #IMPLIED) + * (value CDATA #IMPLIED) + * (type (button|submit|reset) submit) ... should be defined locally. + * (disabled (disabled) #IMPLIED) + * (tabindex NUMBER #IMPLIED) + * (accesskey %Character; #IMPLIED) + * (onfocus %Script; #IMPLIED) + * (onblur %Script; #IMPLIED) + */ + protected void createAttributeDeclarations() { + if (attributes != null) + return; // already created. + if (attributeCollection == null) + return; // fatal + + attributes = new CMNamedNodeMapImpl(); + + // %attrs; + attributeCollection.getAttrs(attributes); + + String[] names = {HTML40Namespace.ATTR_NAME_NAME, HTML40Namespace.ATTR_NAME_VALUE, HTML40Namespace.ATTR_NAME_DISABLED, HTML40Namespace.ATTR_NAME_TABINDEX, HTML40Namespace.ATTR_NAME_ACCESSKEY, HTML40Namespace.ATTR_NAME_ONFOCUS, HTML40Namespace.ATTR_NAME_ONBLUR}; + attributeCollection.getDeclarations(attributes, Arrays.asList(names).iterator()); + + // (type (button|submit|reset) submit) ... should be defined locally. + HTMLCMDataTypeImpl atype = new HTMLCMDataTypeImpl(CMDataType.ENUM); + String[] values = {HTML40Namespace.ATTR_VALUE_BUTTON, HTML40Namespace.ATTR_VALUE_SUBMIT, HTML40Namespace.ATTR_VALUE_RESET}; + atype.setEnumValues(values); + + HTMLAttrDeclImpl attr = new HTMLAttrDeclImpl(HTML40Namespace.ATTR_NAME_TYPE, atype, CMAttributeDeclaration.OPTIONAL); + attributes.putNamedItem(HTML40Namespace.ATTR_NAME_TYPE, attr); + } + + /** + * Exclusion. + * <code>FORM</code> has the exclusion. + * It is <code>FORM</code> itself. + * @see com.ibm.sed.contentmodel.html.HTMLElementDeclaration + */ + public CMContent getExclusion() { + if (exclusion != null) + return exclusion; // already created. + if (elementCollection == null) + return null; // fatal + + exclusion = new CMGroupImpl(CMGroup.CHOICE, 1, 1); + String[] names = {HTML40Namespace.ElementName.A, HTML40Namespace.ElementName.FORM, HTML40Namespace.ElementName.ISINDEX, HTML40Namespace.ElementName.FIELDSET, HTML40Namespace.ElementName.IFRAME}; + elementCollection.getDeclarations(exclusion, Arrays.asList(names).iterator()); + elementCollection.getFormctrl(exclusion); + + return exclusion; + } + + /** + */ + public CMNamedNodeMap getProhibitedAncestors() { + if (prohibitedAncestors != null) + return prohibitedAncestors; + + String[] names = {HTML40Namespace.ElementName.BUTTON}; + prohibitedAncestors = elementCollection.getDeclarations(names); + + return prohibitedAncestors; + } +}
\ No newline at end of file diff --git a/bundles/org.eclipse.wst.html.core/src/org/eclipse/wst/html/core/contentmodel/HedCAPTION.java b/bundles/org.eclipse.wst.html.core/src/org/eclipse/wst/html/core/contentmodel/HedCAPTION.java new file mode 100644 index 0000000000..dbab319f4c --- /dev/null +++ b/bundles/org.eclipse.wst.html.core/src/org/eclipse/wst/html/core/contentmodel/HedCAPTION.java @@ -0,0 +1,48 @@ +/******************************************************************************* + * Copyright (c) 2004 IBM Corporation and others. + * All rights reserved. This program and the accompanying materials + * are made available under the terms of the Eclipse Public License v1.0 + * which accompanies this distribution, and is available at + * http://www.eclipse.org/legal/epl-v10.html + * + * Contributors: + * IBM Corporation - initial API and implementation + *******************************************************************************/ +package org.eclipse.wst.html.core.contentmodel; + +import org.eclipse.wst.html.core.HTML40Namespace; + + + +/** + * CAPTION. + */ +final class HedCAPTION extends HedInlineContainer { + + /** + */ + public HedCAPTION(ElementCollection collection) { + super(HTML40Namespace.ElementName.CAPTION, collection); + layoutType = LAYOUT_BLOCK; + } + + /** + * %attrs; + * (align %CAlign; #IMPLIED) ... should be defined locally. + */ + protected void createAttributeDeclarations() { + if (attributes != null) + return; // already created. + if (attributeCollection == null) + return; // fatal + + attributes = new CMNamedNodeMapImpl(); + + // %attrs; + attributeCollection.getAttrs(attributes); + + HTMLAttrDeclImpl attr = AttributeCollection.createAlignForCaption(); + if (attr != null) + attributes.putNamedItem(HTML40Namespace.ATTR_NAME_ALIGN, attr); + } +}
\ No newline at end of file diff --git a/bundles/org.eclipse.wst.html.core/src/org/eclipse/wst/html/core/contentmodel/HedCENTER.java b/bundles/org.eclipse.wst.html.core/src/org/eclipse/wst/html/core/contentmodel/HedCENTER.java new file mode 100644 index 0000000000..55e0fbf021 --- /dev/null +++ b/bundles/org.eclipse.wst.html.core/src/org/eclipse/wst/html/core/contentmodel/HedCENTER.java @@ -0,0 +1,56 @@ +/******************************************************************************* + * Copyright (c) 2004 IBM Corporation and others. + * All rights reserved. This program and the accompanying materials + * are made available under the terms of the Eclipse Public License v1.0 + * which accompanies this distribution, and is available at + * http://www.eclipse.org/legal/epl-v10.html + * + * Contributors: + * IBM Corporation - initial API and implementation + *******************************************************************************/ +package org.eclipse.wst.html.core.contentmodel; + + + +import org.eclipse.wst.common.contentmodel.CMNamedNodeMap; +import org.eclipse.wst.html.core.HTML40Namespace; + +/** + * CENTER. + */ +final class HedCENTER extends HedFlowContainer { + + /** + */ + public HedCENTER(ElementCollection collection) { + super(HTML40Namespace.ElementName.CENTER, collection); + layoutType = LAYOUT_BLOCK; + } + + /** + * %attrs; + */ + protected void createAttributeDeclarations() { + if (attributes != null) + return; // already created. + if (attributeCollection == null) + return; // fatal + + attributes = new CMNamedNodeMapImpl(); + + // %attrs; + attributeCollection.getAttrs(attributes); + } + + /** + */ + public CMNamedNodeMap getProhibitedAncestors() { + if (prohibitedAncestors != null) + return prohibitedAncestors; + + String[] names = {HTML40Namespace.ElementName.DIR, HTML40Namespace.ElementName.MENU}; + prohibitedAncestors = elementCollection.getDeclarations(names); + + return prohibitedAncestors; + } +}
\ No newline at end of file diff --git a/bundles/org.eclipse.wst.html.core/src/org/eclipse/wst/html/core/contentmodel/HedCOL.java b/bundles/org.eclipse.wst.html.core/src/org/eclipse/wst/html/core/contentmodel/HedCOL.java new file mode 100644 index 0000000000..ba3f1b7362 --- /dev/null +++ b/bundles/org.eclipse.wst.html.core/src/org/eclipse/wst/html/core/contentmodel/HedCOL.java @@ -0,0 +1,67 @@ +/******************************************************************************* + * Copyright (c) 2004 IBM Corporation and others. + * All rights reserved. This program and the accompanying materials + * are made available under the terms of the Eclipse Public License v1.0 + * which accompanies this distribution, and is available at + * http://www.eclipse.org/legal/epl-v10.html + * + * Contributors: + * IBM Corporation - initial API and implementation + *******************************************************************************/ +package org.eclipse.wst.html.core.contentmodel; + + + +import java.util.Arrays; + +import org.eclipse.wst.common.contentmodel.CMAttributeDeclaration; +import org.eclipse.wst.html.core.HTML40Namespace; + +/** + * COL. + */ +final class HedCOL extends HedEmpty { + + /** + */ + public HedCOL(ElementCollection collection) { + super(HTML40Namespace.ElementName.COL, collection); + // LAYOUT_BLOCK. + // Because, COL is GROUP_BLOCK in the C++DOM/DTDParser.cpp. + layoutType = LAYOUT_BLOCK; + } + + /** + * COL. + * %attrs; + * (span NUMBER 1) + * (width %MultiLength; #IMPLIED) ... should be defined locally. + * %cellhalign; + * %cellvalign; + */ + protected void createAttributeDeclarations() { + if (attributes != null) + return; // already created. + if (attributeCollection == null) + return; // fatal + + attributes = new CMNamedNodeMapImpl(); + + // %attrs; + attributeCollection.getAttrs(attributes); + + // (span NUMBER 1) + String[] names = {HTML40Namespace.ATTR_NAME_SPAN}; + attributeCollection.getDeclarations(attributes, Arrays.asList(names).iterator()); + + // (width %MultiLength; #IMPLIED) ... should be defined locally. + HTMLCMDataTypeImpl atype = new HTMLCMDataTypeImpl(HTMLCMDataType.MULTI_LENGTH); + HTMLAttrDeclImpl attr = new HTMLAttrDeclImpl(HTML40Namespace.ATTR_NAME_WIDTH, atype, CMAttributeDeclaration.OPTIONAL); + attributes.putNamedItem(HTML40Namespace.ATTR_NAME_WIDTH, attr); + + // %cellhalign; + attributeCollection.getCellhalign(attributes); + // %cellvalign; + attributeCollection.getCellvalign(attributes); + } +}
\ No newline at end of file diff --git a/bundles/org.eclipse.wst.html.core/src/org/eclipse/wst/html/core/contentmodel/HedCOLGROUP.java b/bundles/org.eclipse.wst.html.core/src/org/eclipse/wst/html/core/contentmodel/HedCOLGROUP.java new file mode 100644 index 0000000000..37528e5a1e --- /dev/null +++ b/bundles/org.eclipse.wst.html.core/src/org/eclipse/wst/html/core/contentmodel/HedCOLGROUP.java @@ -0,0 +1,77 @@ +/******************************************************************************* + * Copyright (c) 2004 IBM Corporation and others. + * All rights reserved. This program and the accompanying materials + * are made available under the terms of the Eclipse Public License v1.0 + * which accompanies this distribution, and is available at + * http://www.eclipse.org/legal/epl-v10.html + * + * Contributors: + * IBM Corporation - initial API and implementation + *******************************************************************************/ +package org.eclipse.wst.html.core.contentmodel; + + + +import java.util.Arrays; +import java.util.Iterator; + +import org.eclipse.wst.common.contentmodel.CMAttributeDeclaration; +import org.eclipse.wst.html.core.HTML40Namespace; + +/** + * COLGROUP. + */ +final class HedCOLGROUP extends HTMLElemDeclImpl { + + private static String[] terminators = {HTML40Namespace.ElementName.COLGROUP, HTML40Namespace.ElementName.CAPTION, HTML40Namespace.ElementName.THEAD, HTML40Namespace.ElementName.TBODY, HTML40Namespace.ElementName.TFOOT, HTML40Namespace.ElementName.TR}; + + /** + * @param ownerDocument com.ibm.sed.contentmodel.html.HCMDocImpl + */ + public HedCOLGROUP(ElementCollection collection) { + super(HTML40Namespace.ElementName.COLGROUP, collection); + typeDefinitionName = ComplexTypeDefinitionFactory.CTYPE_COLUMN_GROUP; + layoutType = LAYOUT_BLOCK; + omitType = OMIT_END; + indentChild = true; + } + + /** + * %attrs; + * (span NUMBER 1) + * (width %MultiLength; #IMPLIED) ... should be defined locally. + * %cellhalign; + * %cellvalign; + */ + protected void createAttributeDeclarations() { + if (attributes != null) + return; // already created. + if (attributeCollection == null) + return; // fatal + + attributes = new CMNamedNodeMapImpl(); + + // %attrs; + attributeCollection.getAttrs(attributes); + // %cellhalign; + attributeCollection.getCellhalign(attributes); + // %cellvalign; + attributeCollection.getCellvalign(attributes); + + String[] names = {HTML40Namespace.ATTR_NAME_SPAN}; + attributeCollection.getDeclarations(attributes, Arrays.asList(names).iterator()); + + // (width %MultiLength; #IMPLIED) ... should be defined locally. + HTMLCMDataTypeImpl atype = new HTMLCMDataTypeImpl(HTMLCMDataType.MULTI_LENGTH); + HTMLAttrDeclImpl attr = new HTMLAttrDeclImpl(HTML40Namespace.ATTR_NAME_WIDTH, atype, CMAttributeDeclaration.OPTIONAL); + attributes.putNamedItem(HTML40Namespace.ATTR_NAME_WIDTH, attr); + } + + /** + * LI has terminators. + * @return java.util.Iterator + */ + protected Iterator getTerminators() { + return Arrays.asList(terminators).iterator(); + } +}
\ No newline at end of file diff --git a/bundles/org.eclipse.wst.html.core/src/org/eclipse/wst/html/core/contentmodel/HedDD.java b/bundles/org.eclipse.wst.html.core/src/org/eclipse/wst/html/core/contentmodel/HedDD.java new file mode 100644 index 0000000000..cdb4f6f603 --- /dev/null +++ b/bundles/org.eclipse.wst.html.core/src/org/eclipse/wst/html/core/contentmodel/HedDD.java @@ -0,0 +1,59 @@ +/******************************************************************************* + * Copyright (c) 2004 IBM Corporation and others. + * All rights reserved. This program and the accompanying materials + * are made available under the terms of the Eclipse Public License v1.0 + * which accompanies this distribution, and is available at + * http://www.eclipse.org/legal/epl-v10.html + * + * Contributors: + * IBM Corporation - initial API and implementation + *******************************************************************************/ +package org.eclipse.wst.html.core.contentmodel; + + + +import java.util.Arrays; +import java.util.Iterator; + +import org.eclipse.wst.html.core.HTML40Namespace; + + +/** + * DD. + */ +final class HedDD extends HedFlowContainer { + + private static String[] terminators = {HTML40Namespace.ElementName.DT, HTML40Namespace.ElementName.DD}; + + /** + */ + public HedDD(ElementCollection collection) { + super(HTML40Namespace.ElementName.DD, collection); + correctionType = CORRECT_EMPTY; + layoutType = LAYOUT_BLOCK; + omitType = OMIT_END_DEFAULT; + } + + /** + * %attrs; + */ + protected void createAttributeDeclarations() { + if (attributes != null) + return; // already created. + if (attributeCollection == null) + return; // fatal + + attributes = new CMNamedNodeMapImpl(); + + // %attrs; + attributeCollection.getAttrs(attributes); + } + + /** + * DD has terminators. + * @return java.util.Iterator + */ + protected Iterator getTerminators() { + return Arrays.asList(terminators).iterator(); + } +}
\ No newline at end of file diff --git a/bundles/org.eclipse.wst.html.core/src/org/eclipse/wst/html/core/contentmodel/HedDIV.java b/bundles/org.eclipse.wst.html.core/src/org/eclipse/wst/html/core/contentmodel/HedDIV.java new file mode 100644 index 0000000000..5faaf3c093 --- /dev/null +++ b/bundles/org.eclipse.wst.html.core/src/org/eclipse/wst/html/core/contentmodel/HedDIV.java @@ -0,0 +1,63 @@ +/******************************************************************************* + * Copyright (c) 2004 IBM Corporation and others. + * All rights reserved. This program and the accompanying materials + * are made available under the terms of the Eclipse Public License v1.0 + * which accompanies this distribution, and is available at + * http://www.eclipse.org/legal/epl-v10.html + * + * Contributors: + * IBM Corporation - initial API and implementation + *******************************************************************************/ +package org.eclipse.wst.html.core.contentmodel; + + + +import org.eclipse.wst.common.contentmodel.CMNamedNodeMap; +import org.eclipse.wst.html.core.HTML40Namespace; + +/** + * DIV. + */ +final class HedDIV extends HedFlowContainer { + + /** + */ + public HedDIV(ElementCollection collection) { + super(HTML40Namespace.ElementName.DIV, collection); + layoutType = LAYOUT_BLOCK; + } + + /** + * %attrs; + * %align; + * %reserved; + */ + protected void createAttributeDeclarations() { + if (attributes != null) + return; // already created. + if (attributeCollection == null) + return; // fatal + + attributes = new CMNamedNodeMapImpl(); + + // %attrs; + attributeCollection.getAttrs(attributes); + // %align; + HTMLAttrDeclImpl attr = AttributeCollection.createAlignForParagraph(); + if (attr != null) + attributes.putNamedItem(HTML40Namespace.ATTR_NAME_ALIGN, attr); + // %reserved; ... empty + } + + /** + */ + public CMNamedNodeMap getProhibitedAncestors() { + if (prohibitedAncestors != null) + return prohibitedAncestors; + + String[] names = {HTML40Namespace.ElementName.DIR, HTML40Namespace.ElementName.MENU}; + prohibitedAncestors = elementCollection.getDeclarations(names); + + return prohibitedAncestors; + } +}
\ No newline at end of file diff --git a/bundles/org.eclipse.wst.html.core/src/org/eclipse/wst/html/core/contentmodel/HedDL.java b/bundles/org.eclipse.wst.html.core/src/org/eclipse/wst/html/core/contentmodel/HedDL.java new file mode 100644 index 0000000000..ff2aba550b --- /dev/null +++ b/bundles/org.eclipse.wst.html.core/src/org/eclipse/wst/html/core/contentmodel/HedDL.java @@ -0,0 +1,64 @@ +/******************************************************************************* + * Copyright (c) 2004 IBM Corporation and others. + * All rights reserved. This program and the accompanying materials + * are made available under the terms of the Eclipse Public License v1.0 + * which accompanies this distribution, and is available at + * http://www.eclipse.org/legal/epl-v10.html + * + * Contributors: + * IBM Corporation - initial API and implementation + *******************************************************************************/ +package org.eclipse.wst.html.core.contentmodel; + + + +import java.util.Arrays; + +import org.eclipse.wst.common.contentmodel.CMNamedNodeMap; +import org.eclipse.wst.html.core.HTML40Namespace; + +/** + * DL. + */ +final class HedDL extends HTMLElemDeclImpl { + + /** + */ + public HedDL(ElementCollection collection) { + super(HTML40Namespace.ElementName.DL, collection); + typeDefinitionName = ComplexTypeDefinitionFactory.CTYPE_DEFINITION_LIST; + correctionType = CORRECT_EMPTY; + layoutType = LAYOUT_BLOCK; + indentChild = true; + } + + /** + * %arrays; + * (compact (compact) #IMPLIED) + */ + protected void createAttributeDeclarations() { + if (attributes != null) + return; // already created. + if (attributeCollection == null) + return; // fatal + attributes = new CMNamedNodeMapImpl(); + + // %attrs; + attributeCollection.getAttrs(attributes); + + String[] names = {HTML40Namespace.ATTR_NAME_COMPACT}; + attributeCollection.getDeclarations(attributes, Arrays.asList(names).iterator()); + } + + /** + */ + public CMNamedNodeMap getProhibitedAncestors() { + if (prohibitedAncestors != null) + return prohibitedAncestors; + + String[] names = {HTML40Namespace.ElementName.DIR, HTML40Namespace.ElementName.MENU}; + prohibitedAncestors = elementCollection.getDeclarations(names); + + return prohibitedAncestors; + } +}
\ No newline at end of file diff --git a/bundles/org.eclipse.wst.html.core/src/org/eclipse/wst/html/core/contentmodel/HedDT.java b/bundles/org.eclipse.wst.html.core/src/org/eclipse/wst/html/core/contentmodel/HedDT.java new file mode 100644 index 0000000000..6c7bd4856a --- /dev/null +++ b/bundles/org.eclipse.wst.html.core/src/org/eclipse/wst/html/core/contentmodel/HedDT.java @@ -0,0 +1,59 @@ +/******************************************************************************* + * Copyright (c) 2004 IBM Corporation and others. + * All rights reserved. This program and the accompanying materials + * are made available under the terms of the Eclipse Public License v1.0 + * which accompanies this distribution, and is available at + * http://www.eclipse.org/legal/epl-v10.html + * + * Contributors: + * IBM Corporation - initial API and implementation + *******************************************************************************/ +package org.eclipse.wst.html.core.contentmodel; + + + +import java.util.Arrays; +import java.util.Iterator; + +import org.eclipse.wst.html.core.HTML40Namespace; + + +/** + * DT. + */ +final class HedDT extends HedInlineContainer { + + private static String[] terminators = {HTML40Namespace.ElementName.DT, HTML40Namespace.ElementName.DD}; + + /** + */ + public HedDT(ElementCollection collection) { + super(HTML40Namespace.ElementName.DT, collection); + correctionType = CORRECT_EMPTY; + layoutType = LAYOUT_BLOCK; + omitType = OMIT_END_DEFAULT; + } + + /** + * %attrs; + */ + protected void createAttributeDeclarations() { + if (attributes != null) + return; // already created. + if (attributeCollection == null) + return; // fatal + + attributes = new CMNamedNodeMapImpl(); + + // %attrs; + attributeCollection.getAttrs(attributes); + } + + /** + * DT has terminators. + * @return java.util.Iterator + */ + protected Iterator getTerminators() { + return Arrays.asList(terminators).iterator(); + } +}
\ No newline at end of file diff --git a/bundles/org.eclipse.wst.html.core/src/org/eclipse/wst/html/core/contentmodel/HedEMBED.java b/bundles/org.eclipse.wst.html.core/src/org/eclipse/wst/html/core/contentmodel/HedEMBED.java new file mode 100644 index 0000000000..1b94431f97 --- /dev/null +++ b/bundles/org.eclipse.wst.html.core/src/org/eclipse/wst/html/core/contentmodel/HedEMBED.java @@ -0,0 +1,94 @@ +/******************************************************************************* + * Copyright (c) 2004 IBM Corporation and others. + * All rights reserved. This program and the accompanying materials + * are made available under the terms of the Eclipse Public License v1.0 + * which accompanies this distribution, and is available at + * http://www.eclipse.org/legal/epl-v10.html + * + * Contributors: + * IBM Corporation - initial API and implementation + *******************************************************************************/ +package org.eclipse.wst.html.core.contentmodel; + + + +import java.util.Arrays; + +import org.eclipse.wst.common.contentmodel.CMAttributeDeclaration; +import org.eclipse.wst.common.contentmodel.CMDataType; +import org.eclipse.wst.html.core.HTML40Namespace; + +/** + * EMBED. + */ +final class HedEMBED extends HTMLElemDeclImpl { + + /** + */ + public HedEMBED(ElementCollection collection) { + super(HTML40Namespace.ElementName.EMBED, collection); + typeDefinitionName = ComplexTypeDefinitionFactory.CTYPE_EMBED; + layoutType = LAYOUT_OBJECT; + omitType = OMIT_END_DEFAULT; + } + + /** + * %coreattrs; + * %events; + * (src %URI; #REQUIRED) ... should be defined locally. + * (height %Length; #IMPLIED) + * (width %Length; #IMPLIED) + * (align %IAlign; #IMPLIED) ... should be defined locally. + * (hspace %Pixels; #IMPLIED) + * (vspace %Pixels; #IMPLIED) + * (loop CDATA #IMPLIED) + * (hidden CDATA #IMPLIED) + * (volume CDATA #IMPLIED) + * (autostart (true|false) #IMPLIED) + * (autoplay (true|false) #IMPLIED) + * (autosize (true|false) #IMPLIED) + * (controller (true|false) true) + * (scale CDATA #IMPLIED) + * (showcontrols (true|false) #IMPLIED) + * (playcount NUMBER #IMPLIED) + * (repeat CDATA #IMPLIED) + * (panel CDATA #IMPLIED) + * (text CDATA #IMPLIED) + * (palette CDATA #IMPLIED) + * (textfocus CDATA #IMPLIED) + * (type CDATA #IMPLIED) ... should be defined locally. + */ + protected void createAttributeDeclarations() { + if (attributes != null) + return; // already created. + if (attributeCollection == null) + return; // fatal + + attributes = new CMNamedNodeMapImpl(); + + // %coreattrs; + attributeCollection.getCore(attributes); + // %events; + attributeCollection.getEvents(attributes); + + String[] names = {HTML40Namespace.ATTR_NAME_HEIGHT, HTML40Namespace.ATTR_NAME_WIDTH, HTML40Namespace.ATTR_NAME_HSPACE, HTML40Namespace.ATTR_NAME_VSPACE, HTML40Namespace.ATTR_NAME_LOOP, HTML40Namespace.ATTR_NAME_HIDDEN, HTML40Namespace.ATTR_NAME_VOLUME, HTML40Namespace.ATTR_NAME_AUTOSTART, HTML40Namespace.ATTR_NAME_AUTOPLAY, HTML40Namespace.ATTR_NAME_AUTOSIZE, HTML40Namespace.ATTR_NAME_CONTROLLER, HTML40Namespace.ATTR_NAME_SCALE, HTML40Namespace.ATTR_NAME_SHOWCONTROLS, HTML40Namespace.ATTR_NAME_PLAYCOUNT, HTML40Namespace.ATTR_NAME_REPEAT, HTML40Namespace.ATTR_NAME_PANEL, HTML40Namespace.ATTR_NAME_TEXT, HTML40Namespace.ATTR_NAME_PALETTE, HTML40Namespace.ATTR_NAME_TEXTFOCUS}; + attributeCollection.getDeclarations(attributes, Arrays.asList(names).iterator()); + + HTMLCMDataTypeImpl atype = null; + HTMLAttrDeclImpl attr = null; + // (src %URI; #REQUIRED) ... should be defined locally. + atype = new HTMLCMDataTypeImpl(CMDataType.URI); + attr = new HTMLAttrDeclImpl(HTML40Namespace.ATTR_NAME_SRC, atype, CMAttributeDeclaration.REQUIRED); + attributes.putNamedItem(HTML40Namespace.ATTR_NAME_SRC, attr); + + // (align %IAlign; #IMPLIED) ... should be defined locally. + attr = AttributeCollection.createAlignForImage(); + if (attr != null) + attributes.putNamedItem(HTML40Namespace.ATTR_NAME_ALIGN, attr); + + // (type CDATA #IMPLIED) ... should be defined locally. + atype = new HTMLCMDataTypeImpl(CMDataType.CDATA); + attr = new HTMLAttrDeclImpl(HTML40Namespace.ATTR_NAME_TYPE, atype, CMAttributeDeclaration.OPTIONAL); + attributes.putNamedItem(HTML40Namespace.ATTR_NAME_TYPE, attr); + } +}
\ No newline at end of file diff --git a/bundles/org.eclipse.wst.html.core/src/org/eclipse/wst/html/core/contentmodel/HedEmpty.java b/bundles/org.eclipse.wst.html.core/src/org/eclipse/wst/html/core/contentmodel/HedEmpty.java new file mode 100644 index 0000000000..bcf3dcee79 --- /dev/null +++ b/bundles/org.eclipse.wst.html.core/src/org/eclipse/wst/html/core/contentmodel/HedEmpty.java @@ -0,0 +1,49 @@ +/******************************************************************************* + * Copyright (c) 2004 IBM Corporation and others. + * All rights reserved. This program and the accompanying materials + * are made available under the terms of the Eclipse Public License v1.0 + * which accompanies this distribution, and is available at + * http://www.eclipse.org/legal/epl-v10.html + * + * Contributors: + * IBM Corporation - initial API and implementation + *******************************************************************************/ +package org.eclipse.wst.html.core.contentmodel; + + + +import org.eclipse.wst.common.contentmodel.CMContent; +import org.eclipse.wst.common.contentmodel.CMElementDeclaration; + +/** + * Base class for EMPTY type element declarations. + */ +abstract class HedEmpty extends HTMLElemDeclImpl { + + /** + */ + public HedEmpty(String elementName, ElementCollection collection) { + super(elementName, collection); + typeDefinitionName = ComplexTypeDefinitionFactory.CTYPE_EMPTY; + // EMPTY type has no end tag. + omitType = OMIT_END_MUST; + } + + /** + * Content.<br> + * EMPTY type always returns <code>null</code>. + * <br> + * @return org.eclipse.wst.common.contentmodel.CMContent + */ + public CMContent getContent() { + return null; + } + + /** + * Content type.<br> + * @see org.eclipse.wst.common.contentmodel.CMElementDeclaration + */ + public int getContentType() { + return CMElementDeclaration.EMPTY; + } +}
\ No newline at end of file diff --git a/bundles/org.eclipse.wst.html.core/src/org/eclipse/wst/html/core/contentmodel/HedFIELDSET.java b/bundles/org.eclipse.wst.html.core/src/org/eclipse/wst/html/core/contentmodel/HedFIELDSET.java new file mode 100644 index 0000000000..16d28c0333 --- /dev/null +++ b/bundles/org.eclipse.wst.html.core/src/org/eclipse/wst/html/core/contentmodel/HedFIELDSET.java @@ -0,0 +1,57 @@ +/******************************************************************************* + * Copyright (c) 2004 IBM Corporation and others. + * All rights reserved. This program and the accompanying materials + * are made available under the terms of the Eclipse Public License v1.0 + * which accompanies this distribution, and is available at + * http://www.eclipse.org/legal/epl-v10.html + * + * Contributors: + * IBM Corporation - initial API and implementation + *******************************************************************************/ +package org.eclipse.wst.html.core.contentmodel; + + + +import org.eclipse.wst.common.contentmodel.CMNamedNodeMap; +import org.eclipse.wst.html.core.HTML40Namespace; + +/** + * FIELDSET. + */ +final class HedFIELDSET extends HTMLElemDeclImpl { + + /** + */ + public HedFIELDSET(ElementCollection collection) { + super(HTML40Namespace.ElementName.FIELDSET, collection); + typeDefinitionName = ComplexTypeDefinitionFactory.CTYPE_FIELDSET; + layoutType = LAYOUT_BLOCK; + } + + /** + * %attrs; + */ + protected void createAttributeDeclarations() { + if (attributes != null) + return; // already created. + if (attributeCollection == null) + return; // fatal + + attributes = new CMNamedNodeMapImpl(); + + // %attrs; + attributeCollection.getAttrs(attributes); + } + + /** + */ + public CMNamedNodeMap getProhibitedAncestors() { + if (prohibitedAncestors != null) + return prohibitedAncestors; + + String[] names = {HTML40Namespace.ElementName.BUTTON, HTML40Namespace.ElementName.DIR, HTML40Namespace.ElementName.MENU}; + prohibitedAncestors = elementCollection.getDeclarations(names); + + return prohibitedAncestors; + } +}
\ No newline at end of file diff --git a/bundles/org.eclipse.wst.html.core/src/org/eclipse/wst/html/core/contentmodel/HedFONT.java b/bundles/org.eclipse.wst.html.core/src/org/eclipse/wst/html/core/contentmodel/HedFONT.java new file mode 100644 index 0000000000..20ec1a5860 --- /dev/null +++ b/bundles/org.eclipse.wst.html.core/src/org/eclipse/wst/html/core/contentmodel/HedFONT.java @@ -0,0 +1,62 @@ +/******************************************************************************* + * Copyright (c) 2004 IBM Corporation and others. + * All rights reserved. This program and the accompanying materials + * are made available under the terms of the Eclipse Public License v1.0 + * which accompanies this distribution, and is available at + * http://www.eclipse.org/legal/epl-v10.html + * + * Contributors: + * IBM Corporation - initial API and implementation + *******************************************************************************/ +package org.eclipse.wst.html.core.contentmodel; + + + +import java.util.Arrays; + +import org.eclipse.wst.common.contentmodel.CMAttributeDeclaration; +import org.eclipse.wst.common.contentmodel.CMDataType; +import org.eclipse.wst.html.core.HTML40Namespace; + +/** + * FONT. + */ +final class HedFONT extends HedInlineContainer { + + /** + */ + public HedFONT(ElementCollection collection) { + super(HTML40Namespace.ElementName.FONT, collection); + // CORRECT_EMPTY - GROUP_COMPACT + correctionType = CORRECT_EMPTY; + } + + /** + * %coreattrs; + * %i18n; + * (size CDATA #IMPLIED) ... should be defined locally. + * (color %Color; #IMPLIED) + * (face CDATA #IMPLIED) + */ + protected void createAttributeDeclarations() { + if (attributes != null) + return; // already created. + if (attributeCollection == null) + return; // fatal + + attributes = new CMNamedNodeMapImpl(); + + // %coreattrs; + attributeCollection.getCore(attributes); + // %i18n; + attributeCollection.getI18n(attributes); + + String[] names = {HTML40Namespace.ATTR_NAME_COLOR, HTML40Namespace.ATTR_NAME_FACE}; + attributeCollection.getDeclarations(attributes, Arrays.asList(names).iterator()); + + // (size CDATA #IMPLIED) ... should be defined locally. + HTMLCMDataTypeImpl atype = new HTMLCMDataTypeImpl(CMDataType.CDATA); + HTMLAttrDeclImpl attr = new HTMLAttrDeclImpl(HTML40Namespace.ATTR_NAME_SIZE, atype, CMAttributeDeclaration.OPTIONAL); + attributes.putNamedItem(HTML40Namespace.ATTR_NAME_SIZE, attr); + } +}
\ No newline at end of file diff --git a/bundles/org.eclipse.wst.html.core/src/org/eclipse/wst/html/core/contentmodel/HedFORM.java b/bundles/org.eclipse.wst.html.core/src/org/eclipse/wst/html/core/contentmodel/HedFORM.java new file mode 100644 index 0000000000..e823b0f134 --- /dev/null +++ b/bundles/org.eclipse.wst.html.core/src/org/eclipse/wst/html/core/contentmodel/HedFORM.java @@ -0,0 +1,93 @@ +/******************************************************************************* + * Copyright (c) 2004 IBM Corporation and others. + * All rights reserved. This program and the accompanying materials + * are made available under the terms of the Eclipse Public License v1.0 + * which accompanies this distribution, and is available at + * http://www.eclipse.org/legal/epl-v10.html + * + * Contributors: + * IBM Corporation - initial API and implementation + *******************************************************************************/ +package org.eclipse.wst.html.core.contentmodel; + + + +import java.util.Arrays; + +import org.eclipse.wst.common.contentmodel.CMContent; +import org.eclipse.wst.common.contentmodel.CMGroup; +import org.eclipse.wst.common.contentmodel.CMNamedNodeMap; +import org.eclipse.wst.common.contentmodel.CMNode; +import org.eclipse.wst.html.core.HTML40Namespace; + +/** + * FORM. + */ +final class HedFORM extends HedFlowContainer { + + /** + */ + public HedFORM(ElementCollection collection) { + super(HTML40Namespace.ElementName.FORM, collection); + layoutType = LAYOUT_BLOCK; + } + + /** + * %attrs; + * (action %URI; #REQUIRED) + * (method (GET|POST) GET) + * (enctype %ContentType; "application/x-www-form-urlencoded") + * (accept %ContentTypes; #IMPLIED) + * (name CDATA #IMPLIED) + * (onsubmit %Script; #IMPLIED) + * (onreset %Script; #IMPLIED) + * (target %FrameTarget; #IMPLIED) + * (accept-charset %Charsets; #IMPLIED) + */ + protected void createAttributeDeclarations() { + if (attributes != null) + return; // already created. + if (attributeCollection == null) + return; // fatal + + attributes = new CMNamedNodeMapImpl(); + + // %attrs; + attributeCollection.getAttrs(attributes); + + String[] names = {HTML40Namespace.ATTR_NAME_ACTION, HTML40Namespace.ATTR_NAME_METHOD, HTML40Namespace.ATTR_NAME_ENCTYPE, HTML40Namespace.ATTR_NAME_ACCEPT, HTML40Namespace.ATTR_NAME_NAME, HTML40Namespace.ATTR_NAME_ONSUBMIT, HTML40Namespace.ATTR_NAME_ONRESET, HTML40Namespace.ATTR_NAME_TARGET, HTML40Namespace.ATTR_NAME_ACCEPT_CHARSET}; + attributeCollection.getDeclarations(attributes, Arrays.asList(names).iterator()); + } + + /** + * Exclusion. + * <code>FORM</code> has the exclusion. + * It is <code>FORM</code> itself. + * @see com.ibm.sed.contentmodel.html.HTMLElementDeclaration + */ + public CMContent getExclusion() { + if (exclusion != null) + return exclusion; // already created. + if (elementCollection == null) + return null; // fatal + + exclusion = new CMGroupImpl(CMGroup.CHOICE, 1, 1); + CMNode form = elementCollection.getNamedItem(HTML40Namespace.ElementName.FORM); + if (form != null) + exclusion.appendChild(form); + + return exclusion; + } + + /** + */ + public CMNamedNodeMap getProhibitedAncestors() { + if (prohibitedAncestors != null) + return prohibitedAncestors; + + String[] names = {HTML40Namespace.ElementName.BUTTON, HTML40Namespace.ElementName.DIR, HTML40Namespace.ElementName.FORM, HTML40Namespace.ElementName.MENU}; + prohibitedAncestors = elementCollection.getDeclarations(names); + + return prohibitedAncestors; + } +}
\ No newline at end of file diff --git a/bundles/org.eclipse.wst.html.core/src/org/eclipse/wst/html/core/contentmodel/HedFRAME.java b/bundles/org.eclipse.wst.html.core/src/org/eclipse/wst/html/core/contentmodel/HedFRAME.java new file mode 100644 index 0000000000..bb7d37305b --- /dev/null +++ b/bundles/org.eclipse.wst.html.core/src/org/eclipse/wst/html/core/contentmodel/HedFRAME.java @@ -0,0 +1,62 @@ +/******************************************************************************* + * Copyright (c) 2004 IBM Corporation and others. + * All rights reserved. This program and the accompanying materials + * are made available under the terms of the Eclipse Public License v1.0 + * which accompanies this distribution, and is available at + * http://www.eclipse.org/legal/epl-v10.html + * + * Contributors: + * IBM Corporation - initial API and implementation + *******************************************************************************/ +package org.eclipse.wst.html.core.contentmodel; + + + +import java.util.Arrays; + +import org.eclipse.wst.html.core.HTML40Namespace; + + +/** + * FRAME. + */ +final class HedFRAME extends HedEmpty { + + /** + */ + public HedFRAME(ElementCollection collection) { + super(HTML40Namespace.ElementName.FRAME, collection); + // LAYOUT_HIDDEN. + // Because, FRAME is GROUP_HIDDEN in the C++DOM/DTDParser.cpp. + layoutType = LAYOUT_HIDDEN; + } + + /** + * FRAME. + * %coreattrs; + * (longdesc %URI; #IMPLIED) + * (name CDATA #IMPLIED) + * (src %URI; #IMPLIED) + * (frameborder (1|0) 1) + * (marginwidth %Pixels; #IMPLIED) + * (marginheight %Pixels; #IMPLIED) + * (noresize (noresize) #IMPLIED) + * (scrolling (yes|no|auto) auto) + * (bordercolor %Color #IMPLIED) ... D205514 + */ + protected void createAttributeDeclarations() { + if (attributes != null) + return; // already created. + if (attributeCollection == null) + return; // fatal + + attributes = new CMNamedNodeMapImpl(); + + // %coreattrs; + attributeCollection.getCore(attributes); + + String[] names = {HTML40Namespace.ATTR_NAME_LONGDESC, HTML40Namespace.ATTR_NAME_NAME, HTML40Namespace.ATTR_NAME_SRC, HTML40Namespace.ATTR_NAME_FRAMEBORDER, HTML40Namespace.ATTR_NAME_MARGINWIDTH, HTML40Namespace.ATTR_NAME_MARGINHEIGHT, HTML40Namespace.ATTR_NAME_NORESIZE, HTML40Namespace.ATTR_NAME_SCROLLING, HTML40Namespace.ATTR_NAME_BORDERCOLOR // D20554 + }; + attributeCollection.getDeclarations(attributes, Arrays.asList(names).iterator()); + } +}
\ No newline at end of file diff --git a/bundles/org.eclipse.wst.html.core/src/org/eclipse/wst/html/core/contentmodel/HedFRAMESET.java b/bundles/org.eclipse.wst.html.core/src/org/eclipse/wst/html/core/contentmodel/HedFRAMESET.java new file mode 100644 index 0000000000..a2ab71ffbd --- /dev/null +++ b/bundles/org.eclipse.wst.html.core/src/org/eclipse/wst/html/core/contentmodel/HedFRAMESET.java @@ -0,0 +1,80 @@ +/******************************************************************************* + * Copyright (c) 2004 IBM Corporation and others. + * All rights reserved. This program and the accompanying materials + * are made available under the terms of the Eclipse Public License v1.0 + * which accompanies this distribution, and is available at + * http://www.eclipse.org/legal/epl-v10.html + * + * Contributors: + * IBM Corporation - initial API and implementation + *******************************************************************************/ +package org.eclipse.wst.html.core.contentmodel; + + + +import java.util.Arrays; + +import org.eclipse.wst.common.contentmodel.CMAttributeDeclaration; +import org.eclipse.wst.common.contentmodel.CMDataType; +import org.eclipse.wst.html.core.HTML40Namespace; + +/** + * FRAMESET. + */ +final class HedFRAMESET extends HTMLElemDeclImpl { + + /** + */ + public HedFRAMESET(ElementCollection collection) { + super(HTML40Namespace.ElementName.FRAMESET, collection); + typeDefinitionName = ComplexTypeDefinitionFactory.CTYPE_FRAMESET; + layoutType = LAYOUT_HIDDEN; + indentChild = true; + } + + /** + * %coreattrs; + * (rows %MultiLengths; #IMPLIED) ... should be defined locally. + * (cols %MultiLengths; #IMPLIED) ... should be defined locally. + * (onload %Script; #IMPLIED) + * (onunload %Script; #IMPLIED) + * (frameborder (yes|no) #IMPLIED) ... should be defined locally. + * (border %Pixels; #IMPLIED) + * (bordercolor %Color #IMPLIED) ... D205514 + * (framespacing CDATA #IMPLIED) ... D215684 + */ + protected void createAttributeDeclarations() { + if (attributes != null) + return; // already created. + if (attributeCollection == null) + return; // fatal + + attributes = new CMNamedNodeMapImpl(); + + // %attrs; + attributeCollection.getCore(attributes); + + String[] names = {HTML40Namespace.ATTR_NAME_ONLOAD, HTML40Namespace.ATTR_NAME_ONUNLOAD, HTML40Namespace.ATTR_NAME_BORDER, HTML40Namespace.ATTR_NAME_BORDERCOLOR, // D205514 + HTML40Namespace.ATTR_NAME_FRAMESPACING // D215684 + }; + attributeCollection.getDeclarations(attributes, Arrays.asList(names).iterator()); + + HTMLCMDataTypeImpl atype = null; + HTMLAttrDeclImpl attr = null; + // (rows %MultiLengths; #IMPLIED) ... should be defined locally. + atype = new HTMLCMDataTypeImpl(HTMLCMDataType.MULTI_LENGTH); + attr = new HTMLAttrDeclImpl(HTML40Namespace.ATTR_NAME_ROWS, atype, CMAttributeDeclaration.OPTIONAL); + attributes.putNamedItem(HTML40Namespace.ATTR_NAME_ROWS, attr); + + // (cols %MultiLengths; #IMPLIED) ... should be defined locally. + attr = new HTMLAttrDeclImpl(HTML40Namespace.ATTR_NAME_COLS, atype, CMAttributeDeclaration.OPTIONAL); + attributes.putNamedItem(HTML40Namespace.ATTR_NAME_COLS, attr); + + // (frameborder (yes|no) #IMPLIED) ... should be defined locally. + atype = new HTMLCMDataTypeImpl(CMDataType.ENUM); + String[] values = {HTML40Namespace.ATTR_VALUE_YES, HTML40Namespace.ATTR_VALUE_NO}; + atype.setEnumValues(values); + attr = new HTMLAttrDeclImpl(HTML40Namespace.ATTR_NAME_FRAMEBORDER, atype, CMAttributeDeclaration.OPTIONAL); + attributes.putNamedItem(HTML40Namespace.ATTR_NAME_FRAMEBORDER, attr); + } +}
\ No newline at end of file diff --git a/bundles/org.eclipse.wst.html.core/src/org/eclipse/wst/html/core/contentmodel/HedFlowContainer.java b/bundles/org.eclipse.wst.html.core/src/org/eclipse/wst/html/core/contentmodel/HedFlowContainer.java new file mode 100644 index 0000000000..6324dee7ca --- /dev/null +++ b/bundles/org.eclipse.wst.html.core/src/org/eclipse/wst/html/core/contentmodel/HedFlowContainer.java @@ -0,0 +1,26 @@ +/******************************************************************************* + * Copyright (c) 2004 IBM Corporation and others. + * All rights reserved. This program and the accompanying materials + * are made available under the terms of the Eclipse Public License v1.0 + * which accompanies this distribution, and is available at + * http://www.eclipse.org/legal/epl-v10.html + * + * Contributors: + * IBM Corporation - initial API and implementation + *******************************************************************************/ +package org.eclipse.wst.html.core.contentmodel; + + + +/** + * Base class for (%flow;)* containers. + */ +abstract class HedFlowContainer extends HTMLElemDeclImpl { + + /** + */ + public HedFlowContainer(String elementName, ElementCollection collection) { + super(elementName, collection); + typeDefinitionName = ComplexTypeDefinitionFactory.CTYPE_FLOW_CONTAINER; + } +}
\ No newline at end of file diff --git a/bundles/org.eclipse.wst.html.core/src/org/eclipse/wst/html/core/contentmodel/HedFontStyle.java b/bundles/org.eclipse.wst.html.core/src/org/eclipse/wst/html/core/contentmodel/HedFontStyle.java new file mode 100644 index 0000000000..ff06724101 --- /dev/null +++ b/bundles/org.eclipse.wst.html.core/src/org/eclipse/wst/html/core/contentmodel/HedFontStyle.java @@ -0,0 +1,65 @@ +/******************************************************************************* + * Copyright (c) 2004 IBM Corporation and others. + * All rights reserved. This program and the accompanying materials + * are made available under the terms of the Eclipse Public License v1.0 + * which accompanies this distribution, and is available at + * http://www.eclipse.org/legal/epl-v10.html + * + * Contributors: + * IBM Corporation - initial API and implementation + *******************************************************************************/ +package org.eclipse.wst.html.core.contentmodel; + + + +import org.eclipse.wst.common.contentmodel.CMNamedNodeMap; +import org.eclipse.wst.html.core.HTML40Namespace; + +/** + * %fontstyle; + */ +final class HedFontStyle extends HedInlineContainer { + + /** + */ + public HedFontStyle(String elementName, ElementCollection collection) { + super(elementName, collection); + if (elementName.equalsIgnoreCase(HTML40Namespace.ElementName.BIG) || elementName.equalsIgnoreCase(HTML40Namespace.ElementName.SMALL)) { + correctionType = CORRECT_EMPTY; + } + else { // B, I, U, ... + correctionType = CORRECT_DUPLICATED; + } + } + + /** + * %attrs; + * @see com.ibm.sed.contentmodel.html.HTMLElemDeclImpl + */ + protected void createAttributeDeclarations() { + if (attributes != null) + return; // already created. + if (attributeCollection == null) + return; // fatal + + attributes = new CMNamedNodeMapImpl(); + + // %attrs; + attributeCollection.getAttrs(attributes); + } + + /** + */ + public CMNamedNodeMap getProhibitedAncestors() { + String myName = getElementName(); + if (!myName.equalsIgnoreCase(HTML40Namespace.ElementName.BIG) && !myName.equalsIgnoreCase(HTML40Namespace.ElementName.SMALL)) + return EMPTY_MAP; + if (prohibitedAncestors != null) + return prohibitedAncestors; + + String[] names = {HTML40Namespace.ElementName.PRE}; + prohibitedAncestors = elementCollection.getDeclarations(names); + + return prohibitedAncestors; + } +}
\ No newline at end of file diff --git a/bundles/org.eclipse.wst.html.core/src/org/eclipse/wst/html/core/contentmodel/HedHEAD.java b/bundles/org.eclipse.wst.html.core/src/org/eclipse/wst/html/core/contentmodel/HedHEAD.java new file mode 100644 index 0000000000..df4a36565f --- /dev/null +++ b/bundles/org.eclipse.wst.html.core/src/org/eclipse/wst/html/core/contentmodel/HedHEAD.java @@ -0,0 +1,78 @@ +/******************************************************************************* + * Copyright (c) 2004 IBM Corporation and others. + * All rights reserved. This program and the accompanying materials + * are made available under the terms of the Eclipse Public License v1.0 + * which accompanies this distribution, and is available at + * http://www.eclipse.org/legal/epl-v10.html + * + * Contributors: + * IBM Corporation - initial API and implementation + *******************************************************************************/ +package org.eclipse.wst.html.core.contentmodel; + + + +import java.util.Arrays; +import java.util.Iterator; + +import org.eclipse.wst.html.core.HTML40Namespace; + + +/** + * HTML. + */ +final class HedHEAD extends HTMLElemDeclImpl { + + private static String[] terminators = {HTML40Namespace.ElementName.HEAD, HTML40Namespace.ElementName.BODY, HTML40Namespace.ElementName.FRAMESET, HTML40Namespace.ElementName.HTML}; + + /** + */ + public HedHEAD(ElementCollection collection) { + super(HTML40Namespace.ElementName.HEAD, collection); + typeDefinitionName = ComplexTypeDefinitionFactory.CTYPE_HEAD; + layoutType = LAYOUT_HIDDEN; + omitType = OMIT_BOTH; + } + + /** + * Create all attribute declarations. + * This method is called once in the constructor of the super class. + * The <code>HEAD</code> element may have the following attributes: + * <table> + * <tbody> + * <tr> + * <th>NAME</th><th>TYPE</th><th>USAGE</th><th>DEFAULT (INITIAL) VALUE</th><th>MEMO</th> + * </tr> + * <tr> + * <td>%i18n;</td><td>-</td><td>-</td><td>-</td><td>-</td> + * </tr> + * <tr> + * <td>profile</td><td>URI</td><td>#IMPLIED</td><td>N/A</td><td>-</td> + * </tr> + * </tbody> + * </table> + */ + protected void createAttributeDeclarations() { + if (attributes != null) + return; // already created. + if (attributeCollection == null) + return; // fatal + + attributes = new CMNamedNodeMapImpl(); + + // %i18n; + attributeCollection.getI18n(attributes); + // profile + HTMLAttributeDeclaration adec = attributeCollection.getDeclaration(HTML40Namespace.ATTR_NAME_PROFILE); + if (adec != null) + attributes.putNamedItem(HTML40Namespace.ATTR_NAME_PROFILE, adec); + } + + /** + * HEAD has terminators. + * @return java.util.Iterator + */ + protected Iterator getTerminators() { + return Arrays.asList(terminators).iterator(); + } +}
\ No newline at end of file diff --git a/bundles/org.eclipse.wst.html.core/src/org/eclipse/wst/html/core/contentmodel/HedHR.java b/bundles/org.eclipse.wst.html.core/src/org/eclipse/wst/html/core/contentmodel/HedHR.java new file mode 100644 index 0000000000..958a1fd556 --- /dev/null +++ b/bundles/org.eclipse.wst.html.core/src/org/eclipse/wst/html/core/contentmodel/HedHR.java @@ -0,0 +1,77 @@ +/******************************************************************************* + * Copyright (c) 2004 IBM Corporation and others. + * All rights reserved. This program and the accompanying materials + * are made available under the terms of the Eclipse Public License v1.0 + * which accompanies this distribution, and is available at + * http://www.eclipse.org/legal/epl-v10.html + * + * Contributors: + * IBM Corporation - initial API and implementation + *******************************************************************************/ +package org.eclipse.wst.html.core.contentmodel; + + + +import java.util.Arrays; + +import org.eclipse.wst.common.contentmodel.CMAttributeDeclaration; +import org.eclipse.wst.common.contentmodel.CMDataType; +import org.eclipse.wst.common.contentmodel.CMNamedNodeMap; +import org.eclipse.wst.html.core.HTML40Namespace; + +/** + * HR. + */ +final class HedHR extends HedEmpty { + + /** + */ + public HedHR(ElementCollection collection) { + super(HTML40Namespace.ElementName.HR, collection); + layoutType = LAYOUT_BLOCK; + } + + /** + * %attrs + * (align (left|center|right) #IMPLIED) ... should be defined locally. + * (noshade (noshade) #IMPLIED) + * (size %Pixels; #IMPLIED) + * (width %Length; #IMPLIED) + * (color %Color; #IMPLIED) ... D205514 + */ + protected void createAttributeDeclarations() { + if (attributes != null) + return; // already created. + if (attributeCollection == null) + return; // fatal + + attributes = new CMNamedNodeMapImpl(); + + // %attrs; + attributeCollection.getAttrs(attributes); + + // (align (left|center|right) #IMPLIED) ... should be defined locally. + HTMLCMDataTypeImpl atype = new HTMLCMDataTypeImpl(CMDataType.ENUM); + String[] values = {HTML40Namespace.ATTR_VALUE_LEFT, HTML40Namespace.ATTR_VALUE_CENTER, HTML40Namespace.ATTR_VALUE_RIGHT}; + atype.setEnumValues(values); + HTMLAttrDeclImpl attr = new HTMLAttrDeclImpl(HTML40Namespace.ATTR_NAME_ALIGN, atype, CMAttributeDeclaration.OPTIONAL); + attributes.putNamedItem(HTML40Namespace.ATTR_NAME_ALIGN, attr); + + // the rest. + String[] names = {HTML40Namespace.ATTR_NAME_NOSHADE, HTML40Namespace.ATTR_NAME_SIZE, HTML40Namespace.ATTR_NAME_WIDTH, HTML40Namespace.ATTR_NAME_COLOR // D205514 + }; + attributeCollection.getDeclarations(attributes, Arrays.asList(names).iterator()); + } + + /** + */ + public CMNamedNodeMap getProhibitedAncestors() { + if (prohibitedAncestors != null) + return prohibitedAncestors; + + String[] names = {HTML40Namespace.ElementName.DIR, HTML40Namespace.ElementName.MENU}; + prohibitedAncestors = elementCollection.getDeclarations(names); + + return prohibitedAncestors; + } +}
\ No newline at end of file diff --git a/bundles/org.eclipse.wst.html.core/src/org/eclipse/wst/html/core/contentmodel/HedHTML.java b/bundles/org.eclipse.wst.html.core/src/org/eclipse/wst/html/core/contentmodel/HedHTML.java new file mode 100644 index 0000000000..bb0dfb2d5c --- /dev/null +++ b/bundles/org.eclipse.wst.html.core/src/org/eclipse/wst/html/core/contentmodel/HedHTML.java @@ -0,0 +1,81 @@ +/******************************************************************************* + * Copyright (c) 2004 IBM Corporation and others. + * All rights reserved. This program and the accompanying materials + * are made available under the terms of the Eclipse Public License v1.0 + * which accompanies this distribution, and is available at + * http://www.eclipse.org/legal/epl-v10.html + * + * Contributors: + * IBM Corporation - initial API and implementation + *******************************************************************************/ +package org.eclipse.wst.html.core.contentmodel; + + + +import java.util.Arrays; +import java.util.Iterator; + +import org.eclipse.wst.html.core.HTML40Namespace; + + +/** + * HTML. + */ +final class HedHTML extends HTMLElemDeclImpl { + + private static String[] terminators = {HTML40Namespace.ElementName.HTML}; + + /** + */ + public HedHTML(ElementCollection collection) { + super(HTML40Namespace.ElementName.HTML, collection); + typeDefinitionName = ComplexTypeDefinitionFactory.CTYPE_HTML; + layoutType = LAYOUT_HIDDEN; + omitType = OMIT_BOTH; + } + + /** + * Create all attribute declarations. + * This method is called once in the constructor of the super class. + * The <code>HTML</code> element may have the following attributes: + * <table> + * <tbody> + * <tr> + * <th>NAME</th><th>TYPE</th><th>USAGE</th><th>DEFAULT (INITIAL) VALUE</th><th>MEMO</th> + * </tr> + * <tr> + * <td><code>%i18n;</code></td><td>-</td><td>-</td><td>-</td> + * <td>{@link PDCMDocImpl#getAttrDeclarationsI18n}</td> + * </tr> + * <tr> + * <td>version</td><td>CDATA</td><td>#FIXED</td> + * <td>{@link HTML_VERSION_TRANSITIONAL}</td><td>deplecated in HTML4.01</td> + * </tr> + * </tbody> + * </table><br> + * @see com.ibm.sed.contentmodel.html.AbstractHTMLElemDeclImpl + */ + protected void createAttributeDeclarations() { + if (attributes != null) + return; // already created. + if (attributeCollection == null) + return; // fatal + + attributes = new CMNamedNodeMapImpl(); + + // %i18n; + attributeCollection.getI18n(attributes); + // version + HTMLAttributeDeclaration adec = attributeCollection.getDeclaration(HTML40Namespace.ATTR_NAME_VERSION); + if (adec != null) + attributes.putNamedItem(HTML40Namespace.ATTR_NAME_VERSION, adec); + } + + /** + * HTML has terminators. + * @return java.util.Iterator + */ + protected Iterator getTerminators() { + return Arrays.asList(terminators).iterator(); + } +}
\ No newline at end of file diff --git a/bundles/org.eclipse.wst.html.core/src/org/eclipse/wst/html/core/contentmodel/HedHeading.java b/bundles/org.eclipse.wst.html.core/src/org/eclipse/wst/html/core/contentmodel/HedHeading.java new file mode 100644 index 0000000000..1e572ebd5c --- /dev/null +++ b/bundles/org.eclipse.wst.html.core/src/org/eclipse/wst/html/core/contentmodel/HedHeading.java @@ -0,0 +1,86 @@ +/******************************************************************************* + * Copyright (c) 2004 IBM Corporation and others. + * All rights reserved. This program and the accompanying materials + * are made available under the terms of the Eclipse Public License v1.0 + * which accompanies this distribution, and is available at + * http://www.eclipse.org/legal/epl-v10.html + * + * Contributors: + * IBM Corporation - initial API and implementation + *******************************************************************************/ +package org.eclipse.wst.html.core.contentmodel; + + + +import org.eclipse.wst.common.contentmodel.CMNamedNodeMap; +import org.eclipse.wst.html.core.HTML40Namespace; + +/** + * H[1-6]. + */ +final class HedHeading extends HedInlineContainer { + + /** + */ + public HedHeading(String elementName, ElementCollection collection) { + super(elementName, collection); + correctionType = CORRECT_EMPTY; + layoutType = LAYOUT_BLOCK; + } + + /** + * Create all attribute declarations. + * This method is called once in the constructor of the super class. + * The <code>H1</code> element may have the following attributes: + * <table> + * <tbody> + * <tr> + * <th>NAME</th><th>TYPE</th><th>USAGE</th><th>DEFAULT (INITIAL) VALUE</th><th>MEMO</th> + * </tr> + * <tr> + * <td>%attrs;</td><td>-</td><td>-</td><td>-</td><td>-</td> + * </tr> + * <tr> + * <td>%align;</td><td>-</td><td>-</td><td>-</td><td>-</td> + * </tr> + * </tbody> + * </table> + * <p><b>%align;</b> means <code>align (left|center|right|justify) #IMPLIED</code>. + * Unfortunately, this <code>align</code> is different from one in + * <code>IMG</code> or <code>TABLE</code>. So, the attribute declaration + * of <code>align</code> should be localy created and it shouldn't be registered + * in a <code>HCMDocImpl</code> instance.</p> + * <p>However, %align is used in sevaral times. I wouldn't write same code + * in many times. So, I add a new utility method into <code>CMUtil</code> + * to create the attribute declaration.</p> + * <br> + * @see com.ibm.sed.contentmodel.html.HTMLElemDeclImpl + */ + protected void createAttributeDeclarations() { + if (attributes != null) + return; // already created. + if (attributeCollection == null) + return; // fatal + + attributes = new CMNamedNodeMapImpl(); + + // %attrs; + attributeCollection.getAttrs(attributes); + // align + HTMLAttrDeclImpl attr = AttributeCollection.createAlignForParagraph(); + if (attr != null) + attributes.putNamedItem(HTML40Namespace.ATTR_NAME_ALIGN, attr); + } + + /** + */ + public CMNamedNodeMap getProhibitedAncestors() { + if (prohibitedAncestors != null) + return prohibitedAncestors; + + String[] names = {HTML40Namespace.ElementName.DIR, HTML40Namespace.ElementName.MENU}; + prohibitedAncestors = elementCollection.getDeclarations(names); + + return prohibitedAncestors; + } +}
\ No newline at end of file diff --git a/bundles/org.eclipse.wst.html.core/src/org/eclipse/wst/html/core/contentmodel/HedIFRAME.java b/bundles/org.eclipse.wst.html.core/src/org/eclipse/wst/html/core/contentmodel/HedIFRAME.java new file mode 100644 index 0000000000..a2c592f596 --- /dev/null +++ b/bundles/org.eclipse.wst.html.core/src/org/eclipse/wst/html/core/contentmodel/HedIFRAME.java @@ -0,0 +1,76 @@ +/******************************************************************************* + * Copyright (c) 2004 IBM Corporation and others. + * All rights reserved. This program and the accompanying materials + * are made available under the terms of the Eclipse Public License v1.0 + * which accompanies this distribution, and is available at + * http://www.eclipse.org/legal/epl-v10.html + * + * Contributors: + * IBM Corporation - initial API and implementation + *******************************************************************************/ +package org.eclipse.wst.html.core.contentmodel; + + + +import java.util.Arrays; + +import org.eclipse.wst.common.contentmodel.CMNamedNodeMap; +import org.eclipse.wst.html.core.HTML40Namespace; + +/** + * IFRAME. + */ +final class HedIFRAME extends HedFlowContainer { + + /** + */ + public HedIFRAME(ElementCollection collection) { + super(HTML40Namespace.ElementName.IFRAME, collection); + layoutType = LAYOUT_OBJECT; + } + + /** + * %coreattrs; + * (longdesc %URI; #IMPLIED) + * (name CDATA #IMPLIED) + * (src %URI; #IMPLIED) + * (frameborder (1|0) 1) + * (marginwidth %Pixels; #IMPLIED) + * (marginheight %Pixels; #IMPLIED) + * (scrolling (yes|no|auto) auto) + * (align %IAlign; #IMPLIED) ... should be defined locally. + * (height %Length; #IMPLIED) + * (width %Length; #IMPLIED) + */ + protected void createAttributeDeclarations() { + if (attributes != null) + return; // already created. + if (attributeCollection == null) + return; // fatal + + attributes = new CMNamedNodeMapImpl(); + + // %coreattrs; + attributeCollection.getCore(attributes); + + String[] names = {HTML40Namespace.ATTR_NAME_LONGDESC, HTML40Namespace.ATTR_NAME_NAME, HTML40Namespace.ATTR_NAME_SRC, HTML40Namespace.ATTR_NAME_FRAMEBORDER, HTML40Namespace.ATTR_NAME_MARGINWIDTH, HTML40Namespace.ATTR_NAME_MARGINHEIGHT, HTML40Namespace.ATTR_NAME_SCROLLING, HTML40Namespace.ATTR_NAME_HEIGHT, HTML40Namespace.ATTR_NAME_WIDTH}; + attributeCollection.getDeclarations(attributes, Arrays.asList(names).iterator()); + + // align + HTMLAttrDeclImpl attr = AttributeCollection.createAlignForImage(); + if (attr != null) + attributes.putNamedItem(HTML40Namespace.ATTR_NAME_ALIGN, attr); + } + + /** + */ + public CMNamedNodeMap getProhibitedAncestors() { + if (prohibitedAncestors != null) + return prohibitedAncestors; + + String[] names = {HTML40Namespace.ElementName.BUTTON}; + prohibitedAncestors = elementCollection.getDeclarations(names); + + return prohibitedAncestors; + } +}
\ No newline at end of file diff --git a/bundles/org.eclipse.wst.html.core/src/org/eclipse/wst/html/core/contentmodel/HedIMG.java b/bundles/org.eclipse.wst.html.core/src/org/eclipse/wst/html/core/contentmodel/HedIMG.java new file mode 100644 index 0000000000..b2244bde26 --- /dev/null +++ b/bundles/org.eclipse.wst.html.core/src/org/eclipse/wst/html/core/contentmodel/HedIMG.java @@ -0,0 +1,89 @@ +/******************************************************************************* + * Copyright (c) 2004 IBM Corporation and others. + * All rights reserved. This program and the accompanying materials + * are made available under the terms of the Eclipse Public License v1.0 + * which accompanies this distribution, and is available at + * http://www.eclipse.org/legal/epl-v10.html + * + * Contributors: + * IBM Corporation - initial API and implementation + *******************************************************************************/ +package org.eclipse.wst.html.core.contentmodel; + + + +import java.util.Arrays; + +import org.eclipse.wst.common.contentmodel.CMAttributeDeclaration; +import org.eclipse.wst.common.contentmodel.CMDataType; +import org.eclipse.wst.common.contentmodel.CMNamedNodeMap; +import org.eclipse.wst.html.core.HTML40Namespace; + +/** + * IMG. + */ +final class HedIMG extends HedEmpty { + + /** + */ + public HedIMG(ElementCollection collection) { + super(HTML40Namespace.ElementName.IMG, collection); + layoutType = LAYOUT_OBJECT; + } + + /** + * IMG. + * %attrs; + * (src %URI; #REQUIRED): should be defined locally. + * (alt %Text; #REQUIRED) + * (longdesc %URI; #IMPLIED) + * (name CDATA #IMPLIED) + * (height %Length; #IMPLIED) + * (width %Length; #IMPLIED) + * (usemap %URI; #IMPLIED) + * (ismap (ismap) #IMPLIED) + * (align %IAlign; #IMPLIED): should be defined locally. + * (border %Pixels; #IMPLIED) + * (hspace %Pixels; #IMPLIED) + * (vspace %Pixels; #IMPLIED) + * (mapfile %URI; #IMPLIED) + * @see com.ibm.sed.contentmodel.html.AbstractHTMLElemDeclImpl + */ + protected void createAttributeDeclarations() { + if (attributes != null) + return; // already created. + if (attributeCollection == null) + return; // fatal + + attributes = new CMNamedNodeMapImpl(); + + // %attrs; + attributeCollection.getAttrs(attributes); + + // (src %URI; #REQUIRED): should be defined locally. + HTMLCMDataTypeImpl atype = null; + HTMLAttrDeclImpl attr = null; + atype = new HTMLCMDataTypeImpl(CMDataType.URI); + attr = new HTMLAttrDeclImpl(HTML40Namespace.ATTR_NAME_SRC, atype, CMAttributeDeclaration.REQUIRED); + attributes.putNamedItem(HTML40Namespace.ATTR_NAME_SRC, attr); + + String[] names = {HTML40Namespace.ATTR_NAME_ALT, HTML40Namespace.ATTR_NAME_LONGDESC, HTML40Namespace.ATTR_NAME_NAME, HTML40Namespace.ATTR_NAME_HEIGHT, HTML40Namespace.ATTR_NAME_WIDTH, HTML40Namespace.ATTR_NAME_USEMAP, HTML40Namespace.ATTR_NAME_ISMAP, HTML40Namespace.ATTR_NAME_BORDER, HTML40Namespace.ATTR_NAME_HSPACE, HTML40Namespace.ATTR_NAME_VSPACE, HTML40Namespace.ATTR_NAME_MAPFILE}; + attributeCollection.getDeclarations(attributes, Arrays.asList(names).iterator()); + + // align (local); should be defined locally. + attr = AttributeCollection.createAlignForImage(); + attributes.putNamedItem(HTML40Namespace.ATTR_NAME_ALIGN, attr); + } + + /** + */ + public CMNamedNodeMap getProhibitedAncestors() { + if (prohibitedAncestors != null) + return prohibitedAncestors; + + String[] names = {HTML40Namespace.ElementName.PRE}; + prohibitedAncestors = elementCollection.getDeclarations(names); + + return prohibitedAncestors; + } +}
\ No newline at end of file diff --git a/bundles/org.eclipse.wst.html.core/src/org/eclipse/wst/html/core/contentmodel/HedINPUT.java b/bundles/org.eclipse.wst.html.core/src/org/eclipse/wst/html/core/contentmodel/HedINPUT.java new file mode 100644 index 0000000000..c1dc3d15b1 --- /dev/null +++ b/bundles/org.eclipse.wst.html.core/src/org/eclipse/wst/html/core/contentmodel/HedINPUT.java @@ -0,0 +1,122 @@ +/******************************************************************************* + * Copyright (c) 2004 IBM Corporation and others. + * All rights reserved. This program and the accompanying materials + * are made available under the terms of the Eclipse Public License v1.0 + * which accompanies this distribution, and is available at + * http://www.eclipse.org/legal/epl-v10.html + * + * Contributors: + * IBM Corporation - initial API and implementation + *******************************************************************************/ +package org.eclipse.wst.html.core.contentmodel; + + + +import java.util.Arrays; + +import org.eclipse.wst.common.contentmodel.CMAttributeDeclaration; +import org.eclipse.wst.common.contentmodel.CMDataType; +import org.eclipse.wst.common.contentmodel.CMNamedNodeMap; +import org.eclipse.wst.html.core.HTML40Namespace; + +/** + * INPUT. + */ +final class HedINPUT extends HedEmpty { + + /** + */ + public HedINPUT(ElementCollection collection) { + super(HTML40Namespace.ElementName.INPUT, collection); + layoutType = LAYOUT_OBJECT; + } + + /** + * INPUT. + * %attrs; + * (type %InputType; TEXT) ... should be defined locally. + * (name CDATA #IMPLIED) + * (value CDATA #IMPLIED) + * (checked (checked) #IMPLIED) + * (disabled (disabled) #IMPLIED) + * (readonly (readonly) #IMPLIED) + * (size CDATA #IMPLIED) ... should be defined locally. + * (maxlength NUMBER #IMPLIED) + * (src %URI; #IMPLIED) + * (alt CDATA #IMPLIED) ... should be defined locally. + * (usemap %URI; #IMPLIED) + * (ismap (ismap) #IMPLIED) + * (tabindex NUMBER #IMPLIED) + * (accesskey %Character; #IMPLIED) + * (onfocus %Script; #IMPLIED) + * (onblur %Script; #IMPLIED) + * (onselect %Script; #IMPLIED) + * (onchange %Script; #IMPLIED) + * (accept %ContentTypes; #IMPLIED) + * (align %IAlign; #IMPLIED) ... should be defined locally. + * (istyle CDATA #IMPLIED) + * <<D215684 + * (width CDATA; #IMPLIED) + * (height CDATA; #IMPLIED) + * (border CDATA; #IMPLIED) + * D215684 + */ + protected void createAttributeDeclarations() { + if (attributes != null) + return; // already created. + if (attributeCollection == null) + return; // fatal + + attributes = new CMNamedNodeMapImpl(); + + // %attrs; + attributeCollection.getAttrs(attributes); + + HTMLCMDataTypeImpl atype = null; + HTMLAttrDeclImpl attr = null; + // (type %InputType; TEXT) ... should be defined locally. + // NOTE: %InputType is ENUM; + // (text | password | checkbox | radio | submit | reset | + // file | hidden | image | button) + atype = new HTMLCMDataTypeImpl(CMDataType.ENUM); + String[] values = {HTML40Namespace.ATTR_VALUE_TEXT, HTML40Namespace.ATTR_VALUE_PASSWORD, HTML40Namespace.ATTR_VALUE_CHECKBOX, HTML40Namespace.ATTR_VALUE_RADIO, HTML40Namespace.ATTR_VALUE_SUBMIT, HTML40Namespace.ATTR_VALUE_RESET, HTML40Namespace.ATTR_VALUE_FILE, HTML40Namespace.ATTR_VALUE_HIDDEN, HTML40Namespace.ATTR_VALUE_IMAGE, HTML40Namespace.ATTR_VALUE_BUTTON}; + atype.setEnumValues(values); + atype.setImpliedValue(CMDataType.IMPLIED_VALUE_DEFAULT, HTML40Namespace.ATTR_VALUE_TEXT); + attr = new HTMLAttrDeclImpl(HTML40Namespace.ATTR_NAME_TYPE, atype, CMAttributeDeclaration.OPTIONAL); + attributes.putNamedItem(HTML40Namespace.ATTR_NAME_TYPE, attr); + + // (size CDATA #IMPLIED) ... should be defined locally. + atype = new HTMLCMDataTypeImpl(CMDataType.CDATA); + attr = new HTMLAttrDeclImpl(HTML40Namespace.ATTR_NAME_SIZE, atype, CMAttributeDeclaration.OPTIONAL); + attributes.putNamedItem(HTML40Namespace.ATTR_NAME_SIZE, attr); + + // (alt CDATA #IMPLIED) ... should be defined locally. + atype = new HTMLCMDataTypeImpl(CMDataType.CDATA); + attr = new HTMLAttrDeclImpl(HTML40Namespace.ATTR_NAME_ALT, atype, CMAttributeDeclaration.OPTIONAL); + attributes.putNamedItem(HTML40Namespace.ATTR_NAME_ALT, attr); + + // (align %IAlign; #IMPLIED) ... should be defined locally. + attr = AttributeCollection.createAlignForImage(); + attributes.putNamedItem(HTML40Namespace.ATTR_NAME_ALIGN, attr); + + // the rest. + String[] names = {HTML40Namespace.ATTR_NAME_NAME, HTML40Namespace.ATTR_NAME_VALUE, HTML40Namespace.ATTR_NAME_CHECKED, HTML40Namespace.ATTR_NAME_DISABLED, HTML40Namespace.ATTR_NAME_READONLY, HTML40Namespace.ATTR_NAME_SIZE, HTML40Namespace.ATTR_NAME_MAXLENGTH, HTML40Namespace.ATTR_NAME_SRC, HTML40Namespace.ATTR_NAME_ALT, HTML40Namespace.ATTR_NAME_USEMAP, HTML40Namespace.ATTR_NAME_ISMAP, HTML40Namespace.ATTR_NAME_TABINDEX, HTML40Namespace.ATTR_NAME_ACCESSKEY, HTML40Namespace.ATTR_NAME_ONFOCUS, HTML40Namespace.ATTR_NAME_ONBLUR, HTML40Namespace.ATTR_NAME_ONSELECT, HTML40Namespace.ATTR_NAME_ONCHANGE, HTML40Namespace.ATTR_NAME_ACCEPT, HTML40Namespace.ATTR_NAME_ALIGN, HTML40Namespace.ATTR_NAME_ISTYLE, + //<<D215684 + HTML40Namespace.ATTR_NAME_WIDTH, HTML40Namespace.ATTR_NAME_HEIGHT, HTML40Namespace.ATTR_NAME_BORDER + //<D215684 + }; + attributeCollection.getDeclarations(attributes, Arrays.asList(names).iterator()); + } + + /** + */ + public CMNamedNodeMap getProhibitedAncestors() { + if (prohibitedAncestors != null) + return prohibitedAncestors; + + String[] names = {HTML40Namespace.ElementName.BUTTON}; + prohibitedAncestors = elementCollection.getDeclarations(names); + + return prohibitedAncestors; + } +}
\ No newline at end of file diff --git a/bundles/org.eclipse.wst.html.core/src/org/eclipse/wst/html/core/contentmodel/HedISINDEX.java b/bundles/org.eclipse.wst.html.core/src/org/eclipse/wst/html/core/contentmodel/HedISINDEX.java new file mode 100644 index 0000000000..7f84d63662 --- /dev/null +++ b/bundles/org.eclipse.wst.html.core/src/org/eclipse/wst/html/core/contentmodel/HedISINDEX.java @@ -0,0 +1,65 @@ +/******************************************************************************* + * Copyright (c) 2004 IBM Corporation and others. + * All rights reserved. This program and the accompanying materials + * are made available under the terms of the Eclipse Public License v1.0 + * which accompanies this distribution, and is available at + * http://www.eclipse.org/legal/epl-v10.html + * + * Contributors: + * IBM Corporation - initial API and implementation + *******************************************************************************/ +package org.eclipse.wst.html.core.contentmodel; + + + +import org.eclipse.wst.common.contentmodel.CMNamedNodeMap; +import org.eclipse.wst.html.core.HTML40Namespace; + +/** + * ISINDEX. + */ +final class HedISINDEX extends HedEmpty { + + /** + */ + public HedISINDEX(ElementCollection collection) { + super(HTML40Namespace.ElementName.ISINDEX, collection); + layoutType = LAYOUT_BLOCK; + } + + /** + * ISINDEX. + * %coreattrs; + * %i18n; + * (prompt %Text; #IMPLIED) + */ + protected void createAttributeDeclarations() { + if (attributes != null) + return; // already created. + if (attributeCollection == null) + return; // fatal + + attributes = new CMNamedNodeMapImpl(); + + // %coreattrs; + attributeCollection.getCore(attributes); + // %i18n; + attributeCollection.getI18n(attributes); + + HTMLAttributeDeclaration attr = attributeCollection.getDeclaration(HTML40Namespace.ATTR_NAME_PROMPT); + if (attr != null) + attributes.putNamedItem(HTML40Namespace.ATTR_NAME_PROMPT, attr); + } + + /** + */ + public CMNamedNodeMap getProhibitedAncestors() { + if (prohibitedAncestors != null) + return prohibitedAncestors; + + String[] names = {HTML40Namespace.ElementName.BUTTON, HTML40Namespace.ElementName.DIR, HTML40Namespace.ElementName.MENU}; + prohibitedAncestors = elementCollection.getDeclarations(names); + + return prohibitedAncestors; + } +}
\ No newline at end of file diff --git a/bundles/org.eclipse.wst.html.core/src/org/eclipse/wst/html/core/contentmodel/HedInlineContainer.java b/bundles/org.eclipse.wst.html.core/src/org/eclipse/wst/html/core/contentmodel/HedInlineContainer.java new file mode 100644 index 0000000000..eb97a66570 --- /dev/null +++ b/bundles/org.eclipse.wst.html.core/src/org/eclipse/wst/html/core/contentmodel/HedInlineContainer.java @@ -0,0 +1,29 @@ +/******************************************************************************* + * Copyright (c) 2004 IBM Corporation and others. + * All rights reserved. This program and the accompanying materials + * are made available under the terms of the Eclipse Public License v1.0 + * which accompanies this distribution, and is available at + * http://www.eclipse.org/legal/epl-v10.html + * + * Contributors: + * IBM Corporation - initial API and implementation + *******************************************************************************/ +package org.eclipse.wst.html.core.contentmodel; + + + +/** + * Base class for (%inline;)* containers. + */ +abstract class HedInlineContainer extends HTMLElemDeclImpl { + + /** + * HedInlineContainer. + * @param elementName java.lang.String + * @param collection ElementCollection + */ + public HedInlineContainer(String elementName, ElementCollection collection) { + super(elementName, collection); + typeDefinitionName = ComplexTypeDefinitionFactory.CTYPE_INLINE_CONTAINER; + } +}
\ No newline at end of file diff --git a/bundles/org.eclipse.wst.html.core/src/org/eclipse/wst/html/core/contentmodel/HedLABEL.java b/bundles/org.eclipse.wst.html.core/src/org/eclipse/wst/html/core/contentmodel/HedLABEL.java new file mode 100644 index 0000000000..5251560714 --- /dev/null +++ b/bundles/org.eclipse.wst.html.core/src/org/eclipse/wst/html/core/contentmodel/HedLABEL.java @@ -0,0 +1,94 @@ +/******************************************************************************* + * Copyright (c) 2004 IBM Corporation and others. + * All rights reserved. This program and the accompanying materials + * are made available under the terms of the Eclipse Public License v1.0 + * which accompanies this distribution, and is available at + * http://www.eclipse.org/legal/epl-v10.html + * + * Contributors: + * IBM Corporation - initial API and implementation + *******************************************************************************/ +package org.eclipse.wst.html.core.contentmodel; + + + +import java.util.Arrays; + +import org.eclipse.wst.common.contentmodel.CMAttributeDeclaration; +import org.eclipse.wst.common.contentmodel.CMContent; +import org.eclipse.wst.common.contentmodel.CMDataType; +import org.eclipse.wst.common.contentmodel.CMGroup; +import org.eclipse.wst.common.contentmodel.CMNamedNodeMap; +import org.eclipse.wst.common.contentmodel.CMNode; +import org.eclipse.wst.html.core.HTML40Namespace; + +/** + * LABEL. + */ +final class HedLABEL extends HedInlineContainer { + + /** + */ + public HedLABEL(ElementCollection collection) { + super(HTML40Namespace.ElementName.LABEL, collection); + } + + /** + * %attrs; + * (for IDREF #IMPLIED) ... should be defined locally. + * (accesskey %Character; #IMPLIED) + * (onfocus %Script; #IMPLIED) + * (onblur %Script; #IMPLIED) + */ + protected void createAttributeDeclarations() { + if (attributes != null) + return; // already created. + if (attributeCollection == null) + return; // fatal + + attributes = new CMNamedNodeMapImpl(); + + // %attrs; + attributeCollection.getAttrs(attributes); + + // (for IDREF #IMPLIED) ... should be defined locally. + HTMLCMDataTypeImpl atype = new HTMLCMDataTypeImpl(CMDataType.IDREF); + HTMLAttrDeclImpl attr = new HTMLAttrDeclImpl(HTML40Namespace.ATTR_NAME_FOR, atype, CMAttributeDeclaration.OPTIONAL); + attributes.putNamedItem(HTML40Namespace.ATTR_NAME_FOR, attr); + + String[] names = {HTML40Namespace.ATTR_NAME_ACCESSKEY, HTML40Namespace.ATTR_NAME_ONFOCUS, HTML40Namespace.ATTR_NAME_ONBLUR}; + attributeCollection.getDeclarations(attributes, Arrays.asList(names).iterator()); + } + + /** + * Exclusion. + * <code>LABEL</code> has the exclusion. + * It is <code>LABEL</code> itself. + * @see com.ibm.sed.contentmodel.html.HTMLElementDeclaration + */ + public CMContent getExclusion() { + if (exclusion != null) + return exclusion; // already created. + if (elementCollection == null) + return null; + + exclusion = new CMGroupImpl(CMGroup.CHOICE, 1, 1); + CMNode label = elementCollection.getNamedItem(HTML40Namespace.ElementName.LABEL); + if (label != null) + exclusion.appendChild(label); + + return exclusion; + } + + /** + */ + public CMNamedNodeMap getProhibitedAncestors() { + if (prohibitedAncestors != null) + return prohibitedAncestors; + + String[] names = {HTML40Namespace.ElementName.BUTTON, HTML40Namespace.ElementName.LABEL}; + prohibitedAncestors = elementCollection.getDeclarations(names); + + return prohibitedAncestors; + } +}
\ No newline at end of file diff --git a/bundles/org.eclipse.wst.html.core/src/org/eclipse/wst/html/core/contentmodel/HedLEGEND.java b/bundles/org.eclipse.wst.html.core/src/org/eclipse/wst/html/core/contentmodel/HedLEGEND.java new file mode 100644 index 0000000000..138f7303a9 --- /dev/null +++ b/bundles/org.eclipse.wst.html.core/src/org/eclipse/wst/html/core/contentmodel/HedLEGEND.java @@ -0,0 +1,54 @@ +/******************************************************************************* + * Copyright (c) 2004 IBM Corporation and others. + * All rights reserved. This program and the accompanying materials + * are made available under the terms of the Eclipse Public License v1.0 + * which accompanies this distribution, and is available at + * http://www.eclipse.org/legal/epl-v10.html + * + * Contributors: + * IBM Corporation - initial API and implementation + *******************************************************************************/ +package org.eclipse.wst.html.core.contentmodel; + + + +import java.util.Arrays; + +import org.eclipse.wst.html.core.HTML40Namespace; + + +/** + * LEGEND. + */ +final class HedLEGEND extends HedInlineContainer { + + /** + */ + public HedLEGEND(ElementCollection collection) { + super(HTML40Namespace.ElementName.LEGEND, collection); + } + + /** + * (accesskey %Character; #IMPLIED) + * (align %LAlign; #IMPLIED) ... shuld be defined locally. + */ + protected void createAttributeDeclarations() { + if (attributes != null) + return; // already created. + if (attributeCollection == null) + return; // fatal + + attributes = new CMNamedNodeMapImpl(); + + // %attrs; + attributeCollection.getAttrs(attributes); + + String[] names = {HTML40Namespace.ATTR_NAME_ACCESSKEY}; + attributeCollection.getDeclarations(attributes, Arrays.asList(names).iterator()); + + // align + HTMLAttrDeclImpl attr = AttributeCollection.createAlignForLegend(); + if (attr != null) + attributes.putNamedItem(HTML40Namespace.ATTR_NAME_ALIGN, attr); + } +}
\ No newline at end of file diff --git a/bundles/org.eclipse.wst.html.core/src/org/eclipse/wst/html/core/contentmodel/HedLI.java b/bundles/org.eclipse.wst.html.core/src/org/eclipse/wst/html/core/contentmodel/HedLI.java new file mode 100644 index 0000000000..892af63cde --- /dev/null +++ b/bundles/org.eclipse.wst.html.core/src/org/eclipse/wst/html/core/contentmodel/HedLI.java @@ -0,0 +1,71 @@ +/******************************************************************************* + * Copyright (c) 2004 IBM Corporation and others. + * All rights reserved. This program and the accompanying materials + * are made available under the terms of the Eclipse Public License v1.0 + * which accompanies this distribution, and is available at + * http://www.eclipse.org/legal/epl-v10.html + * + * Contributors: + * IBM Corporation - initial API and implementation + *******************************************************************************/ +package org.eclipse.wst.html.core.contentmodel; + + + +import java.util.Arrays; +import java.util.Iterator; + +import org.eclipse.wst.common.contentmodel.CMAttributeDeclaration; +import org.eclipse.wst.common.contentmodel.CMDataType; +import org.eclipse.wst.html.core.HTML40Namespace; + +/** + * LI. + */ +final class HedLI extends HedFlowContainer { + + private static String[] terminators = {HTML40Namespace.ElementName.LI}; + + /** + */ + public HedLI(ElementCollection collection) { + super(HTML40Namespace.ElementName.LI, collection); + layoutType = LAYOUT_BLOCK; + omitType = OMIT_END_DEFAULT; + } + + /** + * %attrs; + * (type %LIStyle; #IMPLIED) ... should be defined locally. + * (value NUMBER #IMPLIED) ... should be defined locally. + */ + protected void createAttributeDeclarations() { + if (attributes != null) + return; // already created. + if (attributeCollection == null) + return; // fatal + + attributes = new CMNamedNodeMapImpl(); + + // %attrs; + attributeCollection.getAttrs(attributes); + + // (type %LIStyle; #IMPLIED) ... should be defined locally. + HTMLCMDataTypeImpl atype = new HTMLCMDataTypeImpl(HTMLCMDataType.LI_STYLE); + HTMLAttrDeclImpl attr = new HTMLAttrDeclImpl(HTML40Namespace.ATTR_NAME_TYPE, atype, CMAttributeDeclaration.OPTIONAL); + attributes.putNamedItem(HTML40Namespace.ATTR_NAME_TYPE, attr); + + // (value NUMBER #IMPLIED) ... should be defined locally. + atype = new HTMLCMDataTypeImpl(CMDataType.NUMBER); + attr = new HTMLAttrDeclImpl(HTML40Namespace.ATTR_NAME_VALUE, atype, CMAttributeDeclaration.OPTIONAL); + attributes.putNamedItem(HTML40Namespace.ATTR_NAME_VALUE, attr); + } + + /** + * LI has terminators. + * @return java.util.Iterator + */ + protected Iterator getTerminators() { + return Arrays.asList(terminators).iterator(); + } +}
\ No newline at end of file diff --git a/bundles/org.eclipse.wst.html.core/src/org/eclipse/wst/html/core/contentmodel/HedLINK.java b/bundles/org.eclipse.wst.html.core/src/org/eclipse/wst/html/core/contentmodel/HedLINK.java new file mode 100644 index 0000000000..7489b750f4 --- /dev/null +++ b/bundles/org.eclipse.wst.html.core/src/org/eclipse/wst/html/core/contentmodel/HedLINK.java @@ -0,0 +1,63 @@ +/******************************************************************************* + * Copyright (c) 2004 IBM Corporation and others. + * All rights reserved. This program and the accompanying materials + * are made available under the terms of the Eclipse Public License v1.0 + * which accompanies this distribution, and is available at + * http://www.eclipse.org/legal/epl-v10.html + * + * Contributors: + * IBM Corporation - initial API and implementation + *******************************************************************************/ +package org.eclipse.wst.html.core.contentmodel; + + + +import java.util.Arrays; + +import org.eclipse.wst.common.contentmodel.CMAttributeDeclaration; +import org.eclipse.wst.html.core.HTML40Namespace; + +/** + * LINK. + */ +final class HedLINK extends HedEmpty { + + /** + */ + public HedLINK(ElementCollection collection) { + super(HTML40Namespace.ElementName.LINK, collection); + layoutType = LAYOUT_HIDDEN; + } + + /** + * LINK. + * %attrs; + * (charset %Charset; #IMPLIED) + * (href %URI; #IMPLIED) + * (hreflang %LanguageCode; #IMPLIED) + * (type %ContentType; #IMPLIED): should be defined locally. + * (rel %LinkTypes; #IMPLIED) + * (rev %LinkTypes; #IMPLIED) + * (media %MediaDesc; #IMPLIED) + * (target %FrameTarget; #IMPLIED) + */ + protected void createAttributeDeclarations() { + if (attributes != null) + return; // already created. + if (attributeCollection == null) + return; // fatal + + attributes = new CMNamedNodeMapImpl(); + + // %attrs; + attributeCollection.getAttrs(attributes); + + String[] names = {HTML40Namespace.ATTR_NAME_CHARSET, HTML40Namespace.ATTR_NAME_HREF, HTML40Namespace.ATTR_NAME_HREFLANG, HTML40Namespace.ATTR_NAME_REL, HTML40Namespace.ATTR_NAME_REV, HTML40Namespace.ATTR_NAME_MEDIA, HTML40Namespace.ATTR_NAME_TARGET}; + attributeCollection.getDeclarations(attributes, Arrays.asList(names).iterator()); + + // (type %ContentType; #IMPLIED) + HTMLCMDataTypeImpl atype = new HTMLCMDataTypeImpl(HTMLCMDataType.CONTENT_TYPE); + HTMLAttrDeclImpl attr = new HTMLAttrDeclImpl(HTML40Namespace.ATTR_NAME_TYPE, atype, CMAttributeDeclaration.OPTIONAL); + attributes.putNamedItem(HTML40Namespace.ATTR_NAME_TYPE, attr); + } +}
\ No newline at end of file diff --git a/bundles/org.eclipse.wst.html.core/src/org/eclipse/wst/html/core/contentmodel/HedListItemContainer.java b/bundles/org.eclipse.wst.html.core/src/org/eclipse/wst/html/core/contentmodel/HedListItemContainer.java new file mode 100644 index 0000000000..875bb606c5 --- /dev/null +++ b/bundles/org.eclipse.wst.html.core/src/org/eclipse/wst/html/core/contentmodel/HedListItemContainer.java @@ -0,0 +1,30 @@ +/******************************************************************************* + * Copyright (c) 2004 IBM Corporation and others. + * All rights reserved. This program and the accompanying materials + * are made available under the terms of the Eclipse Public License v1.0 + * which accompanies this distribution, and is available at + * http://www.eclipse.org/legal/epl-v10.html + * + * Contributors: + * IBM Corporation - initial API and implementation + *******************************************************************************/ +package org.eclipse.wst.html.core.contentmodel; + + + +/** + * Base class for list item container declarations. + * - OL, UL, MENU, DIR. + */ +abstract class HedListItemContainer extends HTMLElemDeclImpl { + + /** + */ + public HedListItemContainer(String elementName, ElementCollection collection) { + super(elementName, collection); + typeDefinitionName = ComplexTypeDefinitionFactory.CTYPE_LI_CONTAINER; + correctionType = CORRECT_EMPTY; + layoutType = LAYOUT_BLOCK; + indentChild = true; + } +}
\ No newline at end of file diff --git a/bundles/org.eclipse.wst.html.core/src/org/eclipse/wst/html/core/contentmodel/HedMAP.java b/bundles/org.eclipse.wst.html.core/src/org/eclipse/wst/html/core/contentmodel/HedMAP.java new file mode 100644 index 0000000000..d167f6976d --- /dev/null +++ b/bundles/org.eclipse.wst.html.core/src/org/eclipse/wst/html/core/contentmodel/HedMAP.java @@ -0,0 +1,53 @@ +/******************************************************************************* + * Copyright (c) 2004 IBM Corporation and others. + * All rights reserved. This program and the accompanying materials + * are made available under the terms of the Eclipse Public License v1.0 + * which accompanies this distribution, and is available at + * http://www.eclipse.org/legal/epl-v10.html + * + * Contributors: + * IBM Corporation - initial API and implementation + *******************************************************************************/ +package org.eclipse.wst.html.core.contentmodel; + +import org.eclipse.wst.common.contentmodel.CMAttributeDeclaration; +import org.eclipse.wst.common.contentmodel.CMDataType; +import org.eclipse.wst.html.core.HTML40Namespace; + + + +/** + * MAP. + */ +final class HedMAP extends HTMLElemDeclImpl { + + /** + */ + public HedMAP(ElementCollection collection) { + super(HTML40Namespace.ElementName.MAP, collection); + typeDefinitionName = ComplexTypeDefinitionFactory.CTYPE_MAP; + layoutType = LAYOUT_OBJECT; + indentChild = true; + } + + /** + * %attrs; + * (name CDATA #REQUIRED) ... should be defined locally + */ + protected void createAttributeDeclarations() { + if (attributes != null) + return; // already created. + if (attributeCollection == null) + return; // fatal + + attributes = new CMNamedNodeMapImpl(); + + // %attrs; + attributeCollection.getAttrs(attributes); + + // (name CDATA #REQUIRED) ... should be defined locally + HTMLCMDataTypeImpl atype = new HTMLCMDataTypeImpl(CMDataType.CDATA); + HTMLAttrDeclImpl attr = new HTMLAttrDeclImpl(HTML40Namespace.ATTR_NAME_NAME, atype, CMAttributeDeclaration.REQUIRED); + attributes.putNamedItem(HTML40Namespace.ATTR_NAME_NAME, attr); + } +}
\ No newline at end of file diff --git a/bundles/org.eclipse.wst.html.core/src/org/eclipse/wst/html/core/contentmodel/HedMARQUEE.java b/bundles/org.eclipse.wst.html.core/src/org/eclipse/wst/html/core/contentmodel/HedMARQUEE.java new file mode 100644 index 0000000000..d9ab01cae4 --- /dev/null +++ b/bundles/org.eclipse.wst.html.core/src/org/eclipse/wst/html/core/contentmodel/HedMARQUEE.java @@ -0,0 +1,81 @@ +/******************************************************************************* + * Copyright (c) 2004 IBM Corporation and others. + * All rights reserved. This program and the accompanying materials + * are made available under the terms of the Eclipse Public License v1.0 + * which accompanies this distribution, and is available at + * http://www.eclipse.org/legal/epl-v10.html + * + * Contributors: + * IBM Corporation - initial API and implementation + *******************************************************************************/ +package org.eclipse.wst.html.core.contentmodel; + + + +import java.util.Arrays; + +import org.eclipse.wst.common.contentmodel.CMAttributeDeclaration; +import org.eclipse.wst.common.contentmodel.CMDataType; +import org.eclipse.wst.html.core.HTML40Namespace; + +/** + * MARQUEE. + */ +final class HedMARQUEE extends HedFlowContainer { + + /** + */ + public HedMARQUEE(ElementCollection collection) { + super(HTML40Namespace.ElementName.MARQUEE, collection); + layoutType = LAYOUT_OBJECT; + } + + /** + * %attrs; + * (behavior (scroll|slide|alternate) scroll) + * (bgcolor %Color; #IMPLIED) + * (direction (left|right|up|down) left) + * (height CDATA #IMPLIED) ... should be defined locally. + * (hspace NUMBER #IMPLIED) ... should be defined locally. + * (loop CDATA #IMPLIED) + * (scrollamount NUMBER #IMPLIED) + * (scrolldelay NUMBER #IMPLIED) + * (vspace NUMBER #IMPLIED) ... should be defined locally. + * (width CDATA #IMPLIED) ... should be defined locally. + * (truespeed (truespeed) #IMPLIED) + */ + protected void createAttributeDeclarations() { + if (attributes != null) + return; // already created. + if (attributeCollection == null) + return; // fatal + + attributes = new CMNamedNodeMapImpl(); + + // %attrs; + attributeCollection.getAttrs(attributes); + + String[] names = {HTML40Namespace.ATTR_NAME_BEHAVIOR, HTML40Namespace.ATTR_NAME_BGCOLOR, HTML40Namespace.ATTR_NAME_DIRECTION, HTML40Namespace.ATTR_NAME_LOOP, HTML40Namespace.ATTR_NAME_SCROLLAMOUNT, HTML40Namespace.ATTR_NAME_SCROLLDELAY, HTML40Namespace.ATTR_NAME_TRUESPEED}; + attributeCollection.getDeclarations(attributes, Arrays.asList(names).iterator()); + + HTMLCMDataTypeImpl atype = null; + HTMLAttrDeclImpl attr = null; + // (height CDATA #IMPLIED) ... should be defined locally. + atype = new HTMLCMDataTypeImpl(CMDataType.CDATA); + attr = new HTMLAttrDeclImpl(HTML40Namespace.ATTR_NAME_HEIGHT, atype, CMAttributeDeclaration.OPTIONAL); + attributes.putNamedItem(HTML40Namespace.ATTR_NAME_HEIGHT, attr); + + // (width CDATA #IMPLIED) ... should be defined locally. + attr = new HTMLAttrDeclImpl(HTML40Namespace.ATTR_NAME_WIDTH, atype, CMAttributeDeclaration.OPTIONAL); + attributes.putNamedItem(HTML40Namespace.ATTR_NAME_WIDTH, attr); + + // (hspace NUMBER #IMPLIED) ... should be defined locally. + atype = new HTMLCMDataTypeImpl(CMDataType.NUMBER); + attr = new HTMLAttrDeclImpl(HTML40Namespace.ATTR_NAME_HSPACE, atype, CMAttributeDeclaration.OPTIONAL); + attributes.putNamedItem(HTML40Namespace.ATTR_NAME_HSPACE, attr); + + // (vspace NUMBER #IMPLIED) ... should be defined locally. + attr = new HTMLAttrDeclImpl(HTML40Namespace.ATTR_NAME_VSPACE, atype, CMAttributeDeclaration.OPTIONAL); + attributes.putNamedItem(HTML40Namespace.ATTR_NAME_VSPACE, attr); + } +}
\ No newline at end of file diff --git a/bundles/org.eclipse.wst.html.core/src/org/eclipse/wst/html/core/contentmodel/HedMENU.java b/bundles/org.eclipse.wst.html.core/src/org/eclipse/wst/html/core/contentmodel/HedMENU.java new file mode 100644 index 0000000000..29f0456288 --- /dev/null +++ b/bundles/org.eclipse.wst.html.core/src/org/eclipse/wst/html/core/contentmodel/HedMENU.java @@ -0,0 +1,90 @@ +/******************************************************************************* + * Copyright (c) 2004 IBM Corporation and others. + * All rights reserved. This program and the accompanying materials + * are made available under the terms of the Eclipse Public License v1.0 + * which accompanies this distribution, and is available at + * http://www.eclipse.org/legal/epl-v10.html + * + * Contributors: + * IBM Corporation - initial API and implementation + *******************************************************************************/ +package org.eclipse.wst.html.core.contentmodel; + + + +import java.util.Arrays; + +import org.eclipse.wst.common.contentmodel.CMContent; +import org.eclipse.wst.common.contentmodel.CMGroup; +import org.eclipse.wst.common.contentmodel.CMNamedNodeMap; +import org.eclipse.wst.html.core.HTML40Namespace; + +/** + * MENU/DIR. + */ +final class HedMENU extends HedListItemContainer { + + /** + */ + public HedMENU(String elementName, ElementCollection collection) { + super(elementName, collection); + } + + /** + * MENU/DIR. + * (compact (compact) #IMPLIED) + */ + protected void createAttributeDeclarations() { + if (attributes != null) + return; // already created. + if (attributeCollection == null) + return; // fatal + + attributes = new CMNamedNodeMapImpl(); + + // %attrs; + attributeCollection.getAttrs(attributes); + + String[] names = {HTML40Namespace.ATTR_NAME_COMPACT}; + attributeCollection.getDeclarations(attributes, Arrays.asList(names).iterator()); + } + + /** + * Exclusion. + * <code>MENU/DIR</code> has the exclusion. + * It is <code>%block;</code>. + * %block; is: + * P | %heading; | %list; | %preformatted; | DL | DIV | CENTER | + * NOSCRIPT | NOFRAMES | BLOCKQUOTE | FORM | ISINDEX | HR | + * TABLE | FIELDSET | ADDRESS. + * %heading; is: H1 | H2 | H3 | H4 | H5 | H6. + * %list; is : UL | OL | DIR | MENU. + * %preformatted; is PRE. + * <br> + * @see com.ibm.sed.contentmodel.html.HTMLElementDeclaration + */ + public CMContent getExclusion() { + if (exclusion != null) + return exclusion; // already created. + if (elementCollection == null) + return null; + + // %block; + exclusion = new CMGroupImpl(CMGroup.CHOICE, 1, 1); + String[] names = {HTML40Namespace.ElementName.P, HTML40Namespace.ElementName.H1, HTML40Namespace.ElementName.H2, HTML40Namespace.ElementName.H3, HTML40Namespace.ElementName.H4, HTML40Namespace.ElementName.H5, HTML40Namespace.ElementName.H6, HTML40Namespace.ElementName.UL, HTML40Namespace.ElementName.OL, HTML40Namespace.ElementName.DIR, HTML40Namespace.ElementName.MENU, HTML40Namespace.ElementName.PRE, HTML40Namespace.ElementName.DL, HTML40Namespace.ElementName.DIV, HTML40Namespace.ElementName.CENTER, HTML40Namespace.ElementName.NOSCRIPT, HTML40Namespace.ElementName.NOFRAMES, HTML40Namespace.ElementName.BLOCKQUOTE, HTML40Namespace.ElementName.FORM, HTML40Namespace.ElementName.ISINDEX, HTML40Namespace.ElementName.HR, HTML40Namespace.ElementName.TABLE, HTML40Namespace.ElementName.FIELDSET, HTML40Namespace.ElementName.ADDRESS}; + elementCollection.getDeclarations(exclusion, Arrays.asList(names).iterator()); + return exclusion; + } + + /** + */ + public CMNamedNodeMap getProhibitedAncestors() { + if (prohibitedAncestors != null) + return prohibitedAncestors; + + String[] names = {HTML40Namespace.ElementName.DIR, HTML40Namespace.ElementName.MENU}; + prohibitedAncestors = elementCollection.getDeclarations(names); + + return prohibitedAncestors; + } +}
\ No newline at end of file diff --git a/bundles/org.eclipse.wst.html.core/src/org/eclipse/wst/html/core/contentmodel/HedMETA.java b/bundles/org.eclipse.wst.html.core/src/org/eclipse/wst/html/core/contentmodel/HedMETA.java new file mode 100644 index 0000000000..17f09b4f2c --- /dev/null +++ b/bundles/org.eclipse.wst.html.core/src/org/eclipse/wst/html/core/contentmodel/HedMETA.java @@ -0,0 +1,59 @@ +/******************************************************************************* + * Copyright (c) 2004 IBM Corporation and others. + * All rights reserved. This program and the accompanying materials + * are made available under the terms of the Eclipse Public License v1.0 + * which accompanies this distribution, and is available at + * http://www.eclipse.org/legal/epl-v10.html + * + * Contributors: + * IBM Corporation - initial API and implementation + *******************************************************************************/ +package org.eclipse.wst.html.core.contentmodel; + + + +import java.util.Arrays; + +import org.eclipse.wst.common.contentmodel.CMAttributeDeclaration; +import org.eclipse.wst.html.core.HTML40Namespace; + +/** + * META. + */ +final class HedMETA extends HedEmpty { + + /** + */ + public HedMETA(ElementCollection collection) { + super(HTML40Namespace.ElementName.META, collection); + layoutType = LAYOUT_HIDDEN; + } + + /** + * META. + * %i18n; + * (http-equiv NAME #IMPLIED) + * (name NAME #IMPLIED) ... should be defined locally. + * (content CDATA #REQUIRED) + * (scheme CDATA #IMPLIED) + */ + protected void createAttributeDeclarations() { + if (attributes != null) + return; // already created. + if (attributeCollection == null) + return; // fatal + + attributes = new CMNamedNodeMapImpl(); + + // %i18n; + attributeCollection.getI18n(attributes); + + // (name NAME #IMPLIED) ... should be defined locally. + HTMLCMDataTypeImpl atype = new HTMLCMDataTypeImpl(HTMLCMDataType.NAME); + HTMLAttrDeclImpl attr = new HTMLAttrDeclImpl(HTML40Namespace.ATTR_NAME_NAME, atype, CMAttributeDeclaration.OPTIONAL); + attributes.putNamedItem(HTML40Namespace.ATTR_NAME_NAME, attr); + + String[] names = {HTML40Namespace.ATTR_NAME_HTTP_EQUIV, HTML40Namespace.ATTR_NAME_CONTENT, HTML40Namespace.ATTR_NAME_SCHEME}; + attributeCollection.getDeclarations(attributes, Arrays.asList(names).iterator()); + } +}
\ No newline at end of file diff --git a/bundles/org.eclipse.wst.html.core/src/org/eclipse/wst/html/core/contentmodel/HedMarkChanges.java b/bundles/org.eclipse.wst.html.core/src/org/eclipse/wst/html/core/contentmodel/HedMarkChanges.java new file mode 100644 index 0000000000..e8bcc195ae --- /dev/null +++ b/bundles/org.eclipse.wst.html.core/src/org/eclipse/wst/html/core/contentmodel/HedMarkChanges.java @@ -0,0 +1,50 @@ +/******************************************************************************* + * Copyright (c) 2004 IBM Corporation and others. + * All rights reserved. This program and the accompanying materials + * are made available under the terms of the Eclipse Public License v1.0 + * which accompanies this distribution, and is available at + * http://www.eclipse.org/legal/epl-v10.html + * + * Contributors: + * IBM Corporation - initial API and implementation + *******************************************************************************/ +package org.eclipse.wst.html.core.contentmodel; + + + +import java.util.Arrays; + +import org.eclipse.wst.html.core.HTML40Namespace; + + +/** + * (INS|DEL) + */ +final class HedMarkChanges extends HedFlowContainer { + + /** + */ + public HedMarkChanges(String elementName, ElementCollection collection) { + super(elementName, collection); + } + + /** + * %attrs; + * (cite %URI; #IMPLIED) + * (datetime %Datetime; #IMPLIED) + */ + protected void createAttributeDeclarations() { + if (attributes != null) + return; // already created. + if (attributeCollection == null) + return; // fatal + + attributes = new CMNamedNodeMapImpl(); + + // %attrs; + attributeCollection.getAttrs(attributes); + + String[] names = {HTML40Namespace.ATTR_NAME_CITE, HTML40Namespace.ATTR_NAME_DATETIME}; + attributeCollection.getDeclarations(attributes, Arrays.asList(names).iterator()); + } +}
\ No newline at end of file diff --git a/bundles/org.eclipse.wst.html.core/src/org/eclipse/wst/html/core/contentmodel/HedNOBR.java b/bundles/org.eclipse.wst.html.core/src/org/eclipse/wst/html/core/contentmodel/HedNOBR.java new file mode 100644 index 0000000000..2b18887e9f --- /dev/null +++ b/bundles/org.eclipse.wst.html.core/src/org/eclipse/wst/html/core/contentmodel/HedNOBR.java @@ -0,0 +1,33 @@ +/******************************************************************************* + * Copyright (c) 2004 IBM Corporation and others. + * All rights reserved. This program and the accompanying materials + * are made available under the terms of the Eclipse Public License v1.0 + * which accompanies this distribution, and is available at + * http://www.eclipse.org/legal/epl-v10.html + * + * Contributors: + * IBM Corporation - initial API and implementation + *******************************************************************************/ +package org.eclipse.wst.html.core.contentmodel; + +import org.eclipse.wst.html.core.HTML40Namespace; + + +/** + * NOBR -- not standard tag but it is commonly used. + */ +final class HedNOBR extends HedInlineContainer { + + + public HedNOBR(ElementCollection collection) { + super(HTML40Namespace.ElementName.NOBR, collection); + correctionType = HTMLElementDeclaration.CORRECT_DUPLICATED; + } + + protected void createAttributeDeclarations() { + // No attributes is defined. + if (attributes != null) + return; + attributes = new CMNamedNodeMapImpl(); + } +}
\ No newline at end of file diff --git a/bundles/org.eclipse.wst.html.core/src/org/eclipse/wst/html/core/contentmodel/HedNOEMBED.java b/bundles/org.eclipse.wst.html.core/src/org/eclipse/wst/html/core/contentmodel/HedNOEMBED.java new file mode 100644 index 0000000000..821a3e542c --- /dev/null +++ b/bundles/org.eclipse.wst.html.core/src/org/eclipse/wst/html/core/contentmodel/HedNOEMBED.java @@ -0,0 +1,42 @@ +/******************************************************************************* + * Copyright (c) 2004 IBM Corporation and others. + * All rights reserved. This program and the accompanying materials + * are made available under the terms of the Eclipse Public License v1.0 + * which accompanies this distribution, and is available at + * http://www.eclipse.org/legal/epl-v10.html + * + * Contributors: + * IBM Corporation - initial API and implementation + *******************************************************************************/ +package org.eclipse.wst.html.core.contentmodel; + +import org.eclipse.wst.html.core.HTML40Namespace; + + + +/** + * NOEMBED. + */ +final class HedNOEMBED extends HedFlowContainer { + + /** + */ + public HedNOEMBED(ElementCollection collection) { + super(HTML40Namespace.ElementName.NOEMBED, collection); + } + + /** + * %coreattrs; + */ + protected void createAttributeDeclarations() { + if (attributes != null) + return; // already created. + if (attributeCollection == null) + return; // fatal + + attributes = new CMNamedNodeMapImpl(); + + // %coreattrs; + attributeCollection.getCore(attributes); + } +}
\ No newline at end of file diff --git a/bundles/org.eclipse.wst.html.core/src/org/eclipse/wst/html/core/contentmodel/HedNOFRAMES.java b/bundles/org.eclipse.wst.html.core/src/org/eclipse/wst/html/core/contentmodel/HedNOFRAMES.java new file mode 100644 index 0000000000..c780b6d353 --- /dev/null +++ b/bundles/org.eclipse.wst.html.core/src/org/eclipse/wst/html/core/contentmodel/HedNOFRAMES.java @@ -0,0 +1,80 @@ +/******************************************************************************* + * Copyright (c) 2004 IBM Corporation and others. + * All rights reserved. This program and the accompanying materials + * are made available under the terms of the Eclipse Public License v1.0 + * which accompanies this distribution, and is available at + * http://www.eclipse.org/legal/epl-v10.html + * + * Contributors: + * IBM Corporation - initial API and implementation + *******************************************************************************/ +package org.eclipse.wst.html.core.contentmodel; + + + +import org.eclipse.wst.common.contentmodel.CMContent; +import org.eclipse.wst.common.contentmodel.CMGroup; +import org.eclipse.wst.common.contentmodel.CMNamedNodeMap; +import org.eclipse.wst.common.contentmodel.CMNode; +import org.eclipse.wst.html.core.HTML40Namespace; + +/** + * NOFRAMES. + */ +final class HedNOFRAMES extends HTMLElemDeclImpl { + + /** + */ + public HedNOFRAMES(ElementCollection collection) { + super(HTML40Namespace.ElementName.NOFRAMES, collection); + typeDefinitionName = ComplexTypeDefinitionFactory.CTYPE_NOFRAMES_CONTENT; + layoutType = LAYOUT_HIDDEN; + } + + /** + * %attrs; + */ + protected void createAttributeDeclarations() { + if (attributes != null) + return; // already created. + if (attributeCollection == null) + return; // fatal + + attributes = new CMNamedNodeMapImpl(); + + // %attrs; + attributeCollection.getAttrs(attributes); + } + + /** + * Exclusion. + * <code>NOFRAMES</code> has the exclusion. + * It is <code>NOFRAMES</code> itself. + * @see com.ibm.sed.contentmodel.html.HTMLElementDeclaration + */ + public CMContent getExclusion() { + if (exclusion != null) + return exclusion; // already created. + if (elementCollection == null) + return null; + + exclusion = new CMGroupImpl(CMGroup.CHOICE, 1, 1); + CMNode label = elementCollection.getNamedItem(HTML40Namespace.ElementName.NOFRAMES); + if (label != null) + exclusion.appendChild(label); + + return exclusion; + } + + /** + */ + public CMNamedNodeMap getProhibitedAncestors() { + if (prohibitedAncestors != null) + return prohibitedAncestors; + + String[] names = {HTML40Namespace.ElementName.DIR, HTML40Namespace.ElementName.MENU, HTML40Namespace.ElementName.NOFRAMES}; + prohibitedAncestors = elementCollection.getDeclarations(names); + + return prohibitedAncestors; + } +}
\ No newline at end of file diff --git a/bundles/org.eclipse.wst.html.core/src/org/eclipse/wst/html/core/contentmodel/HedNOSCRIPT.java b/bundles/org.eclipse.wst.html.core/src/org/eclipse/wst/html/core/contentmodel/HedNOSCRIPT.java new file mode 100644 index 0000000000..a3d154c996 --- /dev/null +++ b/bundles/org.eclipse.wst.html.core/src/org/eclipse/wst/html/core/contentmodel/HedNOSCRIPT.java @@ -0,0 +1,56 @@ +/******************************************************************************* + * Copyright (c) 2004 IBM Corporation and others. + * All rights reserved. This program and the accompanying materials + * are made available under the terms of the Eclipse Public License v1.0 + * which accompanies this distribution, and is available at + * http://www.eclipse.org/legal/epl-v10.html + * + * Contributors: + * IBM Corporation - initial API and implementation + *******************************************************************************/ +package org.eclipse.wst.html.core.contentmodel; + + + +import org.eclipse.wst.common.contentmodel.CMNamedNodeMap; +import org.eclipse.wst.html.core.HTML40Namespace; + +/** + * NOSCRIPT. + */ +final class HedNOSCRIPT extends HedFlowContainer { + + /** + */ + public HedNOSCRIPT(ElementCollection collection) { + super(HTML40Namespace.ElementName.NOSCRIPT, collection); + layoutType = LAYOUT_BLOCK; + } + + /** + * %attrs; + */ + protected void createAttributeDeclarations() { + if (attributes != null) + return; // already created. + if (attributeCollection == null) + return; // fatal + + attributes = new CMNamedNodeMapImpl(); + + // %attrs; + attributeCollection.getAttrs(attributes); + } + + /** + */ + public CMNamedNodeMap getProhibitedAncestors() { + if (prohibitedAncestors != null) + return prohibitedAncestors; + + String[] names = {HTML40Namespace.ElementName.DIR, HTML40Namespace.ElementName.MENU}; + prohibitedAncestors = elementCollection.getDeclarations(names); + + return prohibitedAncestors; + } +}
\ No newline at end of file diff --git a/bundles/org.eclipse.wst.html.core/src/org/eclipse/wst/html/core/contentmodel/HedOBJECT.java b/bundles/org.eclipse.wst.html.core/src/org/eclipse/wst/html/core/contentmodel/HedOBJECT.java new file mode 100644 index 0000000000..a0b3c861f5 --- /dev/null +++ b/bundles/org.eclipse.wst.html.core/src/org/eclipse/wst/html/core/contentmodel/HedOBJECT.java @@ -0,0 +1,86 @@ +/******************************************************************************* + * Copyright (c) 2004 IBM Corporation and others. + * All rights reserved. This program and the accompanying materials + * are made available under the terms of the Eclipse Public License v1.0 + * which accompanies this distribution, and is available at + * http://www.eclipse.org/legal/epl-v10.html + * + * Contributors: + * IBM Corporation - initial API and implementation + *******************************************************************************/ +package org.eclipse.wst.html.core.contentmodel; + + + +import java.util.Arrays; + +import org.eclipse.wst.common.contentmodel.CMNamedNodeMap; +import org.eclipse.wst.html.core.HTML40Namespace; + +/** + * OBJECT. + */ +final class HedOBJECT extends HTMLElemDeclImpl { + + /** + */ + public HedOBJECT(ElementCollection collection) { + super(HTML40Namespace.ElementName.OBJECT, collection); + typeDefinitionName = ComplexTypeDefinitionFactory.CTYPE_PARAM_CONTAINER; + layoutType = LAYOUT_OBJECT; + indentChild = true; + } + + /** + * %attrs; + * %reserved; ... empty. + * (declare (declare) #IMPLIED) + * (classid %URI; #IMPLIED) + * (codebase %URI; #IMPLIED) + * (data %URI; #IMPLIED) + * (type %ContentType; #IMPLIED) + * (codetype %ContentType; #IMPLIED) + * (archive CDATA #IMPLIED) + * (standby %Text; #IMPLIED) + * (height %Length; #IMPLIED) + * (width %Length; #IMPLIED) + * (usemap %URI; #IMPLIED) + * (name CDATA #IMPLIED) + * (tabindex NUMBER #IMPLIED) + * (align %IAlign; #IMPLIED) ... should be defined locally. + * (border %Pixels; #IMPLIED) + * (hspace %Pixels; #IMPLIED) + * (vspace %Pixels; #IMPLIED) + */ + protected void createAttributeDeclarations() { + if (attributes != null) + return; // already created. + if (attributeCollection == null) + return; // fatal + + attributes = new CMNamedNodeMapImpl(); + + // %attrs; + attributeCollection.getAttrs(attributes); + // %reserved; ... empty. + + String[] names = {HTML40Namespace.ATTR_NAME_DECLARE, HTML40Namespace.ATTR_NAME_CLASSID, HTML40Namespace.ATTR_NAME_CODEBASE, HTML40Namespace.ATTR_NAME_DATA, HTML40Namespace.ATTR_NAME_TYPE, HTML40Namespace.ATTR_NAME_CODETYPE, HTML40Namespace.ATTR_NAME_ARCHIVE, HTML40Namespace.ATTR_NAME_STANDBY, HTML40Namespace.ATTR_NAME_HEIGHT, HTML40Namespace.ATTR_NAME_WIDTH, HTML40Namespace.ATTR_NAME_USEMAP, HTML40Namespace.ATTR_NAME_NAME, HTML40Namespace.ATTR_NAME_TABINDEX, HTML40Namespace.ATTR_NAME_BORDER, HTML40Namespace.ATTR_NAME_HSPACE, HTML40Namespace.ATTR_NAME_VSPACE}; + attributeCollection.getDeclarations(attributes, Arrays.asList(names).iterator()); + // %align; ... should be defined locally. + HTMLAttrDeclImpl attr = AttributeCollection.createAlignForImage(); + if (attr != null) + attributes.putNamedItem(HTML40Namespace.ATTR_NAME_ALIGN, attr); + } + + /** + */ + public CMNamedNodeMap getProhibitedAncestors() { + if (prohibitedAncestors != null) + return prohibitedAncestors; + + String[] names = {HTML40Namespace.ElementName.PRE}; + prohibitedAncestors = elementCollection.getDeclarations(names); + + return prohibitedAncestors; + } +}
\ No newline at end of file diff --git a/bundles/org.eclipse.wst.html.core/src/org/eclipse/wst/html/core/contentmodel/HedOL.java b/bundles/org.eclipse.wst.html.core/src/org/eclipse/wst/html/core/contentmodel/HedOL.java new file mode 100644 index 0000000000..8e4aa25ddc --- /dev/null +++ b/bundles/org.eclipse.wst.html.core/src/org/eclipse/wst/html/core/contentmodel/HedOL.java @@ -0,0 +1,70 @@ +/******************************************************************************* + * Copyright (c) 2004 IBM Corporation and others. + * All rights reserved. This program and the accompanying materials + * are made available under the terms of the Eclipse Public License v1.0 + * which accompanies this distribution, and is available at + * http://www.eclipse.org/legal/epl-v10.html + * + * Contributors: + * IBM Corporation - initial API and implementation + *******************************************************************************/ +package org.eclipse.wst.html.core.contentmodel; + + + +import java.util.Arrays; + +import org.eclipse.wst.common.contentmodel.CMAttributeDeclaration; +import org.eclipse.wst.common.contentmodel.CMNamedNodeMap; +import org.eclipse.wst.html.core.HTML40Namespace; + +/** + * OL. + */ +final class HedOL extends HedListItemContainer { + + /** + */ + public HedOL(ElementCollection collection) { + super(HTML40Namespace.ElementName.OL, collection); + } + + /** + * OL. + * (type %OLStyle; #IMPLIED) ... should be defined locally. + * (compact (compact) #IMPLIED) + * (start NUMBER #IMPLIED) + */ + protected void createAttributeDeclarations() { + if (attributes != null) + return; // already created. + if (attributeCollection == null) + return; // fatal + + attributes = new CMNamedNodeMapImpl(); + + // %attrs; + attributeCollection.getAttrs(attributes); + + // (type %OLStyle; #IMPLIED) ... should be defined locally. + HTMLCMDataTypeImpl atype = new HTMLCMDataTypeImpl(HTMLCMDataType.OL_STYLE); + HTMLAttrDeclImpl attr = new HTMLAttrDeclImpl(HTML40Namespace.ATTR_NAME_TYPE, atype, CMAttributeDeclaration.OPTIONAL); + attributes.putNamedItem(HTML40Namespace.ATTR_NAME_TYPE, attr); + + // the rest. + String[] names = {HTML40Namespace.ATTR_NAME_COMPACT, HTML40Namespace.ATTR_NAME_START}; + attributeCollection.getDeclarations(attributes, Arrays.asList(names).iterator()); + } + + /** + */ + public CMNamedNodeMap getProhibitedAncestors() { + if (prohibitedAncestors != null) + return prohibitedAncestors; + + String[] names = {HTML40Namespace.ElementName.DIR, HTML40Namespace.ElementName.MENU}; + prohibitedAncestors = elementCollection.getDeclarations(names); + + return prohibitedAncestors; + } +}
\ No newline at end of file diff --git a/bundles/org.eclipse.wst.html.core/src/org/eclipse/wst/html/core/contentmodel/HedOPTGROUP.java b/bundles/org.eclipse.wst.html.core/src/org/eclipse/wst/html/core/contentmodel/HedOPTGROUP.java new file mode 100644 index 0000000000..5ba00196b1 --- /dev/null +++ b/bundles/org.eclipse.wst.html.core/src/org/eclipse/wst/html/core/contentmodel/HedOPTGROUP.java @@ -0,0 +1,55 @@ +/******************************************************************************* + * Copyright (c) 2004 IBM Corporation and others. + * All rights reserved. This program and the accompanying materials + * are made available under the terms of the Eclipse Public License v1.0 + * which accompanies this distribution, and is available at + * http://www.eclipse.org/legal/epl-v10.html + * + * Contributors: + * IBM Corporation - initial API and implementation + *******************************************************************************/ +package org.eclipse.wst.html.core.contentmodel; + + + +import java.util.Arrays; + +import org.eclipse.wst.common.contentmodel.CMAttributeDeclaration; +import org.eclipse.wst.html.core.HTML40Namespace; + +/** + * OPTGROUP. + */ +final class HedOPTGROUP extends HTMLElemDeclImpl { + + /** + */ + public HedOPTGROUP(ElementCollection collection) { + super(HTML40Namespace.ElementName.OPTGROUP, collection); + typeDefinitionName = ComplexTypeDefinitionFactory.CTYPE_OPTION_CONTAINER; + layoutType = LAYOUT_HIDDEN; + indentChild = true; + } + + /** + * %attrs; + * (disabled (disabled) #IMPLIED) + * (label %Text; #REQUIRED) ... should be defined locally. + */ + protected void createAttributeDeclarations() { + if (attributes != null) + return; // already created. + attributes = new CMNamedNodeMapImpl(); + + // %attrs; + attributeCollection.getAttrs(attributes); + // (disabled (disabled) #IMPLIED) + String[] names = {HTML40Namespace.ATTR_NAME_DISABLED}; + attributeCollection.getDeclarations(attributes, Arrays.asList(names).iterator()); + + // (label %Text; #REQUIRED) ... should be defined locally. + HTMLCMDataTypeImpl atype = new HTMLCMDataTypeImpl(HTMLCMDataType.TEXT); + HTMLAttrDeclImpl attr = new HTMLAttrDeclImpl(HTML40Namespace.ATTR_NAME_LABEL, atype, CMAttributeDeclaration.REQUIRED); + attributes.putNamedItem(HTML40Namespace.ATTR_NAME_LABEL, attr); + } +}
\ No newline at end of file diff --git a/bundles/org.eclipse.wst.html.core/src/org/eclipse/wst/html/core/contentmodel/HedOPTION.java b/bundles/org.eclipse.wst.html.core/src/org/eclipse/wst/html/core/contentmodel/HedOPTION.java new file mode 100644 index 0000000000..9657f5ab9e --- /dev/null +++ b/bundles/org.eclipse.wst.html.core/src/org/eclipse/wst/html/core/contentmodel/HedOPTION.java @@ -0,0 +1,66 @@ +/******************************************************************************* + * Copyright (c) 2004 IBM Corporation and others. + * All rights reserved. This program and the accompanying materials + * are made available under the terms of the Eclipse Public License v1.0 + * which accompanies this distribution, and is available at + * http://www.eclipse.org/legal/epl-v10.html + * + * Contributors: + * IBM Corporation - initial API and implementation + *******************************************************************************/ +package org.eclipse.wst.html.core.contentmodel; + + + +import java.util.Arrays; +import java.util.Iterator; + +import org.eclipse.wst.html.core.HTML40Namespace; + + +/** + * OPTION. + */ +final class HedOPTION extends HedPcdata { + + private static String[] terminators = {HTML40Namespace.ElementName.OPTION}; + + /** + */ + public HedOPTION(ElementCollection collection) { + super(HTML40Namespace.ElementName.OPTION, collection); + layoutType = LAYOUT_HIDDEN; + omitType = OMIT_END; + } + + /** + * OPTION. + * %attrs; + * (selected (selected) #IMPLIED) + * (disabled (disabled) #IMPLIED) + * (label %Text; #IMPLIED) + * (value CDATA #IMPLIED) + */ + protected void createAttributeDeclarations() { + if (attributes != null) + return; // already created. + if (attributeCollection == null) + return; // fatal + + attributes = new CMNamedNodeMapImpl(); + + // %attrs; + attributeCollection.getAttrs(attributes); + + String[] names = {HTML40Namespace.ATTR_NAME_SELECTED, HTML40Namespace.ATTR_NAME_DISABLED, HTML40Namespace.ATTR_NAME_LABEL, HTML40Namespace.ATTR_NAME_VALUE}; + attributeCollection.getDeclarations(attributes, Arrays.asList(names).iterator()); + } + + /** + * OPTION has terminators. + * @return java.util.Iterator + */ + protected Iterator getTerminators() { + return Arrays.asList(terminators).iterator(); + } +}
\ No newline at end of file diff --git a/bundles/org.eclipse.wst.html.core/src/org/eclipse/wst/html/core/contentmodel/HedP.java b/bundles/org.eclipse.wst.html.core/src/org/eclipse/wst/html/core/contentmodel/HedP.java new file mode 100644 index 0000000000..492be84fca --- /dev/null +++ b/bundles/org.eclipse.wst.html.core/src/org/eclipse/wst/html/core/contentmodel/HedP.java @@ -0,0 +1,106 @@ +/******************************************************************************* + * Copyright (c) 2004 IBM Corporation and others. + * All rights reserved. This program and the accompanying materials + * are made available under the terms of the Eclipse Public License v1.0 + * which accompanies this distribution, and is available at + * http://www.eclipse.org/legal/epl-v10.html + * + * Contributors: + * IBM Corporation - initial API and implementation + *******************************************************************************/ +package org.eclipse.wst.html.core.contentmodel; + + + +import java.util.Collection; +import java.util.Iterator; +import java.util.Vector; + +import org.eclipse.wst.common.contentmodel.CMNamedNodeMap; +import org.eclipse.wst.html.core.HTML40Namespace; + +/** + * P. + */ +final class HedP extends HedInlineContainer { + + private static Collection terminators = null; + + /** + */ + public HedP(ElementCollection collection) { + super(HTML40Namespace.ElementName.P, collection); + correctionType = CORRECT_EMPTY; + layoutType = LAYOUT_BLOCK; + omitType = OMIT_END; + } + + /** + * Create all attribute declarations. + * This method is called once in the constructor of the super class. + * The <code>P</code> element may have the following attributes: + * <table> + * <tbody> + * <tr> + * <th>NAME</th><th>TYPE</th><th>USAGE</th><th>DEFAULT (INITIAL) VALUE</th><th>MEMO</th> + * </tr> + * <tr> + * <td>%attrs;</td><td>-</td><td>-</td><td>-</td><td>-</td> + * </tr> + * <tr> + * <td>%align;</td><td>-</td><td>-</td><td>-</td><td>-</td> + * </tr> + * </tbody> + * </table> + * <p><b>%align;</b> means <code>align (left|center|right|justify) #IMPLIED</code>. + * Unfortunately, this <code>align</code> is different from one in + * <code>IMG</code> or <code>TABLE</code>. So, the attribute declaration + * of <code>align</code> should be localy created and it shouldn't be registered + * in a <code>HCMDocImpl</code> instance.</p> + * <p>However, %align is used in sevaral times. I wouldn't write same code + * in many times. So, I add a new utility method into <code>CMUtil</code> + * to create the attribute declaration.</p> + * <br> + * @see com.ibm.sed.contentmodel.html.HTMLElemDeclImpl + */ + protected void createAttributeDeclarations() { + if (attributes != null) + return; // already created. + if (attributeCollection == null) + return; // fatal + attributes = new CMNamedNodeMapImpl(); + // %attrs; + attributeCollection.getAttrs(attributes); + // align + HTMLAttrDeclImpl adec = AttributeCollection.createAlignForParagraph(); + attributes.putNamedItem(HTML40Namespace.ATTR_NAME_ALIGN, adec); + } + + /** + */ + public CMNamedNodeMap getProhibitedAncestors() { + if (prohibitedAncestors != null) + return prohibitedAncestors; + String[] names = {HTML40Namespace.ElementName.DIR, HTML40Namespace.ElementName.MENU}; + prohibitedAncestors = elementCollection.getDeclarations(names); + return prohibitedAncestors; + } + + /** + * Return names of terminators. + * <code>P</code> has terminators. + * @return java.util.Iterator + */ + protected Iterator getTerminators() { + if (terminators != null) + return terminators.iterator(); + //<<D217982 + terminators = new Vector(); + terminators.addAll(elementCollection.getNamesOfBlock()); + terminators.add(HTML40Namespace.ElementName.LI); + terminators.add(HTML40Namespace.ElementName.DT); + terminators.add(HTML40Namespace.ElementName.DD); + //D217982 + return terminators.iterator(); + } +}
\ No newline at end of file diff --git a/bundles/org.eclipse.wst.html.core/src/org/eclipse/wst/html/core/contentmodel/HedPARAM.java b/bundles/org.eclipse.wst.html.core/src/org/eclipse/wst/html/core/contentmodel/HedPARAM.java new file mode 100644 index 0000000000..3b6c56bc98 --- /dev/null +++ b/bundles/org.eclipse.wst.html.core/src/org/eclipse/wst/html/core/contentmodel/HedPARAM.java @@ -0,0 +1,57 @@ +/******************************************************************************* + * Copyright (c) 2004 IBM Corporation and others. + * All rights reserved. This program and the accompanying materials + * are made available under the terms of the Eclipse Public License v1.0 + * which accompanies this distribution, and is available at + * http://www.eclipse.org/legal/epl-v10.html + * + * Contributors: + * IBM Corporation - initial API and implementation + *******************************************************************************/ +package org.eclipse.wst.html.core.contentmodel; + + + +import java.util.Arrays; + +import org.eclipse.wst.common.contentmodel.CMAttributeDeclaration; +import org.eclipse.wst.common.contentmodel.CMDataType; +import org.eclipse.wst.html.core.HTML40Namespace; + +/** + * PARAM. + */ +final class HedPARAM extends HedEmpty { + + /** + */ + public HedPARAM(ElementCollection collection) { + super(HTML40Namespace.ElementName.PARAM, collection); + layoutType = LAYOUT_HIDDEN; + } + + /** + * PARAM. + * (id ID #IMPLIED) + * (name CDATA #REQUIRED) ... should be defined locally. + * (value CDATA #IMPLIED) + * (valuetype (DATA|REF|OBJECT) DATA) + * (type %ContentType; #IMPLIED) + */ + protected void createAttributeDeclarations() { + if (attributes != null) + return; // already created. + if (attributeCollection == null) + return; // fatal + + attributes = new CMNamedNodeMapImpl(); + + String[] names = {HTML40Namespace.ATTR_NAME_ID, HTML40Namespace.ATTR_NAME_VALUE, HTML40Namespace.ATTR_NAME_VALUETYPE, HTML40Namespace.ATTR_NAME_TYPE}; + attributeCollection.getDeclarations(attributes, Arrays.asList(names).iterator()); + + // (name CDATA #REQUIRED) ... should be defined locally. + HTMLCMDataTypeImpl atype = new HTMLCMDataTypeImpl(CMDataType.CDATA); + HTMLAttrDeclImpl attr = new HTMLAttrDeclImpl(HTML40Namespace.ATTR_NAME_NAME, atype, CMAttributeDeclaration.REQUIRED); + attributes.putNamedItem(HTML40Namespace.ATTR_NAME_NAME, attr); + } +}
\ No newline at end of file diff --git a/bundles/org.eclipse.wst.html.core/src/org/eclipse/wst/html/core/contentmodel/HedPRE.java b/bundles/org.eclipse.wst.html.core/src/org/eclipse/wst/html/core/contentmodel/HedPRE.java new file mode 100644 index 0000000000..19c9019163 --- /dev/null +++ b/bundles/org.eclipse.wst.html.core/src/org/eclipse/wst/html/core/contentmodel/HedPRE.java @@ -0,0 +1,92 @@ +/******************************************************************************* + * Copyright (c) 2004 IBM Corporation and others. + * All rights reserved. This program and the accompanying materials + * are made available under the terms of the Eclipse Public License v1.0 + * which accompanies this distribution, and is available at + * http://www.eclipse.org/legal/epl-v10.html + * + * Contributors: + * IBM Corporation - initial API and implementation + *******************************************************************************/ +package org.eclipse.wst.html.core.contentmodel; + + + +import java.util.Arrays; + +import org.eclipse.wst.common.contentmodel.CMAttributeDeclaration; +import org.eclipse.wst.common.contentmodel.CMContent; +import org.eclipse.wst.common.contentmodel.CMDataType; +import org.eclipse.wst.common.contentmodel.CMGroup; +import org.eclipse.wst.common.contentmodel.CMNamedNodeMap; +import org.eclipse.wst.html.core.HTML40Namespace; + +/** + * PRE. + */ +final class HedPRE extends HedInlineContainer { + + /** + * PRE element should keep spaces in its source. + */ + public HedPRE(ElementCollection collection) { + super(HTML40Namespace.ElementName.PRE, collection); + // CORRECT_EMPTY - GROUP_COMPACT + correctionType = CORRECT_EMPTY; + + keepSpaces = true; + } + + /** + * %attrs; + * (width NUMBER #IMPLIED) ... should be defined locally. + */ + protected void createAttributeDeclarations() { + if (attributes != null) + return; // already created. + if (attributeCollection == null) + return; // fatal + + attributes = new CMNamedNodeMapImpl(); + + // %attrs; + attributeCollection.getAttrs(attributes); + // (width NUMBER #IMPLIED) ... should be defined locally. + HTMLCMDataTypeImpl atype = new HTMLCMDataTypeImpl(CMDataType.NUMBER); + HTMLAttrDeclImpl attr = new HTMLAttrDeclImpl(HTML40Namespace.ATTR_NAME_WIDTH, atype, CMAttributeDeclaration.OPTIONAL); + attributes.putNamedItem(HTML40Namespace.ATTR_NAME_WIDTH, attr); + } + + /** + * Exclusion. + * <code>PRE</code> has the exclusion. + * It is <code>%pre.exclusion;</code>. + * %pre.exclusion is: + * IMG | OBJECT | APPLET | BIG | SMALL | SUB | SUP | FONT | BASEFONT + * @see com.ibm.sed.contentmodel.html.HTMLElementDeclaration + */ + public CMContent getExclusion() { + if (exclusion != null) + return exclusion; // already created. + if (elementCollection == null) + return null; + + exclusion = new CMGroupImpl(CMGroup.CHOICE, 1, 1); + String[] names = {HTML40Namespace.ElementName.IMG, HTML40Namespace.ElementName.OBJECT, HTML40Namespace.ElementName.APPLET, HTML40Namespace.ElementName.BIG, HTML40Namespace.ElementName.SMALL, HTML40Namespace.ElementName.SUB, HTML40Namespace.ElementName.SUP, HTML40Namespace.ElementName.FONT, HTML40Namespace.ElementName.BASEFONT}; + elementCollection.getDeclarations(exclusion, Arrays.asList(names).iterator()); + + return exclusion; + } + + /** + */ + public CMNamedNodeMap getProhibitedAncestors() { + if (prohibitedAncestors != null) + return prohibitedAncestors; + + String[] names = {HTML40Namespace.ElementName.DIR, HTML40Namespace.ElementName.MENU}; + prohibitedAncestors = elementCollection.getDeclarations(names); + + return prohibitedAncestors; + } +}
\ No newline at end of file diff --git a/bundles/org.eclipse.wst.html.core/src/org/eclipse/wst/html/core/contentmodel/HedPcdata.java b/bundles/org.eclipse.wst.html.core/src/org/eclipse/wst/html/core/contentmodel/HedPcdata.java new file mode 100644 index 0000000000..b9d053d0d3 --- /dev/null +++ b/bundles/org.eclipse.wst.html.core/src/org/eclipse/wst/html/core/contentmodel/HedPcdata.java @@ -0,0 +1,47 @@ +/******************************************************************************* + * Copyright (c) 2004 IBM Corporation and others. + * All rights reserved. This program and the accompanying materials + * are made available under the terms of the Eclipse Public License v1.0 + * which accompanies this distribution, and is available at + * http://www.eclipse.org/legal/epl-v10.html + * + * Contributors: + * IBM Corporation - initial API and implementation + *******************************************************************************/ +package org.eclipse.wst.html.core.contentmodel; + + + +import org.eclipse.wst.common.contentmodel.CMContent; +import org.eclipse.wst.common.contentmodel.CMElementDeclaration; + +/** + * Base class for PCDATA type element declarations.<br> + */ +abstract class HedPcdata extends HTMLElemDeclImpl { + + /** + */ + public HedPcdata(String elementName, ElementCollection collection) { + super(elementName, collection); + typeDefinitionName = ComplexTypeDefinitionFactory.CTYPE_PCDATA; + } + + /** + * Content.<br> + * PCDATA type always returns <code>null</code>. + * <br> + * @return org.eclipse.wst.common.contentmodel.CMContent + */ + public CMContent getContent() { + return null; + } + + /** + * Content type.<br> + * @see org.eclipse.wst.common.contentmodel.CMElementDeclaration + */ + public int getContentType() { + return CMElementDeclaration.PCDATA; + } +}
\ No newline at end of file diff --git a/bundles/org.eclipse.wst.html.core/src/org/eclipse/wst/html/core/contentmodel/HedPhrase.java b/bundles/org.eclipse.wst.html.core/src/org/eclipse/wst/html/core/contentmodel/HedPhrase.java new file mode 100644 index 0000000000..e8e6cc1eb7 --- /dev/null +++ b/bundles/org.eclipse.wst.html.core/src/org/eclipse/wst/html/core/contentmodel/HedPhrase.java @@ -0,0 +1,42 @@ +/******************************************************************************* + * Copyright (c) 2004 IBM Corporation and others. + * All rights reserved. This program and the accompanying materials + * are made available under the terms of the Eclipse Public License v1.0 + * which accompanies this distribution, and is available at + * http://www.eclipse.org/legal/epl-v10.html + * + * Contributors: + * IBM Corporation - initial API and implementation + *******************************************************************************/ +package org.eclipse.wst.html.core.contentmodel; + + + +/** + * %phrase; + */ +final class HedPhrase extends HedInlineContainer { + + /** + */ + public HedPhrase(String elementName, ElementCollection collection) { + super(elementName, collection); + correctionType = HTMLElementDeclaration.CORRECT_DUPLICATED; + } + + /** + * %attrs; + * @see com.ibm.sed.contentmodel.html.HTMLElemDeclImpl + */ + protected void createAttributeDeclarations() { + if (attributes != null) + return; // already created. + if (attributeCollection == null) + return; // fatal + + attributes = new CMNamedNodeMapImpl(); + + // %attrs; + attributeCollection.getAttrs(attributes); + } +}
\ No newline at end of file diff --git a/bundles/org.eclipse.wst.html.core/src/org/eclipse/wst/html/core/contentmodel/HedQ.java b/bundles/org.eclipse.wst.html.core/src/org/eclipse/wst/html/core/contentmodel/HedQ.java new file mode 100644 index 0000000000..11bd04d484 --- /dev/null +++ b/bundles/org.eclipse.wst.html.core/src/org/eclipse/wst/html/core/contentmodel/HedQ.java @@ -0,0 +1,49 @@ +/******************************************************************************* + * Copyright (c) 2004 IBM Corporation and others. + * All rights reserved. This program and the accompanying materials + * are made available under the terms of the Eclipse Public License v1.0 + * which accompanies this distribution, and is available at + * http://www.eclipse.org/legal/epl-v10.html + * + * Contributors: + * IBM Corporation - initial API and implementation + *******************************************************************************/ +package org.eclipse.wst.html.core.contentmodel; + + + +import java.util.Arrays; + +import org.eclipse.wst.html.core.HTML40Namespace; + + +/** + * Q. + */ +final class HedQ extends HedInlineContainer { + + /** + */ + public HedQ(ElementCollection collection) { + super(HTML40Namespace.ElementName.Q, collection); + correctionType = CORRECT_DUPLICATED; + } + + /** + * %attrs; + * (cite %URI; #IMPLIED) + */ + protected void createAttributeDeclarations() { + if (attributes != null) + return; // already created. + if (attributeCollection == null) + return; // fatal + attributes = new CMNamedNodeMapImpl(); + + // %attrs; + attributeCollection.getAttrs(attributes); + + String[] names = {HTML40Namespace.ATTR_NAME_CITE}; + attributeCollection.getDeclarations(attributes, Arrays.asList(names).iterator()); + } +}
\ No newline at end of file diff --git a/bundles/org.eclipse.wst.html.core/src/org/eclipse/wst/html/core/contentmodel/HedSCRIPT.java b/bundles/org.eclipse.wst.html.core/src/org/eclipse/wst/html/core/contentmodel/HedSCRIPT.java new file mode 100644 index 0000000000..6a0153db86 --- /dev/null +++ b/bundles/org.eclipse.wst.html.core/src/org/eclipse/wst/html/core/contentmodel/HedSCRIPT.java @@ -0,0 +1,81 @@ +/******************************************************************************* + * Copyright (c) 2004 IBM Corporation and others. + * All rights reserved. This program and the accompanying materials + * are made available under the terms of the Eclipse Public License v1.0 + * which accompanies this distribution, and is available at + * http://www.eclipse.org/legal/epl-v10.html + * + * Contributors: + * IBM Corporation - initial API and implementation + *******************************************************************************/ +package org.eclipse.wst.html.core.contentmodel; + + + +import java.util.Arrays; + +import org.eclipse.wst.common.contentmodel.CMAttributeDeclaration; +import org.eclipse.wst.common.contentmodel.CMContent; +import org.eclipse.wst.common.contentmodel.CMDataType; +import org.eclipse.wst.common.contentmodel.CMElementDeclaration; +import org.eclipse.wst.html.core.HTML40Namespace; + +/** + * SCRIPT. + */ +final class HedSCRIPT extends HTMLElemDeclImpl { + + /** + */ + public HedSCRIPT(ElementCollection collection) { + super(HTML40Namespace.ElementName.SCRIPT, collection); + typeDefinitionName = ComplexTypeDefinitionFactory.CTYPE_CDATA; + layoutType = LAYOUT_OBJECT; + } + + /** + * SCRIPT. + * (charset %Charset; #IMPLIED) + * (type %ContentType; #REQUIRED) ... should be defined locally. + * (language CDATA #IMPLIED) + * (src %URI; #IMPLIED) + * (defer (defer) #IMPLIED) + * (event CDATA #IMPLIED) + * (for %URI; #IMPLIED) + */ + protected void createAttributeDeclarations() { + if (attributes != null) + return; // already created. + if (attributeCollection == null) + return; // fatal + + attributes = new CMNamedNodeMapImpl(); + + String[] names = {HTML40Namespace.ATTR_NAME_CHARSET, HTML40Namespace.ATTR_NAME_LANGUAGE, HTML40Namespace.ATTR_NAME_SRC, HTML40Namespace.ATTR_NAME_DEFER, HTML40Namespace.ATTR_NAME_EVENT, HTML40Namespace.ATTR_NAME_FOR}; + attributeCollection.getDeclarations(attributes, Arrays.asList(names).iterator()); + + // (type %ContentType; #REQUIRED) ... should be defined locally. + HTMLCMDataTypeImpl atype = new HTMLCMDataTypeImpl(HTMLCMDataType.CONTENT_TYPE); + atype.setImpliedValue(CMDataType.IMPLIED_VALUE_DEFAULT, "text/javascript"); //$NON-NLS-1$ + HTMLAttrDeclImpl attr = new HTMLAttrDeclImpl(HTML40Namespace.ATTR_NAME_TYPE, atype, CMAttributeDeclaration.REQUIRED); + attributes.putNamedItem(HTML40Namespace.ATTR_NAME_TYPE, attr); + } + + /** + * <code>SCRIPT</code> is CDATA type. + * So, the method always returns <code>null</code>. + * <br> + * @return org.eclipse.wst.common.contentmodel.CMContent + */ + public CMContent getContent() { + return null; + } + + /** + * CDATA content.<br> + * @return int + */ + public int getContentType() { + return CMElementDeclaration.CDATA; + } +}
\ No newline at end of file diff --git a/bundles/org.eclipse.wst.html.core/src/org/eclipse/wst/html/core/contentmodel/HedSELECT.java b/bundles/org.eclipse.wst.html.core/src/org/eclipse/wst/html/core/contentmodel/HedSELECT.java new file mode 100644 index 0000000000..3e7438e6d4 --- /dev/null +++ b/bundles/org.eclipse.wst.html.core/src/org/eclipse/wst/html/core/contentmodel/HedSELECT.java @@ -0,0 +1,79 @@ +/******************************************************************************* + * Copyright (c) 2004 IBM Corporation and others. + * All rights reserved. This program and the accompanying materials + * are made available under the terms of the Eclipse Public License v1.0 + * which accompanies this distribution, and is available at + * http://www.eclipse.org/legal/epl-v10.html + * + * Contributors: + * IBM Corporation - initial API and implementation + *******************************************************************************/ +package org.eclipse.wst.html.core.contentmodel; + + + +import java.util.Arrays; + +import org.eclipse.wst.common.contentmodel.CMAttributeDeclaration; +import org.eclipse.wst.common.contentmodel.CMDataType; +import org.eclipse.wst.common.contentmodel.CMNamedNodeMap; +import org.eclipse.wst.html.core.HTML40Namespace; + +/** + * SELECT. + */ +final class HedSELECT extends HTMLElemDeclImpl { + + /** + */ + public HedSELECT(ElementCollection collection) { + super(HTML40Namespace.ElementName.SELECT, collection); + typeDefinitionName = ComplexTypeDefinitionFactory.CTYPE_SELECT; + layoutType = LAYOUT_OBJECT; + indentChild = true; + } + + /** + * %attrs; + * %reserved; + * (name CDATA #IMPLIED) + * (size NUMBER #IMPLIED) ... should be defined locally. + * (multiple (multiple) #IMPLIED) + * (disabled (disabled) #IMPLIED) + * (tabindex NUMBER #IMPLIED) + * (onfocus %Script; #IMPLIED) + * (onblur %Script; #IMPLIED) + * (onchange %Script; #IMPLIED) + */ + protected void createAttributeDeclarations() { + if (attributes != null) + return; // already created. + if (attributeCollection == null) + return; // fatal + + attributes = new CMNamedNodeMapImpl(); + + // %attrs; + attributeCollection.getAttrs(attributes); + + // (size NUMBER #IMPLIED) ... should be defined locally. + HTMLCMDataTypeImpl atype = new HTMLCMDataTypeImpl(CMDataType.NUMBER); + HTMLAttrDeclImpl attr = new HTMLAttrDeclImpl(HTML40Namespace.ATTR_NAME_SIZE, atype, CMAttributeDeclaration.OPTIONAL); + attributes.putNamedItem(HTML40Namespace.ATTR_NAME_SIZE, attr); + + String[] names = {HTML40Namespace.ATTR_NAME_NAME, HTML40Namespace.ATTR_NAME_MULTIPLE, HTML40Namespace.ATTR_NAME_DISABLED, HTML40Namespace.ATTR_NAME_TABINDEX, HTML40Namespace.ATTR_NAME_ONFOCUS, HTML40Namespace.ATTR_NAME_ONBLUR, HTML40Namespace.ATTR_NAME_ONCHANGE}; + attributeCollection.getDeclarations(attributes, Arrays.asList(names).iterator()); + } + + /** + */ + public CMNamedNodeMap getProhibitedAncestors() { + if (prohibitedAncestors != null) + return prohibitedAncestors; + + String[] names = {HTML40Namespace.ElementName.BUTTON}; + prohibitedAncestors = elementCollection.getDeclarations(names); + + return prohibitedAncestors; + } +}
\ No newline at end of file diff --git a/bundles/org.eclipse.wst.html.core/src/org/eclipse/wst/html/core/contentmodel/HedSPAN.java b/bundles/org.eclipse.wst.html.core/src/org/eclipse/wst/html/core/contentmodel/HedSPAN.java new file mode 100644 index 0000000000..b1fc4f5818 --- /dev/null +++ b/bundles/org.eclipse.wst.html.core/src/org/eclipse/wst/html/core/contentmodel/HedSPAN.java @@ -0,0 +1,44 @@ +/******************************************************************************* + * Copyright (c) 2004 IBM Corporation and others. + * All rights reserved. This program and the accompanying materials + * are made available under the terms of the Eclipse Public License v1.0 + * which accompanies this distribution, and is available at + * http://www.eclipse.org/legal/epl-v10.html + * + * Contributors: + * IBM Corporation - initial API and implementation + *******************************************************************************/ +package org.eclipse.wst.html.core.contentmodel; + +import org.eclipse.wst.html.core.HTML40Namespace; + + + +/** + * SPAN. + */ +final class HedSPAN extends HedInlineContainer { + + /** + * SPAN. + */ + public HedSPAN(ElementCollection collection) { + super(HTML40Namespace.ElementName.SPAN, collection); + } + + /** + * %attrs; + * %reserved; ... empty. + */ + protected void createAttributeDeclarations() { + if (attributes != null) + return; // already created. + if (attributeCollection == null) + return; // fatal + + attributes = new CMNamedNodeMapImpl(); + + // %attrs; + attributeCollection.getAttrs(attributes); + } +}
\ No newline at end of file diff --git a/bundles/org.eclipse.wst.html.core/src/org/eclipse/wst/html/core/contentmodel/HedSSIBase.java b/bundles/org.eclipse.wst.html.core/src/org/eclipse/wst/html/core/contentmodel/HedSSIBase.java new file mode 100644 index 0000000000..7a0bee45b5 --- /dev/null +++ b/bundles/org.eclipse.wst.html.core/src/org/eclipse/wst/html/core/contentmodel/HedSSIBase.java @@ -0,0 +1,50 @@ +/******************************************************************************* + * Copyright (c) 2004 IBM Corporation and others. + * All rights reserved. This program and the accompanying materials + * are made available under the terms of the Eclipse Public License v1.0 + * which accompanies this distribution, and is available at + * http://www.eclipse.org/legal/epl-v10.html + * + * Contributors: + * IBM Corporation - initial API and implementation + *******************************************************************************/ +package org.eclipse.wst.html.core.contentmodel; + +import org.eclipse.wst.html.core.HTMLCMProperties; + + + +/** + * Base class for SSI declarations. + */ +abstract class HedSSIBase extends HedEmpty { + + /** + */ + public HedSSIBase(String elementName, ElementCollection collection) { + super(elementName, collection); + layoutType = LAYOUT_OBJECT; + } + + /** + */ + public int getFormatType() { + return HTMLElementDeclaration.FORMAT_SSI; + } + + /** + */ + public boolean supports(String propName) { + if (propName.equals(HTMLCMProperties.IS_SSI)) + return true; + return super.supports(propName); + } + + /* + */ + public Object getProperty(String propName) { + if (propName.equals(HTMLCMProperties.IS_SSI)) + return new Boolean(true); + return super.getProperty(propName); + } +}
\ No newline at end of file diff --git a/bundles/org.eclipse.wst.html.core/src/org/eclipse/wst/html/core/contentmodel/HedSSIConfig.java b/bundles/org.eclipse.wst.html.core/src/org/eclipse/wst/html/core/contentmodel/HedSSIConfig.java new file mode 100644 index 0000000000..af32153a04 --- /dev/null +++ b/bundles/org.eclipse.wst.html.core/src/org/eclipse/wst/html/core/contentmodel/HedSSIConfig.java @@ -0,0 +1,48 @@ +/******************************************************************************* + * Copyright (c) 2004 IBM Corporation and others. + * All rights reserved. This program and the accompanying materials + * are made available under the terms of the Eclipse Public License v1.0 + * which accompanies this distribution, and is available at + * http://www.eclipse.org/legal/epl-v10.html + * + * Contributors: + * IBM Corporation - initial API and implementation + *******************************************************************************/ +package org.eclipse.wst.html.core.contentmodel; + + + +import java.util.Arrays; + +import org.eclipse.wst.html.core.HTML40Namespace; + + +/** + * SSI:CONFIG. + */ +final class HedSSIConfig extends HedSSIBase { + + /** + */ + public HedSSIConfig(ElementCollection collection) { + super(HTML40Namespace.ElementName.SSI_CONFIG, collection); + } + + /** + * SSI:CONFIG. + * (errmsg CDATA #IMPLIED) + * (sizefmt CDATA #IMPLIED) + * (timefmt CDATA #IMPLIED) + */ + protected void createAttributeDeclarations() { + if (attributes != null) + return; // already created. + if (attributeCollection == null) + return; // fatal + + attributes = new CMNamedNodeMapImpl(); + + String[] names = {HTML40Namespace.ATTR_NAME_ERRMSG, HTML40Namespace.ATTR_NAME_SIZEFMT, HTML40Namespace.ATTR_NAME_TIMEFMT}; + attributeCollection.getDeclarations(attributes, Arrays.asList(names).iterator()); + } +}
\ No newline at end of file diff --git a/bundles/org.eclipse.wst.html.core/src/org/eclipse/wst/html/core/contentmodel/HedSSIEcho.java b/bundles/org.eclipse.wst.html.core/src/org/eclipse/wst/html/core/contentmodel/HedSSIEcho.java new file mode 100644 index 0000000000..3e958d1d97 --- /dev/null +++ b/bundles/org.eclipse.wst.html.core/src/org/eclipse/wst/html/core/contentmodel/HedSSIEcho.java @@ -0,0 +1,46 @@ +/******************************************************************************* + * Copyright (c) 2004 IBM Corporation and others. + * All rights reserved. This program and the accompanying materials + * are made available under the terms of the Eclipse Public License v1.0 + * which accompanies this distribution, and is available at + * http://www.eclipse.org/legal/epl-v10.html + * + * Contributors: + * IBM Corporation - initial API and implementation + *******************************************************************************/ +package org.eclipse.wst.html.core.contentmodel; + + + +import java.util.Arrays; + +import org.eclipse.wst.html.core.HTML40Namespace; + + +/** + * SSI:ECHO. + */ +final class HedSSIEcho extends HedSSIBase { + + /** + */ + public HedSSIEcho(ElementCollection collection) { + super(HTML40Namespace.ElementName.SSI_ECHO, collection); + } + + /** + * SSI:ECHO + * (var CDATA #IMPLIED) + */ + protected void createAttributeDeclarations() { + if (attributes != null) + return; // already created. + if (attributeCollection == null) + return; // fatal + + attributes = new CMNamedNodeMapImpl(); + + String[] names = {HTML40Namespace.ATTR_NAME_VAR}; + attributeCollection.getDeclarations(attributes, Arrays.asList(names).iterator()); + } +}
\ No newline at end of file diff --git a/bundles/org.eclipse.wst.html.core/src/org/eclipse/wst/html/core/contentmodel/HedSSIExec.java b/bundles/org.eclipse.wst.html.core/src/org/eclipse/wst/html/core/contentmodel/HedSSIExec.java new file mode 100644 index 0000000000..6d18d97464 --- /dev/null +++ b/bundles/org.eclipse.wst.html.core/src/org/eclipse/wst/html/core/contentmodel/HedSSIExec.java @@ -0,0 +1,47 @@ +/******************************************************************************* + * Copyright (c) 2004 IBM Corporation and others. + * All rights reserved. This program and the accompanying materials + * are made available under the terms of the Eclipse Public License v1.0 + * which accompanies this distribution, and is available at + * http://www.eclipse.org/legal/epl-v10.html + * + * Contributors: + * IBM Corporation - initial API and implementation + *******************************************************************************/ +package org.eclipse.wst.html.core.contentmodel; + + + +import java.util.Arrays; + +import org.eclipse.wst.html.core.HTML40Namespace; + + +/** + * SSI:EXEC. + */ +final class HedSSIExec extends HedSSIBase { + + /** + */ + public HedSSIExec(ElementCollection collection) { + super(HTML40Namespace.ElementName.SSI_EXEC, collection); + } + + /** + * SSI:EXEC + * (cgi %URI; #IMPLIED) + * (cmd CDATA #IMPLIED) + */ + protected void createAttributeDeclarations() { + if (attributes != null) + return; // already created. + if (attributeCollection == null) + return; // fatal + + attributes = new CMNamedNodeMapImpl(); + + String[] names = {HTML40Namespace.ATTR_NAME_CGI, HTML40Namespace.ATTR_NAME_CMD}; + attributeCollection.getDeclarations(attributes, Arrays.asList(names).iterator()); + } +}
\ No newline at end of file diff --git a/bundles/org.eclipse.wst.html.core/src/org/eclipse/wst/html/core/contentmodel/HedSSIFlastmod.java b/bundles/org.eclipse.wst.html.core/src/org/eclipse/wst/html/core/contentmodel/HedSSIFlastmod.java new file mode 100644 index 0000000000..e2092e088f --- /dev/null +++ b/bundles/org.eclipse.wst.html.core/src/org/eclipse/wst/html/core/contentmodel/HedSSIFlastmod.java @@ -0,0 +1,47 @@ +/******************************************************************************* + * Copyright (c) 2004 IBM Corporation and others. + * All rights reserved. This program and the accompanying materials + * are made available under the terms of the Eclipse Public License v1.0 + * which accompanies this distribution, and is available at + * http://www.eclipse.org/legal/epl-v10.html + * + * Contributors: + * IBM Corporation - initial API and implementation + *******************************************************************************/ +package org.eclipse.wst.html.core.contentmodel; + + + +import java.util.Arrays; + +import org.eclipse.wst.html.core.HTML40Namespace; + + +/** + * SSI:FLASTMOD. + */ +final class HedSSIFlastmod extends HedSSIBase { + + /** + */ + public HedSSIFlastmod(ElementCollection collection) { + super(HTML40Namespace.ElementName.SSI_FLASTMOD, collection); + } + + /** + * SSI:FLASTMOD + * (file %URI; #IMPLIED) + * (virtual %URI #IMPLIED) + */ + protected void createAttributeDeclarations() { + if (attributes != null) + return; // already created. + if (attributeCollection == null) + return; // fatal + + attributes = new CMNamedNodeMapImpl(); + + String[] names = {HTML40Namespace.ATTR_NAME_FILE, HTML40Namespace.ATTR_NAME_VIRTUAL}; + attributeCollection.getDeclarations(attributes, Arrays.asList(names).iterator()); + } +}
\ No newline at end of file diff --git a/bundles/org.eclipse.wst.html.core/src/org/eclipse/wst/html/core/contentmodel/HedSSIFsize.java b/bundles/org.eclipse.wst.html.core/src/org/eclipse/wst/html/core/contentmodel/HedSSIFsize.java new file mode 100644 index 0000000000..bcb7cb4b02 --- /dev/null +++ b/bundles/org.eclipse.wst.html.core/src/org/eclipse/wst/html/core/contentmodel/HedSSIFsize.java @@ -0,0 +1,47 @@ +/******************************************************************************* + * Copyright (c) 2004 IBM Corporation and others. + * All rights reserved. This program and the accompanying materials + * are made available under the terms of the Eclipse Public License v1.0 + * which accompanies this distribution, and is available at + * http://www.eclipse.org/legal/epl-v10.html + * + * Contributors: + * IBM Corporation - initial API and implementation + *******************************************************************************/ +package org.eclipse.wst.html.core.contentmodel; + + + +import java.util.Arrays; + +import org.eclipse.wst.html.core.HTML40Namespace; + + +/** + * SSI:FSIZE. + */ +final class HedSSIFsize extends HedSSIBase { + + /** + */ + public HedSSIFsize(ElementCollection collection) { + super(HTML40Namespace.ElementName.SSI_FSIZE, collection); + } + + /** + * SSI:FSIZE + * (file %URI; #IMPLIED) + * (virtual %URI #IMPLIED) + */ + protected void createAttributeDeclarations() { + if (attributes != null) + return; // already created. + if (attributeCollection == null) + return; // fatal + + attributes = new CMNamedNodeMapImpl(); + + String[] names = {HTML40Namespace.ATTR_NAME_FILE, HTML40Namespace.ATTR_NAME_VIRTUAL}; + attributeCollection.getDeclarations(attributes, Arrays.asList(names).iterator()); + } +}
\ No newline at end of file diff --git a/bundles/org.eclipse.wst.html.core/src/org/eclipse/wst/html/core/contentmodel/HedSSIInclude.java b/bundles/org.eclipse.wst.html.core/src/org/eclipse/wst/html/core/contentmodel/HedSSIInclude.java new file mode 100644 index 0000000000..a14459f702 --- /dev/null +++ b/bundles/org.eclipse.wst.html.core/src/org/eclipse/wst/html/core/contentmodel/HedSSIInclude.java @@ -0,0 +1,47 @@ +/******************************************************************************* + * Copyright (c) 2004 IBM Corporation and others. + * All rights reserved. This program and the accompanying materials + * are made available under the terms of the Eclipse Public License v1.0 + * which accompanies this distribution, and is available at + * http://www.eclipse.org/legal/epl-v10.html + * + * Contributors: + * IBM Corporation - initial API and implementation + *******************************************************************************/ +package org.eclipse.wst.html.core.contentmodel; + + + +import java.util.Arrays; + +import org.eclipse.wst.html.core.HTML40Namespace; + + +/** + * SSI:INCLUDE. + */ +final class HedSSIInclude extends HedSSIBase { + + /** + */ + public HedSSIInclude(ElementCollection collection) { + super(HTML40Namespace.ElementName.SSI_INCLUDE, collection); + } + + /** + * SSI:INCLUDE + * (file %URI; #IMPLIED) + * (virtual %URI #IMPLIED) + */ + protected void createAttributeDeclarations() { + if (attributes != null) + return; // already created. + if (attributeCollection == null) + return; // fatal + + attributes = new CMNamedNodeMapImpl(); + + String[] names = {HTML40Namespace.ATTR_NAME_FILE, HTML40Namespace.ATTR_NAME_VIRTUAL}; + attributeCollection.getDeclarations(attributes, Arrays.asList(names).iterator()); + } +}
\ No newline at end of file diff --git a/bundles/org.eclipse.wst.html.core/src/org/eclipse/wst/html/core/contentmodel/HedSSIPrintenv.java b/bundles/org.eclipse.wst.html.core/src/org/eclipse/wst/html/core/contentmodel/HedSSIPrintenv.java new file mode 100644 index 0000000000..29b4ed9e10 --- /dev/null +++ b/bundles/org.eclipse.wst.html.core/src/org/eclipse/wst/html/core/contentmodel/HedSSIPrintenv.java @@ -0,0 +1,49 @@ +/******************************************************************************* + * Copyright (c) 2004 IBM Corporation and others. + * All rights reserved. This program and the accompanying materials + * are made available under the terms of the Eclipse Public License v1.0 + * which accompanies this distribution, and is available at + * http://www.eclipse.org/legal/epl-v10.html + * + * Contributors: + * IBM Corporation - initial API and implementation + *******************************************************************************/ +package org.eclipse.wst.html.core.contentmodel; + + + +import org.eclipse.wst.common.contentmodel.CMNamedNodeMap; +import org.eclipse.wst.html.core.HTML40Namespace; + +/** + * SSI:PRINTENV. + */ +final class HedSSIPrintenv extends HedSSIBase { + + /** + */ + public HedSSIPrintenv(ElementCollection collection) { + super(HTML40Namespace.ElementName.SSI_PRINTENV, collection); + } + + /** + */ + protected void createAttributeDeclarations() { + if (attributes != null) + return; // already created. + if (attributeCollection == null) + return; // fatal + + attributes = new CMNamedNodeMapImpl(); + } + + /** + * SSI:PRINTENV has no attributes. So, this method should + * always return <code>null</code>. + * Note: Since somebody doesn't expect null is returned, return the empty attribute + * like a custom tag which doesn't have attributes + */ + public CMNamedNodeMap getAttributes() { + return super.getAttributes(); + } +}
\ No newline at end of file diff --git a/bundles/org.eclipse.wst.html.core/src/org/eclipse/wst/html/core/contentmodel/HedSSISet.java b/bundles/org.eclipse.wst.html.core/src/org/eclipse/wst/html/core/contentmodel/HedSSISet.java new file mode 100644 index 0000000000..2ac31d4f64 --- /dev/null +++ b/bundles/org.eclipse.wst.html.core/src/org/eclipse/wst/html/core/contentmodel/HedSSISet.java @@ -0,0 +1,47 @@ +/******************************************************************************* + * Copyright (c) 2004 IBM Corporation and others. + * All rights reserved. This program and the accompanying materials + * are made available under the terms of the Eclipse Public License v1.0 + * which accompanies this distribution, and is available at + * http://www.eclipse.org/legal/epl-v10.html + * + * Contributors: + * IBM Corporation - initial API and implementation + *******************************************************************************/ +package org.eclipse.wst.html.core.contentmodel; + + + +import java.util.Arrays; + +import org.eclipse.wst.html.core.HTML40Namespace; + + +/** + * SSI:SET. + */ +final class HedSSISet extends HedSSIBase { + + /** + */ + public HedSSISet(ElementCollection collection) { + super(HTML40Namespace.ElementName.SSI_SET, collection); + } + + /** + * SSI:SET + * (var CDATA #IMPLIED) + * (value CDATA #IMPLIED) + */ + protected void createAttributeDeclarations() { + if (attributes != null) + return; // already created. + if (attributeCollection == null) + return; // fatal + + attributes = new CMNamedNodeMapImpl(); + + String[] names = {HTML40Namespace.ATTR_NAME_VAR, HTML40Namespace.ATTR_NAME_VALUE}; + attributeCollection.getDeclarations(attributes, Arrays.asList(names).iterator()); + } +}
\ No newline at end of file diff --git a/bundles/org.eclipse.wst.html.core/src/org/eclipse/wst/html/core/contentmodel/HedSTYLE.java b/bundles/org.eclipse.wst.html.core/src/org/eclipse/wst/html/core/contentmodel/HedSTYLE.java new file mode 100644 index 0000000000..4288cf7bc7 --- /dev/null +++ b/bundles/org.eclipse.wst.html.core/src/org/eclipse/wst/html/core/contentmodel/HedSTYLE.java @@ -0,0 +1,77 @@ +/******************************************************************************* + * Copyright (c) 2004 IBM Corporation and others. + * All rights reserved. This program and the accompanying materials + * are made available under the terms of the Eclipse Public License v1.0 + * which accompanies this distribution, and is available at + * http://www.eclipse.org/legal/epl-v10.html + * + * Contributors: + * IBM Corporation - initial API and implementation + *******************************************************************************/ +package org.eclipse.wst.html.core.contentmodel; + + + +import java.util.Arrays; + +import org.eclipse.wst.common.contentmodel.CMAttributeDeclaration; +import org.eclipse.wst.common.contentmodel.CMContent; +import org.eclipse.wst.common.contentmodel.CMElementDeclaration; +import org.eclipse.wst.html.core.HTML40Namespace; + +/** + * STYLE. + */ +final class HedSTYLE extends HTMLElemDeclImpl { + + /** + */ + public HedSTYLE(ElementCollection collection) { + super(HTML40Namespace.ElementName.STYLE, collection); + typeDefinitionName = ComplexTypeDefinitionFactory.CTYPE_CDATA; + layoutType = LAYOUT_HIDDEN; + } + + /** + * STYLE + * %i18n; + * (type %ContentType; #REQUIRED) ... should be defined locally. + * (media %MediaDesc; #IMPLIED) + * (title %Text; #IMPLIED) + */ + protected void createAttributeDeclarations() { + if (attributes != null) + return; // already created. + if (attributeCollection == null) + return; // fatal + + attributes = new CMNamedNodeMapImpl(); + + // %i18n; + attributeCollection.getI18n(attributes); + + String[] names = {HTML40Namespace.ATTR_NAME_MEDIA, HTML40Namespace.ATTR_NAME_TITLE}; + attributeCollection.getDeclarations(attributes, Arrays.asList(names).iterator()); + // (type %ContentType; #REQUIRED) ... should be defined locally. + HTMLCMDataTypeImpl atype = new HTMLCMDataTypeImpl(HTMLCMDataType.CONTENT_TYPE); + HTMLAttrDeclImpl attr = new HTMLAttrDeclImpl(HTML40Namespace.ATTR_NAME_TYPE, atype, CMAttributeDeclaration.REQUIRED); + attributes.putNamedItem(HTML40Namespace.ATTR_NAME_TYPE, attr); + } + + /** + * Content.<br> + * <code>STYLE</code> is CDATA content type. So, it always returns <code>null</code>. + * @return org.eclipse.wst.common.contentmodel.CMContent + */ + public CMContent getContent() { + return null; + } + + /** + * CDATA content.<br> + * @return int + */ + public int getContentType() { + return CMElementDeclaration.CDATA; + } +}
\ No newline at end of file diff --git a/bundles/org.eclipse.wst.html.core/src/org/eclipse/wst/html/core/contentmodel/HedScripts.java b/bundles/org.eclipse.wst.html.core/src/org/eclipse/wst/html/core/contentmodel/HedScripts.java new file mode 100644 index 0000000000..f25a804fd9 --- /dev/null +++ b/bundles/org.eclipse.wst.html.core/src/org/eclipse/wst/html/core/contentmodel/HedScripts.java @@ -0,0 +1,56 @@ +/******************************************************************************* + * Copyright (c) 2004 IBM Corporation and others. + * All rights reserved. This program and the accompanying materials + * are made available under the terms of the Eclipse Public License v1.0 + * which accompanies this distribution, and is available at + * http://www.eclipse.org/legal/epl-v10.html + * + * Contributors: + * IBM Corporation - initial API and implementation + *******************************************************************************/ +package org.eclipse.wst.html.core.contentmodel; + + + +import org.eclipse.wst.common.contentmodel.CMNamedNodeMap; +import org.eclipse.wst.html.core.HTML40Namespace; + +/** + * SUB and SUP. + */ +final class HedScripts extends HedInlineContainer { + + /** + */ + public HedScripts(String elementName, ElementCollection collection) { + super(elementName, collection); + correctionType = CORRECT_EMPTY; + } + + /** + * %attrs; + */ + protected void createAttributeDeclarations() { + if (attributes != null) + return; // already created. + if (attributeCollection == null) + return; // fatal + + attributes = new CMNamedNodeMapImpl(); + + // %attrs; + attributeCollection.getAttrs(attributes); + } + + /** + */ + public CMNamedNodeMap getProhibitedAncestors() { + if (prohibitedAncestors != null) + return prohibitedAncestors; + + String[] names = {HTML40Namespace.ElementName.PRE}; + prohibitedAncestors = elementCollection.getDeclarations(names); + + return prohibitedAncestors; + } +}
\ No newline at end of file diff --git a/bundles/org.eclipse.wst.html.core/src/org/eclipse/wst/html/core/contentmodel/HedTABLE.java b/bundles/org.eclipse.wst.html.core/src/org/eclipse/wst/html/core/contentmodel/HedTABLE.java new file mode 100644 index 0000000000..7a77ff639c --- /dev/null +++ b/bundles/org.eclipse.wst.html.core/src/org/eclipse/wst/html/core/contentmodel/HedTABLE.java @@ -0,0 +1,91 @@ +/******************************************************************************* + * Copyright (c) 2004 IBM Corporation and others. + * All rights reserved. This program and the accompanying materials + * are made available under the terms of the Eclipse Public License v1.0 + * which accompanies this distribution, and is available at + * http://www.eclipse.org/legal/epl-v10.html + * + * Contributors: + * IBM Corporation - initial API and implementation + *******************************************************************************/ +package org.eclipse.wst.html.core.contentmodel; + + + +import java.util.Arrays; + +import org.eclipse.wst.common.contentmodel.CMAttributeDeclaration; +import org.eclipse.wst.common.contentmodel.CMDataType; +import org.eclipse.wst.common.contentmodel.CMNamedNodeMap; +import org.eclipse.wst.html.core.HTML40Namespace; + +/** + * TABLE. + */ +final class HedTABLE extends HTMLElemDeclImpl { + + /** + */ + public HedTABLE(ElementCollection collection) { + super(HTML40Namespace.ElementName.TABLE, collection); + typeDefinitionName = ComplexTypeDefinitionFactory.CTYPE_TABLE; + layoutType = LAYOUT_BLOCK; + indentChild = true; + } + + /** + * TABLE. + * %attrs; + * %reserved; + * (summary %Text; #IMPLIED) + * (width %Length; #IMPLIED) + * (border %Pixels; #IMPLIED) + * (frame %TFrame; #IMPLIED) + * (rules %TRules; #IMPLIED) + * (cellspacing %Length; #IMPLIED) + * (cellpadding %Length; #IMPLIED) + * (align %TAlign; #IMPLIED) + * (bgcolor %Color; #IMPLIED) + * (datapagesize CDATA #IMPLIED) + * (height %Pixels; #IMPLIED) + * (background %URI; #IMPLIED) + * (bordercolor %Color #IMPLIED) ... D205514 + * @see com.ibm.sed.contentmodel.html.AbstractHTMLElemDeclImpl + */ + protected void createAttributeDeclarations() { + if (attributes != null) + return; // already created. + if (attributeCollection == null) + return; // fatal + + attributes = new CMNamedNodeMapImpl(); + + // %attrs; + attributeCollection.getAttrs(attributes); + // %reserved; + // ... %reserved; is empty in the current DTD. + + String[] names = {HTML40Namespace.ATTR_NAME_SUMMARY, HTML40Namespace.ATTR_NAME_WIDTH, HTML40Namespace.ATTR_NAME_BORDER, HTML40Namespace.ATTR_NAME_FRAME, HTML40Namespace.ATTR_NAME_RULES, HTML40Namespace.ATTR_NAME_CELLSPACING, HTML40Namespace.ATTR_NAME_CELLPADDING, HTML40Namespace.ATTR_NAME_BGCOLOR, HTML40Namespace.ATTR_NAME_DATAPAGESIZE, HTML40Namespace.ATTR_NAME_HEIGHT, HTML40Namespace.ATTR_NAME_BACKGROUND, HTML40Namespace.ATTR_NAME_BORDERCOLOR // D205514 + }; + attributeCollection.getDeclarations(attributes, Arrays.asList(names).iterator()); + + // align (local) + HTMLCMDataTypeImpl atype = new HTMLCMDataTypeImpl(CMDataType.ENUM); + String[] alignValues = {HTML40Namespace.ATTR_VALUE_LEFT, HTML40Namespace.ATTR_VALUE_CENTER, HTML40Namespace.ATTR_VALUE_RIGHT}; + atype.setEnumValues(alignValues); + HTMLAttrDeclImpl adec = new HTMLAttrDeclImpl(HTML40Namespace.ATTR_NAME_ALIGN, atype, CMAttributeDeclaration.OPTIONAL); + attributes.putNamedItem(HTML40Namespace.ATTR_NAME_ALIGN, adec); + } + + /** + */ + public CMNamedNodeMap getProhibitedAncestors() { + if (prohibitedAncestors != null) + return prohibitedAncestors; + + String[] names = {HTML40Namespace.ElementName.DIR, HTML40Namespace.ElementName.MENU}; + prohibitedAncestors = elementCollection.getDeclarations(names); + + return prohibitedAncestors; + } +}
\ No newline at end of file diff --git a/bundles/org.eclipse.wst.html.core/src/org/eclipse/wst/html/core/contentmodel/HedTEXTAREA.java b/bundles/org.eclipse.wst.html.core/src/org/eclipse/wst/html/core/contentmodel/HedTEXTAREA.java new file mode 100644 index 0000000000..ad5f71acdc --- /dev/null +++ b/bundles/org.eclipse.wst.html.core/src/org/eclipse/wst/html/core/contentmodel/HedTEXTAREA.java @@ -0,0 +1,77 @@ +/******************************************************************************* + * Copyright (c) 2004 IBM Corporation and others. + * All rights reserved. This program and the accompanying materials + * are made available under the terms of the Eclipse Public License v1.0 + * which accompanies this distribution, and is available at + * http://www.eclipse.org/legal/epl-v10.html + * + * Contributors: + * IBM Corporation - initial API and implementation + *******************************************************************************/ +package org.eclipse.wst.html.core.contentmodel; + + + +import java.util.Arrays; + +import org.eclipse.wst.common.contentmodel.CMNamedNodeMap; +import org.eclipse.wst.html.core.HTML40Namespace; + +/** + * TEXTAREA. + */ +final class HedTEXTAREA extends HedPcdata { + + /** + * TEXTAREA should keep spaces in its source. + */ + public HedTEXTAREA(ElementCollection collection) { + super(HTML40Namespace.ElementName.TEXTAREA, collection); + layoutType = LAYOUT_OBJECT; + + keepSpaces = true; + } + + /** + * TEXTAREA. + * %attrs; + * %reserved; ... empty + * (name CDATA #IMPLIED) + * (rows NUMBER #REQUIRED) + * (cols NUMBER #REQUIRED) + * (disabled (disabled) #IMPLIED) + * (readonly (readonly) #IMPLIED) + * (tabindex NUMBER #IMPLIED) + * (accesskey %Character; #IMPLIED) + * (onfocus %Script; #IMPLIED) + * (onblur %Script; #IMPLIED) + * (onselect %Script; #IMPLIED) + * (onchange %Script; #IMPLIED) + * (istyle CDATA #IMPLIED) + */ + protected void createAttributeDeclarations() { + if (attributes != null) + return; // already created. + if (attributeCollection == null) + return; // fatal + attributes = new CMNamedNodeMapImpl(); + + // %attrs; + attributeCollection.getAttrs(attributes); + + String[] names = {HTML40Namespace.ATTR_NAME_NAME, HTML40Namespace.ATTR_NAME_ROWS, HTML40Namespace.ATTR_NAME_COLS, HTML40Namespace.ATTR_NAME_DISABLED, HTML40Namespace.ATTR_NAME_READONLY, HTML40Namespace.ATTR_NAME_TABINDEX, HTML40Namespace.ATTR_NAME_ACCESSKEY, HTML40Namespace.ATTR_NAME_ONFOCUS, HTML40Namespace.ATTR_NAME_ONBLUR, HTML40Namespace.ATTR_NAME_ONSELECT, HTML40Namespace.ATTR_NAME_ONCHANGE, HTML40Namespace.ATTR_NAME_ISTYLE}; + attributeCollection.getDeclarations(attributes, Arrays.asList(names).iterator()); + } + + /** + */ + public CMNamedNodeMap getProhibitedAncestors() { + if (prohibitedAncestors != null) + return prohibitedAncestors; + + String[] names = {HTML40Namespace.ElementName.BUTTON}; + prohibitedAncestors = elementCollection.getDeclarations(names); + + return prohibitedAncestors; + } +}
\ No newline at end of file diff --git a/bundles/org.eclipse.wst.html.core/src/org/eclipse/wst/html/core/contentmodel/HedTITLE.java b/bundles/org.eclipse.wst.html.core/src/org/eclipse/wst/html/core/contentmodel/HedTITLE.java new file mode 100644 index 0000000000..23e77ce572 --- /dev/null +++ b/bundles/org.eclipse.wst.html.core/src/org/eclipse/wst/html/core/contentmodel/HedTITLE.java @@ -0,0 +1,70 @@ +/******************************************************************************* + * Copyright (c) 2004 IBM Corporation and others. + * All rights reserved. This program and the accompanying materials + * are made available under the terms of the Eclipse Public License v1.0 + * which accompanies this distribution, and is available at + * http://www.eclipse.org/legal/epl-v10.html + * + * Contributors: + * IBM Corporation - initial API and implementation + *******************************************************************************/ +package org.eclipse.wst.html.core.contentmodel; + + + +import java.util.Arrays; + +import org.eclipse.wst.common.contentmodel.CMContent; +import org.eclipse.wst.common.contentmodel.CMGroup; +import org.eclipse.wst.html.core.HTML40Namespace; + +/** + * TITLE. + */ +final class HedTITLE extends HedPcdata { + + /** + */ + public HedTITLE(ElementCollection collection) { + super(HTML40Namespace.ElementName.TITLE, collection); + layoutType = LAYOUT_HIDDEN; + } + + /** + * TITLE. + * %i18n; + */ + protected void createAttributeDeclarations() { + if (attributes != null) + return; // already created. + if (attributeCollection == null) + return; // fatal + + attributes = new CMNamedNodeMapImpl(); + + // %i18n; + attributeCollection.getI18n(attributes); + } + + /** + * Exclusion. + * <code>TITLE</code> has the exclusion. + * It is <code>%head.misc;</code>. + * %head.misc; is <code>SCRIPT|STYLE|META|LINK|OBJECT</code>. + * <br> + * @see com.ibm.sed.contentmodel.html.HTMLElementDeclaration + */ + public CMContent getExclusion() { + if (exclusion != null) + return exclusion; // already created. + if (elementCollection == null) + return null; + + // (SCRIPT|STYLE|META|LINK|OBJECT) + exclusion = new CMGroupImpl(CMGroup.CHOICE, 1, 1); + + String[] names = {HTML40Namespace.ElementName.SCRIPT, HTML40Namespace.ElementName.STYLE, HTML40Namespace.ElementName.META, HTML40Namespace.ElementName.LINK, HTML40Namespace.ElementName.OBJECT}; + elementCollection.getDeclarations(exclusion, Arrays.asList(names).iterator()); + return exclusion; + } +}
\ No newline at end of file diff --git a/bundles/org.eclipse.wst.html.core/src/org/eclipse/wst/html/core/contentmodel/HedTR.java b/bundles/org.eclipse.wst.html.core/src/org/eclipse/wst/html/core/contentmodel/HedTR.java new file mode 100644 index 0000000000..c66423633f --- /dev/null +++ b/bundles/org.eclipse.wst.html.core/src/org/eclipse/wst/html/core/contentmodel/HedTR.java @@ -0,0 +1,74 @@ +/******************************************************************************* + * Copyright (c) 2004 IBM Corporation and others. + * All rights reserved. This program and the accompanying materials + * are made available under the terms of the Eclipse Public License v1.0 + * which accompanies this distribution, and is available at + * http://www.eclipse.org/legal/epl-v10.html + * + * Contributors: + * IBM Corporation - initial API and implementation + *******************************************************************************/ +package org.eclipse.wst.html.core.contentmodel; + + + +import java.util.Arrays; +import java.util.Iterator; + +import org.eclipse.wst.html.core.HTML40Namespace; + + +/** + * TR. + */ +final class HedTR extends HTMLElemDeclImpl { + + private static String[] terminators = {HTML40Namespace.ElementName.TR}; + + /** + */ + public HedTR(ElementCollection collection) { + super(HTML40Namespace.ElementName.TR, collection); + typeDefinitionName = ComplexTypeDefinitionFactory.CTYPE_TCELL_CONTAINER; + layoutType = LAYOUT_BLOCK; + omitType = OMIT_END; + indentChild = true; + } + + /** + * %attrs; + * %cellhalign; + * %cellvalign; + * (bgcolor %Color; #IMPLIED) + * (background %URI; #IMPLIED) + * (bordercolor %Color #IMPLIED) ... D205514 + * (height %Length #IMPLIED) bug2246 + */ + protected void createAttributeDeclarations() { + if (attributes != null) + return; // already created. + if (attributeCollection == null) + return; // fatal + + attributes = new CMNamedNodeMapImpl(); + + // %attrs; + attributeCollection.getAttrs(attributes); + // %cellhalign; + attributeCollection.getCellhalign(attributes); + // %cellvalign; + attributeCollection.getCellvalign(attributes); + + String[] names = {HTML40Namespace.ATTR_NAME_BGCOLOR, HTML40Namespace.ATTR_NAME_BACKGROUND, HTML40Namespace.ATTR_NAME_BORDERCOLOR, HTML40Namespace.ATTR_NAME_HEIGHT // D205514 + }; + attributeCollection.getDeclarations(attributes, Arrays.asList(names).iterator()); + } + + /** + * TR has terminators. + * @return java.util.Iterator + */ + protected Iterator getTerminators() { + return Arrays.asList(terminators).iterator(); + } +}
\ No newline at end of file diff --git a/bundles/org.eclipse.wst.html.core/src/org/eclipse/wst/html/core/contentmodel/HedTableBody.java b/bundles/org.eclipse.wst.html.core/src/org/eclipse/wst/html/core/contentmodel/HedTableBody.java new file mode 100644 index 0000000000..3360016f7f --- /dev/null +++ b/bundles/org.eclipse.wst.html.core/src/org/eclipse/wst/html/core/contentmodel/HedTableBody.java @@ -0,0 +1,73 @@ +/******************************************************************************* + * Copyright (c) 2004 IBM Corporation and others. + * All rights reserved. This program and the accompanying materials + * are made available under the terms of the Eclipse Public License v1.0 + * which accompanies this distribution, and is available at + * http://www.eclipse.org/legal/epl-v10.html + * + * Contributors: + * IBM Corporation - initial API and implementation + *******************************************************************************/ +package org.eclipse.wst.html.core.contentmodel; + + + +import java.util.Arrays; +import java.util.Iterator; + +import org.eclipse.wst.html.core.HTML40Namespace; + + +/** + * THEAD/TFOOT/TBODY + */ +final class HedTableBody extends HTMLElemDeclImpl { + + private static String[] terminators = {HTML40Namespace.ElementName.CAPTION, HTML40Namespace.ElementName.COL, HTML40Namespace.ElementName.COLGROUP, HTML40Namespace.ElementName.THEAD, HTML40Namespace.ElementName.TBODY, HTML40Namespace.ElementName.TFOOT}; + + /** + */ + public HedTableBody(String elementName, ElementCollection collection) { + super(elementName, collection); + typeDefinitionName = ComplexTypeDefinitionFactory.CTYPE_TR_CONTAINER; + correctionType = CORRECT_EMPTY; + layoutType = LAYOUT_BLOCK; + if (elementName == HTML40Namespace.ElementName.TBODY) { + omitType = OMIT_BOTH; + } + else { + omitType = OMIT_END; + } + indentChild = true; + } + + /** + * TBODY/TFOOT/THEAD + * %attrs; + * %cellhalign; + * %cellvalign; + */ + protected void createAttributeDeclarations() { + if (attributes != null) + return; // already created. + if (attributeCollection == null) + return; // fatal + + attributes = new CMNamedNodeMapImpl(); + + // %attrs; + attributeCollection.getAttrs(attributes); + // %cellhalign; + attributeCollection.getCellhalign(attributes); + // %cellvalign; + attributeCollection.getCellvalign(attributes); + } + + /** + * THEAD, TFOOT and TBODY have terminators. + * @return java.util.Iterator + */ + protected Iterator getTerminators() { + return Arrays.asList(terminators).iterator(); + } +}
\ No newline at end of file diff --git a/bundles/org.eclipse.wst.html.core/src/org/eclipse/wst/html/core/contentmodel/HedTableCell.java b/bundles/org.eclipse.wst.html.core/src/org/eclipse/wst/html/core/contentmodel/HedTableCell.java new file mode 100644 index 0000000000..1e641938e6 --- /dev/null +++ b/bundles/org.eclipse.wst.html.core/src/org/eclipse/wst/html/core/contentmodel/HedTableCell.java @@ -0,0 +1,80 @@ +/******************************************************************************* + * Copyright (c) 2004 IBM Corporation and others. + * All rights reserved. This program and the accompanying materials + * are made available under the terms of the Eclipse Public License v1.0 + * which accompanies this distribution, and is available at + * http://www.eclipse.org/legal/epl-v10.html + * + * Contributors: + * IBM Corporation - initial API and implementation + *******************************************************************************/ +package org.eclipse.wst.html.core.contentmodel; + + + +import java.util.Arrays; +import java.util.Iterator; + +import org.eclipse.wst.html.core.HTML40Namespace; + + +/** + * (TH | TD). + */ +final class HedTableCell extends HedFlowContainer { + + private static String[] terminators = {HTML40Namespace.ElementName.TR, HTML40Namespace.ElementName.TH, HTML40Namespace.ElementName.TD}; + + /** + */ + public HedTableCell(String elementName, ElementCollection collection) { + super(elementName, collection); + layoutType = LAYOUT_BLOCK; + omitType = OMIT_END; + } + + /** + * %attrs; + * (abbr %Text; #IMPLIED) + * (axis CDATA #IMPLIED) + * (headers IDREFS #IMPLIED) + * (scope %Scope; #IMPLIED) + * (rowspan NUMBER 1) + * (colspan NUMBER 1) + * %cellhalign; + * %cellvalign; + * (nowrap (nowrap) #IMPLIED) + * (bgcolor %Color; #IMPLIED) + * (width %Length; #IMPLIED) + * (height %Length; #IMPLIED) + * (background %URI; #IMPLIED) + * (bordercolor %Color #IMPLIED) ... D205514 + */ + protected void createAttributeDeclarations() { + if (attributes != null) + return; // already created. + if (attributeCollection == null) + return; // fatal + + attributes = new CMNamedNodeMapImpl(); + + // %attrs; + attributeCollection.getAttrs(attributes); + // %cellhalign; + attributeCollection.getCellhalign(attributes); + // %cellvalign; + attributeCollection.getCellvalign(attributes); + + String[] names = {HTML40Namespace.ATTR_NAME_ABBR, HTML40Namespace.ATTR_NAME_AXIS, HTML40Namespace.ATTR_NAME_HEADERS, HTML40Namespace.ATTR_NAME_SCOPE, HTML40Namespace.ATTR_NAME_ROWSPAN, HTML40Namespace.ATTR_NAME_COLSPAN, HTML40Namespace.ATTR_NAME_NOWRAP, HTML40Namespace.ATTR_NAME_BGCOLOR, HTML40Namespace.ATTR_NAME_WIDTH, HTML40Namespace.ATTR_NAME_HEIGHT, HTML40Namespace.ATTR_NAME_BACKGROUND, HTML40Namespace.ATTR_NAME_BORDERCOLOR // D205514 + }; + attributeCollection.getDeclarations(attributes, Arrays.asList(names).iterator()); + } + + /** + * TH and TD have terminators. + * @return java.util.Iterator + */ + protected Iterator getTerminators() { + return Arrays.asList(terminators).iterator(); + } +}
\ No newline at end of file diff --git a/bundles/org.eclipse.wst.html.core/src/org/eclipse/wst/html/core/contentmodel/HedUL.java b/bundles/org.eclipse.wst.html.core/src/org/eclipse/wst/html/core/contentmodel/HedUL.java new file mode 100644 index 0000000000..1bf48d381e --- /dev/null +++ b/bundles/org.eclipse.wst.html.core/src/org/eclipse/wst/html/core/contentmodel/HedUL.java @@ -0,0 +1,73 @@ +/******************************************************************************* + * Copyright (c) 2004 IBM Corporation and others. + * All rights reserved. This program and the accompanying materials + * are made available under the terms of the Eclipse Public License v1.0 + * which accompanies this distribution, and is available at + * http://www.eclipse.org/legal/epl-v10.html + * + * Contributors: + * IBM Corporation - initial API and implementation + *******************************************************************************/ +package org.eclipse.wst.html.core.contentmodel; + + + +import java.util.Arrays; + +import org.eclipse.wst.common.contentmodel.CMAttributeDeclaration; +import org.eclipse.wst.common.contentmodel.CMDataType; +import org.eclipse.wst.common.contentmodel.CMNamedNodeMap; +import org.eclipse.wst.html.core.HTML40Namespace; + +/** + * UL. + */ +final class HedUL extends HedListItemContainer { + + /** + */ + public HedUL(ElementCollection collection) { + super(HTML40Namespace.ElementName.UL, collection); + } + + /** + * UL. + * (type %ULStyle; #IMPLIED) ... should be defined locally. + * (compact (compact) #IMPLIED) + */ + protected void createAttributeDeclarations() { + if (attributes != null) + return; // already created. + if (attributeCollection == null) + return; // fatal + + attributes = new CMNamedNodeMapImpl(); + + // %attrs; + attributeCollection.getAttrs(attributes); + + // (type %ULStyle; #IMPLIED) ... should be defined locally. + // %ULStyle; is (disc|square|circle). + HTMLCMDataTypeImpl atype = new HTMLCMDataTypeImpl(CMDataType.ENUM); + String[] values = {HTML40Namespace.ATTR_VALUE_DISC, HTML40Namespace.ATTR_VALUE_SQUARE, HTML40Namespace.ATTR_VALUE_CIRCLE}; + atype.setEnumValues(values); + HTMLAttrDeclImpl attr = new HTMLAttrDeclImpl(HTML40Namespace.ATTR_NAME_TYPE, atype, CMAttributeDeclaration.OPTIONAL); + attributes.putNamedItem(HTML40Namespace.ATTR_NAME_TYPE, attr); + + // the rest. + String[] names = {HTML40Namespace.ATTR_NAME_COMPACT}; + attributeCollection.getDeclarations(attributes, Arrays.asList(names).iterator()); + } + + /** + */ + public CMNamedNodeMap getProhibitedAncestors() { + if (prohibitedAncestors != null) + return prohibitedAncestors; + + String[] names = {HTML40Namespace.ElementName.DIR, HTML40Namespace.ElementName.MENU}; + prohibitedAncestors = elementCollection.getDeclarations(names); + + return prohibitedAncestors; + } +}
\ No newline at end of file diff --git a/bundles/org.eclipse.wst.html.core/src/org/eclipse/wst/html/core/contentmodel/HedWBR.java b/bundles/org.eclipse.wst.html.core/src/org/eclipse/wst/html/core/contentmodel/HedWBR.java new file mode 100644 index 0000000000..51bedf0a47 --- /dev/null +++ b/bundles/org.eclipse.wst.html.core/src/org/eclipse/wst/html/core/contentmodel/HedWBR.java @@ -0,0 +1,32 @@ +/******************************************************************************* + * Copyright (c) 2004 IBM Corporation and others. + * All rights reserved. This program and the accompanying materials + * are made available under the terms of the Eclipse Public License v1.0 + * which accompanies this distribution, and is available at + * http://www.eclipse.org/legal/epl-v10.html + * + * Contributors: + * IBM Corporation - initial API and implementation + *******************************************************************************/ +package org.eclipse.wst.html.core.contentmodel; + +import org.eclipse.wst.html.core.HTML40Namespace; + + + +final class HedWBR extends HedEmpty { + + public HedWBR(ElementCollection collection) { + super(HTML40Namespace.ElementName.WBR, collection); + // LAYOUT_BREAK. + // same as BR. + layoutType = LAYOUT_BREAK; + } + + protected void createAttributeDeclarations() { + // No attributes is defined. + if (attributes != null) + return; + attributes = new CMNamedNodeMapImpl(); + } +}
\ No newline at end of file diff --git a/bundles/org.eclipse.wst.html.core/src/org/eclipse/wst/html/core/contentmodel/JCMDocImpl.java b/bundles/org.eclipse.wst.html.core/src/org/eclipse/wst/html/core/contentmodel/JCMDocImpl.java new file mode 100644 index 0000000000..7401ac5bc8 --- /dev/null +++ b/bundles/org.eclipse.wst.html.core/src/org/eclipse/wst/html/core/contentmodel/JCMDocImpl.java @@ -0,0 +1,79 @@ +/******************************************************************************* + * Copyright (c) 2004 IBM Corporation and others. + * All rights reserved. This program and the accompanying materials + * are made available under the terms of the Eclipse Public License v1.0 + * which accompanies this distribution, and is available at + * http://www.eclipse.org/legal/epl-v10.html + * + * Contributors: + * IBM Corporation - initial API and implementation + *******************************************************************************/ +package org.eclipse.wst.html.core.contentmodel; + + + +import org.eclipse.wst.common.contentmodel.CMNamedNodeMap; +import org.eclipse.wst.common.contentmodel.CMNode; + +/** + * Implementation of CMDocument for the JSP 1.1. + */ +class JCMDocImpl extends CMNodeImpl implements JSPCMDocument { + + /** Namespace for all names of elements, entities and attributes. */ + private CMNamespaceImpl namespace = null; + private JSPElementCollection elements = null; + + /** + * HCMDocImpl constructor comment. + */ + public JCMDocImpl(String docTypeName, CMNamespaceImpl targetNamespace) { + super(docTypeName); + namespace = targetNamespace; + elements = new JSPElementCollection(); + } + + /** + * @see com.ibm.sed.contentmodel.html.HTMLCMDocument + */ + public HTMLElementDeclaration getElementDeclaration(String elementName) { + if (elements == null) + return null; + return (HTMLElementDeclaration) elements.getNamedItem(elementName); + } + + /** + * @see org.eclipse.wst.common.contentmodel.CMDocument + */ + public CMNamedNodeMap getElements() { + return elements; + } + + /** + * @see org.eclipse.wst.common.contentmodel.CMDocument + */ + public CMNamedNodeMap getEntities() { + return null; + } + + /** + * @see com.ibm.sed.contentmodel.html.HTMLCMDocument + */ + public HTMLEntityDeclaration getEntityDeclaration(String entityName) { + return null; + } + + /** + * @see org.eclipse.wst.common.contentmodel.CMDocument + */ + public org.eclipse.wst.common.contentmodel.CMNamespace getNamespace() { + return namespace; + } + + /** + * @see org.eclipse.wst.common.contentmodel.CMNode + */ + public int getNodeType() { + return CMNode.DOCUMENT; + } +}
\ No newline at end of file diff --git a/bundles/org.eclipse.wst.html.core/src/org/eclipse/wst/html/core/contentmodel/JSP11Namespace.java b/bundles/org.eclipse.wst.html.core/src/org/eclipse/wst/html/core/contentmodel/JSP11Namespace.java new file mode 100644 index 0000000000..893c034e77 --- /dev/null +++ b/bundles/org.eclipse.wst.html.core/src/org/eclipse/wst/html/core/contentmodel/JSP11Namespace.java @@ -0,0 +1,112 @@ +/******************************************************************************* + * Copyright (c) 2004 IBM Corporation and others. + * All rights reserved. This program and the accompanying materials + * are made available under the terms of the Eclipse Public License v1.0 + * which accompanies this distribution, and is available at + * http://www.eclipse.org/legal/epl-v10.html + * + * Contributors: + * IBM Corporation - initial API and implementation + *******************************************************************************/ +package org.eclipse.wst.html.core.contentmodel; + + +/** + * JSP 1.1 Namespace. Note, this interface was + * copied form JSP core packages. One implication + * is that extra care is needed in using '==' instead + * of '.equals'. + */ +public interface JSP11Namespace { + + public static interface ElementName { + // Element names + public static final String SCRIPTLET = "jsp:scriptlet"; //$NON-NLS-1$ + public static final String EXPRESSION = "jsp:expression"; //$NON-NLS-1$ + public static final String DECLARATION = "jsp:declaration"; //$NON-NLS-1$ + public static final String DIRECTIVE_PAGE = "jsp:directive.page"; //$NON-NLS-1$ + public static final String DIRECTIVE_INCLUDE = "jsp:directive.include"; //$NON-NLS-1$ + public static final String DIRECTIVE_TAGLIB = "jsp:directive.taglib"; //$NON-NLS-1$ + public static final String USEBEAN = "jsp:useBean"; //$NON-NLS-1$ + public static final String SETPROPERTY = "jsp:setProperty"; //$NON-NLS-1$ + public static final String GETPROPERTY = "jsp:getProperty"; //$NON-NLS-1$ + public static final String INCLUDE = "jsp:include"; //$NON-NLS-1$ + public static final String FORWARD = "jsp:forward"; //$NON-NLS-1$ + public static final String PLUGIN = "jsp:plugin"; //$NON-NLS-1$ + public static final String PARAMS = "jsp:params"; //$NON-NLS-1$ + public static final String FALLBACK = "jsp:fallback"; //$NON-NLS-1$ + public static final String PARAM = "jsp:param"; //$NON-NLS-1$ + public static final String ROOT = "jsp:root"; //$NON-NLS-1$ + public static final String TEXT = "jsp:text"; //$NON-NLS-1$ + } + + public static final String JSP11_URI = ""; //$NON-NLS-1$ + public static final String JSP_TAG_PREFIX = "jsp"; //$NON-NLS-1$ + // attribute names + // directive.page + public static final String ATTR_NAME_LANGUAGE = "language"; //$NON-NLS-1$ + public static final String ATTR_NAME_EXTENDS = "extends"; //$NON-NLS-1$ + public static final String ATTR_NAME_CONTENT_TYPE = "contentType"; //$NON-NLS-1$ + public static final String ATTR_NAME_IMPORT = "import"; //$NON-NLS-1$ + public static final String ATTR_NAME_SESSION = "session"; //$NON-NLS-1$ + public static final String ATTR_NAME_BUFFER = "buffer"; //$NON-NLS-1$ + public static final String ATTR_NAME_AUTOFLUSH = "autoFlush"; //$NON-NLS-1$ + public static final String ATTR_NAME_IS_THREAD_SAFE = "isThreadSafe"; //$NON-NLS-1$ + public static final String ATTR_NAME_INFO = "info"; //$NON-NLS-1$ + public static final String ATTR_NAME_ERROR_PAGE = "errorPage"; //$NON-NLS-1$ + public static final String ATTR_NAME_IS_ERROR_PAGE = "isErrorPage"; //$NON-NLS-1$ + public static final String ATTR_NAME_PAGE_ENCODING = "pageEncoding"; //$NON-NLS-1$ + // directive.include + public static final String ATTR_NAME_FILE = "file"; //$NON-NLS-1$ + // directive.taglib + public static final String ATTR_NAME_URI = "uri"; //$NON-NLS-1$ + public static final String ATTR_NAME_PREFIX = "prefix"; //$NON-NLS-1$ + // useBean + public static final String ATTR_NAME_ID = "id"; //$NON-NLS-1$ + public static final String ATTR_NAME_SCOPE = "scope"; //$NON-NLS-1$ + public static final String ATTR_NAME_CLASS = "class"; //$NON-NLS-1$ + public static final String ATTR_NAME_BEAN_NAME = "beanName"; //$NON-NLS-1$ + public static final String ATTR_NAME_TYPE = "type"; //$NON-NLS-1$ + // setProperty + public static final String ATTR_NAME_NAME = "name"; //$NON-NLS-1$ + public static final String ATTR_NAME_PROPERTY = "property"; //$NON-NLS-1$ + public static final String ATTR_NAME_VALUE = "value"; //$NON-NLS-1$ + public static final String ATTR_NAME_PARAM = "param"; //$NON-NLS-1$ + // include + public static final String ATTR_NAME_PAGE = "page"; //$NON-NLS-1$ + public static final String ATTR_NAME_FLUSH = "flush"; //$NON-NLS-1$ + // plugin + public static final String ATTR_NAME_CODE = "code"; //$NON-NLS-1$ + public static final String ATTR_NAME_CODEBASE = "codebase"; //$NON-NLS-1$ + public static final String ATTR_NAME_ALIGN = "align"; //$NON-NLS-1$ + public static final String ATTR_NAME_ARCHIVE = "archive"; //$NON-NLS-1$ + public static final String ATTR_NAME_HEIGHT = "height"; //$NON-NLS-1$ + public static final String ATTR_NAME_HSPACE = "hspace"; //$NON-NLS-1$ + public static final String ATTR_NAME_JREVERSION = "jreversion"; //$NON-NLS-1$ + public static final String ATTR_NAME_VSPACE = "vspace"; //$NON-NLS-1$ + public static final String ATTR_NAME_WIDTH = "width"; //$NON-NLS-1$ + public static final String ATTR_NAME_NSPLUGINURL = "nspluginurl"; //$NON-NLS-1$ + public static final String ATTR_NAME_IEPLUGINURL = "iepluginurl"; //$NON-NLS-1$ + // root + public static final String ATTR_NAME_XMLNS_JSP = "xmlns:jsp"; //$NON-NLS-1$ + public static final String ATTR_NAME_VERSION = "version"; //$NON-NLS-1$ + // attribute values + public static final String ATTR_VALUE_TRUE = "true"; //$NON-NLS-1$ + public static final String ATTR_VALUE_FALSE = "false"; //$NON-NLS-1$ + public static final String ATTR_VALUE_JAVA = "java"; //$NON-NLS-1$ + public static final String ATTR_VALUE_CT_DEFAULT = "text/html; charset=ISO-8859-1";//D195366 //$NON-NLS-1$ + public static final String ATTR_VALUE_BUFSIZ_DEFAULT = "8kb"; //$NON-NLS-1$ + public static final String ATTR_VALUE_PAGE = "page"; //$NON-NLS-1$ + public static final String ATTR_VALUE_SESSION = "session"; //$NON-NLS-1$ + public static final String ATTR_VALUE_REQUEST = "request"; //$NON-NLS-1$ + public static final String ATTR_VALUE_APPLICATION = "application"; //$NON-NLS-1$ + public static final String ATTR_VALUE_BEAN = "bean"; //$NON-NLS-1$ + public static final String ATTR_VALUE_APPLET = "applet"; //$NON-NLS-1$ + public static final String ATTR_VALUE_TOP = "top"; //$NON-NLS-1$ + public static final String ATTR_VALUE_MIDDLE = "middle"; //$NON-NLS-1$ + public static final String ATTR_VALUE_BOTTOM = "bottom"; //$NON-NLS-1$ + public static final String ATTR_VALUE_LEFT = "left"; //$NON-NLS-1$ + public static final String ATTR_VALUE_RIGHT = "right"; //$NON-NLS-1$ + public static final String ATTR_VALUE_JVER11 = "1.1"; //$NON-NLS-1$ + public static final String ATTR_VALUE_XMLNS_JSP = "http://java.sun.com/JSP/Page"; //$NON-NLS-1$ +}
\ No newline at end of file diff --git a/bundles/org.eclipse.wst.html.core/src/org/eclipse/wst/html/core/contentmodel/JSPCMDocument.java b/bundles/org.eclipse.wst.html.core/src/org/eclipse/wst/html/core/contentmodel/JSPCMDocument.java new file mode 100644 index 0000000000..e547c93ed1 --- /dev/null +++ b/bundles/org.eclipse.wst.html.core/src/org/eclipse/wst/html/core/contentmodel/JSPCMDocument.java @@ -0,0 +1,29 @@ +/******************************************************************************* + * Copyright (c) 2004 IBM Corporation and others. + * All rights reserved. This program and the accompanying materials + * are made available under the terms of the Eclipse Public License v1.0 + * which accompanies this distribution, and is available at + * http://www.eclipse.org/legal/epl-v10.html + * + * Contributors: + * IBM Corporation - initial API and implementation + *******************************************************************************/ +package org.eclipse.wst.html.core.contentmodel; + + + +/** + * JSP extension for CMDocument. + * This interface provides some short hand methods to get declarations + * by a name. + */ +public interface JSPCMDocument extends org.eclipse.wst.common.contentmodel.CMDocument { + + /** + * A short hand method to get a element declaration for a JSP element. + * JSP declaration class implements HTMLElementDeclaration interface. + * @return com.ibm.sed.contentmodel.html.HTMLElementDeclaration + * @param elementName java.lang.String + */ + HTMLElementDeclaration getElementDeclaration(String elementName); +}
\ No newline at end of file diff --git a/bundles/org.eclipse.wst.html.core/src/org/eclipse/wst/html/core/contentmodel/JSPElementCollection.java b/bundles/org.eclipse.wst.html.core/src/org/eclipse/wst/html/core/contentmodel/JSPElementCollection.java new file mode 100644 index 0000000000..3cd6748ab4 --- /dev/null +++ b/bundles/org.eclipse.wst.html.core/src/org/eclipse/wst/html/core/contentmodel/JSPElementCollection.java @@ -0,0 +1,897 @@ +/******************************************************************************* + * Copyright (c) 2004 IBM Corporation and others. + * All rights reserved. This program and the accompanying materials + * are made available under the terms of the Eclipse Public License v1.0 + * which accompanies this distribution, and is available at + * http://www.eclipse.org/legal/epl-v10.html + * + * Contributors: + * IBM Corporation - initial API and implementation + *******************************************************************************/ +package org.eclipse.wst.html.core.contentmodel; + + + +import java.lang.reflect.Field; +import java.util.Arrays; +import java.util.Enumeration; +import java.util.Iterator; +import java.util.Vector; + +import org.eclipse.wst.common.contentmodel.CMAttributeDeclaration; +import org.eclipse.wst.common.contentmodel.CMContent; +import org.eclipse.wst.common.contentmodel.CMDataType; +import org.eclipse.wst.common.contentmodel.CMElementDeclaration; +import org.eclipse.wst.common.contentmodel.CMGroup; +import org.eclipse.wst.common.contentmodel.CMNamedNodeMap; +import org.eclipse.wst.common.contentmodel.CMNode; +import org.eclipse.wst.html.core.HTMLCMProperties; + +/** + * Factory for element declarations of the JSP 1.1. + */ +final class JSPElementCollection extends DeclCollection implements JSP11Namespace.ElementName { + + + private class TypePacket { + public String name = null; + public int content = CMElementDeclaration.EMPTY; + public int omit = HTMLElementDeclaration.OMIT_NONE; + public int lineBreak = HTMLElementDeclaration.BREAK_NONE; + public int layout = HTMLElementDeclaration.LAYOUT_NONE; + public int correct = HTMLElementDeclaration.CORRECT_NONE; + public int format = HTMLElementDeclaration.FORMAT_XML; + public boolean indentChild = false; + + public TypePacket() { + } + } + + /** JSP element declaration. */ + private class ElemDecl extends CMContentImpl implements HTMLElementDeclaration, HTMLPropertyDeclaration { + private TypePacket type = null; + private CMGroupImpl content = null; + private CMNamedNodeMapImpl attributes = null; + + public ElemDecl(TypePacket t) { + super(t.name, 1, 1); + type = t; + } + + public void setContent(CMGroupImpl group) { + content = group; + } + + public void setAttributes(CMNamedNodeMapImpl attrs) { + attributes = attrs; + } + + // implementes CMNode + public int getNodeType() { + return CMNode.ELEMENT_DECLARATION; + } + + public boolean supports(String propertyName) { + if (propertyName.equals(HTMLCMProperties.SHOULD_IGNORE_CASE)) { + return true; + } + else if (propertyName.equals(HTMLCMProperties.CONTENT_HINT)) { + return true; + } + else { + PropertyProvider pp = PropertyProviderFactory.getProvider(propertyName); + if (pp == null) + return false; + return pp.supports(this); + } + } + + public Object getProperty(String propertyName) { + if (propertyName.equals(HTMLCMProperties.SHOULD_IGNORE_CASE)) { + return new Boolean(false); //D208839 + } + else if (propertyName.equals(HTMLCMProperties.CONTENT_HINT)) { + String myName = getElementName(); + if (myName == JSP11Namespace.ElementName.PLUGIN) { + return getNamedItem(JSP11Namespace.ElementName.PARAMS); // outer class method. + } + else if (myName == JSP11Namespace.ElementName.PARAMS) { + return getNamedItem(JSP11Namespace.ElementName.PARAM); // outer class method. + } + else { + return null; + } + } + else { + PropertyProvider pp = PropertyProviderFactory.getProvider(propertyName); + if (pp == null) + return null; + return pp.get(this); + } + } + + // implementes CMElementDeclaration + public CMNamedNodeMap getAttributes() { + return attributes; + } + + public CMContent getContent() { + return content; + } + + public int getContentType() { + return type.content; + } + + public CMDataType getDataType() { + return null; + } + + public String getElementName() { + return getNodeName(); + } + + public CMNamedNodeMap getLocalElements() { + return null; + } + + // implementes HTMLElementDeclaration + public HTMLAttributeDeclaration getAttributeDeclaration(String attrName) { + if (attributes == null) + return null; + return (HTMLAttributeDeclaration) attributes.getNamedItem(attrName); + } + + public int getCorrectionType() { + return type.correct; + } + + public CMContent getExclusion() { + return null; + } + + public CMContent getInclusion() { + return null; + } + + public CMNamedNodeMap getProhibitedAncestors() { + return EMPTY_MAP; + } + + public int getFormatType() { + return type.format; + } + + public int getLayoutType() { + return type.layout; + } + + public int getLineBreakHint() { + return type.lineBreak; + } + + public int getOmitType() { + return type.omit; + } + + public boolean shouldTerminateAt(HTMLElementDeclaration dec) { + return false; + } + + public boolean shouldKeepSpaces() { + return false; + } + + public boolean shouldIndentChildSource() { + return type.indentChild; + } + + public boolean isJSP() { + return true; + } + } + + // element IDs + private static class Ids { + public static final int ID_SCRIPTLET = 0; + public static final int ID_EXPRESSION = 1; + public static final int ID_DECLARATION = 2; + public static final int ID_DIRECTIVE_PAGE = 3; + public static final int ID_DIRECTIVE_INCLUDE = 4; + public static final int ID_DIRECTIVE_TAGLIB = 5; + public static final int ID_USEBEAN = 6; + public static final int ID_SETPROPERTY = 7; + public static final int ID_GETPROPERTY = 8; + public static final int ID_INCLUDE = 9; + public static final int ID_FORWARD = 10; + public static final int ID_PLUGIN = 11; + public static final int ID_PARAMS = 12; + public static final int ID_FALLBACK = 13; + public static final int ID_PARAM = 14; + public static final int ID_ROOT = 15; + public static final int ID_TEXT = 16; + + public static int getNumOfIds() { + if (numofids != -1) + return numofids; + + // NOTE: If the reflection is too slow, this method should + // just return the literal value, like 105. + // -- 5/25/2001 + Class clazz = Ids.class; + Field[] fields = clazz.getFields(); + numofids = 0; + for (int i = 0; i < fields.length; i++) { + String name = fields[i].getName(); + if (name.startsWith("ID_"))//$NON-NLS-1$ + numofids++; + } + return numofids; + } + + // chache the result of the reflection. + private static int numofids = -1; + } + + // attribute creater + private class JACreater implements JSP11Namespace { + // attribute declaration + private class AttrDecl extends CMNodeImpl implements HTMLAttributeDeclaration { + HTMLCMDataTypeImpl type = null; + int usage = CMAttributeDeclaration.OPTIONAL; + + // methods + public AttrDecl(String attrName) { + super(attrName); + } + + public String getAttrName() { + return getNodeName(); + } + + public CMDataType getAttrType() { + return type; + } + + /** @deprecated by superclass */ + public String getDefaultValue() { + if (type.getImpliedValueKind() != CMDataType.IMPLIED_VALUE_DEFAULT) + return null; + return type.getImpliedValue(); + } + + /** @deprecated by superclass */ + public Enumeration getEnumAttr() { + Vector v = new Vector(Arrays.asList(type.getEnumeratedValues())); + return v.elements(); + } + + public int getNodeType() { + return CMNode.ATTRIBUTE_DECLARATION; + } + + public int getUsage() { + return usage; + } + + public boolean shouldIgnoreCase() { + return false; + } + } + + private CMNamedNodeMapImpl declarations = null; + + public JACreater() { + declarations = new CMNamedNodeMapImpl(); + } + + public CMNamedNodeMapImpl getDeclarations(int eid) { + switch (eid) { + case Ids.ID_DIRECTIVE_PAGE : + createForDirPage(); + break; + case Ids.ID_DIRECTIVE_INCLUDE : + createForDirInclude(); + break; + case Ids.ID_DIRECTIVE_TAGLIB : + createForDirTaglib(); + break; + case Ids.ID_USEBEAN : + createForUseBean(); + break; + case Ids.ID_SETPROPERTY : + createForSetProperty(); + break; + case Ids.ID_GETPROPERTY : + createForGetProperty(); + break; + case Ids.ID_INCLUDE : + createForInclude(); + break; + case Ids.ID_FORWARD : + createForForward(); + break; + case Ids.ID_PLUGIN : + createForPlugin(); + break; + case Ids.ID_PARAM : + createForParam(); + break; + case Ids.ID_ROOT : + createForRoot(); + break; + default : + // should warn. + break; + } + return declarations; + } + + private AttrDecl createBoolType(String name, String defValue) { + AttrDecl adec = new AttrDecl(name); + adec.type = new HTMLCMDataTypeImpl(CMDataType.ENUM); + String[] values = {ATTR_VALUE_TRUE, ATTR_VALUE_FALSE}; + adec.type.setEnumValues(values); + adec.type.setImpliedValue(CMDataType.IMPLIED_VALUE_DEFAULT, defValue); + return adec; + } + + private void createForDirPage() { + AttrDecl adec = null; + // ("language" CDATA DECLARED "java") + adec = new AttrDecl(ATTR_NAME_LANGUAGE); + adec.type = new HTMLCMDataTypeImpl(CMDataType.CDATA); + adec.type.setImpliedValue(CMDataType.IMPLIED_VALUE_DEFAULT, ATTR_VALUE_JAVA); + declarations.putNamedItem(ATTR_NAME_LANGUAGE, adec); + + // ("extends" CDATA IMPLIED) + adec = new AttrDecl(ATTR_NAME_EXTENDS); + adec.type = new HTMLCMDataTypeImpl(CMDataType.CDATA); + declarations.putNamedItem(ATTR_NAME_EXTENDS, adec); + + // ("contentType" CDATA DECLARED "text/html; ISO-8859-1") + adec = new AttrDecl(ATTR_NAME_CONTENT_TYPE); + adec.type = new HTMLCMDataTypeImpl(CMDataType.CDATA); + adec.type.setImpliedValue(CMDataType.IMPLIED_VALUE_DEFAULT, ATTR_VALUE_CT_DEFAULT); + declarations.putNamedItem(ATTR_NAME_CONTENT_TYPE, adec); + + // ("import" CDATA IMPLIED) + adec = new AttrDecl(ATTR_NAME_IMPORT); + adec.type = new HTMLCMDataTypeImpl(CMDataType.CDATA); + declarations.putNamedItem(ATTR_NAME_IMPORT, adec); + + // ("session" ENUM DECLARED (true|false) "true") + adec = createBoolType(ATTR_NAME_SESSION, ATTR_VALUE_TRUE); + if (adec != null) + declarations.putNamedItem(ATTR_NAME_SESSION, adec); + + // ("buffer" CDATA DECLARED "8kb") + adec = new AttrDecl(ATTR_NAME_BUFFER); + adec.type = new HTMLCMDataTypeImpl(CMDataType.CDATA); + adec.type.setImpliedValue(CMDataType.IMPLIED_VALUE_DEFAULT, ATTR_VALUE_BUFSIZ_DEFAULT); + declarations.putNamedItem(ATTR_NAME_BUFFER, adec); + + // ("autoFlush" ENUM DECLARED (true|false) "true") + adec = createBoolType(ATTR_NAME_AUTOFLUSH, ATTR_VALUE_TRUE); + if (adec != null) + declarations.putNamedItem(ATTR_NAME_AUTOFLUSH, adec); + + // ("isThreadSafe" ENUM DECLARED (true|false) "true") + adec = createBoolType(ATTR_NAME_IS_THREAD_SAFE, ATTR_VALUE_TRUE); + if (adec != null) + declarations.putNamedItem(ATTR_NAME_IS_THREAD_SAFE, adec); + + // ("info" CDATA IMPLIED) + adec = new AttrDecl(ATTR_NAME_INFO); + adec.type = new HTMLCMDataTypeImpl(CMDataType.CDATA); + declarations.putNamedItem(ATTR_NAME_INFO, adec); + + // ("errorPage" URI IMPLIED) + adec = new AttrDecl(ATTR_NAME_ERROR_PAGE); + adec.type = new HTMLCMDataTypeImpl(CMDataType.URI); + declarations.putNamedItem(ATTR_NAME_ERROR_PAGE, adec); + + // ("isErrorPage" ENUM DECLARED (true|false) "false") + adec = createBoolType(ATTR_NAME_IS_ERROR_PAGE, ATTR_VALUE_FALSE); + if (adec != null) + declarations.putNamedItem(ATTR_NAME_IS_ERROR_PAGE, adec); + + // ("pageEncoding" CDATA IMPLIED) + adec = new AttrDecl(ATTR_NAME_PAGE_ENCODING); + adec.type = new HTMLCMDataTypeImpl(CMDataType.CDATA); + declarations.putNamedItem(ATTR_NAME_PAGE_ENCODING, adec); + + } + + private void createForDirInclude() { + // ("file" URI REQUIRED); Defect TORO:185241 + AttrDecl adec = new AttrDecl(ATTR_NAME_FILE); + adec.type = new HTMLCMDataTypeImpl(CMDataType.URI); + adec.usage = CMAttributeDeclaration.REQUIRED; + declarations.putNamedItem(ATTR_NAME_FILE, adec); + } + + private void createForDirTaglib() { + // ("uri" URI REQUIRED) + AttrDecl adec = new AttrDecl(ATTR_NAME_URI); + adec.type = new HTMLCMDataTypeImpl(CMDataType.URI); + adec.usage = CMAttributeDeclaration.REQUIRED; + declarations.putNamedItem(ATTR_NAME_URI, adec); + + // ("prefix" CDATA REQUIRED) + adec = new AttrDecl(ATTR_NAME_PREFIX); + adec.type = new HTMLCMDataTypeImpl(CMDataType.CDATA); + adec.usage = CMAttributeDeclaration.REQUIRED; + declarations.putNamedItem(ATTR_NAME_PREFIX, adec); + } + + private void createForUseBean() { + // ("id" ID REQUIRED) + AttrDecl adec = new AttrDecl(ATTR_NAME_ID); + adec.type = new HTMLCMDataTypeImpl(CMDataType.ID); + adec.usage = CMAttributeDeclaration.REQUIRED; + declarations.putNamedItem(ATTR_NAME_ID, adec); + + // ("scope" ENUM DECLARED (page|session|request|application) "page") + adec = new AttrDecl(ATTR_NAME_SCOPE); + adec.type = new HTMLCMDataTypeImpl(CMDataType.ENUM); + String[] values = {ATTR_VALUE_PAGE, ATTR_VALUE_SESSION, ATTR_VALUE_REQUEST, ATTR_VALUE_APPLICATION}; + adec.type.setEnumValues(values); + adec.type.setImpliedValue(CMDataType.IMPLIED_VALUE_DEFAULT, ATTR_VALUE_PAGE); + declarations.putNamedItem(ATTR_NAME_SCOPE, adec); + + // ("class" CDATA IMPLIED) + adec = new AttrDecl(ATTR_NAME_CLASS); + adec.type = new HTMLCMDataTypeImpl(CMDataType.CDATA); + declarations.putNamedItem(ATTR_NAME_CLASS, adec); + + // ("beanName" CDATA IMPLIED) + adec = new AttrDecl(ATTR_NAME_BEAN_NAME); + adec.type = new HTMLCMDataTypeImpl(CMDataType.CDATA); + declarations.putNamedItem(ATTR_NAME_BEAN_NAME, adec); + + // ("type" CDATA IMPLIED) + adec = new AttrDecl(ATTR_NAME_TYPE); + adec.type = new HTMLCMDataTypeImpl(CMDataType.CDATA); + declarations.putNamedItem(ATTR_NAME_TYPE, adec); + } + + private void createForSetProperty() { + // ("name" IDREF REQUIRED) + AttrDecl adec = new AttrDecl(ATTR_NAME_NAME); + adec.type = new HTMLCMDataTypeImpl(CMDataType.IDREF); + adec.usage = CMAttributeDeclaration.REQUIRED; + declarations.putNamedItem(ATTR_NAME_NAME, adec); + + // ("property" CDATA REQUIRED) + adec = new AttrDecl(ATTR_NAME_PROPERTY); + adec.type = new HTMLCMDataTypeImpl(CMDataType.CDATA); + adec.usage = CMAttributeDeclaration.REQUIRED; + declarations.putNamedItem(ATTR_NAME_PROPERTY, adec); + + // ("value" CDATA IMPLIED) + adec = new AttrDecl(ATTR_NAME_VALUE); + adec.type = new HTMLCMDataTypeImpl(CMDataType.CDATA); + declarations.putNamedItem(ATTR_NAME_VALUE, adec); + + // ("param" CDATA IMPLIED) + adec = new AttrDecl(ATTR_NAME_PARAM); + adec.type = new HTMLCMDataTypeImpl(CMDataType.CDATA); + declarations.putNamedItem(ATTR_NAME_PARAM, adec); + + } + + private void createForGetProperty() { + // ("name" IDREF REQUIRED) + AttrDecl adec = new AttrDecl(ATTR_NAME_NAME); + adec.type = new HTMLCMDataTypeImpl(CMDataType.IDREF); + adec.usage = CMAttributeDeclaration.REQUIRED; + declarations.putNamedItem(ATTR_NAME_NAME, adec); + + // ("property" CDATA REQUIRED) + adec = new AttrDecl(ATTR_NAME_PROPERTY); + adec.type = new HTMLCMDataTypeImpl(CMDataType.CDATA); + adec.usage = CMAttributeDeclaration.REQUIRED; + declarations.putNamedItem(ATTR_NAME_PROPERTY, adec); + + } + + private void createForInclude() { + AttrDecl adec = null; + // ("page" URI REQUIRED) + adec = new AttrDecl(ATTR_NAME_PAGE); + adec.type = new HTMLCMDataTypeImpl(CMDataType.URI); + adec.usage = CMAttributeDeclaration.REQUIRED; + declarations.putNamedItem(ATTR_NAME_PAGE, adec); + + // ("flush" ENUM REQUIRED (true|false)); Defect TORO:185241 + adec = new AttrDecl(ATTR_NAME_FLUSH); + adec.type = new HTMLCMDataTypeImpl(CMDataType.ENUM); + adec.usage = CMAttributeDeclaration.REQUIRED; + String[] values = {ATTR_VALUE_TRUE, ATTR_VALUE_FALSE}; + adec.type.setEnumValues(values); + declarations.putNamedItem(ATTR_NAME_FLUSH, adec); + } + + private void createForForward() { + // ("page" URI REQUIRED) + AttrDecl adec = new AttrDecl(ATTR_NAME_PAGE); + adec.type = new HTMLCMDataTypeImpl(CMDataType.URI); + adec.usage = CMAttributeDeclaration.REQUIRED; + declarations.putNamedItem(ATTR_NAME_PAGE, adec); + } + + private void createForPlugin() { + // ("type" ENUM REQUIRED (bean|applet)) + AttrDecl adec = new AttrDecl(ATTR_NAME_TYPE); + adec.type = new HTMLCMDataTypeImpl(CMDataType.ENUM); + adec.usage = CMAttributeDeclaration.REQUIRED; + String[] values = {ATTR_VALUE_BEAN, ATTR_VALUE_APPLET}; + adec.type.setEnumValues(values); + declarations.putNamedItem(ATTR_NAME_TYPE, adec); + + // ("code" CDATA REQUIRED) + adec = new AttrDecl(ATTR_NAME_CODE); + adec.type = new HTMLCMDataTypeImpl(CMDataType.URI); + adec.usage = CMAttributeDeclaration.REQUIRED; + declarations.putNamedItem(ATTR_NAME_CODE, adec); + + // ("codebase" URI REQUIRED) + adec = new AttrDecl(ATTR_NAME_CODEBASE); + adec.type = new HTMLCMDataTypeImpl(CMDataType.URI); + adec.usage = CMAttributeDeclaration.REQUIRED; + declarations.putNamedItem(ATTR_NAME_CODEBASE, adec); + + // ("align" ENUM IMPLIED (top|middle|bottom|left|right)) + adec = new AttrDecl(ATTR_NAME_ALIGN); + adec.type = new HTMLCMDataTypeImpl(CMDataType.ENUM); + String[] aligns = {ATTR_VALUE_TOP, ATTR_VALUE_MIDDLE, ATTR_VALUE_BOTTOM, ATTR_VALUE_LEFT, ATTR_VALUE_RIGHT}; + adec.type.setEnumValues(aligns); + declarations.putNamedItem(ATTR_NAME_ALIGN, adec); + + // ("archive" CDATA IMPLIED) + adec = new AttrDecl(ATTR_NAME_ARCHIVE); + adec.type = new HTMLCMDataTypeImpl(CMDataType.CDATA); + declarations.putNamedItem(ATTR_NAME_ARCHIVE, adec); + + // ("height" CDATA IMPLIED) + adec = new AttrDecl(ATTR_NAME_HEIGHT); + adec.type = new HTMLCMDataTypeImpl(CMDataType.CDATA); + declarations.putNamedItem(ATTR_NAME_HEIGHT, adec); + + // ("hspace" CDATA IMPLIED) + adec = new AttrDecl(ATTR_NAME_HSPACE); + adec.type = new HTMLCMDataTypeImpl(CMDataType.CDATA); + declarations.putNamedItem(ATTR_NAME_HSPACE, adec); + + // ("jreversion" CDATA DECLARED "1.1") + adec = new AttrDecl(ATTR_NAME_JREVERSION); + adec.type = new HTMLCMDataTypeImpl(CMDataType.CDATA); + adec.type.setImpliedValue(CMDataType.IMPLIED_VALUE_DEFAULT, ATTR_VALUE_JVER11); + declarations.putNamedItem(ATTR_NAME_JREVERSION, adec); + + // ("name" CDATA IMPLIED) + adec = new AttrDecl(ATTR_NAME_NAME); + adec.type = new HTMLCMDataTypeImpl(CMDataType.CDATA); + declarations.putNamedItem(ATTR_NAME_NAME, adec); + + // ("vspace" CDATA IMPLIED) + adec = new AttrDecl(ATTR_NAME_VSPACE); + adec.type = new HTMLCMDataTypeImpl(CMDataType.CDATA); + declarations.putNamedItem(ATTR_NAME_VSPACE, adec); + + // ("width" CDATA IMPLIED) + adec = new AttrDecl(ATTR_NAME_WIDTH); + adec.type = new HTMLCMDataTypeImpl(CMDataType.CDATA); + declarations.putNamedItem(ATTR_NAME_WIDTH, adec); + + // ("nspluginurl" URI IMPLIED) + adec = new AttrDecl(ATTR_NAME_NSPLUGINURL); + adec.type = new HTMLCMDataTypeImpl(CMDataType.URI); + declarations.putNamedItem(ATTR_NAME_NSPLUGINURL, adec); + + // ("iepluginurl" URI IMPLIED) + adec = new AttrDecl(ATTR_NAME_IEPLUGINURL); + adec.type = new HTMLCMDataTypeImpl(CMDataType.URI); + declarations.putNamedItem(ATTR_NAME_IEPLUGINURL, adec); + } + + private void createForParam() { + // ("name" CDATA REQUIRED) + AttrDecl adec = new AttrDecl(ATTR_NAME_NAME); + adec.type = new HTMLCMDataTypeImpl(CMDataType.CDATA); + adec.usage = CMAttributeDeclaration.REQUIRED; + declarations.putNamedItem(ATTR_NAME_NAME, adec); + + // ("value" CDATA REQUIRED); Defect TORO:185241 + adec = new AttrDecl(ATTR_NAME_VALUE); + adec.type = new HTMLCMDataTypeImpl(CMDataType.CDATA); + adec.usage = CMAttributeDeclaration.REQUIRED; + declarations.putNamedItem(ATTR_NAME_VALUE, adec); + + } + + private void createForRoot() { + // ("xmlns:jsp" CDATA "http://jva.sun.com/JSP/Page") + AttrDecl adec = new AttrDecl(ATTR_NAME_XMLNS_JSP); + adec.type = new HTMLCMDataTypeImpl(CMDataType.CDATA); + adec.type.setImpliedValue(CMDataType.IMPLIED_VALUE_DEFAULT, ATTR_VALUE_XMLNS_JSP); + declarations.putNamedItem(ATTR_NAME_XMLNS_JSP, adec); + // ("version" CDATA REQUIRED) + adec = new AttrDecl(ATTR_NAME_VERSION); + adec.type = new HTMLCMDataTypeImpl(CMDataType.CDATA); + adec.usage = CMAttributeDeclaration.REQUIRED; + declarations.putNamedItem(ATTR_NAME_VERSION, adec); + } + } + + private final static CMNamedNodeMap EMPTY_MAP = new CMNamedNodeMap() { + public int getLength() { + return 0; + } + + public CMNode getNamedItem(String name) { + return null; + } + + public CMNode item(int index) { + return null; + } + + public Iterator iterator() { + return new Iterator() { + public boolean hasNext() { + return false; + } + + public Object next() { + return null; + } + + public void remove() { + } + }; + } + }; + private static String[] names = null; + + static { + names = new String[Ids.getNumOfIds()]; + names[Ids.ID_SCRIPTLET] = SCRIPTLET; + names[Ids.ID_EXPRESSION] = EXPRESSION; + names[Ids.ID_DECLARATION] = DECLARATION; + names[Ids.ID_DIRECTIVE_PAGE] = DIRECTIVE_PAGE; + names[Ids.ID_DIRECTIVE_INCLUDE] = DIRECTIVE_INCLUDE; + names[Ids.ID_DIRECTIVE_TAGLIB] = DIRECTIVE_TAGLIB; + names[Ids.ID_USEBEAN] = USEBEAN; + names[Ids.ID_SETPROPERTY] = SETPROPERTY; + names[Ids.ID_GETPROPERTY] = GETPROPERTY; + names[Ids.ID_INCLUDE] = INCLUDE; + names[Ids.ID_FORWARD] = FORWARD; + names[Ids.ID_PLUGIN] = PLUGIN; + names[Ids.ID_PARAMS] = PARAMS; + names[Ids.ID_FALLBACK] = FALLBACK; + names[Ids.ID_PARAM] = PARAM; + names[Ids.ID_ROOT] = ROOT; + names[Ids.ID_TEXT] = TEXT; + } + + /** + */ + public JSPElementCollection() { + super(names, TOLERANT_CASE); + } + + /** + * @return org.eclipse.wst.common.contentmodel.CMNode + * @param elementName java.lang.String + */ + protected CMNode create(String elementName) { + return createElemDecl(getID(elementName)); + } + + /** + * @return com.ibm.sed.contentmodel.html.CMGroupImpl + * @param eid int + */ + private CMGroupImpl createContent(int eid) { + if (eid == ID_UNKNOWN) + return null; + + CMGroupImpl content = null; + CMNode child = null; + + switch (eid) { + case Ids.ID_INCLUDE : + case Ids.ID_FORWARD : + // (jsp:param)* + content = new CMGroupImpl(CMGroup.SEQUENCE, 0, CMContentImpl.UNBOUNDED); + child = item(Ids.ID_PARAM); + if (child != null) + content.appendChild(child); + break; + case Ids.ID_PLUGIN : + // (jsp:params | jsp:fallback)? + content = new CMGroupImpl(CMGroup.CHOICE, 0, 1); + // jsp:params + child = item(Ids.ID_PARAMS); + if (child != null) + content.appendChild(child); + // jsp:fallback + child = item(Ids.ID_FALLBACK); + if (child != null) + content.appendChild(child); + break; + case Ids.ID_PARAMS : + // (jsp:param)+ + content = new CMGroupImpl(CMGroup.SEQUENCE, 1, CMContentImpl.UNBOUNDED); + child = item(Ids.ID_PARAM); + if (child != null) + content.appendChild(child); + break; + case Ids.ID_ROOT : + // %Body; + // --> (jsp:text|%Directives;|%Scripts;|%Actions;)* + // %Directives --> jsp:directive.page|jsp:directive.include + // %Scripts; --> jsp:scriptlet|jsp:declaration|jsp:expression + // %Actions --> jsp:useBean|jsp.setProperty|jsp:getProperty + // |jsp:include|jsp:forward|jsp:plugin + content = new CMGroupImpl(CMGroup.CHOICE, 0, CMContentImpl.UNBOUNDED); + int validChildren[] = {Ids.ID_TEXT, + // %Directves; + Ids.ID_DIRECTIVE_PAGE, Ids.ID_DIRECTIVE_INCLUDE, + // %Scripts; + Ids.ID_SCRIPTLET, Ids.ID_DECLARATION, Ids.ID_EXPRESSION, + // %Actions; + Ids.ID_USEBEAN, Ids.ID_SETPROPERTY, Ids.ID_GETPROPERTY, Ids.ID_INCLUDE, Ids.ID_FORWARD, Ids.ID_PLUGIN}; + for (int i = 0; i < validChildren.length; i++) { + child = item(validChildren[i]); + if (child != null) + content.appendChild(child); + } + break; + } + + return content; + } + + /** + * @return com.ibm.sed.contentmodel.html.HTMLElemDeclImpl + * @param eid int + */ + private HTMLElementDeclaration createElemDecl(int eid) { + if (eid == ID_UNKNOWN) + return null; + + TypePacket packet = new TypePacket(); + switch (eid) { + case Ids.ID_SCRIPTLET : + // content, omit, lineBreak, layout, correct, format + // scriptlet + packet.name = SCRIPTLET; + packet.content = CMElementDeclaration.CDATA; + packet.layout = HTMLElementDeclaration.LAYOUT_OBJECT; + packet.format = HTMLElementDeclaration.FORMAT_JSP_SCRIPT; + break; + case Ids.ID_EXPRESSION : + // expression + packet.name = EXPRESSION; + packet.content = CMElementDeclaration.CDATA; + packet.layout = HTMLElementDeclaration.LAYOUT_OBJECT; + packet.format = HTMLElementDeclaration.FORMAT_JSP_SCRIPT; + break; + case Ids.ID_DECLARATION : + // declaration + packet.name = DECLARATION; + packet.content = CMElementDeclaration.CDATA; + packet.layout = HTMLElementDeclaration.LAYOUT_HIDDEN; + packet.format = HTMLElementDeclaration.FORMAT_JSP_SCRIPT; + break; + case Ids.ID_DIRECTIVE_PAGE : + // directive.page + packet.name = DIRECTIVE_PAGE; + packet.omit = HTMLElementDeclaration.OMIT_END; + packet.layout = HTMLElementDeclaration.LAYOUT_HIDDEN; + packet.format = HTMLElementDeclaration.FORMAT_JSP_DIRECTIVE; + break; + case Ids.ID_DIRECTIVE_INCLUDE : + // directive.inlcude + packet.name = DIRECTIVE_INCLUDE; + packet.omit = HTMLElementDeclaration.OMIT_END; + packet.layout = HTMLElementDeclaration.LAYOUT_HIDDEN; + packet.format = HTMLElementDeclaration.FORMAT_JSP_DIRECTIVE; + break; + case Ids.ID_DIRECTIVE_TAGLIB : + // directive.taglib + packet.name = DIRECTIVE_TAGLIB; + packet.omit = HTMLElementDeclaration.OMIT_END; + packet.layout = HTMLElementDeclaration.LAYOUT_HIDDEN; + packet.format = HTMLElementDeclaration.FORMAT_JSP_DIRECTIVE; + break; + case Ids.ID_USEBEAN : + // useBean + packet.name = USEBEAN; + packet.content = CMElementDeclaration.ANY; + packet.layout = HTMLElementDeclaration.LAYOUT_HIDDEN; + packet.indentChild = true; + break; + case Ids.ID_SETPROPERTY : + // setProperty + packet.name = SETPROPERTY; + packet.omit = HTMLElementDeclaration.OMIT_END; + packet.layout = HTMLElementDeclaration.LAYOUT_HIDDEN; + break; + case Ids.ID_GETPROPERTY : + // getProperty + packet.name = GETPROPERTY; + packet.omit = HTMLElementDeclaration.OMIT_END; + packet.layout = HTMLElementDeclaration.LAYOUT_OBJECT; + break; + case Ids.ID_INCLUDE : + // include + packet.name = INCLUDE; + packet.content = CMElementDeclaration.ELEMENT; + packet.omit = HTMLElementDeclaration.OMIT_END; + packet.layout = HTMLElementDeclaration.LAYOUT_OBJECT; + packet.indentChild = true; + break; + case Ids.ID_FORWARD : + // forward + packet.name = FORWARD; + packet.content = CMElementDeclaration.ELEMENT; + packet.omit = HTMLElementDeclaration.OMIT_END; + packet.layout = HTMLElementDeclaration.LAYOUT_OBJECT; + packet.indentChild = true; + break; + case Ids.ID_PLUGIN : + // plugin + packet.name = PLUGIN; + packet.content = CMElementDeclaration.ELEMENT; + packet.layout = HTMLElementDeclaration.LAYOUT_OBJECT; + packet.indentChild = true; + break; + case Ids.ID_PARAMS : + // params + packet.name = PARAMS; + packet.content = CMElementDeclaration.ELEMENT; + packet.layout = HTMLElementDeclaration.LAYOUT_HIDDEN; + packet.indentChild = true; + break; + case Ids.ID_FALLBACK : + // fallback + packet.name = FALLBACK; + packet.content = CMElementDeclaration.CDATA; + packet.layout = HTMLElementDeclaration.LAYOUT_HIDDEN; + break; + case Ids.ID_PARAM : + // param + packet.name = PARAM; + packet.omit = HTMLElementDeclaration.OMIT_END; + packet.layout = HTMLElementDeclaration.LAYOUT_HIDDEN; + break; + case Ids.ID_ROOT : + packet.name = ROOT; + packet.content = CMElementDeclaration.ELEMENT; + packet.layout = HTMLElementDeclaration.LAYOUT_HIDDEN; // same as HTML + break; + case Ids.ID_TEXT : + packet.name = TEXT; + packet.content = CMElementDeclaration.PCDATA; + break; + default : + // unknown ID + return null; + } + + ElemDecl dec = new ElemDecl(packet); + + CMGroupImpl content = createContent(eid); + if (content != null) + dec.setContent(content); + + JACreater creater = new JACreater(); + dec.setAttributes(creater.getDeclarations(eid)); + + return dec; + } +}
\ No newline at end of file diff --git a/bundles/org.eclipse.wst.html.core/src/org/eclipse/wst/html/core/contentmodel/PropertyProvider.java b/bundles/org.eclipse.wst.html.core/src/org/eclipse/wst/html/core/contentmodel/PropertyProvider.java new file mode 100644 index 0000000000..ebe5e0c7cb --- /dev/null +++ b/bundles/org.eclipse.wst.html.core/src/org/eclipse/wst/html/core/contentmodel/PropertyProvider.java @@ -0,0 +1,23 @@ +/******************************************************************************* + * Copyright (c) 2004 IBM Corporation and others. + * All rights reserved. This program and the accompanying materials + * are made available under the terms of the Eclipse Public License v1.0 + * which accompanies this distribution, and is available at + * http://www.eclipse.org/legal/epl-v10.html + * + * Contributors: + * IBM Corporation - initial API and implementation + *******************************************************************************/ +package org.eclipse.wst.html.core.contentmodel; + + +/** + * PropertyProvider class. + * This class is intended to be used in HTMLElementDeclaration instances. + */ +interface PropertyProvider { + + boolean supports(HTMLElementDeclaration edecl); + + Object get(HTMLElementDeclaration edecl); +}
\ No newline at end of file diff --git a/bundles/org.eclipse.wst.html.core/src/org/eclipse/wst/html/core/contentmodel/PropertyProviderFactory.java b/bundles/org.eclipse.wst.html.core/src/org/eclipse/wst/html/core/contentmodel/PropertyProviderFactory.java new file mode 100644 index 0000000000..3347343d40 --- /dev/null +++ b/bundles/org.eclipse.wst.html.core/src/org/eclipse/wst/html/core/contentmodel/PropertyProviderFactory.java @@ -0,0 +1,359 @@ +/******************************************************************************* + * Copyright (c) 2004 IBM Corporation and others. + * All rights reserved. This program and the accompanying materials + * are made available under the terms of the Eclipse Public License v1.0 + * which accompanies this distribution, and is available at + * http://www.eclipse.org/legal/epl-v10.html + * + * Contributors: + * IBM Corporation - initial API and implementation + *******************************************************************************/ +package org.eclipse.wst.html.core.contentmodel; + +import java.util.Hashtable; + +import org.eclipse.wst.common.contentmodel.annotation.AnnotationMap; +import org.eclipse.wst.html.core.HTMLCMProperties; + +/** + * The factory object of PropertyProvider. + */ +final class PropertyProviderFactory { + + + /** + * DefaultProvider is intended to be used for unknown properties. + * It always returns null value for any properties. + */ + class DefaultProvider implements PropertyProvider { + public DefaultProvider() { + super(); + } + + public boolean supports(HTMLElementDeclaration edecl) { + return false; + } + + public Object get(HTMLElementDeclaration edecl) { + return null; + } + } + + abstract class AbstractElementPropertyProvider implements PropertyProvider { + protected AbstractElementPropertyProvider() { + super(); + } + + public boolean supports(HTMLElementDeclaration edecl) { + return (edecl != null); + } + + public Object get(HTMLElementDeclaration edecl) { + if (!(edecl instanceof HTMLPropertyDeclaration)) + return null; + return getElementProperty((HTMLPropertyDeclaration)edecl); + } + + abstract protected Object getElementProperty(HTMLPropertyDeclaration decl); + } + + /* + * "tagInfo" + * gets documentation for the element + */ + class PPTagInfo extends AbstractElementPropertyProvider { + private final static String htmlAnnotationLoc = "platform:/plugin/org.eclipse.wst.html.core/data/htmref.xml"; //$NON-NLS-1$ + protected AnnotationMap fAnnotationMap = null; + + public PPTagInfo() { + super(); + } + + /** + * Gets the annotationMap. + * @return Returns a AnnotationMap + */ + protected AnnotationMap getAnnotationMap() { + if (fAnnotationMap == null) { + fAnnotationMap = new AnnotationMap(); + try { + fAnnotationMap.load(htmlAnnotationLoc); + } + catch (Exception e) { + // no annotation available + } + } + return fAnnotationMap; + } + + protected Object getElementProperty(HTMLPropertyDeclaration decl) { + if (decl instanceof HTMLElementDeclaration) { + return getAnnotationMap().getProperty(((HTMLElementDeclaration)decl).getElementName(), "tagInfo"); //$NON-NLS-1$ + } else { + return null; + } + } + } + + /* + * "shouldKeepSpace" + */ + class PPShouldKeepSpace extends AbstractElementPropertyProvider { + public PPShouldKeepSpace() { + super(); + } + + protected Object getElementProperty(HTMLPropertyDeclaration decl) { + return new Boolean(decl.shouldKeepSpaces()); + } + } + + /* + * "shouldIndentChildSource" + */ + class PPShouldIndentChildSource extends AbstractElementPropertyProvider { + public PPShouldIndentChildSource() { + super(); + } + + protected Object getElementProperty(HTMLPropertyDeclaration decl) { + return new Boolean(decl.shouldIndentChildSource()); + } + } + + /* + * "terminators" + */ + class PPTerminators extends AbstractElementPropertyProvider { + public PPTerminators() { + super(); + } + + protected Object getElementProperty(HTMLPropertyDeclaration decl) { + if (! (decl instanceof HTMLElemDeclImpl)) return null; + return ((HTMLElemDeclImpl)decl).getTerminators(); + } + } + + /* + * "prohibitedAncestors" + */ + class PPProhibitedAncestors extends AbstractElementPropertyProvider { + public PPProhibitedAncestors() { + super(); + } + + protected Object getElementProperty(HTMLPropertyDeclaration decl) { + return decl.getProhibitedAncestors(); + } + } + + /* + * "isJSP" + */ + class PPIsJSP extends AbstractElementPropertyProvider { + public PPIsJSP() { + super(); + } + + protected Object getElementProperty(HTMLPropertyDeclaration decl) { + return new Boolean(decl.isJSP()); + } + } + + /* + * "isXHTML" + * HTMLElementDeclaration itself never represent any XHTML element declaration. + * So, this property must be always false. + */ + class PPIsXHTML extends AbstractElementPropertyProvider { + public PPIsXHTML() { + super(); + } + + protected Object getElementProperty(HTMLPropertyDeclaration decl) { + return new Boolean(false); + } + } + + /* + * "isSSI" + * Each declaration class for SSI elements must provide this property itself, + * and then return true. Other declaration must always return false. + */ + class PPIsSSI extends AbstractElementPropertyProvider { + public PPIsSSI() { + super(); + } + + protected Object getElementProperty(HTMLPropertyDeclaration decl) { + return new Boolean(false); + } + } + + /* + * "lineBreakHint" + */ + class PPLineBreakHint extends AbstractElementPropertyProvider { + public PPLineBreakHint() { + super(); + } + + protected Object getElementProperty(HTMLPropertyDeclaration decl) { + String hint = HTMLCMProperties.Values.BREAK_NONE; + switch (decl.getLineBreakHint()) { + case HTMLElementDeclaration.BREAK_AFTER_START : + hint = HTMLCMProperties.Values.BREAK_AFTER_START; + break; + case HTMLElementDeclaration.BREAK_BEFORE_START_AND_AFTER_END : + hint = HTMLCMProperties.Values.BREAK_BEFORE_START_AND_AFTER_END; + break; + case HTMLElementDeclaration.BREAK_NONE : + // nothing to do + default : + break; + } + return hint; + } + } + + /* + * "layoutType" + */ + class PPLayoutType extends AbstractElementPropertyProvider { + public PPLayoutType() { + super(); + } + + protected Object getElementProperty(HTMLPropertyDeclaration decl) { + String type = HTMLCMProperties.Values.LAYOUT_NONE; + switch (decl.getLayoutType()) { + case HTMLElementDeclaration.LAYOUT_BLOCK : + type = HTMLCMProperties.Values.LAYOUT_BLOCK; + break; + case HTMLElementDeclaration.LAYOUT_BREAK : + type = HTMLCMProperties.Values.LAYOUT_BREAK; + break; + case HTMLElementDeclaration.LAYOUT_HIDDEN : + type = HTMLCMProperties.Values.LAYOUT_HIDDEN; + break; + case HTMLElementDeclaration.LAYOUT_OBJECT : + type = HTMLCMProperties.Values.LAYOUT_OBJECT; + break; + case HTMLElementDeclaration.LAYOUT_WRAP : + type = HTMLCMProperties.Values.LAYOUT_WRAP; + break; + case HTMLElementDeclaration.LAYOUT_NONE : + // nothing to do. + default : + break; + } + return type; + } + } + + /* + * "omitType" + */ + class PPOmitType extends AbstractElementPropertyProvider { + public PPOmitType() { + super(); + } + + protected Object getElementProperty(HTMLPropertyDeclaration decl) { + String type = HTMLCMProperties.Values.OMIT_NONE; + switch (decl.getOmitType()) { + case HTMLElementDeclaration.OMIT_BOTH : + type = HTMLCMProperties.Values.OMIT_BOTH; + break; + case HTMLElementDeclaration.OMIT_END : + type = HTMLCMProperties.Values.OMIT_END; + break; + case HTMLElementDeclaration.OMIT_END_DEFAULT : + type = HTMLCMProperties.Values.OMIT_END_DEFAULT; + break; + case HTMLElementDeclaration.OMIT_END_MUST : + type = HTMLCMProperties.Values.OMIT_END_MUST; + break; + case HTMLElementDeclaration.OMIT_NONE : + // nothing to do. + default : + break; + } + return type; + } + } + + /* + * "inclusion" + */ + class PPInclusion extends AbstractElementPropertyProvider { + public PPInclusion() { + super(); + } + + protected Object getElementProperty(HTMLPropertyDeclaration decl) { + return decl.getInclusion(); + } + } + + public static PropertyProvider getProvider(String propName) { + PropertyProviderFactory factory = getInstance(); + PropertyProvider pp = (PropertyProvider) factory.registry.get(propName); + if (pp != null) + return pp; + + pp = factory.create(propName); + if (pp == null) + return factory.defaultProvider; + + factory.registry.put(propName, pp); + return pp; + } + + private static PropertyProviderFactory instance = null; + + private synchronized static PropertyProviderFactory getInstance() { + if (instance != null) + return instance; + instance = new PropertyProviderFactory(); + return instance; + } + + private Hashtable registry = new Hashtable(); + private PropertyProvider defaultProvider = new DefaultProvider(); + + private PropertyProviderFactory() { + super(); + } + + private PropertyProvider create(String propName) { + PropertyProvider pp = null; + if (propName.equals(HTMLCMProperties.IS_JSP)) + pp = new PPIsJSP(); + else if (propName.equals(HTMLCMProperties.IS_XHTML)) + pp = new PPIsXHTML(); + else if (propName.equals(HTMLCMProperties.IS_SSI)) + pp = new PPIsSSI(); + else if (propName.equals(HTMLCMProperties.LAYOUT_TYPE)) + pp = new PPLayoutType(); + else if (propName.equals(HTMLCMProperties.LINE_BREAK_HINT)) + pp = new PPLineBreakHint(); + else if (propName.equals(HTMLCMProperties.PROHIBITED_ANCESTORS)) + pp = new PPProhibitedAncestors(); + else if (propName.equals(HTMLCMProperties.SHOULD_KEEP_SPACE)) + pp = new PPShouldKeepSpace(); + else if (propName.equals(HTMLCMProperties.SHOULD_INDENT_CHILD_SOURCE)) + pp = new PPShouldIndentChildSource(); + else if (propName.equals(HTMLCMProperties.TERMINATORS)) + pp = new PPTerminators(); + else if (propName.equals(HTMLCMProperties.TAGINFO)) + pp = new PPTagInfo(); + else if (propName.equals(HTMLCMProperties.OMIT_TYPE)) + pp = new PPOmitType(); + else if (propName.equals(HTMLCMProperties.INCLUSION)) + pp = new PPInclusion(); + + return pp; + } +}
\ No newline at end of file diff --git a/bundles/org.eclipse.wst.html.core/src/org/eclipse/wst/html/core/contentmodel/chtml/AttributeCollection.java b/bundles/org.eclipse.wst.html.core/src/org/eclipse/wst/html/core/contentmodel/chtml/AttributeCollection.java new file mode 100644 index 0000000000..8b388bd48c --- /dev/null +++ b/bundles/org.eclipse.wst.html.core/src/org/eclipse/wst/html/core/contentmodel/chtml/AttributeCollection.java @@ -0,0 +1,324 @@ +/******************************************************************************* + * Copyright (c) 2004 IBM Corporation and others. + * All rights reserved. This program and the accompanying materials + * are made available under the terms of the Eclipse Public License v1.0 + * which accompanies this distribution, and is available at + * http://www.eclipse.org/legal/epl-v10.html + * + * Contributors: + * IBM Corporation - initial API and implementation + *******************************************************************************/ +package org.eclipse.wst.html.core.contentmodel.chtml; + + + +import java.util.Iterator; + +import org.eclipse.wst.common.contentmodel.CMAttributeDeclaration; +import org.eclipse.wst.common.contentmodel.CMDataType; +import org.eclipse.wst.common.contentmodel.CMNode; +import org.eclipse.wst.html.core.contentmodel.HTMLAttributeDeclaration; +import org.eclipse.wst.html.core.contentmodel.HTMLCMDataType; + +/** + * Factory for attribute declarations. + */ +final class AttributeCollection extends CMNamedNodeMapImpl implements CHTMLNamespace { + /** + * constructor. + */ + public AttributeCollection() { + super(); + } + + /** + * Create an attribute declaration. + * @return com.ibm.sed.contentmodel.html.HTMLAttrDeclImpl + * @param attrName java.lang.String + */ + private HTMLAttrDeclImpl create(String attrName) { + HTMLAttrDeclImpl attr = null; + HTMLCMDataTypeImpl atype = null; + + if (attrName.equalsIgnoreCase(ATTR_NAME_ACTION)) { + // (action %URI #REQUIRED) + atype = new HTMLCMDataTypeImpl(CMDataType.URI); + attr = new HTMLAttrDeclImpl(ATTR_NAME_ACTION, atype, CMAttributeDeclaration.REQUIRED); + + } + else if (attrName.equalsIgnoreCase(ATTR_NAME_ALT)) { + // (alt %Text; #REQUIRED) + atype = new HTMLCMDataTypeImpl(HTMLCMDataType.TEXT); + attr = new HTMLAttrDeclImpl(ATTR_NAME_ALT, atype, CMAttributeDeclaration.REQUIRED); + + } + else if (attrName.equalsIgnoreCase(ATTR_NAME_BORDER)) { + // (border %Pixels; #IMPLIED) + atype = new HTMLCMDataTypeImpl(HTMLCMDataType.PIXELS); + attr = new HTMLAttrDeclImpl(ATTR_NAME_BORDER, atype, CMAttributeDeclaration.OPTIONAL); + + } + else if (attrName.equalsIgnoreCase(ATTR_NAME_CHECKED)) { + // (checked (checked) #IMPLIED) + atype = new HTMLCMDataTypeImpl(CMDataType.ENUM); + String[] values = {ATTR_NAME_CHECKED}; + atype.setEnumValues(values); + attr = new HTMLAttrDeclImpl(ATTR_NAME_CHECKED, atype, CMAttributeDeclaration.OPTIONAL); + + } + else if (attrName.equalsIgnoreCase(ATTR_NAME_CLEAR)) { + // (clear (left | all | right | none) none) + atype = new HTMLCMDataTypeImpl(CMDataType.ENUM); + String[] values = {ATTR_VALUE_LEFT, ATTR_VALUE_ALL, ATTR_VALUE_RIGHT, ATTR_VALUE_NONE}; + atype.setEnumValues(values); + atype.setImpliedValue(CMDataType.IMPLIED_VALUE_DEFAULT, ATTR_VALUE_NONE); + + attr = new HTMLAttrDeclImpl(ATTR_NAME_CLEAR, atype, CMAttributeDeclaration.OPTIONAL); + + } + else if (attrName.equalsIgnoreCase(ATTR_NAME_COLS)) { + // (cols NUMBER #REQUIRED) + atype = new HTMLCMDataTypeImpl(CMDataType.NUMBER); + attr = new HTMLAttrDeclImpl(ATTR_NAME_COLS, atype, CMAttributeDeclaration.REQUIRED); + + } + else if (attrName.equalsIgnoreCase(ATTR_NAME_ENCTYPE)) { + // (enctype %ContentType; "application/x-www-form-urlencoded") + atype = new HTMLCMDataTypeImpl(HTMLCMDataType.CONTENT_TYPE); + atype.setImpliedValue(CMDataType.IMPLIED_VALUE_DEFAULT, ATTR_VALUE_WWW_FORM_URLENCODED); + attr = new HTMLAttrDeclImpl(ATTR_NAME_ENCTYPE, atype, CMAttributeDeclaration.OPTIONAL); + + } + else if (attrName.equalsIgnoreCase(ATTR_NAME_HEIGHT)) { + // (height %Length; #IMPLIED) + atype = new HTMLCMDataTypeImpl(HTMLCMDataType.LENGTH); + attr = new HTMLAttrDeclImpl(ATTR_NAME_HEIGHT, atype, CMAttributeDeclaration.OPTIONAL); + + } + else if (attrName.equalsIgnoreCase(ATTR_NAME_HREF)) { + // (href %URI; #IMPLIED) + atype = new HTMLCMDataTypeImpl(CMDataType.URI); + attr = new HTMLAttrDeclImpl(ATTR_NAME_HREF, atype, CMAttributeDeclaration.OPTIONAL); + + } + else if (attrName.equalsIgnoreCase(ATTR_NAME_HSPACE)) { + // (hspace %Pixels; #IMPLIED) + atype = new HTMLCMDataTypeImpl(HTMLCMDataType.PIXELS); + attr = new HTMLAttrDeclImpl(ATTR_NAME_HSPACE, atype, CMAttributeDeclaration.OPTIONAL); + + } + else if (attrName.equalsIgnoreCase(ATTR_NAME_HTTP_EQUIV)) { + // (http-equiv NAME #IMPLIED) + atype = new HTMLCMDataTypeImpl(HTMLCMDataType.NAME); + attr = new HTMLAttrDeclImpl(ATTR_NAME_HTTP_EQUIV, atype, CMAttributeDeclaration.OPTIONAL); + + } + else if (attrName.equalsIgnoreCase(ATTR_NAME_MAXLENGTH)) { + // (maxlength NUMBER #IMPLIED) + atype = new HTMLCMDataTypeImpl(CMDataType.NUMBER); + attr = new HTMLAttrDeclImpl(ATTR_NAME_MAXLENGTH, atype, CMAttributeDeclaration.OPTIONAL); + + } + else if (attrName.equalsIgnoreCase(ATTR_NAME_METHOD)) { + // (method (GET|POST) GET) + atype = new HTMLCMDataTypeImpl(CMDataType.ENUM); + String[] values = {ATTR_VALUE_GET, ATTR_VALUE_POST}; + atype.setEnumValues(values); + atype.setImpliedValue(CMDataType.IMPLIED_VALUE_DEFAULT, ATTR_VALUE_GET); + attr = new HTMLAttrDeclImpl(ATTR_NAME_METHOD, atype, CMAttributeDeclaration.OPTIONAL); + + } + else if (attrName.equalsIgnoreCase(ATTR_NAME_MULTIPLE)) { + // (multiple (multiple) #IMPLIED) + atype = new HTMLCMDataTypeImpl(CMDataType.ENUM); + String[] values = {ATTR_NAME_MULTIPLE}; + atype.setEnumValues(values); + attr = new HTMLAttrDeclImpl(ATTR_NAME_MULTIPLE, atype, CMAttributeDeclaration.OPTIONAL); + + } + else if (attrName.equalsIgnoreCase(ATTR_NAME_NAME)) { + // (name CDATA #IMPLIED) + atype = new HTMLCMDataTypeImpl(CMDataType.CDATA); + attr = new HTMLAttrDeclImpl(ATTR_NAME_NAME, atype, CMAttributeDeclaration.OPTIONAL); + + } + else if (attrName.equalsIgnoreCase(ATTR_NAME_NOSHADE)) { + // (noshade (noshade) #IMPLIED) + atype = new HTMLCMDataTypeImpl(CMDataType.ENUM); + String[] values = {ATTR_NAME_NOSHADE}; + atype.setEnumValues(values); + attr = new HTMLAttrDeclImpl(ATTR_NAME_NOSHADE, atype, CMAttributeDeclaration.OPTIONAL); + + } + else if (attrName.equalsIgnoreCase(ATTR_NAME_ROWS)) { + // (rows NUMBER #REQUIRED) + atype = new HTMLCMDataTypeImpl(CMDataType.NUMBER); + attr = new HTMLAttrDeclImpl(ATTR_NAME_ROWS, atype, CMAttributeDeclaration.REQUIRED); + + } + else if (attrName.equalsIgnoreCase(ATTR_NAME_SELECTED)) { + // (selected (selected) #IMPLIED) + atype = new HTMLCMDataTypeImpl(CMDataType.ENUM); + String[] values = {ATTR_NAME_SELECTED}; + atype.setEnumValues(values); + attr = new HTMLAttrDeclImpl(ATTR_NAME_SELECTED, atype, CMAttributeDeclaration.OPTIONAL); + + } + else if (attrName.equalsIgnoreCase(ATTR_NAME_SIZE)) { + // (size %Pixels; #IMPLIED) + atype = new HTMLCMDataTypeImpl(HTMLCMDataType.PIXELS); + attr = new HTMLAttrDeclImpl(ATTR_NAME_SIZE, atype, CMAttributeDeclaration.OPTIONAL); + + } + else if (attrName.equalsIgnoreCase(ATTR_NAME_SRC)) { + // (src %URI; #IMPLIED) + // NOTE: "src" attributes are defined in several elements. + // The definition of IMG is different from others. + // So, it should be locally defined. + atype = new HTMLCMDataTypeImpl(CMDataType.URI); + attr = new HTMLAttrDeclImpl(ATTR_NAME_SRC, atype, CMAttributeDeclaration.OPTIONAL); + + } + else if (attrName.equalsIgnoreCase(ATTR_NAME_TYPE)) { + // (type %CotentType; #IMPLIED) + atype = new HTMLCMDataTypeImpl(HTMLCMDataType.CONTENT_TYPE); + attr = new HTMLAttrDeclImpl(ATTR_NAME_TYPE, atype, CMAttributeDeclaration.OPTIONAL); + + } + else if (attrName.equalsIgnoreCase(ATTR_NAME_VALUE)) { + // (value CDATA #IMPLIED) + atype = new HTMLCMDataTypeImpl(CMDataType.CDATA); + attr = new HTMLAttrDeclImpl(ATTR_NAME_VALUE, atype, CMAttributeDeclaration.OPTIONAL); + + } + else if (attrName.equalsIgnoreCase(ATTR_NAME_VERSION)) { + // (version CDATA #FIXED '%HTML.Version;) + atype = new HTMLCMDataTypeImpl(CMDataType.CDATA); + atype.setImpliedValue(CMDataType.IMPLIED_VALUE_FIXED, ATTR_VALUE_VERSION_TRANSITIONAL); + attr = new HTMLAttrDeclImpl(ATTR_NAME_VERSION, atype, CMAttributeDeclaration.FIXED); + + } + else if (attrName.equalsIgnoreCase(ATTR_NAME_WIDTH)) { + // (width %Length; #IMPLIED) + atype = new HTMLCMDataTypeImpl(HTMLCMDataType.LENGTH); + attr = new HTMLAttrDeclImpl(ATTR_NAME_WIDTH, atype, CMAttributeDeclaration.OPTIONAL); + + } + else if (attrName.equalsIgnoreCase(ATTR_NAME_VSPACE)) { + // (vspace %Pixels; #IMPLIED) + atype = new HTMLCMDataTypeImpl(HTMLCMDataType.PIXELS); + attr = new HTMLAttrDeclImpl(ATTR_NAME_VSPACE, atype, CMAttributeDeclaration.OPTIONAL); + + // <<D205514 + } + else { + // unknown attribute; maybe error. + // should warn. + attr = null; + } + + return attr; + } + + /** + * Get %bodycolors; declarations. + * @param attributes com.ibm.sed.contentmodel.html.CMNamedNodeMapImpl + */ + public void getBodycolors(CMNamedNodeMapImpl declarations) { + } + + /** + * Get align attribute which has %IAlign; as values.. + * @param attributes com.ibm.sed.contentmodel.html.CMNamedNodeMapImpl + */ + public static final HTMLAttrDeclImpl createAlignForImage() { + // align (local) + HTMLCMDataTypeImpl atype = new HTMLCMDataTypeImpl(CMDataType.ENUM); + // set enum values + String[] values = {ATTR_VALUE_TOP, ATTR_VALUE_MIDDLE, ATTR_VALUE_BOTTOM, ATTR_VALUE_LEFT, ATTR_VALUE_RIGHT}; + atype.setEnumValues(values); + + HTMLAttrDeclImpl attr = new HTMLAttrDeclImpl(ATTR_NAME_ALIGN, atype, CMAttributeDeclaration.OPTIONAL); + return attr; + } + + /** + * Create an attribute declaration for <code>align</code> + * in several elements, like <code>P</code>, <code>DIV</code>. + * The values are different from attributes those have the same name + * in other elements (<code>IMG</code> and <code>TABLE</code>). + * So, it can't treat as global attributes. + * <strong>NOTE: These attribute declaration has + * no owner CMDocument instance.</strong> + * @return com.ibm.sed.contentmodel.html.HTMLAttrDeclImpl + */ + public static final HTMLAttrDeclImpl createAlignForParagraph() { + HTMLCMDataTypeImpl atype = new HTMLCMDataTypeImpl(CMDataType.ENUM); + // set enum values: left|center|right|justify + String[] values = {ATTR_VALUE_LEFT, ATTR_VALUE_CENTER, ATTR_VALUE_RIGHT,}; + atype.setEnumValues(values); + + HTMLAttrDeclImpl attr = new HTMLAttrDeclImpl(ATTR_NAME_ALIGN, atype, CMAttributeDeclaration.OPTIONAL); + return attr; + } + + /** + * Get %attrs; declarations. + * %attrs; consists of %coreattrs;, %i18n, and %events;. + * @param attributes com.ibm.sed.contentmodel.html.CMNamedNodeMapImpl + */ + public void getAttrs(CMNamedNodeMapImpl declarations) { + } + + /** + * Get %coreattrs; declarations. + * @param attributes com.ibm.sed.contentmodel.html.CMNamedNodeMapImpl + */ + public void getCore(CMNamedNodeMapImpl declarations) { + } + + /** + * Get a global attribute declaration. + * @return com.ibm.sed.contentmodel.html.HTMLAttrributeDeclaration + * @param attrName java.lang.String + */ + public HTMLAttributeDeclaration getDeclaration(String attrName) { + CMNode cmnode = getNamedItem(attrName); + if (cmnode != null) + return (HTMLAttributeDeclaration) cmnode; // already exists. + + HTMLAttrDeclImpl dec = create(attrName); + if (dec != null) + putNamedItem(attrName, dec); + + return dec; + } + + /** + * Get declarations which are specified by names. + * @param declarations com.ibm.sed.contentmodel.html.CMNamedNodeMapImpl + * @param names java.util.Iterator + */ + public void getDeclarations(CMNamedNodeMapImpl declarations, Iterator names) { + while (names.hasNext()) { + String attrName = (String) names.next(); + HTMLAttributeDeclaration dec = getDeclaration(attrName); + if (dec != null) + declarations.putNamedItem(attrName, dec); + } + } + + /** + * Get %events; declarations. + * @param attributes com.ibm.sed.contentmodel.html.CMNamedNodeMapImpl + */ + public void getEvents(CMNamedNodeMapImpl declarations) { + } + + /** + * Get %i18n; declarations. + * @param attributes com.ibm.sed.contentmodel.html.CMNamedNodeMapImpl + */ + public void getI18n(CMNamedNodeMapImpl declarations) { + } +}
\ No newline at end of file diff --git a/bundles/org.eclipse.wst.html.core/src/org/eclipse/wst/html/core/contentmodel/chtml/CHCMDocImpl.java b/bundles/org.eclipse.wst.html.core/src/org/eclipse/wst/html/core/contentmodel/chtml/CHCMDocImpl.java new file mode 100644 index 0000000000..d191f98b40 --- /dev/null +++ b/bundles/org.eclipse.wst.html.core/src/org/eclipse/wst/html/core/contentmodel/chtml/CHCMDocImpl.java @@ -0,0 +1,95 @@ +/******************************************************************************* + * Copyright (c) 2004 IBM Corporation and others. + * All rights reserved. This program and the accompanying materials + * are made available under the terms of the Eclipse Public License v1.0 + * which accompanies this distribution, and is available at + * http://www.eclipse.org/legal/epl-v10.html + * + * Contributors: + * IBM Corporation - initial API and implementation + *******************************************************************************/ +package org.eclipse.wst.html.core.contentmodel.chtml; + + + +import org.eclipse.wst.common.contentmodel.CMNamedNodeMap; +import org.eclipse.wst.common.contentmodel.CMNamespace; +import org.eclipse.wst.common.contentmodel.CMNode; +import org.eclipse.wst.html.core.contentmodel.HTMLCMDocument; +import org.eclipse.wst.html.core.contentmodel.HTMLElementDeclaration; +import org.eclipse.wst.html.core.contentmodel.HTMLEntityDeclaration; + +/** + * CMDocument implementation for the HTML. + */ +public class CHCMDocImpl extends CMNodeImpl implements HTMLCMDocument { + + /** Namespace for all names of elements, entities and attributes. */ + private CMNamespace namespace = null; + private ElementCollection elements = null; + private EntityCollection entities = null; + private AttributeCollection attributes = null; + + /** + */ + public CHCMDocImpl(String docTypeName, CMNamespace targetNamespace) { + super(docTypeName); + namespace = targetNamespace; + attributes = new AttributeCollection(); + elements = new ElementCollection(attributes); + entities = new EntityCollection(); + } + + /** + * @return com.ibm.sed.contentmodel.html.AttributeCollection + */ + AttributeCollection getAttributes() { + return attributes; + } + + /** + * @see com.ibm.sed.contentmodel.html.HTMLCMDocument + */ + public HTMLElementDeclaration getElementDeclaration(String elementName) { + if (elements == null) + return null; + return (HTMLElementDeclaration) elements.getNamedItem(elementName); + } + + /** + * @see org.eclipse.wst.common.contentmodel.CMDocument + */ + public CMNamedNodeMap getElements() { + return elements; + } + + /** + * @see org.eclipse.wst.common.contentmodel.CMDocument + */ + public CMNamedNodeMap getEntities() { + return entities; + } + + /** + * @see com.ibm.sed.contentmodel.html.HTMLCMDocument + */ + public HTMLEntityDeclaration getEntityDeclaration(String entityName) { + if (entities == null) + return null; + return (HTMLEntityDeclaration) entities.getNamedItem(entityName); + } + + /** + * @see org.eclipse.wst.common.contentmodel.CMDocument + */ + public org.eclipse.wst.common.contentmodel.CMNamespace getNamespace() { + return namespace; + } + + /** + * @see org.eclipse.wst.common.contentmodel.CMNode + */ + public int getNodeType() { + return CMNode.DOCUMENT; + } +}
\ No newline at end of file diff --git a/bundles/org.eclipse.wst.html.core/src/org/eclipse/wst/html/core/contentmodel/chtml/CHTMLNamespace.java b/bundles/org.eclipse.wst.html.core/src/org/eclipse/wst/html/core/contentmodel/chtml/CHTMLNamespace.java new file mode 100644 index 0000000000..d2d2d8e2fd --- /dev/null +++ b/bundles/org.eclipse.wst.html.core/src/org/eclipse/wst/html/core/contentmodel/chtml/CHTMLNamespace.java @@ -0,0 +1,152 @@ +/******************************************************************************* + * Copyright (c) 2004 IBM Corporation and others. + * All rights reserved. This program and the accompanying materials + * are made available under the terms of the Eclipse Public License v1.0 + * which accompanies this distribution, and is available at + * http://www.eclipse.org/legal/epl-v10.html + * + * Contributors: + * IBM Corporation - initial API and implementation + *******************************************************************************/ +package org.eclipse.wst.html.core.contentmodel.chtml; + +import org.eclipse.wst.html.core.HTML40Namespace; + + + +/** + * Provide all names defined in the HTML 4.0? specification. + */ +public interface CHTMLNamespace { + + // Element names + public static interface ElementName { + public static final String A = HTML40Namespace.ElementName.A; + public static final String ADDRESS = HTML40Namespace.ElementName.ADDRESS; + public static final String BASE = HTML40Namespace.ElementName.BASE; + public static final String BLOCKQUOTE = HTML40Namespace.ElementName.BLOCKQUOTE; + public static final String BODY = HTML40Namespace.ElementName.BODY; + public static final String BR = HTML40Namespace.ElementName.BR; + public static final String CENTER = HTML40Namespace.ElementName.CENTER; + public static final String DD = HTML40Namespace.ElementName.DD; + public static final String DIR = HTML40Namespace.ElementName.DIR; + public static final String DIV = HTML40Namespace.ElementName.DIV; + public static final String DL = HTML40Namespace.ElementName.DL; + public static final String DT = HTML40Namespace.ElementName.DT; + public static final String FORM = HTML40Namespace.ElementName.FORM; + public static final String H1 = HTML40Namespace.ElementName.H1; + public static final String H2 = HTML40Namespace.ElementName.H2; + public static final String H3 = HTML40Namespace.ElementName.H3; + public static final String H4 = HTML40Namespace.ElementName.H4; + public static final String H5 = HTML40Namespace.ElementName.H5; + public static final String H6 = HTML40Namespace.ElementName.H6; + public static final String HEAD = HTML40Namespace.ElementName.HEAD; + public static final String HR = HTML40Namespace.ElementName.HR; + public static final String HTML = HTML40Namespace.ElementName.HTML; + public static final String IMG = HTML40Namespace.ElementName.IMG; + public static final String INPUT = HTML40Namespace.ElementName.INPUT; + public static final String LI = HTML40Namespace.ElementName.LI; + public static final String MENU = HTML40Namespace.ElementName.MENU; + public static final String META = HTML40Namespace.ElementName.META; + public static final String OL = HTML40Namespace.ElementName.OL; + public static final String OPTION = HTML40Namespace.ElementName.OPTION; + public static final String P = HTML40Namespace.ElementName.P; + public static final String PRE = HTML40Namespace.ElementName.PRE; + public static final String SELECT = HTML40Namespace.ElementName.SELECT; + public static final String TEXTAREA = HTML40Namespace.ElementName.TEXTAREA; + public static final String TITLE = HTML40Namespace.ElementName.TITLE; + public static final String UL = HTML40Namespace.ElementName.UL; + public static final String SSI_CONFIG = HTML40Namespace.ElementName.SSI_CONFIG; + public static final String SSI_ECHO = HTML40Namespace.ElementName.SSI_ECHO; + public static final String SSI_EXEC = HTML40Namespace.ElementName.SSI_EXEC; + public static final String SSI_FSIZE = HTML40Namespace.ElementName.SSI_FSIZE; + public static final String SSI_FLASTMOD = HTML40Namespace.ElementName.SSI_FLASTMOD; + public static final String SSI_INCLUDE = HTML40Namespace.ElementName.SSI_INCLUDE; + public static final String SSI_PRINTENV = HTML40Namespace.ElementName.SSI_PRINTENV; + public static final String SSI_SET = HTML40Namespace.ElementName.SSI_SET; + } + + // Character Entities + public static interface EntityName { + } + + // global attribute names + public static final String ATTR_NAME_VERSION = HTML40Namespace.ATTR_NAME_VERSION; + public static final String ATTR_NAME_SRC = HTML40Namespace.ATTR_NAME_SRC; + public static final String ATTR_NAME_ALT = HTML40Namespace.ATTR_NAME_ALT; + public static final String ATTR_NAME_HEIGHT = HTML40Namespace.ATTR_NAME_HEIGHT; + public static final String ATTR_NAME_WIDTH = HTML40Namespace.ATTR_NAME_WIDTH; + public static final String ATTR_NAME_ALIGN = HTML40Namespace.ATTR_NAME_ALIGN; + public static final String ATTR_NAME_BORDER = HTML40Namespace.ATTR_NAME_BORDER; + public static final String ATTR_NAME_HSPACE = HTML40Namespace.ATTR_NAME_HSPACE; + public static final String ATTR_NAME_VSPACE = HTML40Namespace.ATTR_NAME_VSPACE; + public static final String ATTR_NAME_NAME = HTML40Namespace.ATTR_NAME_NAME; + public static final String ATTR_NAME_CLEAR = HTML40Namespace.ATTR_NAME_CLEAR; + public static final String ATTR_NAME_NOSHADE = HTML40Namespace.ATTR_NAME_NOSHADE; + public static final String ATTR_NAME_CHECKED = HTML40Namespace.ATTR_NAME_CHECKED; + public static final String ATTR_NAME_MAXLENGTH = HTML40Namespace.ATTR_NAME_MAXLENGTH; + public static final String ATTR_NAME_ISTYLE = HTML40Namespace.ATTR_NAME_ISTYLE; + public static final String ATTR_NAME_HTTP_EQUIV = HTML40Namespace.ATTR_NAME_HTTP_EQUIV; + public static final String ATTR_NAME_CONTENT = HTML40Namespace.ATTR_NAME_CONTENT; + + public static final String ATTR_NAME_HREF = HTML40Namespace.ATTR_NAME_HREF; + public static final String ATTR_NAME_MULTIPLE = HTML40Namespace.ATTR_NAME_MULTIPLE; + public static final String ATTR_NAME_SELECTED = HTML40Namespace.ATTR_NAME_SELECTED; + public static final String ATTR_NAME_ROWS = HTML40Namespace.ATTR_NAME_ROWS; + public static final String ATTR_NAME_COLS = HTML40Namespace.ATTR_NAME_COLS; + public static final String ATTR_NAME_ACTION = HTML40Namespace.ATTR_NAME_ACTION; + public static final String ATTR_NAME_METHOD = HTML40Namespace.ATTR_NAME_METHOD; + public static final String ATTR_NAME_ENCTYPE = HTML40Namespace.ATTR_NAME_ENCTYPE; + public static final String ATTR_NAME_SIZE = HTML40Namespace.ATTR_NAME_SIZE; + public static final String ATTR_NAME_TYPE = HTML40Namespace.ATTR_NAME_TYPE; + public static final String ATTR_NAME_VALUE = HTML40Namespace.ATTR_NAME_VALUE; + + + + public static final String ATTR_NAME_ERRMSG = HTML40Namespace.ATTR_NAME_ERRMSG; + public static final String ATTR_NAME_SIZEFMT = HTML40Namespace.ATTR_NAME_SIZEFMT; + public static final String ATTR_NAME_TIMEFMT = HTML40Namespace.ATTR_NAME_TIMEFMT; + public static final String ATTR_NAME_VAR = HTML40Namespace.ATTR_NAME_VAR; + public static final String ATTR_NAME_CGI = HTML40Namespace.ATTR_NAME_CGI; + public static final String ATTR_NAME_CMD = HTML40Namespace.ATTR_NAME_CMD; + public static final String ATTR_NAME_FILE = HTML40Namespace.ATTR_NAME_FILE; + public static final String ATTR_NAME_VIRTUAL = HTML40Namespace.ATTR_NAME_VIRTUAL; + + // global attribute values; mainly used in enumeration. + public static final String ATTR_VALUE_VERSION_TRANSITIONAL = "-//W3C//DTD Compact HTML 1.0 Draft//EN"; //$NON-NLS-1$ + // for align (top|middle|bottom|left|right) + public static final String ATTR_VALUE_TOP = HTML40Namespace.ATTR_VALUE_TOP; + public static final String ATTR_VALUE_MIDDLE = HTML40Namespace.ATTR_VALUE_MIDDLE; + public static final String ATTR_VALUE_BOTTOM = HTML40Namespace.ATTR_VALUE_BOTTOM; + public static final String ATTR_VALUE_LEFT = HTML40Namespace.ATTR_VALUE_LEFT; + public static final String ATTR_VALUE_CENTER = HTML40Namespace.ATTR_VALUE_CENTER; + public static final String ATTR_VALUE_RIGHT = HTML40Namespace.ATTR_VALUE_RIGHT; + // for clear (left|all|right|none): left and right are already defined above. + public static final String ATTR_VALUE_ALL = HTML40Namespace.ATTR_VALUE_ALL; + public static final String ATTR_VALUE_NONE = HTML40Namespace.ATTR_VALUE_NONE; + // for type of INPUT + // (text | password | checkbox | radio | submit | reset | + // file | hidden | image | button) + public static final String ATTR_VALUE_TEXT = HTML40Namespace.ATTR_VALUE_TEXT; + public static final String ATTR_VALUE_PASSWORD = HTML40Namespace.ATTR_VALUE_PASSWORD; + public static final String ATTR_VALUE_CHECKBOX = HTML40Namespace.ATTR_VALUE_CHECKBOX; + public static final String ATTR_VALUE_RADIO = HTML40Namespace.ATTR_VALUE_RADIO; + public static final String ATTR_VALUE_SUBMIT = HTML40Namespace.ATTR_VALUE_SUBMIT; + public static final String ATTR_VALUE_RESET = HTML40Namespace.ATTR_VALUE_RESET; + public static final String ATTR_VALUE_HIDDEN = HTML40Namespace.ATTR_VALUE_HIDDEN; + // for span, colspan, rowspan + public static final String ATTR_VALUE_1 = HTML40Namespace.ATTR_VALUE_1; + // for frameborder + public static final String ATTR_VALUE_0 = HTML40Namespace.ATTR_VALUE_0; + // for method of FORM + public static final String ATTR_VALUE_GET = HTML40Namespace.ATTR_VALUE_GET; + public static final String ATTR_VALUE_POST = HTML40Namespace.ATTR_VALUE_POST; + public static final String ATTR_VALUE_WWW_FORM_URLENCODED = HTML40Namespace.ATTR_VALUE_WWW_FORM_URLENCODED; + // for behaviro of MARQUEE + public static final String ATTR_VALUE_SCROLL = HTML40Namespace.ATTR_VALUE_SCROLL; + public static final String ATTR_VALUE_SLIDE = HTML40Namespace.ATTR_VALUE_SLIDE; + public static final String ATTR_VALUE_ALTERNATE = HTML40Namespace.ATTR_VALUE_ALTERNATE; + // for direction of MARQUEE + public static final String ATTR_VALUE_UP = HTML40Namespace.ATTR_VALUE_UP; + public static final String ATTR_VALUE_DOWN = HTML40Namespace.ATTR_VALUE_DOWN; +}
\ No newline at end of file diff --git a/bundles/org.eclipse.wst.html.core/src/org/eclipse/wst/html/core/contentmodel/chtml/CMContentImpl.java b/bundles/org.eclipse.wst.html.core/src/org/eclipse/wst/html/core/contentmodel/chtml/CMContentImpl.java new file mode 100644 index 0000000000..c9f5219d8f --- /dev/null +++ b/bundles/org.eclipse.wst.html.core/src/org/eclipse/wst/html/core/contentmodel/chtml/CMContentImpl.java @@ -0,0 +1,56 @@ +/******************************************************************************* + * Copyright (c) 2004 IBM Corporation and others. + * All rights reserved. This program and the accompanying materials + * are made available under the terms of the Eclipse Public License v1.0 + * which accompanies this distribution, and is available at + * http://www.eclipse.org/legal/epl-v10.html + * + * Contributors: + * IBM Corporation - initial API and implementation + *******************************************************************************/ +package org.eclipse.wst.html.core.contentmodel.chtml; + + + +/** + * Implementation of CMContent for HTML CM. + */ +abstract class CMContentImpl extends CMNodeImpl implements org.eclipse.wst.common.contentmodel.CMContent { + + public static final int UNBOUNDED = -1; + /** -1: it's UNBOUNDED. */ + private int maxOccur = UNBOUNDED; + /** 0: it's OPTIONAL, 1, it's REQUIRED. */ + private int minOccur = 0; + + /** + * The primary consturctor. + * Use this one for usual cases.<br> + */ + public CMContentImpl(String name, int min, int max) { + super(name); + minOccur = min; + maxOccur = max; + } + + /** + * getMaxOccur method + * @return int + * + * If -1, it's UNBOUNDED. + */ + public int getMaxOccur() { + return maxOccur; + } + + /** + * getMinOccur method + * @return int + * + * If 0, it's OPTIONAL. + * If 1, it's REQUIRED. + */ + public int getMinOccur() { + return minOccur; + } +}
\ No newline at end of file diff --git a/bundles/org.eclipse.wst.html.core/src/org/eclipse/wst/html/core/contentmodel/chtml/CMGroupImpl.java b/bundles/org.eclipse.wst.html.core/src/org/eclipse/wst/html/core/contentmodel/chtml/CMGroupImpl.java new file mode 100644 index 0000000000..509bf9e173 --- /dev/null +++ b/bundles/org.eclipse.wst.html.core/src/org/eclipse/wst/html/core/contentmodel/chtml/CMGroupImpl.java @@ -0,0 +1,83 @@ +/******************************************************************************* + * Copyright (c) 2004 IBM Corporation and others. + * All rights reserved. This program and the accompanying materials + * are made available under the terms of the Eclipse Public License v1.0 + * which accompanies this distribution, and is available at + * http://www.eclipse.org/legal/epl-v10.html + * + * Contributors: + * IBM Corporation - initial API and implementation + *******************************************************************************/ +package org.eclipse.wst.html.core.contentmodel.chtml; + + + +import org.eclipse.wst.common.contentmodel.CMGroup; +import org.eclipse.wst.common.contentmodel.CMNode; +import org.eclipse.wst.common.contentmodel.CMNodeList; + +/** + */ +class CMGroupImpl extends CMContentImpl implements CMGroup { + + private int operator = CMGroup.SEQUENCE; + private CMNodeListImpl children = null; + + /** + * CMGroupImpl constructor comment. + */ + public CMGroupImpl(int op, int minOccur, int maxOccur) { + super(null, minOccur, maxOccur); + switch (op) { + case CMGroup.ALL : + case CMGroup.CHOICE : + case CMGroup.SEQUENCE : + operator = op; + break; + default : + // should warn. + break; + } + } + + /** + * @return org.eclipse.wst.common.contentmodel.CMNode + * @param org.eclipse.wst.common.contentmodel.CMNode + */ + protected CMNode appendChild(CMNode child) { + if (child == null) + return null; + if (children == null) + children = new CMNodeListImpl(); + return children.appendNode(child); + } + + /** + * @return org.eclipse.wst.common.contentmodel.CMNodeList + */ + public CMNodeList getChildNodes() { + return children; + } + + /** + * getNodeType method + * @return int + * + * Returns one of : + * ELEMENT_DECLARATION, ATTRIBUTE_DECLARATION, GROUP, ENTITY_DECLARATION. + */ + public int getNodeType() { + return CMNode.GROUP; + } + + /** + * getOperation method + * @return int + * + * Returns one of : + * ALONE (a), SEQUENCE (a,b), CHOICE (a|b), ALL (a&b). + */ + public int getOperator() { + return operator; + } +}
\ No newline at end of file diff --git a/bundles/org.eclipse.wst.html.core/src/org/eclipse/wst/html/core/contentmodel/chtml/CMNamedNodeMapImpl.java b/bundles/org.eclipse.wst.html.core/src/org/eclipse/wst/html/core/contentmodel/chtml/CMNamedNodeMapImpl.java new file mode 100644 index 0000000000..39a7ba9a81 --- /dev/null +++ b/bundles/org.eclipse.wst.html.core/src/org/eclipse/wst/html/core/contentmodel/chtml/CMNamedNodeMapImpl.java @@ -0,0 +1,97 @@ +/******************************************************************************* + * Copyright (c) 2004 IBM Corporation and others. + * All rights reserved. This program and the accompanying materials + * are made available under the terms of the Eclipse Public License v1.0 + * which accompanies this distribution, and is available at + * http://www.eclipse.org/legal/epl-v10.html + * + * Contributors: + * IBM Corporation - initial API and implementation + *******************************************************************************/ +package org.eclipse.wst.html.core.contentmodel.chtml; + + + +import java.util.Iterator; + +import org.eclipse.wst.common.contentmodel.CMNode; + +/** + * An implementation of the CMNamedNodeMap interface. + * This class is intented to be used as a container of attribute declarations. + * If someone wants to use this class for other purpose, he must pay attention + * to the fact that this class is tolerant of the key name case. That is, this + * class does not distinguish "name", "NAME", and "Name" as a key name. + */ +class CMNamedNodeMapImpl implements org.eclipse.wst.common.contentmodel.CMNamedNodeMap { + + private java.util.Hashtable items = null; + + /** + */ + public CMNamedNodeMapImpl() { + super(); + items = new java.util.Hashtable(); + } + + /** + * getLength method + * @return int + */ + public int getLength() { + return items.size(); + } + + /** + * getNamedItem method + * @return CMNode <code>null</code> for unknown keys. + * @param name java.lang.String + */ + public CMNode getNamedItem(String name) { + String cookedName = makeCanonicalForm(name); + if (!items.containsKey(cookedName)) + return null; + return (CMNode) items.get(cookedName); + } + + /** + * item method + * @return CMNode + * @param index int + */ + public CMNode item(int index) { + Iterator iter = iterator(); + while (iter.hasNext()) { + CMNode node = (CMNode) iter.next(); + if (--index < 0) + return node; + } + return null; + } + + /** + * @return java.util.Iterator + */ + public Iterator iterator() { + return items.values().iterator(); + } + + /** + * @return java.lang.String + * @param rawForm java.lang.String + */ + private String makeCanonicalForm(String rawForm) { + return rawForm.toUpperCase(); + } + + /** + * @param key java.lang.String + * @param item java.lang.String + */ + void putNamedItem(String name, CMNode item) { + String cookedName = makeCanonicalForm(name); + if (items.containsKey(cookedName)) + return; // already registered. + items.put(cookedName, item); + } +}
\ No newline at end of file diff --git a/bundles/org.eclipse.wst.html.core/src/org/eclipse/wst/html/core/contentmodel/chtml/CMNodeImpl.java b/bundles/org.eclipse.wst.html.core/src/org/eclipse/wst/html/core/contentmodel/chtml/CMNodeImpl.java new file mode 100644 index 0000000000..69707962d5 --- /dev/null +++ b/bundles/org.eclipse.wst.html.core/src/org/eclipse/wst/html/core/contentmodel/chtml/CMNodeImpl.java @@ -0,0 +1,64 @@ +/******************************************************************************* + * Copyright (c) 2004 IBM Corporation and others. + * All rights reserved. This program and the accompanying materials + * are made available under the terms of the Eclipse Public License v1.0 + * which accompanies this distribution, and is available at + * http://www.eclipse.org/legal/epl-v10.html + * + * Contributors: + * IBM Corporation - initial API and implementation + *******************************************************************************/ +package org.eclipse.wst.html.core.contentmodel.chtml; + +import org.eclipse.wst.html.core.HTMLCMProperties; + + + +/** + */ +abstract class CMNodeImpl implements org.eclipse.wst.common.contentmodel.CMNode { + + private java.lang.String name = null; + + /** + * CMNodeImpl constructor comment. + */ + public CMNodeImpl(String nm) { + super(); + name = nm; + } + + /** + * getNodeName method + * @return java.lang.String + */ + public String getNodeName() { + return name; + } + + /** + * getProperty method + * @return java.lang.Object + * + * Returns the object property desciped by the propertyName + * + */ + public Object getProperty(String propertyName) { + if (propertyName.equals(HTMLCMProperties.IS_XHTML)) + return new Boolean(false); + return null; + } + + /** + * supports method + * @return boolean + * + * Returns true if the CMNode supports a specified property + * + */ + public boolean supports(String propertyName) { + if (propertyName.equals(HTMLCMProperties.IS_XHTML)) + return true; + return false; + } +}
\ No newline at end of file diff --git a/bundles/org.eclipse.wst.html.core/src/org/eclipse/wst/html/core/contentmodel/chtml/CMNodeListImpl.java b/bundles/org.eclipse.wst.html.core/src/org/eclipse/wst/html/core/contentmodel/chtml/CMNodeListImpl.java new file mode 100644 index 0000000000..1aba885873 --- /dev/null +++ b/bundles/org.eclipse.wst.html.core/src/org/eclipse/wst/html/core/contentmodel/chtml/CMNodeListImpl.java @@ -0,0 +1,61 @@ +/******************************************************************************* + * Copyright (c) 2004 IBM Corporation and others. + * All rights reserved. This program and the accompanying materials + * are made available under the terms of the Eclipse Public License v1.0 + * which accompanies this distribution, and is available at + * http://www.eclipse.org/legal/epl-v10.html + * + * Contributors: + * IBM Corporation - initial API and implementation + *******************************************************************************/ +package org.eclipse.wst.html.core.contentmodel.chtml; + + + +import org.eclipse.wst.common.contentmodel.CMNode; + +/** + * Analog of dom.NodeList for CM. + * So, the implementation is very similar to + * {@link com.ibm.sed.model.xml.NodeListImpl}.<br> + */ +class CMNodeListImpl implements org.eclipse.wst.common.contentmodel.CMNodeList { + + private java.util.Vector nodes = null; + + /** + * CMNodeListImpl constructor comment. + */ + public CMNodeListImpl() { + super(); + nodes = new java.util.Vector(); + } + + /** + * @return org.eclipse.wst.common.contentmodel.CMNode + * @param node org.eclipse.wst.common.contentmodel.CMNode + */ + protected CMNode appendNode(CMNode node) { + nodes.addElement(node); + return node; + } + + /** + * getLength method + * @return int + */ + public int getLength() { + return nodes.size(); + } + + /** + * item method + * @return CMNode + * @param index int + */ + public CMNode item(int index) { + if (index < 0 || index >= nodes.size()) + return null; + return (CMNode) nodes.elementAt(index); + } +}
\ No newline at end of file diff --git a/bundles/org.eclipse.wst.html.core/src/org/eclipse/wst/html/core/contentmodel/chtml/ComplexTypeDefinition.java b/bundles/org.eclipse.wst.html.core/src/org/eclipse/wst/html/core/contentmodel/chtml/ComplexTypeDefinition.java new file mode 100644 index 0000000000..c3d730496b --- /dev/null +++ b/bundles/org.eclipse.wst.html.core/src/org/eclipse/wst/html/core/contentmodel/chtml/ComplexTypeDefinition.java @@ -0,0 +1,77 @@ +/******************************************************************************* + * Copyright (c) 2004 IBM Corporation and others. + * All rights reserved. This program and the accompanying materials + * are made available under the terms of the Eclipse Public License v1.0 + * which accompanies this distribution, and is available at + * http://www.eclipse.org/legal/epl-v10.html + * + * Contributors: + * IBM Corporation - initial API and implementation + *******************************************************************************/ +package org.eclipse.wst.html.core.contentmodel.chtml; + + + +import org.eclipse.wst.common.contentmodel.CMGroup; +import org.eclipse.wst.html.core.contentmodel.HTMLElementDeclaration; + +/** + * This class is intended to represent a complex type definition + * in XML Schema.<br> + */ +abstract class ComplexTypeDefinition { + + protected CMGroupImpl content = null; + protected ElementCollection collection = null; + protected String primaryCandidateName = null; + + /** + * ComplexTypeDefinition constructor comment. + */ + public ComplexTypeDefinition(ElementCollection elementCollection) { + super(); + collection = elementCollection; + createContent(); + } + + /** + * Create an actual content model. + * This method should be called once and only once in the constructor.<br> + */ + protected abstract void createContent(); + + /** + * @return org.eclipse.wst.common.contentmodel.CMGroup + */ + public CMGroup getContent() { + return content; + } + + /** + * @return int; Should be one of ANY, EMPTY, ELEMENT, MIXED, PCDATA, CDATA, + * those are defined in CMElementDeclaration. + */ + /* NOTE: Do we need LOGICAL type? + * -- 3/7/2001 + */ + public abstract int getContentType(); + + /** + * Get content hint. + * @return com.ibm.sed.contentmodel.html.HTMLElementDeclaration + */ + public HTMLElementDeclaration getPrimaryCandidate() { + if (primaryCandidateName == null) + return null; + return (HTMLElementDeclaration) collection.getNamedItem(primaryCandidateName); + } + + /** + * Name of complex type definition. + * Each singleton must know its own name. + * All names should be defined in + * {@link <code>ComplexTypeDefinitionFactory</code>} as constants.<br> + * @return java.lang.String + */ + public abstract String getTypeName(); +}
\ No newline at end of file diff --git a/bundles/org.eclipse.wst.html.core/src/org/eclipse/wst/html/core/contentmodel/chtml/ComplexTypeDefinitionFactory.java b/bundles/org.eclipse.wst.html.core/src/org/eclipse/wst/html/core/contentmodel/chtml/ComplexTypeDefinitionFactory.java new file mode 100644 index 0000000000..4d66fb5f30 --- /dev/null +++ b/bundles/org.eclipse.wst.html.core/src/org/eclipse/wst/html/core/contentmodel/chtml/ComplexTypeDefinitionFactory.java @@ -0,0 +1,146 @@ +/******************************************************************************* + * Copyright (c) 2004 IBM Corporation and others. + * All rights reserved. This program and the accompanying materials + * are made available under the terms of the Eclipse Public License v1.0 + * which accompanies this distribution, and is available at + * http://www.eclipse.org/legal/epl-v10.html + * + * Contributors: + * IBM Corporation - initial API and implementation + *******************************************************************************/ +package org.eclipse.wst.html.core.contentmodel.chtml; + + + +/** + * Factory of ComplexTypeDefinition. + */ +final class ComplexTypeDefinitionFactory { + + private static ComplexTypeDefinitionFactory instance = null; + private java.util.Hashtable definitions = null; + // constants for complex type name + /** for ADDRESS. */ + public final static String CTYPE_ADDRESS = "CTYPE_ADDRESS";//$NON-NLS-1$ + /** CDATA content. No ComplexTypeDefinition instance shuld be created. */ + public final static String CTYPE_CDATA = "CTYPE_CDATA";//$NON-NLS-1$ + /** col group content. COL* */ + public final static String CTYPE_COLUMN_GROUP = "CTYPE_COLUMN_GROUP";//$NON-NLS-1$ + /** for DL. */ + public final static String CTYPE_DEFINITION_LIST = "CTYPE_DEFINITION_LIST";//$NON-NLS-1$ + /** for EMBED. */ + public final static String CTYPE_EMBED = "CTYPE_EMBED";//$NON-NLS-1$ + /** empty content. No ComplexTypeDefinition instance should be created. */ + public final static String CTYPE_EMPTY = "CTYPE_EMPTY";//$NON-NLS-1$ + /** for FIELDSET. */ + public final static String CTYPE_FIELDSET = "CTYPE_FIELDSET";//$NON-NLS-1$ + /** for FRAMESET. */ + public final static String CTYPE_FRAMESET = "CTYPE_FRAMESET";//$NON-NLS-1$ + /** flow content. (%flow;)* */ + public final static String CTYPE_FLOW_CONTAINER = "CTYPE_FLOW_CONTAINER";//$NON-NLS-1$ + /** html content. HEAD, (FRAMESET|BODY) */ + public final static String CTYPE_HTML = "CTYPE_HTML";//$NON-NLS-1$ + /** head content. TITLE & ISINDEX? & BASE? */ + public final static String CTYPE_HEAD = "CTYPE_HEAD";//$NON-NLS-1$ + /** inline content. (%inline;)* */ + public final static String CTYPE_INLINE_CONTAINER = "CTYPE_INLINE_CONTAINER";//$NON-NLS-1$ + /** list item container. (LI)+ */ + public final static String CTYPE_LI_CONTAINER = "CTYPE_LI_CONTAINER";//$NON-NLS-1$ + /** for MAP. */ + public final static String CTYPE_MAP = "CTYPE_MAP";//$NON-NLS-1$ + /** noframes content. */ + public final static String CTYPE_NOFRAMES_CONTENT = "CTYPE_NOFRAMES_CONTENT";//$NON-NLS-1$ + /** for OPTGROUP. */ + public final static String CTYPE_OPTION_CONTAINER = "CTYPE_OPTION_CONTAINER";//$NON-NLS-1$ + /** param container. For OBJECT/APPLET. */ + public final static String CTYPE_PARAM_CONTAINER = "CTYPE_PARAM_CONTAINER";//$NON-NLS-1$ + /** PCDATA content. No ComplexTypeDefinition instance shuld be created. */ + public final static String CTYPE_PCDATA = "CTYPE_PCDATA";//$NON-NLS-1$ + /** for SELECT. */ + public final static String CTYPE_SELECT = "CTYPE_SELECT";//$NON-NLS-1$ + /** table content. CAPTION?, (COL*|COLGROUP*), THEAD?, TFOOT?, TBODY+ */ + public final static String CTYPE_TABLE = "CTYPE_TABLE";//$NON-NLS-1$ + /** table cell contaier. (TH|TD)+ */ + public final static String CTYPE_TCELL_CONTAINER = "CTYPE_TCELL_CONTAINER";//$NON-NLS-1$ + /** table record container. (TR)+ */ + public final static String CTYPE_TR_CONTAINER = "CTYPE_TR_CONTAINER";//$NON-NLS-1$ + + /** + * ComplexTypeDefinitionFactory constructor comment. + */ + private ComplexTypeDefinitionFactory() { + super(); + definitions = new java.util.Hashtable(); + } + + /** + * Factory method for ComplexTypeDefinition. + * Each instance created in this method must be registered into + * the map with its name. + * @return com.ibm.sed.contentmodel.html.ComplexTypeDefinition + * @param definitionName java.lang.String + * @param elementCollection ElementCollection + */ + public ComplexTypeDefinition createTypeDefinition(String definitionName, ElementCollection elementCollection) { + if (definitions.containsKey(definitionName)) { + return (ComplexTypeDefinition) definitions.get(definitionName); + } + + ComplexTypeDefinition def = null; + if (definitionName == CTYPE_ADDRESS) { + def = new CtdAddress(elementCollection); + + } + else if (definitionName == CTYPE_DEFINITION_LIST) { + def = new CtdDl(elementCollection); + + } + else if (definitionName == CTYPE_FLOW_CONTAINER) { + def = new CtdFlowContainer(elementCollection); + + } + else if (definitionName == CTYPE_HEAD) { + def = new CtdHead(elementCollection); + + } + else if (definitionName == CTYPE_HTML) { + def = new CtdHtml(elementCollection); + + } + else if (definitionName == CTYPE_INLINE_CONTAINER) { + def = new CtdInlineContainer(elementCollection); + + } + else if (definitionName == CTYPE_LI_CONTAINER) { + def = new CtdLiContainer(elementCollection); + + + } + else if (definitionName == CTYPE_OPTION_CONTAINER) { + def = new CtdOptionContainer(elementCollection); + + } + else if (definitionName == CTYPE_SELECT) { + def = new CtdSelect(elementCollection); + + } + else { + def = null; + } + if (def == null) + return null; // fail to create. + definitions.put(definitionName, def); + return def; + } + + /** + * For singleton.<br> + * @return com.ibm.sed.contentmodel.html.ComplexTypeDefinitionFactory + */ + public synchronized static ComplexTypeDefinitionFactory getInstance() { + if (instance != null) + return instance; + instance = new ComplexTypeDefinitionFactory(); + return instance; + } +}
\ No newline at end of file diff --git a/bundles/org.eclipse.wst.html.core/src/org/eclipse/wst/html/core/contentmodel/chtml/CtdAddress.java b/bundles/org.eclipse.wst.html.core/src/org/eclipse/wst/html/core/contentmodel/chtml/CtdAddress.java new file mode 100644 index 0000000000..8b2392e7ff --- /dev/null +++ b/bundles/org.eclipse.wst.html.core/src/org/eclipse/wst/html/core/contentmodel/chtml/CtdAddress.java @@ -0,0 +1,70 @@ +/******************************************************************************* + * Copyright (c) 2004 IBM Corporation and others. + * All rights reserved. This program and the accompanying materials + * are made available under the terms of the Eclipse Public License v1.0 + * which accompanies this distribution, and is available at + * http://www.eclipse.org/legal/epl-v10.html + * + * Contributors: + * IBM Corporation - initial API and implementation + *******************************************************************************/ +package org.eclipse.wst.html.core.contentmodel.chtml; + + + +import org.eclipse.wst.common.contentmodel.CMElementDeclaration; +import org.eclipse.wst.common.contentmodel.CMGroup; +import org.eclipse.wst.common.contentmodel.CMNode; + +/** + * for ADDRESS. + */ +final class CtdAddress extends ComplexTypeDefinition { + + /** + * @param elementCollection ElementCollection + */ + public CtdAddress(ElementCollection elementCollection) { + super(elementCollection); + } + + /** + * ((%inline) | P)*. + */ + protected void createContent() { + if (content != null) + return; // already created. + if (collection == null) + return; + + // ( | )* + content = new CMGroupImpl(CMGroup.CHOICE, 0, CMContentImpl.UNBOUNDED); + // (%inline) + CMGroupImpl inlines = new CMGroupImpl(CMGroup.CHOICE, 1, 1); + if (inlines == null) + return; + collection.getInline(inlines); + content.appendChild(inlines); + // P + CMNode p = collection.getNamedItem(CHTMLNamespace.ElementName.P); + if (p != null) + content.appendChild(p); + } + + /** + * ((%inline) | P)*. + * Because %inline; contains #PCDATA, the type is MIXED. + * @return int; Should be one of ANY, EMPTY, ELEMENT, MIXED, PCDATA, CDATA, + * those are defined in CMElementDeclaration. + */ + public int getContentType() { + return CMElementDeclaration.MIXED; + } + + /** + * @return java.lang.String + */ + public String getTypeName() { + return ComplexTypeDefinitionFactory.CTYPE_ADDRESS; + } +}
\ No newline at end of file diff --git a/bundles/org.eclipse.wst.html.core/src/org/eclipse/wst/html/core/contentmodel/chtml/CtdDl.java b/bundles/org.eclipse.wst.html.core/src/org/eclipse/wst/html/core/contentmodel/chtml/CtdDl.java new file mode 100644 index 0000000000..51cd5ad75d --- /dev/null +++ b/bundles/org.eclipse.wst.html.core/src/org/eclipse/wst/html/core/contentmodel/chtml/CtdDl.java @@ -0,0 +1,68 @@ +/******************************************************************************* + * Copyright (c) 2004 IBM Corporation and others. + * All rights reserved. This program and the accompanying materials + * are made available under the terms of the Eclipse Public License v1.0 + * which accompanies this distribution, and is available at + * http://www.eclipse.org/legal/epl-v10.html + * + * Contributors: + * IBM Corporation - initial API and implementation + *******************************************************************************/ +package org.eclipse.wst.html.core.contentmodel.chtml; + + + +import org.eclipse.wst.common.contentmodel.CMElementDeclaration; +import org.eclipse.wst.common.contentmodel.CMGroup; +import org.eclipse.wst.common.contentmodel.CMNode; + +/** + * for DL. + */ +final class CtdDl extends ComplexTypeDefinition { + + /** + * @param elementCollection ElementCollection + */ + public CtdDl(ElementCollection elementCollection) { + super(elementCollection); + primaryCandidateName = CHTMLNamespace.ElementName.DT; + } + + /** + * (DT | DD)+ + */ + protected void createContent() { + if (content != null) + return; // already created. + if (collection == null) + return; + + // ( | )+ + content = new CMGroupImpl(CMGroup.CHOICE, 1, CMContentImpl.UNBOUNDED); + // DT + CMNode dec = collection.getNamedItem(CHTMLNamespace.ElementName.DT); + if (dec != null) + content.appendChild(dec); + // DD + dec = collection.getNamedItem(CHTMLNamespace.ElementName.DD); + if (dec != null) + content.appendChild(dec); + } + + /** + * (DT | DD)+. + * @return int; Should be one of ANY, EMPTY, ELEMENT, MIXED, PCDATA, CDATA, + * those are defined in CMElementDeclaration. + */ + public int getContentType() { + return CMElementDeclaration.ELEMENT; + } + + /** + * @return java.lang.String + */ + public String getTypeName() { + return ComplexTypeDefinitionFactory.CTYPE_DEFINITION_LIST; + } +}
\ No newline at end of file diff --git a/bundles/org.eclipse.wst.html.core/src/org/eclipse/wst/html/core/contentmodel/chtml/CtdFlowContainer.java b/bundles/org.eclipse.wst.html.core/src/org/eclipse/wst/html/core/contentmodel/chtml/CtdFlowContainer.java new file mode 100644 index 0000000000..cbf733a867 --- /dev/null +++ b/bundles/org.eclipse.wst.html.core/src/org/eclipse/wst/html/core/contentmodel/chtml/CtdFlowContainer.java @@ -0,0 +1,55 @@ +/******************************************************************************* + * Copyright (c) 2004 IBM Corporation and others. + * All rights reserved. This program and the accompanying materials + * are made available under the terms of the Eclipse Public License v1.0 + * which accompanies this distribution, and is available at + * http://www.eclipse.org/legal/epl-v10.html + * + * Contributors: + * IBM Corporation - initial API and implementation + *******************************************************************************/ +package org.eclipse.wst.html.core.contentmodel.chtml; + + + +import org.eclipse.wst.common.contentmodel.CMElementDeclaration; +import org.eclipse.wst.common.contentmodel.CMGroup; + +/** + * Complex type definition for containers of <code>%flow;</code>. + */ +final class CtdFlowContainer extends ComplexTypeDefinition { + + /** + */ + public CtdFlowContainer(ElementCollection elementCollection) { + super(elementCollection); + } + + /** + * (%flow;)* + */ + protected void createContent() { + if (content != null) + return; // already created. + if (collection == null) + return; + + content = new CMGroupImpl(CMGroup.CHOICE, 0, CMContentImpl.UNBOUNDED); + collection.getFlow(content); + } + + /** + * @see com.ibm.sed.contentmodel.html.ComplexTypeDefinition + */ + public int getContentType() { + return CMElementDeclaration.MIXED; + } + + /** + * @see com.ibm.sed.contentmodel.html.ComplexTypeDefinition + */ + public String getTypeName() { + return ComplexTypeDefinitionFactory.CTYPE_FLOW_CONTAINER; + } +}
\ No newline at end of file diff --git a/bundles/org.eclipse.wst.html.core/src/org/eclipse/wst/html/core/contentmodel/chtml/CtdHead.java b/bundles/org.eclipse.wst.html.core/src/org/eclipse/wst/html/core/contentmodel/chtml/CtdHead.java new file mode 100644 index 0000000000..a3172351ef --- /dev/null +++ b/bundles/org.eclipse.wst.html.core/src/org/eclipse/wst/html/core/contentmodel/chtml/CtdHead.java @@ -0,0 +1,175 @@ +/******************************************************************************* + * Copyright (c) 2004 IBM Corporation and others. + * All rights reserved. This program and the accompanying materials + * are made available under the terms of the Eclipse Public License v1.0 + * which accompanies this distribution, and is available at + * http://www.eclipse.org/legal/epl-v10.html + * + * Contributors: + * IBM Corporation - initial API and implementation + *******************************************************************************/ +package org.eclipse.wst.html.core.contentmodel.chtml; + + + +import java.util.Arrays; + +import org.eclipse.wst.common.contentmodel.CMElementDeclaration; +import org.eclipse.wst.common.contentmodel.CMGroup; +import org.eclipse.wst.common.contentmodel.CMNode; + +/** + * Complex type definition for the head content. + * Content Model: (TITLE & ISINDEX? & BASE?) + */ +final class CtdHead extends ComplexTypeDefinition { + + /** + */ + public CtdHead(ElementCollection elementCollection) { + super(elementCollection); + primaryCandidateName = CHTMLNamespace.ElementName.TITLE; + } + + /** + * for HEAD. + * To avoid using inclusion, the content model comes from the XHTML 1.0. + * + * (%head.misc;, ((title, %head.misc;, (base, %head.misc;)?) | (base, %head.misc;, (title, %head.misc;)))) + * And %head.misc; is: + * (script|style|meta|link|object|isindex)* + * + * 0: (%head.misc, A) + * A: (B | C) + * B: (title, %head.misc;, D) + * C: (base, %head.misc;, E) + * D: (base, %head.misc;)? + * E: (title, %head.misc;) + */ + protected void createContent() { + if (content != null) + return; // already created. + if (collection == null) + return; + + // At 1st, create %head.misc; content. + // %head.misc; + // ( | )* + CMGroupImpl misc = new CMGroupImpl(CMGroup.CHOICE, 0, CMContentImpl.UNBOUNDED); + if (misc == null) + return; + String[] names = {CHTMLNamespace.ElementName.META,}; + collection.getDeclarations(misc, Arrays.asList(names).iterator()); + // 2nd, get a title + CMNode title = collection.getNamedItem(CHTMLNamespace.ElementName.TITLE); + // 3rd, get a base + CMNode base = collection.getNamedItem(CHTMLNamespace.ElementName.BASE); + if (title == null || base == null) + return; + + // Top level content is a sequence of %head.misc; and A. + // 0: (%head.misc;, A) + // create a sequence + content = new CMGroupImpl(CMGroup.SEQUENCE, 1, 1); + if (content == null) + return; + // append %head.misc; + content.appendChild(misc); + // create A and append it to the top level. + { + // A is a choice of B and C. + // A: (B | C) + // create a choice + CMGroupImpl gA = new CMGroupImpl(CMGroup.CHOICE, 1, 1); + if (gA == null) + return; + // append A to the top level. + content.appendChild(gA); + + // create B and append it to A + { + // B is a sequence of title, %head.misc;, and D. + // B: (title, %head.misc;, D) + // create a sequence + CMGroupImpl gB = new CMGroupImpl(CMGroup.SEQUENCE, 1, 1); + if (gB == null) + return; + // append B to A. + gA.appendChild(gB); + + // append title to B + gB.appendChild(title); + // append %head.misc; to B + gB.appendChild(misc); + // create D and append it to B. + { + // D is a sequence of base, %head.misc;. + // D: (base, %head.misc;)? + // create a sequence + CMGroupImpl gD = new CMGroupImpl(CMGroup.SEQUENCE, 0, 1); + if (gD == null) + return; + // append D to B. + gB.appendChild(gD); + + // append base to D + gD.appendChild(base); + // append %head.misc; to D. + gD.appendChild(misc); + } + } + // create C and append it to A + { + // C is a sequence of base, %head.misc;, and E + // C: (base, %head.misc;, E) + // create a sequence + CMGroupImpl gC = new CMGroupImpl(CMGroup.SEQUENCE, 1, 1); + if (gC == null) + return; + // append C to A. + gA.appendChild(gC); + + // append base to C + gC.appendChild(base); + // append %head.misc; to C + gC.appendChild(misc); + + // create E and append it to C. + { + // E is a sequence of title and %head.misc;. + // E: (title, %head.misc;) + // create a sequence + CMGroupImpl gE = new CMGroupImpl(CMGroup.SEQUENCE, 1, 1); + if (gE == null) + return; + // append E to C. + gC.appendChild(gE); + + // append title to E + gE.appendChild(title); + // append %head.misc; to E. + gE.appendChild(misc); + } + } + } + } + + /** + * Element content.<br> + * @see com.ibm.sed.contentmodel.html.ComplexTypeDefinition + */ + public int getContentType() { + return CMElementDeclaration.ELEMENT; + } + + /** + * Name of complex type definition. + * Each singleton must know its own name. + * All names should be defined in + * {@link <code>ComplexTypeDefinitionFactory</code>} as constants.<br> + * @return java.lang.String + */ + public String getTypeName() { + return ComplexTypeDefinitionFactory.CTYPE_HEAD; + } +}
\ No newline at end of file diff --git a/bundles/org.eclipse.wst.html.core/src/org/eclipse/wst/html/core/contentmodel/chtml/CtdHtml.java b/bundles/org.eclipse.wst.html.core/src/org/eclipse/wst/html/core/contentmodel/chtml/CtdHtml.java new file mode 100644 index 0000000000..34db54866f --- /dev/null +++ b/bundles/org.eclipse.wst.html.core/src/org/eclipse/wst/html/core/contentmodel/chtml/CtdHtml.java @@ -0,0 +1,79 @@ +/******************************************************************************* + * Copyright (c) 2004 IBM Corporation and others. + * All rights reserved. This program and the accompanying materials + * are made available under the terms of the Eclipse Public License v1.0 + * which accompanies this distribution, and is available at + * http://www.eclipse.org/legal/epl-v10.html + * + * Contributors: + * IBM Corporation - initial API and implementation + *******************************************************************************/ +package org.eclipse.wst.html.core.contentmodel.chtml; + + + +import java.util.Arrays; + +import org.eclipse.wst.common.contentmodel.CMElementDeclaration; +import org.eclipse.wst.common.contentmodel.CMGroup; +import org.eclipse.wst.common.contentmodel.CMNode; + +/** + * Complex type definition for <code>HTML</code>.<br> + * Content Model: + * HEAD, (FRAMESET|BODY)<br> + */ +final class CtdHtml extends ComplexTypeDefinition { + + /** + */ + public CtdHtml(ElementCollection elementCollection) { + super(elementCollection); + primaryCandidateName = CHTMLNamespace.ElementName.HEAD; + } + + /** + * (%html.content;). + * %html.content; is HEAD, (FRAMESET | BODY). + * @see com.ibm.sed.contentmodel.html.ComplexTypeDefinition + */ + protected void createContent() { + if (content != null) + return; // already created. + if (collection == null) + return; + + // ( ) + content = new CMGroupImpl(CMGroup.SEQUENCE, 1, 1); + if (content == null) + return; + + // HEAD + CMNode edec = collection.getNamedItem(CHTMLNamespace.ElementName.HEAD); + if (edec != null) + content.appendChild(edec); + + // ( | ) + CMGroupImpl group = new CMGroupImpl(CMGroup.CHOICE, 1, 1); + content.appendChild(group); + + // FRAMESET, BODY + String[] names = {CHTMLNamespace.ElementName.BODY}; + collection.getDeclarations(group, Arrays.asList(names).iterator()); + } + + /** + * Element content. + * @see com.ibm.sed.contentmodel.html.ComplexTypeDefinition + */ + public int getContentType() { + return CMElementDeclaration.ELEMENT; + } + + /** + * @see com.ibm.sed.contentmodel.html.ComplexTypeDefinition + */ + public String getTypeName() { + return ComplexTypeDefinitionFactory.CTYPE_HTML; + } +}
\ No newline at end of file diff --git a/bundles/org.eclipse.wst.html.core/src/org/eclipse/wst/html/core/contentmodel/chtml/CtdInlineContainer.java b/bundles/org.eclipse.wst.html.core/src/org/eclipse/wst/html/core/contentmodel/chtml/CtdInlineContainer.java new file mode 100644 index 0000000000..b00c3acf6b --- /dev/null +++ b/bundles/org.eclipse.wst.html.core/src/org/eclipse/wst/html/core/contentmodel/chtml/CtdInlineContainer.java @@ -0,0 +1,56 @@ +/******************************************************************************* + * Copyright (c) 2004 IBM Corporation and others. + * All rights reserved. This program and the accompanying materials + * are made available under the terms of the Eclipse Public License v1.0 + * which accompanies this distribution, and is available at + * http://www.eclipse.org/legal/epl-v10.html + * + * Contributors: + * IBM Corporation - initial API and implementation + *******************************************************************************/ +package org.eclipse.wst.html.core.contentmodel.chtml; + + + +import org.eclipse.wst.common.contentmodel.CMElementDeclaration; +import org.eclipse.wst.common.contentmodel.CMGroup; + +/** + * Complex type definition for (%inline;)*. + */ +final class CtdInlineContainer extends ComplexTypeDefinition { + + /** + * @param elementCollection ElementCollection + */ + public CtdInlineContainer(ElementCollection elementCollection) { + super(elementCollection); + } + + /** + * (%inline)*. + */ + protected void createContent() { + if (content != null) + return; // already created. + if (collection == null) + return; + + content = new CMGroupImpl(CMGroup.CHOICE, 0, CMContentImpl.UNBOUNDED); + collection.getInline(content); + } + + /** + * @see com.ibm.sed.contentmodel.html.ComplexTypeDefinition + */ + public int getContentType() { + return CMElementDeclaration.MIXED; + } + + /** + * @see com.ibm.sed.contentmodel.html.ComplexTypeDefinition + */ + public String getTypeName() { + return ComplexTypeDefinitionFactory.CTYPE_INLINE_CONTAINER; + } +}
\ No newline at end of file diff --git a/bundles/org.eclipse.wst.html.core/src/org/eclipse/wst/html/core/contentmodel/chtml/CtdLiContainer.java b/bundles/org.eclipse.wst.html.core/src/org/eclipse/wst/html/core/contentmodel/chtml/CtdLiContainer.java new file mode 100644 index 0000000000..7b8cb714ed --- /dev/null +++ b/bundles/org.eclipse.wst.html.core/src/org/eclipse/wst/html/core/contentmodel/chtml/CtdLiContainer.java @@ -0,0 +1,68 @@ +/******************************************************************************* + * Copyright (c) 2004 IBM Corporation and others. + * All rights reserved. This program and the accompanying materials + * are made available under the terms of the Eclipse Public License v1.0 + * which accompanies this distribution, and is available at + * http://www.eclipse.org/legal/epl-v10.html + * + * Contributors: + * IBM Corporation - initial API and implementation + *******************************************************************************/ +package org.eclipse.wst.html.core.contentmodel.chtml; + + + +import org.eclipse.wst.common.contentmodel.CMElementDeclaration; +import org.eclipse.wst.common.contentmodel.CMGroup; +import org.eclipse.wst.common.contentmodel.CMNode; + +/** + * List item container. + * (LI)+ + */ +final class CtdLiContainer extends ComplexTypeDefinition { + + /** + * @param elemenCollection ElementCollection + */ + public CtdLiContainer(ElementCollection elementCollection) { + super(elementCollection); + primaryCandidateName = CHTMLNamespace.ElementName.LI; + } + + /** + * (LI)+. + */ + protected void createContent() { + if (content != null) + return; // already created. + if (collection == null) + return; + + // (LI)+ + content = new CMGroupImpl(CMGroup.SEQUENCE, 1, CMContentImpl.UNBOUNDED); + CMNode li = collection.getNamedItem(CHTMLNamespace.ElementName.LI); + if (li != null) + content.appendChild(li); + } + + /** + * ELEMENT content.<br> + * @return int; Should be one of ANY, EMPTY, ELEMENT, MIXED, PCDATA, CDATA, + * those are defined in CMElementDeclaration. + */ + public int getContentType() { + return CMElementDeclaration.ELEMENT; + } + + /** + * Name of complex type definition. + * Each singleton must know its own name. + * All names should be defined in + * {@link <code>ComplexTypeDefinitionFactory</code>} as constants.<br> + * @return java.lang.String + */ + public String getTypeName() { + return ComplexTypeDefinitionFactory.CTYPE_LI_CONTAINER; + } +}
\ No newline at end of file diff --git a/bundles/org.eclipse.wst.html.core/src/org/eclipse/wst/html/core/contentmodel/chtml/CtdOptionContainer.java b/bundles/org.eclipse.wst.html.core/src/org/eclipse/wst/html/core/contentmodel/chtml/CtdOptionContainer.java new file mode 100644 index 0000000000..45f8430586 --- /dev/null +++ b/bundles/org.eclipse.wst.html.core/src/org/eclipse/wst/html/core/contentmodel/chtml/CtdOptionContainer.java @@ -0,0 +1,69 @@ +/******************************************************************************* + * Copyright (c) 2004 IBM Corporation and others. + * All rights reserved. This program and the accompanying materials + * are made available under the terms of the Eclipse Public License v1.0 + * which accompanies this distribution, and is available at + * http://www.eclipse.org/legal/epl-v10.html + * + * Contributors: + * IBM Corporation - initial API and implementation + *******************************************************************************/ +package org.eclipse.wst.html.core.contentmodel.chtml; + + + +import org.eclipse.wst.common.contentmodel.CMElementDeclaration; +import org.eclipse.wst.common.contentmodel.CMGroup; +import org.eclipse.wst.common.contentmodel.CMNode; + +/** + * OPTION container. + * (OPTION)+ + */ +final class CtdOptionContainer extends ComplexTypeDefinition { + + /** + * @param elementCollection ElementCollection + */ + public CtdOptionContainer(ElementCollection elementCollection) { + super(elementCollection); + primaryCandidateName = CHTMLNamespace.ElementName.OPTION; + } + + /** + * (OPTION)+. + */ + protected void createContent() { + if (content != null) + return; // already created. + if (collection == null) + return; + + // ( )+ + content = new CMGroupImpl(CMGroup.SEQUENCE, 1, CMContentImpl.UNBOUNDED); + // OPTION + CMNode dec = collection.getNamedItem(CHTMLNamespace.ElementName.OPTION); + if (dec != null) + content.appendChild(dec); + } + + /** + * (OPTION)+ + * @return int; Should be one of ANY, EMPTY, ELEMENT, MIXED, PCDATA, CDATA, + * those are defined in CMElementDeclaration. + */ + public int getContentType() { + return CMElementDeclaration.ELEMENT; + } + + /** + * Name of complex type definition. + * Each singleton must know its own name. + * All names should be defined in + * {@link <code>ComplexTypeDefinitionFactory</code>} as constants.<br> + * @return java.lang.String + */ + public String getTypeName() { + return ComplexTypeDefinitionFactory.CTYPE_OPTION_CONTAINER; + } +}
\ No newline at end of file diff --git a/bundles/org.eclipse.wst.html.core/src/org/eclipse/wst/html/core/contentmodel/chtml/CtdSelect.java b/bundles/org.eclipse.wst.html.core/src/org/eclipse/wst/html/core/contentmodel/chtml/CtdSelect.java new file mode 100644 index 0000000000..ea83c5991c --- /dev/null +++ b/bundles/org.eclipse.wst.html.core/src/org/eclipse/wst/html/core/contentmodel/chtml/CtdSelect.java @@ -0,0 +1,64 @@ +/******************************************************************************* + * Copyright (c) 2004 IBM Corporation and others. + * All rights reserved. This program and the accompanying materials + * are made available under the terms of the Eclipse Public License v1.0 + * which accompanies this distribution, and is available at + * http://www.eclipse.org/legal/epl-v10.html + * + * Contributors: + * IBM Corporation - initial API and implementation + *******************************************************************************/ +package org.eclipse.wst.html.core.contentmodel.chtml; + + + +import org.eclipse.wst.common.contentmodel.CMElementDeclaration; +import org.eclipse.wst.common.contentmodel.CMGroup; +import org.eclipse.wst.common.contentmodel.CMNode; + +/** + * for SELECT. + */ +final class CtdSelect extends ComplexTypeDefinition { + + /** + * @param elementCollection ElementCollection + */ + public CtdSelect(ElementCollection elementCollection) { + super(elementCollection); + primaryCandidateName = CHTMLNamespace.ElementName.OPTION; + } + + /** + * (OPTGROUP | OPTION)+. + */ + protected void createContent() { + if (content != null) + return; // already created. + if (collection == null) + return; + + // ( | )+ + content = new CMGroupImpl(CMGroup.CHOICE, 1, CMContentImpl.UNBOUNDED); + // OPTION + CMNode dec = collection.getNamedItem(CHTMLNamespace.ElementName.OPTION); + if (dec != null) + content.appendChild(dec); + } + + /** + * (OPTGROUP | OPTION)+. + * @return int; Should be one of ANY, EMPTY, ELEMENT, MIXED, PCDATA, CDATA, + * those are defined in CMElementDeclaration. + */ + public int getContentType() { + return CMElementDeclaration.ELEMENT; + } + + /** + * @return java.lang.String + */ + public String getTypeName() { + return ComplexTypeDefinitionFactory.CTYPE_SELECT; + } +}
\ No newline at end of file diff --git a/bundles/org.eclipse.wst.html.core/src/org/eclipse/wst/html/core/contentmodel/chtml/DeclCollection.java b/bundles/org.eclipse.wst.html.core/src/org/eclipse/wst/html/core/contentmodel/chtml/DeclCollection.java new file mode 100644 index 0000000000..62809a8cdd --- /dev/null +++ b/bundles/org.eclipse.wst.html.core/src/org/eclipse/wst/html/core/contentmodel/chtml/DeclCollection.java @@ -0,0 +1,238 @@ +/******************************************************************************* + * Copyright (c) 2004 IBM Corporation and others. + * All rights reserved. This program and the accompanying materials + * are made available under the terms of the Eclipse Public License v1.0 + * which accompanies this distribution, and is available at + * http://www.eclipse.org/legal/epl-v10.html + * + * Contributors: + * IBM Corporation - initial API and implementation + *******************************************************************************/ +package org.eclipse.wst.html.core.contentmodel.chtml; + + + +import java.util.HashMap; +import java.util.Iterator; + +import org.eclipse.wst.common.contentmodel.CMNamedNodeMap; +import org.eclipse.wst.common.contentmodel.CMNode; + +/** + */ +abstract class DeclCollection implements CMNamedNodeMap { + + + protected class DualMap { + public DualMap() { + super(); + } + + public DualMap(Object[] objects) { + super(); + initialize(objects); + } + + public int size() { + return table.length; + } + + public Object getValue(int key) { + if (!isValidIndex(key)) + return null; + return table[key]; + } + + public int getKey(Object value) { + Integer keyObj = (Integer) map.get(value); + if (keyObj == null) + return ID_UNKNOWN; + return keyObj.intValue(); + } + + protected void initialize(Object[] objects) { + if (objects == null) + return; + table = objects; + map = new HashMap(); + for (int key = 0; key < objects.length; key++) { + Object value = table[key]; + map.put(value, new Integer(key)); + } + } + + private Object[] table = null; + private HashMap map = null; + + private boolean isValidIndex(int index) { + return index >= 0 && index < table.length; + } + } + + protected class TolerantStringDualMap extends DualMap { + public TolerantStringDualMap(String[] names) { + super(); + Object[] objects = new Object[names.length]; + for (int i = 0; i < names.length; i++) { + objects[i] = makeCanonicalForm(names[i]); + } + initialize(objects); + } + + public int getKey(Object value) { + try { + String name = (String) value; + return super.getKey(makeCanonicalForm(name)); + } + catch (ClassCastException e) { + return ID_UNKNOWN; + } + } + + private String makeCanonicalForm(String raw) { + return raw.toUpperCase(); + } + } + + private class DeclIterator implements Iterator { + public DeclIterator() { + maxid = fDecls.length - 1; + } + + public boolean hasNext() { + return id < maxid; + } + + public Object next() { + if (!hasNext()) + return null; + return item(++id); + } + + public void remove() { /* nothing should be done. */ + } + + private int id = -1; + private int maxid = -1; + } + + CMNode[] fDecls = null; + protected final static boolean STRICT_CASE = false; + protected final static boolean TOLERANT_CASE = true; + protected final static int ID_UNKNOWN = -1; + private DualMap fMap = null; + + /** + */ + public DeclCollection(String[] names, boolean tolerant) { + super(); + fDecls = new CMNode[names.length]; + if (tolerant) { + fMap = new TolerantStringDualMap(names); + } + else { + fMap = new DualMap(names); + } + } + + /** + * @return org.eclipse.wst.common.contentmodel.CMNode + * @param id int + */ + protected abstract CMNode create(String name); + + /** + */ + public CMNamedNodeMap getDeclarations(String[] names) { + CMNamedNodeMapImpl map = new CMNamedNodeMapImpl(); + for (int i = 0; i < names.length; i++) { + String name = names[i]; + CMNode node = getNamedItem(name); + if (node == null) + continue; + map.putNamedItem(name, node); + } + return map; + } + + /** + * @param declarations com.ibm.sed.contentmodel.html.CMGroupImpl + * @param names java.util.Iterator + */ + public void getDeclarations(CMGroupImpl group, Iterator names) { + while (names.hasNext()) { + String entityName = (String) names.next(); + CMNode dec = getNamedItem(entityName); + if (dec != null) + group.appendChild(dec); + } + } + + /** + * Map name to id. + * @return int + * @param name java.lang.String + */ + protected int getID(String name) { + return fMap.getKey(name); + } + + /** + * getLength method + * @return int + */ + public int getLength() { + return fDecls.length; + } + + /** + * @return java.lang.String + * @param id int + */ + protected String getName(int id) { + return (String) fMap.getValue(id); + } + + /** + * getNamedItem method + * @return CMNode + * @param name java.lang.String + */ + public CMNode getNamedItem(String name) { + int id = getID(name); + if (!isValidID(id)) + return null; + return item(id); + } + + /** + * @return boolean + * @param id int + */ + private boolean isValidID(int id) { + return id >= 0 && id < fDecls.length; + } + + /** + * item method + * @return CMNode + * @param index int + */ + public CMNode item(int index) { + if (!isValidID(index)) + return null; + CMNode decl = fDecls[index]; + if (decl != null) + return decl; // already exist. + + decl = create(getName(index)); + fDecls[index] = decl; + return decl; + } + + /** + */ + public Iterator iterator() { + return new DeclIterator(); + } +}
\ No newline at end of file diff --git a/bundles/org.eclipse.wst.html.core/src/org/eclipse/wst/html/core/contentmodel/chtml/ElementCollection.java b/bundles/org.eclipse.wst.html.core/src/org/eclipse/wst/html/core/contentmodel/chtml/ElementCollection.java new file mode 100644 index 0000000000..854806427d --- /dev/null +++ b/bundles/org.eclipse.wst.html.core/src/org/eclipse/wst/html/core/contentmodel/chtml/ElementCollection.java @@ -0,0 +1,495 @@ +/******************************************************************************* + * Copyright (c) 2004 IBM Corporation and others. + * All rights reserved. This program and the accompanying materials + * are made available under the terms of the Eclipse Public License v1.0 + * which accompanies this distribution, and is available at + * http://www.eclipse.org/legal/epl-v10.html + * + * Contributors: + * IBM Corporation - initial API and implementation + *******************************************************************************/ +package org.eclipse.wst.html.core.contentmodel.chtml; + + + +import java.lang.reflect.Field; +import java.util.Arrays; +import java.util.Collection; +import java.util.Vector; + +import org.eclipse.wst.common.contentmodel.CMNode; + +/** + * Factory for element declarations. + */ +final class ElementCollection extends DeclCollection implements org.eclipse.wst.html.core.HTML40Namespace.ElementName { + + + // Element IDs + private static class Ids { + public static final int ID_A = 0; + public static final int ID_ADDRESS = 1; + public static final int ID_BASE = 2; + public static final int ID_BLOCKQUOTE = 3; + public static final int ID_BODY = 4; + public static final int ID_BR = 5; + public static final int ID_CENTER = 6; + public static final int ID_DD = 7; + public static final int ID_DIR = 8; + public static final int ID_DIV = 9; + public static final int ID_DL = 10; + public static final int ID_DT = 11; + public static final int ID_FORM = 12; + public static final int ID_H1 = 13; + public static final int ID_H2 = 14; + public static final int ID_H3 = 15; + public static final int ID_H4 = 16; + public static final int ID_H5 = 17; + public static final int ID_H6 = 18; + public static final int ID_HEAD = 19; + public static final int ID_HR = 20; + public static final int ID_HTML = 21; + public static final int ID_IMG = 22; + public static final int ID_INPUT = 23; + public static final int ID_LI = 24; + public static final int ID_MENU = 25; + public static final int ID_META = 26; + public static final int ID_OL = 27; + public static final int ID_OPTION = 28; + public static final int ID_P = 29; + public static final int ID_PRE = 30; + public static final int ID_SELECT = 31; + public static final int ID_TEXTAREA = 32; + public static final int ID_TITLE = 33; + public static final int ID_UL = 34; + public static final int ID_SSI_CONFIG = 35; + public static final int ID_SSI_ECHO = 36; + public static final int ID_SSI_EXEC = 37; + public static final int ID_SSI_FSIZE = 38; + public static final int ID_SSI_FLASTMOD = 39; + public static final int ID_SSI_INCLUDE = 40; + public static final int ID_SSI_PRINTENV = 41; + public static final int ID_SSI_SET = 42; + + public static int getNumOfIds() { + if (numofids != -1) + return numofids; + + // NOTE: If the reflection is too slow, this method should + // just return the literal value, like 105. + // -- 5/25/2001 + Class clazz = Ids.class; + Field[] fields = clazz.getFields(); + numofids = 0; + for (int i = 0; i < fields.length; i++) { + String name = fields[i].getName(); + if (name.startsWith("ID_"))//$NON-NLS-1$ + numofids++; + } + return numofids; + } + + // chache the result of the reflection. + private static int numofids = -1; + } + + /** %formctl;. INPUT | SELECT | TEXTAREA */ + private static final String[] FORMCTL = {INPUT, SELECT, TEXTAREA}; + /** %phrase;. + * DFN + */ + private static final String[] PHRASE = {DFN}; + /** %special;. + * A | IMG | BR + */ + private static final String[] SPECIAL = {A, IMG, BR}; + /** %heading;. H[1-6] */ + private static final String[] HEADING = {H1, H2, H3, H4, H5, H6}; + /** %list;. UL | OL | DIR | MENU */ + private static final String[] LIST = {UL, OL, DIR, MENU}; + /** %preformatted;. PRE */ + private static final String[] PREFORMATTED = {PRE}; + private AttributeCollection attributeCollection = null; + private static String[] names = null; + + static { + names = new String[Ids.getNumOfIds()]; + names[Ids.ID_A] = A; + names[Ids.ID_ADDRESS] = ADDRESS; + names[Ids.ID_BASE] = BASE; + names[Ids.ID_BLOCKQUOTE] = BLOCKQUOTE; + names[Ids.ID_BODY] = BODY; + names[Ids.ID_BR] = BR; + names[Ids.ID_CENTER] = CENTER; + names[Ids.ID_DD] = DD; + names[Ids.ID_DIR] = DIR; + names[Ids.ID_DIV] = DIV; + names[Ids.ID_DL] = DL; + names[Ids.ID_DT] = DT; + names[Ids.ID_FORM] = FORM; + names[Ids.ID_H1] = H1; + names[Ids.ID_H2] = H2; + names[Ids.ID_H3] = H3; + names[Ids.ID_H4] = H4; + names[Ids.ID_H5] = H5; + names[Ids.ID_H6] = H6; + names[Ids.ID_HEAD] = HEAD; + names[Ids.ID_HR] = HR; + names[Ids.ID_HTML] = HTML; + names[Ids.ID_IMG] = IMG; + names[Ids.ID_INPUT] = INPUT; + names[Ids.ID_LI] = LI; + names[Ids.ID_MENU] = MENU; + names[Ids.ID_META] = META; + names[Ids.ID_OL] = OL; + names[Ids.ID_OPTION] = OPTION; + names[Ids.ID_P] = P; + names[Ids.ID_PRE] = PRE; + names[Ids.ID_SELECT] = SELECT; + names[Ids.ID_TEXTAREA] = TEXTAREA; + names[Ids.ID_TITLE] = TITLE; + names[Ids.ID_UL] = UL; + names[Ids.ID_SSI_CONFIG] = SSI_CONFIG; + names[Ids.ID_SSI_ECHO] = SSI_ECHO; + names[Ids.ID_SSI_EXEC] = SSI_EXEC; + names[Ids.ID_SSI_FSIZE] = SSI_FSIZE; + names[Ids.ID_SSI_FLASTMOD] = SSI_FLASTMOD; + names[Ids.ID_SSI_INCLUDE] = SSI_INCLUDE; + names[Ids.ID_SSI_PRINTENV] = SSI_PRINTENV; + names[Ids.ID_SSI_SET] = SSI_SET; + } + + /** + */ + public ElementCollection(AttributeCollection collection) { + super(names, TOLERANT_CASE); + attributeCollection = collection; + } + + /** + * Actually creates HTMLElementDeclaration instance. + * @return HTMLElementDeclaration + */ + protected CMNode create(String elementName) { + HTMLElemDeclImpl edec = null; + + if (elementName.equalsIgnoreCase(A)) { + edec = new HedA(this); + + } + else if (elementName.equalsIgnoreCase(ADDRESS)) { + edec = new HedADDRESS(this); + + } + else if (elementName.equalsIgnoreCase(BASE)) { + edec = new HedBASE(this); + + } + else if (elementName.equalsIgnoreCase(BLOCKQUOTE)) { + edec = new HedBLOCKQUOTE(this); + + } + else if (elementName.equalsIgnoreCase(BODY)) { + edec = new HedBODY(this); + + } + else if (elementName.equalsIgnoreCase(BR)) { + edec = new HedBR(this); + + } + else if (elementName.equalsIgnoreCase(CENTER)) { + edec = new HedCENTER(this); + + } + else if (elementName.equalsIgnoreCase(DD)) { + edec = new HedDD(this); + + } + else if (elementName.equalsIgnoreCase(DIR)) { + edec = new HedMENU(DIR, this); + + } + else if (elementName.equalsIgnoreCase(DIV)) { + edec = new HedDIV(this); + + } + else if (elementName.equalsIgnoreCase(DL)) { + edec = new HedDL(this); + + } + else if (elementName.equalsIgnoreCase(DT)) { + edec = new HedDT(this); + + } + else if (elementName.equalsIgnoreCase(FORM)) { + edec = new HedFORM(this); + + } + else if (elementName.equalsIgnoreCase(H1)) { + edec = new HedHeading(H1, this); + + } + else if (elementName.equalsIgnoreCase(H2)) { + edec = new HedHeading(H2, this); + + } + else if (elementName.equalsIgnoreCase(H3)) { + edec = new HedHeading(H3, this); + + } + else if (elementName.equalsIgnoreCase(H4)) { + edec = new HedHeading(H4, this); + + } + else if (elementName.equalsIgnoreCase(H5)) { + edec = new HedHeading(H5, this); + + } + else if (elementName.equalsIgnoreCase(H6)) { + edec = new HedHeading(H6, this); + + } + else if (elementName.equalsIgnoreCase(HEAD)) { + edec = new HedHEAD(this); + + } + else if (elementName.equalsIgnoreCase(HR)) { + edec = new HedHR(this); + + } + else if (elementName.equalsIgnoreCase(HTML)) { + edec = new HedHTML(this); + + } + else if (elementName.equalsIgnoreCase(IMG)) { + edec = new HedIMG(this); + + } + else if (elementName.equalsIgnoreCase(INPUT)) { + edec = new HedINPUT(this); + + } + else if (elementName.equalsIgnoreCase(LI)) { + edec = new HedLI(this); + + } + else if (elementName.equalsIgnoreCase(MENU)) { + edec = new HedMENU(MENU, this); + + } + else if (elementName.equalsIgnoreCase(META)) { + edec = new HedMETA(this); + + } + else if (elementName.equalsIgnoreCase(OL)) { + edec = new HedOL(this); + + } + else if (elementName.equalsIgnoreCase(OPTION)) { + edec = new HedOPTION(this); + + } + else if (elementName.equalsIgnoreCase(P)) { + edec = new HedP(this); + + } + else if (elementName.equalsIgnoreCase(PRE)) { + edec = new HedPRE(this); + + } + else if (elementName.equalsIgnoreCase(SELECT)) { + edec = new HedSELECT(this); + + } + else if (elementName.equalsIgnoreCase(TEXTAREA)) { + edec = new HedTEXTAREA(this); + + } + else if (elementName.equalsIgnoreCase(TITLE)) { + edec = new HedTITLE(this); + + } + else if (elementName.equalsIgnoreCase(UL)) { + edec = new HedUL(this); + + } + else if (elementName.equalsIgnoreCase(SSI_CONFIG)) { + edec = new HedSSIConfig(this); + + } + else if (elementName.equalsIgnoreCase(SSI_ECHO)) { + edec = new HedSSIEcho(this); + + } + else if (elementName.equalsIgnoreCase(SSI_EXEC)) { + edec = new HedSSIExec(this); + + } + else if (elementName.equalsIgnoreCase(SSI_FSIZE)) { + edec = new HedSSIFsize(this); + + } + else if (elementName.equalsIgnoreCase(SSI_FLASTMOD)) { + edec = new HedSSIFlastmod(this); + + } + else if (elementName.equalsIgnoreCase(SSI_INCLUDE)) { + edec = new HedSSIInclude(this); + + } + else if (elementName.equalsIgnoreCase(SSI_PRINTENV)) { + edec = new HedSSIPrintenv(this); + + } + else if (elementName.equalsIgnoreCase(SSI_SET)) { + edec = new HedSSISet(this); + + } // unknown + else { + // NOTE: We don't define the UNKNOWN element declaration. + // <code>null</code> for a declaration is a sign of + // the target element is unknown. + // -- 3/9/2001 + edec = null; + } + return edec; + } + + /** + * @return com.ibm.sed.contentmodel.html.AttributeCollection + */ + public AttributeCollection getAttributeCollection() { + return attributeCollection; + } + + /** + */ + public final Collection getNamesOfBlock() { + // P | %list | %preformatted | DL | DIV | CENTER | BLOCKQUOTE | FORM | HR + String[] blockMisc = {P, DL, DIV, CENTER, BLOCKQUOTE, FORM, HR,}; + Vector blockNames = new Vector(Arrays.asList(blockMisc)); + // %heading; + blockNames.addAll(Arrays.asList(HEADING)); + // %list; + blockNames.addAll(Arrays.asList(LIST)); + // %preformatted; + blockNames.addAll(Arrays.asList(PREFORMATTED)); + + return blockNames; + } + + /** + * %block;. + * %block; is: + * P | %heading; | %list; | %preformatted; | DL | DIV | CENTER | + * NOSCRIPT | NOFRAMES | BLOCKQUOTE | FORM | ISINDEX | HR | + * TABLE | FIELDSET | ADDRESS.<br> + * @param group CMGroupImpl Return values. + */ + public final void getBlock(CMGroupImpl group) { + if (group == null) + return; + getDeclarations(group, getNamesOfBlock().iterator()); + } + + /** + * Create element declarations and store them + * into a <code>CMGroupImpl</code> instance. + * @param group CMGroupImpl Return values. + */ + public final void getFlow(CMGroupImpl group) { + if (group == null) + return; + getBlock(group); + getInline(group); + } + + /** + * Create element declarations and store them into a <code>CMGroupImpl</code> + * instance.<br> + * @param group CMGroupImpl Return values. + */ + public final void getFontstyle(CMGroupImpl group) { + return; + } + + /** + * Create element declarations and store them into a <code>CMGroupImpl</code> + * instance.<br> + * @param group CMGroupImpl Return values. + */ + public final void getFormctrl(CMGroupImpl group) { + if (group == null) + return; + getDeclarations(group, Arrays.asList(FORMCTL).iterator()); + } + + /** + * %heading;. + * @param group CMGroupImpl Return values. + */ + public final void getHeading(CMGroupImpl group) { + if (group == null) + return; + + getDeclarations(group, Arrays.asList(HEADING).iterator()); + } + + /** + * Create element declarations and store them + * into a <code>CMGroupImpl</code> instance. + * @param group CMGroupImpl Return values. + */ + public final void getInline(CMGroupImpl group) { + if (group == null) + return; + getFontstyle(group); + getPhrase(group); + getSpecial(group); + getFormctrl(group); + } + + /** + * %list;. + * @param group CMGroupImpl Return values. + */ + public final void getList(CMGroupImpl group) { + if (group == null) + return; + + getDeclarations(group, Arrays.asList(LIST).iterator()); + } + + /** + * Create element declarations and store them into a <code>CMGroupImpl</code> + * instance.<br> + * @param group CMGroupImpl Return values. + */ + public final void getPhrase(CMGroupImpl group) { + if (group == null) + return; + getDeclarations(group, Arrays.asList(PHRASE).iterator()); + } + + /** + * %preformatted; + * @param group CMGroupImpl Return values. + */ + public final void getPreformatted(CMGroupImpl group) { + if (group == null) + return; + + getDeclarations(group, Arrays.asList(PREFORMATTED).iterator()); + } + + /** + * Create element declarations and store them into a <code>CMGroupImpl</code> + * instance.<br> + * @param group CMGroupImpl Return values. + */ + public final void getSpecial(CMGroupImpl group) { + if (group == null) + return; + getDeclarations(group, Arrays.asList(SPECIAL).iterator()); + } +}
\ No newline at end of file diff --git a/bundles/org.eclipse.wst.html.core/src/org/eclipse/wst/html/core/contentmodel/chtml/EntityCollection.java b/bundles/org.eclipse.wst.html.core/src/org/eclipse/wst/html/core/contentmodel/chtml/EntityCollection.java new file mode 100644 index 0000000000..1ae092584c --- /dev/null +++ b/bundles/org.eclipse.wst.html.core/src/org/eclipse/wst/html/core/contentmodel/chtml/EntityCollection.java @@ -0,0 +1,837 @@ +/******************************************************************************* + * Copyright (c) 2004 IBM Corporation and others. + * All rights reserved. This program and the accompanying materials + * are made available under the terms of the Eclipse Public License v1.0 + * which accompanies this distribution, and is available at + * http://www.eclipse.org/legal/epl-v10.html + * + * Contributors: + * IBM Corporation - initial API and implementation + *******************************************************************************/ +package org.eclipse.wst.html.core.contentmodel.chtml; + + + +import java.lang.reflect.Field; + +import org.eclipse.wst.common.contentmodel.CMNode; + +/** + * Factory for entity declarations. + */ +final class EntityCollection extends DeclCollection implements org.eclipse.wst.html.core.HTML40Namespace.EntityName { + + + private static class Ids { + public static final int ID_AACUTE_L = 0; + public static final int ID_AACUTE_U = 1; + public static final int ID_ACIRC_L = 2; + public static final int ID_ACIRC_U = 3; + public static final int ID_ACUTE = 4; + public static final int ID_AELIG_L = 5; + public static final int ID_AELIG_U = 6; + public static final int ID_AGRAVE_L = 7; + public static final int ID_AGRAVE_U = 8; + public static final int ID_ALEFSYM = 9; + public static final int ID_ALPHA_L = 10; + public static final int ID_ALPHA_U = 11; + public static final int ID_AMP = 12; + public static final int ID_AND = 13; + public static final int ID_ANG = 14; + public static final int ID_ARING_L = 15; + public static final int ID_ARING_U = 16; + public static final int ID_ASYMP = 17; + public static final int ID_ATILDE_L = 18; + public static final int ID_ATILDE_U = 19; + public static final int ID_AUML_L = 20; + public static final int ID_AUML_U = 21; + public static final int ID_BDQUO = 22; + public static final int ID_BETA_L = 23; + public static final int ID_BETA_U = 24; + public static final int ID_BRVBAR = 25; + public static final int ID_BULL = 26; + public static final int ID_CAP = 27; + public static final int ID_CCEDIL_L = 28; + public static final int ID_CCEDIL_U = 29; + public static final int ID_CEDIL = 30; + public static final int ID_CENT = 31; + public static final int ID_CHI_L = 32; + public static final int ID_CHI_U = 33; + public static final int ID_CIRC = 34; + public static final int ID_CLUBS = 35; + public static final int ID_CONG = 36; + public static final int ID_COPY = 37; + public static final int ID_CRARR = 38; + public static final int ID_CUP = 39; + public static final int ID_CURREN = 40; + public static final int ID_DAGGER_L = 41; + public static final int ID_DAGGER_U = 42; + public static final int ID_DARR_L = 43; + public static final int ID_DARR_U = 44; + public static final int ID_DEG = 45; + public static final int ID_DELTA_L = 46; + public static final int ID_DELTA_U = 47; + public static final int ID_DIAMS = 48; + public static final int ID_DIVIDE = 49; + public static final int ID_EACUTE_L = 50; + public static final int ID_EACUTE_U = 51; + public static final int ID_ECIRC_L = 52; + public static final int ID_ECIRC_U = 53; + public static final int ID_EGRAVE_L = 54; + public static final int ID_EGRAVE_U = 55; + public static final int ID_EMPTY = 56; + public static final int ID_EMSP = 57; + public static final int ID_ENSP = 58; + public static final int ID_EPSILON_L = 59; + public static final int ID_EPSILON_U = 60; + public static final int ID_EQUIV = 61; + public static final int ID_ETA_L = 62; + public static final int ID_ETA_U = 63; + public static final int ID_ETH_L = 64; + public static final int ID_ETH_U = 65; + public static final int ID_EUML_L = 66; + public static final int ID_EUML_U = 67; + public static final int ID_EURO = 68; + public static final int ID_EXIST = 69; + public static final int ID_FNOF = 70; + public static final int ID_FORALL = 71; + public static final int ID_FRAC12 = 72; + public static final int ID_FRAC14 = 73; + public static final int ID_FRAC34 = 74; + public static final int ID_FRASL = 75; + public static final int ID_GAMMA_L = 76; + public static final int ID_GAMMA_U = 77; + public static final int ID_GE = 78; + public static final int ID_GT = 79; + public static final int ID_HARR_L = 80; + public static final int ID_HARR_U = 81; + public static final int ID_HEARTS = 82; + public static final int ID_HELLIP = 83; + public static final int ID_IACUTE_L = 84; + public static final int ID_IACUTE_U = 85; + public static final int ID_ICIRC_L = 86; + public static final int ID_ICIRC_U = 87; + public static final int ID_IEXCL = 88; + public static final int ID_IGRAVE_L = 89; + public static final int ID_IGRAVE_U = 90; + public static final int ID_IMAGE = 91; + public static final int ID_INFIN = 92; + public static final int ID_INT = 93; + public static final int ID_IOTA_L = 94; + public static final int ID_IOTA_U = 95; + public static final int ID_IQUEST = 96; + public static final int ID_ISIN = 97; + public static final int ID_IUML_L = 98; + public static final int ID_IUML_U = 99; + public static final int ID_KAPPA_L = 100; + public static final int ID_KAPPA_U = 101; + public static final int ID_LAMBDA_L = 102; + public static final int ID_LAMBDA_U = 103; + public static final int ID_LANG = 104; + public static final int ID_LAQUO = 105; + public static final int ID_LARR_L = 106; + public static final int ID_LARR_U = 107; + public static final int ID_LCEIL = 108; + public static final int ID_LDQUO = 109; + public static final int ID_LE = 110; + public static final int ID_LFLOOR = 111; + public static final int ID_LOWAST = 112; + public static final int ID_LOZ = 113; + public static final int ID_LRM = 114; + public static final int ID_LSAQUO = 115; + public static final int ID_LSQUO = 116; + public static final int ID_LT = 117; + public static final int ID_MACR = 118; + public static final int ID_MDASH = 119; + public static final int ID_MICRO = 120; + public static final int ID_MIDDOT = 121; + public static final int ID_MINUS = 122; + public static final int ID_MU_L = 123; + public static final int ID_MU_U = 124; + public static final int ID_NABLA = 125; + public static final int ID_NBSP = 126; + public static final int ID_NDASH = 127; + public static final int ID_NE = 128; + public static final int ID_NI = 129; + public static final int ID_NOT = 130; + public static final int ID_NOTIN = 131; + public static final int ID_NSUB = 132; + public static final int ID_NTILDE_L = 133; + public static final int ID_NTILDE_U = 134; + public static final int ID_NU_L = 135; + public static final int ID_NU_U = 136; + public static final int ID_OACUTE_L = 137; + public static final int ID_OACUTE_U = 138; + public static final int ID_OCIRC_L = 139; + public static final int ID_OCIRC_U = 140; + public static final int ID_OELIG_L = 141; + public static final int ID_OELIG_U = 142; + public static final int ID_OGRAVE_L = 143; + public static final int ID_OGRAVE_U = 144; + public static final int ID_OLINE = 145; + public static final int ID_OMEGA_L = 146; + public static final int ID_OMEGA_U = 147; + public static final int ID_OMICRON_L = 148; + public static final int ID_OMICRON_U = 149; + public static final int ID_OPLUS = 150; + public static final int ID_OR = 151; + public static final int ID_ORDF = 152; + public static final int ID_ORDM = 153; + public static final int ID_OSLASH_L = 154; + public static final int ID_OSLASH_U = 155; + public static final int ID_OTILDE_L = 156; + public static final int ID_OTILDE_U = 157; + public static final int ID_OTIMES = 158; + public static final int ID_OUML_L = 159; + public static final int ID_OUML_U = 160; + public static final int ID_PARA = 161; + public static final int ID_PART = 162; + public static final int ID_PERMIL = 163; + public static final int ID_PERP = 164; + public static final int ID_PHI_L = 165; + public static final int ID_PHI_U = 166; + public static final int ID_PIV = 167; + public static final int ID_PI_L = 168; + public static final int ID_PI_U = 169; + public static final int ID_PLUSMN = 170; + public static final int ID_POUND = 171; + public static final int ID_PRIME_L = 172; + public static final int ID_PRIME_U = 173; + public static final int ID_PROD = 174; + public static final int ID_PROP = 175; + public static final int ID_PSI_L = 176; + public static final int ID_PSI_U = 177; + public static final int ID_QUOT = 178; + public static final int ID_RADIC = 179; + public static final int ID_RANG = 180; + public static final int ID_RAQUO = 181; + public static final int ID_RARR_L = 182; + public static final int ID_RARR_U = 183; + public static final int ID_RCEIL = 184; + public static final int ID_RDQUO = 185; + public static final int ID_REAL = 186; + public static final int ID_REG = 187; + public static final int ID_RFLOOR = 188; + public static final int ID_RHO_L = 189; + public static final int ID_RHO_U = 190; + public static final int ID_RLM = 191; + public static final int ID_RSAQUO = 192; + public static final int ID_RSQUO = 193; + public static final int ID_SBQUO = 194; + public static final int ID_SCARON_L = 195; + public static final int ID_SCARON_U = 196; + public static final int ID_SDOT = 197; + public static final int ID_SECT = 198; + public static final int ID_SHY = 199; + public static final int ID_SIGMAF = 200; + public static final int ID_SIGMA_L = 201; + public static final int ID_SIGMA_U = 202; + public static final int ID_SIM = 203; + public static final int ID_SPADES = 204; + public static final int ID_SUB = 205; + public static final int ID_SUBE = 206; + public static final int ID_SUM = 207; + public static final int ID_SUP = 208; + public static final int ID_SUP1 = 209; + public static final int ID_SUP2 = 210; + public static final int ID_SUP3 = 211; + public static final int ID_SUPE = 212; + public static final int ID_SZLIG = 213; + public static final int ID_TAU_L = 214; + public static final int ID_TAU_U = 215; + public static final int ID_THERE4 = 216; + public static final int ID_THETASYM = 217; + public static final int ID_THETA_L = 218; + public static final int ID_THETA_U = 219; + public static final int ID_THINSP = 220; + public static final int ID_THORN_L = 221; + public static final int ID_THORN_U = 222; + public static final int ID_TILDE = 223; + public static final int ID_TIMES = 224; + public static final int ID_TRADE = 225; + public static final int ID_UACUTE_L = 226; + public static final int ID_UACUTE_U = 227; + public static final int ID_UARR_L = 228; + public static final int ID_UARR_U = 229; + public static final int ID_UCIRC_L = 230; + public static final int ID_UCIRC_U = 231; + public static final int ID_UGRAVE_L = 232; + public static final int ID_UGRAVE_U = 233; + public static final int ID_UML = 234; + public static final int ID_UPSIH = 235; + public static final int ID_UPSILON_L = 236; + public static final int ID_UPSILON_U = 237; + public static final int ID_UUML_L = 238; + public static final int ID_UUML_U = 239; + public static final int ID_WEIERP = 240; + public static final int ID_XI_L = 241; + public static final int ID_XI_U = 242; + public static final int ID_YACUTE_L = 243; + public static final int ID_YACUTE_U = 244; + public static final int ID_YEN = 245; + public static final int ID_YUML_L = 246; + public static final int ID_YUML_U = 247; + public static final int ID_ZETA_L = 248; + public static final int ID_ZETA_U = 249; + public static final int ID_ZWJ = 250; + public static final int ID_ZWNJ = 251; + + public static int getNumOfIds() { + if (numofids != -1) + return numofids; + + // NOTE: If the reflection is too slow, this method should + // just return the literal value, like 252. + // -- 5/24/2001 + Class clazz = Ids.class; + Field[] fields = clazz.getFields(); + numofids = 0; + for (int i = 0; i < fields.length; i++) { + String name = fields[i].getName(); + if (name.startsWith("ID_"))//$NON-NLS-1$ + numofids++; + } + return numofids; + } + + // chache the result of the reflection. + private static int numofids = -1; + } + + private static String[] names = null; + + static { + names = new String[Ids.getNumOfIds()]; + names[Ids.ID_AACUTE_L] = AACUTE_L; + names[Ids.ID_AACUTE_U] = AACUTE_U; + names[Ids.ID_ACIRC_L] = ACIRC_L; + names[Ids.ID_ACIRC_U] = ACIRC_U; + names[Ids.ID_ACUTE] = ACUTE; + names[Ids.ID_AELIG_L] = AELIG_L; + names[Ids.ID_AELIG_U] = AELIG_U; + names[Ids.ID_AGRAVE_L] = AGRAVE_L; + names[Ids.ID_AGRAVE_U] = AGRAVE_U; + names[Ids.ID_ALEFSYM] = ALEFSYM; + names[Ids.ID_ALPHA_L] = ALPHA_L; + names[Ids.ID_ALPHA_U] = ALPHA_U; + names[Ids.ID_AMP] = AMP; + names[Ids.ID_AND] = AND; + names[Ids.ID_ANG] = ANG; + names[Ids.ID_ARING_L] = ARING_L; + names[Ids.ID_ARING_U] = ARING_U; + names[Ids.ID_ASYMP] = ASYMP; + names[Ids.ID_ATILDE_L] = ATILDE_L; + names[Ids.ID_ATILDE_U] = ATILDE_U; + names[Ids.ID_AUML_L] = AUML_L; + names[Ids.ID_AUML_U] = AUML_U; + names[Ids.ID_BDQUO] = BDQUO; + names[Ids.ID_BETA_L] = BETA_L; + names[Ids.ID_BETA_U] = BETA_U; + names[Ids.ID_BRVBAR] = BRVBAR; + names[Ids.ID_BULL] = BULL; + names[Ids.ID_CAP] = CAP; + names[Ids.ID_CCEDIL_L] = CCEDIL_L; + names[Ids.ID_CCEDIL_U] = CCEDIL_U; + names[Ids.ID_CEDIL] = CEDIL; + names[Ids.ID_CENT] = CENT; + names[Ids.ID_CHI_L] = CHI_L; + names[Ids.ID_CHI_U] = CHI_U; + names[Ids.ID_CIRC] = CIRC; + names[Ids.ID_CLUBS] = CLUBS; + names[Ids.ID_CONG] = CONG; + names[Ids.ID_COPY] = COPY; + names[Ids.ID_CRARR] = CRARR; + names[Ids.ID_CUP] = CUP; + names[Ids.ID_CURREN] = CURREN; + names[Ids.ID_DAGGER_L] = DAGGER_L; + names[Ids.ID_DAGGER_U] = DAGGER_U; + names[Ids.ID_DARR_L] = DARR_L; + names[Ids.ID_DARR_U] = DARR_U; + names[Ids.ID_DEG] = DEG; + names[Ids.ID_DELTA_L] = DELTA_L; + names[Ids.ID_DELTA_U] = DELTA_U; + names[Ids.ID_DIAMS] = DIAMS; + names[Ids.ID_DIVIDE] = DIVIDE; + names[Ids.ID_EACUTE_L] = EACUTE_L; + names[Ids.ID_EACUTE_U] = EACUTE_U; + names[Ids.ID_ECIRC_L] = ECIRC_L; + names[Ids.ID_ECIRC_U] = ECIRC_U; + names[Ids.ID_EGRAVE_L] = EGRAVE_L; + names[Ids.ID_EGRAVE_U] = EGRAVE_U; + names[Ids.ID_EMPTY] = EMPTY; + names[Ids.ID_EMSP] = EMSP; + names[Ids.ID_ENSP] = ENSP; + names[Ids.ID_EPSILON_L] = EPSILON_L; + names[Ids.ID_EPSILON_U] = EPSILON_U; + names[Ids.ID_EQUIV] = EQUIV; + names[Ids.ID_ETA_L] = ETA_L; + names[Ids.ID_ETA_U] = ETA_U; + names[Ids.ID_ETH_L] = ETH_L; + names[Ids.ID_ETH_U] = ETH_U; + names[Ids.ID_EUML_L] = EUML_L; + names[Ids.ID_EUML_U] = EUML_U; + names[Ids.ID_EURO] = EURO; + names[Ids.ID_EXIST] = EXIST; + names[Ids.ID_FNOF] = FNOF; + names[Ids.ID_FORALL] = FORALL; + names[Ids.ID_FRAC12] = FRAC12; + names[Ids.ID_FRAC14] = FRAC14; + names[Ids.ID_FRAC34] = FRAC34; + names[Ids.ID_FRASL] = FRASL; + names[Ids.ID_GAMMA_L] = GAMMA_L; + names[Ids.ID_GAMMA_U] = GAMMA_U; + names[Ids.ID_GE] = GE; + names[Ids.ID_GT] = GT; + names[Ids.ID_HARR_L] = HARR_L; + names[Ids.ID_HARR_U] = HARR_U; + names[Ids.ID_HEARTS] = HEARTS; + names[Ids.ID_HELLIP] = HELLIP; + names[Ids.ID_IACUTE_L] = IACUTE_L; + names[Ids.ID_IACUTE_U] = IACUTE_U; + names[Ids.ID_ICIRC_L] = ICIRC_L; + names[Ids.ID_ICIRC_U] = ICIRC_U; + names[Ids.ID_IEXCL] = IEXCL; + names[Ids.ID_IGRAVE_L] = IGRAVE_L; + names[Ids.ID_IGRAVE_U] = IGRAVE_U; + names[Ids.ID_IMAGE] = IMAGE; + names[Ids.ID_INFIN] = INFIN; + names[Ids.ID_INT] = INT; + names[Ids.ID_IOTA_L] = IOTA_L; + names[Ids.ID_IOTA_U] = IOTA_U; + names[Ids.ID_IQUEST] = IQUEST; + names[Ids.ID_ISIN] = ISIN; + names[Ids.ID_IUML_L] = IUML_L; + names[Ids.ID_IUML_U] = IUML_U; + names[Ids.ID_KAPPA_L] = KAPPA_L; + names[Ids.ID_KAPPA_U] = KAPPA_U; + names[Ids.ID_LAMBDA_L] = LAMBDA_L; + names[Ids.ID_LAMBDA_U] = LAMBDA_U; + names[Ids.ID_LANG] = LANG; + names[Ids.ID_LAQUO] = LAQUO; + names[Ids.ID_LARR_L] = LARR_L; + names[Ids.ID_LARR_U] = LARR_U; + names[Ids.ID_LCEIL] = LCEIL; + names[Ids.ID_LDQUO] = LDQUO; + names[Ids.ID_LE] = LE; + names[Ids.ID_LFLOOR] = LFLOOR; + names[Ids.ID_LOWAST] = LOWAST; + names[Ids.ID_LOZ] = LOZ; + names[Ids.ID_LRM] = LRM; + names[Ids.ID_LSAQUO] = LSAQUO; + names[Ids.ID_LSQUO] = LSQUO; + names[Ids.ID_LT] = LT; + names[Ids.ID_MACR] = MACR; + names[Ids.ID_MDASH] = MDASH; + names[Ids.ID_MICRO] = MICRO; + names[Ids.ID_MIDDOT] = MIDDOT; + names[Ids.ID_MINUS] = MINUS; + names[Ids.ID_MU_L] = MU_L; + names[Ids.ID_MU_U] = MU_U; + names[Ids.ID_NABLA] = NABLA; + names[Ids.ID_NBSP] = NBSP; + names[Ids.ID_NDASH] = NDASH; + names[Ids.ID_NE] = NE; + names[Ids.ID_NI] = NI; + names[Ids.ID_NOT] = NOT; + names[Ids.ID_NOTIN] = NOTIN; + names[Ids.ID_NSUB] = NSUB; + names[Ids.ID_NTILDE_L] = NTILDE_L; + names[Ids.ID_NTILDE_U] = NTILDE_U; + names[Ids.ID_NU_L] = NU_L; + names[Ids.ID_NU_U] = NU_U; + names[Ids.ID_OACUTE_L] = OACUTE_L; + names[Ids.ID_OACUTE_U] = OACUTE_U; + names[Ids.ID_OCIRC_L] = OCIRC_L; + names[Ids.ID_OCIRC_U] = OCIRC_U; + names[Ids.ID_OELIG_L] = OELIG_L; + names[Ids.ID_OELIG_U] = OELIG_U; + names[Ids.ID_OGRAVE_L] = OGRAVE_L; + names[Ids.ID_OGRAVE_U] = OGRAVE_U; + names[Ids.ID_OLINE] = OLINE; + names[Ids.ID_OMEGA_L] = OMEGA_L; + names[Ids.ID_OMEGA_U] = OMEGA_U; + names[Ids.ID_OMICRON_L] = OMICRON_L; + names[Ids.ID_OMICRON_U] = OMICRON_U; + names[Ids.ID_OPLUS] = OPLUS; + names[Ids.ID_OR] = OR; + names[Ids.ID_ORDF] = ORDF; + names[Ids.ID_ORDM] = ORDM; + names[Ids.ID_OSLASH_L] = OSLASH_L; + names[Ids.ID_OSLASH_U] = OSLASH_U; + names[Ids.ID_OTILDE_L] = OTILDE_L; + names[Ids.ID_OTILDE_U] = OTILDE_U; + names[Ids.ID_OTIMES] = OTIMES; + names[Ids.ID_OUML_L] = OUML_L; + names[Ids.ID_OUML_U] = OUML_U; + names[Ids.ID_PARA] = PARA; + names[Ids.ID_PART] = PART; + names[Ids.ID_PERMIL] = PERMIL; + names[Ids.ID_PERP] = PERP; + names[Ids.ID_PHI_L] = PHI_L; + names[Ids.ID_PHI_U] = PHI_U; + names[Ids.ID_PIV] = PIV; + names[Ids.ID_PI_L] = PI_L; + names[Ids.ID_PI_U] = PI_U; + names[Ids.ID_PLUSMN] = PLUSMN; + names[Ids.ID_POUND] = POUND; + names[Ids.ID_PRIME_L] = PRIME_L; + names[Ids.ID_PRIME_U] = PRIME_U; + names[Ids.ID_PROD] = PROD; + names[Ids.ID_PROP] = PROP; + names[Ids.ID_PSI_L] = PSI_L; + names[Ids.ID_PSI_U] = PSI_U; + names[Ids.ID_QUOT] = QUOT; + names[Ids.ID_RADIC] = RADIC; + names[Ids.ID_RANG] = RANG; + names[Ids.ID_RAQUO] = RAQUO; + names[Ids.ID_RARR_L] = RARR_L; + names[Ids.ID_RARR_U] = RARR_U; + names[Ids.ID_RCEIL] = RCEIL; + names[Ids.ID_RDQUO] = RDQUO; + names[Ids.ID_REAL] = REAL; + names[Ids.ID_REG] = REG; + names[Ids.ID_RFLOOR] = RFLOOR; + names[Ids.ID_RHO_L] = RHO_L; + names[Ids.ID_RHO_U] = RHO_U; + names[Ids.ID_RLM] = RLM; + names[Ids.ID_RSAQUO] = RSAQUO; + names[Ids.ID_RSQUO] = RSQUO; + names[Ids.ID_SBQUO] = SBQUO; + names[Ids.ID_SCARON_L] = SCARON_L; + names[Ids.ID_SCARON_U] = SCARON_U; + names[Ids.ID_SDOT] = SDOT; + names[Ids.ID_SECT] = SECT; + names[Ids.ID_SHY] = SHY; + names[Ids.ID_SIGMAF] = SIGMAF; + names[Ids.ID_SIGMA_L] = SIGMA_L; + names[Ids.ID_SIGMA_U] = SIGMA_U; + names[Ids.ID_SIM] = SIM; + names[Ids.ID_SPADES] = SPADES; + names[Ids.ID_SUB] = SUB; + names[Ids.ID_SUBE] = SUBE; + names[Ids.ID_SUM] = SUM; + names[Ids.ID_SUP] = SUP; + names[Ids.ID_SUP1] = SUP1; + names[Ids.ID_SUP2] = SUP2; + names[Ids.ID_SUP3] = SUP3; + names[Ids.ID_SUPE] = SUPE; + names[Ids.ID_SZLIG] = SZLIG; + names[Ids.ID_TAU_L] = TAU_L; + names[Ids.ID_TAU_U] = TAU_U; + names[Ids.ID_THERE4] = THERE4; + names[Ids.ID_THETASYM] = THETASYM; + names[Ids.ID_THETA_L] = THETA_L; + names[Ids.ID_THETA_U] = THETA_U; + names[Ids.ID_THINSP] = THINSP; + names[Ids.ID_THORN_L] = THORN_L; + names[Ids.ID_THORN_U] = THORN_U; + names[Ids.ID_TILDE] = TILDE; + names[Ids.ID_TIMES] = TIMES; + names[Ids.ID_TRADE] = TRADE; + names[Ids.ID_UACUTE_L] = UACUTE_L; + names[Ids.ID_UACUTE_U] = UACUTE_U; + names[Ids.ID_UARR_L] = UARR_L; + names[Ids.ID_UARR_U] = UARR_U; + names[Ids.ID_UCIRC_L] = UCIRC_L; + names[Ids.ID_UCIRC_U] = UCIRC_U; + names[Ids.ID_UGRAVE_L] = UGRAVE_L; + names[Ids.ID_UGRAVE_U] = UGRAVE_U; + names[Ids.ID_UML] = UML; + names[Ids.ID_UPSIH] = UPSIH; + names[Ids.ID_UPSILON_L] = UPSILON_L; + names[Ids.ID_UPSILON_U] = UPSILON_U; + names[Ids.ID_UUML_L] = UUML_L; + names[Ids.ID_UUML_U] = UUML_U; + names[Ids.ID_WEIERP] = WEIERP; + names[Ids.ID_XI_L] = XI_L; + names[Ids.ID_XI_U] = XI_U; + names[Ids.ID_YACUTE_L] = YACUTE_L; + names[Ids.ID_YACUTE_U] = YACUTE_U; + names[Ids.ID_YEN] = YEN; + names[Ids.ID_YUML_L] = YUML_L; + names[Ids.ID_YUML_U] = YUML_U; + names[Ids.ID_ZETA_L] = ZETA_L; + names[Ids.ID_ZETA_U] = ZETA_U; + names[Ids.ID_ZWJ] = ZWJ; + names[Ids.ID_ZWNJ] = ZWNJ; + } + private static char[] values = null; + + static { + values = new char[Ids.getNumOfIds()]; + values[Ids.ID_AACUTE_L] = 225; + values[Ids.ID_AACUTE_U] = 193; + values[Ids.ID_ACIRC_L] = 226; + values[Ids.ID_ACIRC_U] = 194; + values[Ids.ID_ACUTE] = 180; + values[Ids.ID_AELIG_L] = 230; + values[Ids.ID_AELIG_U] = 198; + values[Ids.ID_AGRAVE_L] = 224; + values[Ids.ID_AGRAVE_U] = 192; + values[Ids.ID_ALEFSYM] = 8501; + values[Ids.ID_ALPHA_L] = 945; + values[Ids.ID_ALPHA_U] = 913; + values[Ids.ID_AMP] = 38; + values[Ids.ID_AND] = 8743; + values[Ids.ID_ANG] = 8736; + values[Ids.ID_ARING_L] = 229; + values[Ids.ID_ARING_U] = 197; + values[Ids.ID_ASYMP] = 8776; + values[Ids.ID_ATILDE_L] = 227; + values[Ids.ID_ATILDE_U] = 195; + values[Ids.ID_AUML_L] = 228; + values[Ids.ID_AUML_U] = 196; + values[Ids.ID_BDQUO] = 8222; + values[Ids.ID_BETA_L] = 946; + values[Ids.ID_BETA_U] = 914; + values[Ids.ID_BRVBAR] = 166; + values[Ids.ID_BULL] = 8226; + values[Ids.ID_CAP] = 8745; + values[Ids.ID_CCEDIL_L] = 231; + values[Ids.ID_CCEDIL_U] = 199; + values[Ids.ID_CEDIL] = 184; + values[Ids.ID_CENT] = 162; + values[Ids.ID_CHI_L] = 967; + values[Ids.ID_CHI_U] = 935; + values[Ids.ID_CIRC] = 710; + values[Ids.ID_CLUBS] = 9827; + values[Ids.ID_CONG] = 8773; + values[Ids.ID_COPY] = 169; + values[Ids.ID_CRARR] = 8629; + values[Ids.ID_CUP] = 8746; + values[Ids.ID_CURREN] = 164; + values[Ids.ID_DAGGER_L] = 8224; + values[Ids.ID_DAGGER_U] = 8225; + values[Ids.ID_DARR_L] = 8595; + values[Ids.ID_DARR_U] = 8659; + values[Ids.ID_DEG] = 176; + values[Ids.ID_DELTA_L] = 948; + values[Ids.ID_DELTA_U] = 916; + values[Ids.ID_DIAMS] = 9830; + values[Ids.ID_DIVIDE] = 247; + values[Ids.ID_EACUTE_L] = 233; + values[Ids.ID_EACUTE_U] = 201; + values[Ids.ID_ECIRC_L] = 234; + values[Ids.ID_ECIRC_U] = 202; + values[Ids.ID_EGRAVE_L] = 232; + values[Ids.ID_EGRAVE_U] = 200; + values[Ids.ID_EMPTY] = 8709; + values[Ids.ID_EMSP] = 8195; + values[Ids.ID_ENSP] = 8194; + values[Ids.ID_EPSILON_L] = 949; + values[Ids.ID_EPSILON_U] = 917; + values[Ids.ID_EQUIV] = 8801; + values[Ids.ID_ETA_L] = 951; + values[Ids.ID_ETA_U] = 919; + values[Ids.ID_ETH_L] = 240; + values[Ids.ID_ETH_U] = 208; + values[Ids.ID_EUML_L] = 235; + values[Ids.ID_EUML_U] = 203; + values[Ids.ID_EURO] = 8364; + values[Ids.ID_EXIST] = 8707; + values[Ids.ID_FNOF] = 402; + values[Ids.ID_FORALL] = 8704; + values[Ids.ID_FRAC12] = 189; + values[Ids.ID_FRAC14] = 188; + values[Ids.ID_FRAC34] = 190; + values[Ids.ID_FRASL] = 8260; + values[Ids.ID_GAMMA_L] = 947; + values[Ids.ID_GAMMA_U] = 915; + values[Ids.ID_GE] = 8805; + values[Ids.ID_GT] = 62; + values[Ids.ID_HARR_L] = 8596; + values[Ids.ID_HARR_U] = 8660; + values[Ids.ID_HEARTS] = 9829; + values[Ids.ID_HELLIP] = 8230; + values[Ids.ID_IACUTE_L] = 237; + values[Ids.ID_IACUTE_U] = 205; + values[Ids.ID_ICIRC_L] = 238; + values[Ids.ID_ICIRC_U] = 206; + values[Ids.ID_IEXCL] = 161; + values[Ids.ID_IGRAVE_L] = 236; + values[Ids.ID_IGRAVE_U] = 204; + values[Ids.ID_IMAGE] = 8465; + values[Ids.ID_INFIN] = 8734; + values[Ids.ID_INT] = 8747; + values[Ids.ID_IOTA_L] = 953; + values[Ids.ID_IOTA_U] = 921; + values[Ids.ID_IQUEST] = 191; + values[Ids.ID_ISIN] = 8712; + values[Ids.ID_IUML_L] = 239; + values[Ids.ID_IUML_U] = 207; + values[Ids.ID_KAPPA_L] = 954; + values[Ids.ID_KAPPA_U] = 922; + values[Ids.ID_LAMBDA_L] = 955; + values[Ids.ID_LAMBDA_U] = 923; + values[Ids.ID_LANG] = 9001; + values[Ids.ID_LAQUO] = 171; + values[Ids.ID_LARR_L] = 8592; + values[Ids.ID_LARR_U] = 8656; + values[Ids.ID_LCEIL] = 8968; + values[Ids.ID_LDQUO] = 8220; + values[Ids.ID_LE] = 8804; + values[Ids.ID_LFLOOR] = 8970; + values[Ids.ID_LOWAST] = 8727; + values[Ids.ID_LOZ] = 9674; + values[Ids.ID_LRM] = 8206; + values[Ids.ID_LSAQUO] = 8249; + values[Ids.ID_LSQUO] = 8216; + values[Ids.ID_LT] = 60; + values[Ids.ID_MACR] = 175; + values[Ids.ID_MDASH] = 8212; + values[Ids.ID_MICRO] = 181; + values[Ids.ID_MIDDOT] = 183; + values[Ids.ID_MINUS] = 8722; + values[Ids.ID_MU_L] = 956; + values[Ids.ID_MU_U] = 924; + values[Ids.ID_NABLA] = 8711; + values[Ids.ID_NBSP] = 160; + values[Ids.ID_NDASH] = 8211; + values[Ids.ID_NE] = 8800; + values[Ids.ID_NI] = 8715; + values[Ids.ID_NOT] = 172; + values[Ids.ID_NOTIN] = 8713; + values[Ids.ID_NSUB] = 8836; + values[Ids.ID_NTILDE_L] = 241; + values[Ids.ID_NTILDE_U] = 209; + values[Ids.ID_NU_L] = 957; + values[Ids.ID_NU_U] = 925; + values[Ids.ID_OACUTE_L] = 243; + values[Ids.ID_OACUTE_U] = 211; + values[Ids.ID_OCIRC_L] = 244; + values[Ids.ID_OCIRC_U] = 212; + values[Ids.ID_OELIG_L] = 339; + values[Ids.ID_OELIG_U] = 338; + values[Ids.ID_OGRAVE_L] = 242; + values[Ids.ID_OGRAVE_U] = 210; + values[Ids.ID_OLINE] = 8254; + values[Ids.ID_OMEGA_L] = 969; + values[Ids.ID_OMEGA_U] = 937; + values[Ids.ID_OMICRON_L] = 959; + values[Ids.ID_OMICRON_U] = 927; + values[Ids.ID_OPLUS] = 8853; + values[Ids.ID_OR] = 8744; + values[Ids.ID_ORDF] = 170; + values[Ids.ID_ORDM] = 186; + values[Ids.ID_OSLASH_L] = 248; + values[Ids.ID_OSLASH_U] = 216; + values[Ids.ID_OTILDE_L] = 245; + values[Ids.ID_OTILDE_U] = 213; + values[Ids.ID_OTIMES] = 8855; + values[Ids.ID_OUML_L] = 246; + values[Ids.ID_OUML_U] = 214; + values[Ids.ID_PARA] = 182; + values[Ids.ID_PART] = 8706; + values[Ids.ID_PERMIL] = 8240; + values[Ids.ID_PERP] = 8869; + values[Ids.ID_PHI_L] = 966; + values[Ids.ID_PHI_U] = 934; + values[Ids.ID_PIV] = 982; + values[Ids.ID_PI_L] = 960; + values[Ids.ID_PI_U] = 928; + values[Ids.ID_PLUSMN] = 177; + values[Ids.ID_POUND] = 163; + values[Ids.ID_PRIME_L] = 8242; + values[Ids.ID_PRIME_U] = 8243; + values[Ids.ID_PROD] = 8719; + values[Ids.ID_PROP] = 8733; + values[Ids.ID_PSI_L] = 968; + values[Ids.ID_PSI_U] = 936; + values[Ids.ID_QUOT] = 34; + values[Ids.ID_RADIC] = 8730; + values[Ids.ID_RANG] = 9002; + values[Ids.ID_RAQUO] = 187; + values[Ids.ID_RARR_L] = 8594; + values[Ids.ID_RARR_U] = 8658; + values[Ids.ID_RCEIL] = 8969; + values[Ids.ID_RDQUO] = 8221; + values[Ids.ID_REAL] = 8476; + values[Ids.ID_REG] = 174; + values[Ids.ID_RFLOOR] = 8971; + values[Ids.ID_RHO_L] = 961; + values[Ids.ID_RHO_U] = 929; + values[Ids.ID_RLM] = 8207; + values[Ids.ID_RSAQUO] = 8250; + values[Ids.ID_RSQUO] = 8217; + values[Ids.ID_SBQUO] = 8218; + values[Ids.ID_SCARON_L] = 353; + values[Ids.ID_SCARON_U] = 352; + values[Ids.ID_SDOT] = 8901; + values[Ids.ID_SECT] = 167; + values[Ids.ID_SHY] = 173; + values[Ids.ID_SIGMAF] = 962; + values[Ids.ID_SIGMA_L] = 963; + values[Ids.ID_SIGMA_U] = 931; + values[Ids.ID_SIM] = 8764; + values[Ids.ID_SPADES] = 9824; + values[Ids.ID_SUB] = 8834; + values[Ids.ID_SUBE] = 8838; + values[Ids.ID_SUM] = 8721; + values[Ids.ID_SUP] = 8835; + values[Ids.ID_SUP1] = 185; + values[Ids.ID_SUP2] = 178; + values[Ids.ID_SUP3] = 179; + values[Ids.ID_SUPE] = 8839; + values[Ids.ID_SZLIG] = 223; + values[Ids.ID_TAU_L] = 964; + values[Ids.ID_TAU_U] = 932; + values[Ids.ID_THERE4] = 8756; + values[Ids.ID_THETASYM] = 977; + values[Ids.ID_THETA_L] = 952; + values[Ids.ID_THETA_U] = 920; + values[Ids.ID_THINSP] = 8201; + values[Ids.ID_THORN_L] = 254; + values[Ids.ID_THORN_U] = 222; + values[Ids.ID_TILDE] = 732; + values[Ids.ID_TIMES] = 215; + values[Ids.ID_TRADE] = 8482; + values[Ids.ID_UACUTE_L] = 250; + values[Ids.ID_UACUTE_U] = 218; + values[Ids.ID_UARR_L] = 8593; + values[Ids.ID_UARR_U] = 8657; + values[Ids.ID_UCIRC_L] = 251; + values[Ids.ID_UCIRC_U] = 219; + values[Ids.ID_UGRAVE_L] = 249; + values[Ids.ID_UGRAVE_U] = 217; + values[Ids.ID_UML] = 168; + values[Ids.ID_UPSIH] = 978; + values[Ids.ID_UPSILON_L] = 965; + values[Ids.ID_UPSILON_U] = 933; + values[Ids.ID_UUML_L] = 252; + values[Ids.ID_UUML_U] = 220; + values[Ids.ID_WEIERP] = 8472; + values[Ids.ID_XI_L] = 958; + values[Ids.ID_XI_U] = 926; + values[Ids.ID_YACUTE_L] = 253; + values[Ids.ID_YACUTE_U] = 221; + values[Ids.ID_YEN] = 165; + values[Ids.ID_YUML_L] = 255; + values[Ids.ID_YUML_U] = 376; + values[Ids.ID_ZETA_L] = 950; + values[Ids.ID_ZETA_U] = 918; + values[Ids.ID_ZWJ] = 8205; + values[Ids.ID_ZWNJ] = 8204; + } + + /** + */ + public EntityCollection() { + super(names, STRICT_CASE); + } + + /** + * Create an entity declaration. + * @return org.eclipse.wst.common.contentmodel.CMNode + * @param attrName java.lang.String + */ + protected CMNode create(String entityName) { + int id = getID(entityName); + if (id == ID_UNKNOWN) + return null; + + String value = String.valueOf(values[id]); + HTMLEntityDeclImpl dec = new HTMLEntityDeclImpl(entityName, value); + + return dec; + } +}
\ No newline at end of file diff --git a/bundles/org.eclipse.wst.html.core/src/org/eclipse/wst/html/core/contentmodel/chtml/HTMLAttrDeclImpl.java b/bundles/org.eclipse.wst.html.core/src/org/eclipse/wst/html/core/contentmodel/chtml/HTMLAttrDeclImpl.java new file mode 100644 index 0000000000..e0fbc52466 --- /dev/null +++ b/bundles/org.eclipse.wst.html.core/src/org/eclipse/wst/html/core/contentmodel/chtml/HTMLAttrDeclImpl.java @@ -0,0 +1,118 @@ +/******************************************************************************* + * Copyright (c) 2004 IBM Corporation and others. + * All rights reserved. This program and the accompanying materials + * are made available under the terms of the Eclipse Public License v1.0 + * which accompanies this distribution, and is available at + * http://www.eclipse.org/legal/epl-v10.html + * + * Contributors: + * IBM Corporation - initial API and implementation + *******************************************************************************/ +package org.eclipse.wst.html.core.contentmodel.chtml; + + + +import java.util.Arrays; +import java.util.Enumeration; +import java.util.Vector; + +import org.eclipse.wst.common.contentmodel.CMDataType; +import org.eclipse.wst.common.contentmodel.CMNode; +import org.eclipse.wst.html.core.HTMLCMProperties; +import org.eclipse.wst.html.core.contentmodel.HTMLAttributeDeclaration; + +/** + * Implementation class of {@link <code>HTMLAttributeDeclaration</code>} interface.<br> + */ +class HTMLAttrDeclImpl extends CMNodeImpl implements HTMLAttributeDeclaration { + + private HTMLCMDataTypeImpl type = null; + private int usage = 0; + + /** + */ + public HTMLAttrDeclImpl(String attrName, HTMLCMDataTypeImpl valueType, int valueUsage) { + super(attrName); + this.type = valueType; + + switch (valueUsage) { + case OPTIONAL : + case REQUIRED : + case FIXED : + case PROHIBITED : + this.usage = valueUsage; + break; + default : + // should warn... + this.usage = OPTIONAL; // fall back + break; + } + } + + /** + * getAttrName method + * @return java.lang.String + */ + public String getAttrName() { + return getNodeName(); + } + + /** + * getAttrType method + * @return CMDataType + */ + public CMDataType getAttrType() { + return type; + } + + /** + * @deprecated in superclass + */ + public String getDefaultValue() { + if (type.getImpliedValueKind() != CMDataType.IMPLIED_VALUE_DEFAULT) + return null; + return type.getImpliedValue(); + } + + /** + * @deprecated in superclass + */ + public Enumeration getEnumAttr() { + Vector v = new Vector(Arrays.asList(type.getEnumeratedValues())); + return v.elements(); + } + + /** + * getNodeType method + * @return int + * + * Returns one of : + * ELEMENT_DECLARATION, ATTRIBUTE_DECLARATION, GROUP, ENTITY_DECLARATION. + */ + public int getNodeType() { + return CMNode.ATTRIBUTE_DECLARATION; + } + + /** + * @return int + */ + public int getUsage() { + return usage; + } + + /** + */ + public boolean supports(String propertyName) { + if (propertyName.equals(HTMLCMProperties.SHOULD_IGNORE_CASE)) + return true; + return super.supports(propertyName); + } + + /** + */ + public Object getProperty(String propertyName) { + if (propertyName.equals(HTMLCMProperties.SHOULD_IGNORE_CASE)) + return new Boolean(true); + return super.getProperty(propertyName); + } +}
\ No newline at end of file diff --git a/bundles/org.eclipse.wst.html.core/src/org/eclipse/wst/html/core/contentmodel/chtml/HTMLCMDataTypeImpl.java b/bundles/org.eclipse.wst.html.core/src/org/eclipse/wst/html/core/contentmodel/chtml/HTMLCMDataTypeImpl.java new file mode 100644 index 0000000000..3757c6eea7 --- /dev/null +++ b/bundles/org.eclipse.wst.html.core/src/org/eclipse/wst/html/core/contentmodel/chtml/HTMLCMDataTypeImpl.java @@ -0,0 +1,126 @@ +/******************************************************************************* + * Copyright (c) 2004 IBM Corporation and others. + * All rights reserved. This program and the accompanying materials + * are made available under the terms of the Eclipse Public License v1.0 + * which accompanies this distribution, and is available at + * http://www.eclipse.org/legal/epl-v10.html + * + * Contributors: + * IBM Corporation - initial API and implementation + *******************************************************************************/ +package org.eclipse.wst.html.core.contentmodel.chtml; + +import org.eclipse.wst.common.contentmodel.CMNode; +import org.eclipse.wst.html.core.contentmodel.HTMLCMDataType; + + + +/** + */ +class HTMLCMDataTypeImpl extends CMNodeImpl implements HTMLCMDataType { + + private int impliedValueKind = IMPLIED_VALUE_NONE; + private String impliedValue = null; + private final static String[] emptyArray = new String[0]; + private String[] enumValues = emptyArray; + private String instanceValue = null; + + /** + * HTMLCMDataTypeImpl constructor comment. + * @param nm java.lang.String + */ + public HTMLCMDataTypeImpl(String typeName) { + super(typeName); + } + + /** + * HTMLCMDataTypeImpl constructor comment. + * @param nm java.lang.String + */ + public HTMLCMDataTypeImpl(String typeName, String instanceValue) { + super(typeName); + this.instanceValue = instanceValue; + } + + /** + * getTypeName method + * @return java.lang.String + * + * This method returns a suitable default value that can be used when an instance of the data type is created. + * This returns null of a suitable default is not available. + */ + public String generateInstanceValue() { + return instanceValue; + } + + /** + * @see org.eclipse.wst.common.contentmodel.CMDataType + */ + public String getDataTypeName() { + return getNodeName(); + } + + /** + * getTypeName method + * @return java.lang.String[] + * + */ + public String[] getEnumeratedValues() { + return enumValues; + } + + /** + * getTypeName method + * @return java.lang.String + * + * Returns the implied value or null if none exists. + */ + public String getImpliedValue() { + return impliedValue; + } + + /** + * getImpliedValueKind method + * @return int + * + * Returns one of : + * IMPLIED_VALUE_NONE, IMPLIED_VALUE_FIXED, IMPLIED_VALUE_DEFAULT. + */ + public int getImpliedValueKind() { + return impliedValueKind; + } + + /** + * @see org.eclipse.wst.common.contentmodel.CMNode + */ + public int getNodeType() { + return CMNode.DATA_TYPE; + } + + /** + */ + void setEnumValues(String[] values) { + enumValues = new String[values.length]; + for (int i = 0; i < values.length; i++) { + enumValues[i] = values[i]; + } + } + + /** + * package scope. + */ + void setImpliedValue(int kind, String value) { + switch (kind) { + case IMPLIED_VALUE_FIXED : + case IMPLIED_VALUE_DEFAULT : + impliedValueKind = kind; + impliedValue = value; + break; + case IMPLIED_VALUE_NONE : + default : + impliedValueKind = IMPLIED_VALUE_NONE; + impliedValue = null; // maybe a null string? + break; + } + } +}
\ No newline at end of file diff --git a/bundles/org.eclipse.wst.html.core/src/org/eclipse/wst/html/core/contentmodel/chtml/HTMLCMNode.java b/bundles/org.eclipse.wst.html.core/src/org/eclipse/wst/html/core/contentmodel/chtml/HTMLCMNode.java new file mode 100644 index 0000000000..26166410de --- /dev/null +++ b/bundles/org.eclipse.wst.html.core/src/org/eclipse/wst/html/core/contentmodel/chtml/HTMLCMNode.java @@ -0,0 +1,32 @@ +/******************************************************************************* + * Copyright (c) 2004 IBM Corporation and others. + * All rights reserved. This program and the accompanying materials + * are made available under the terms of the Eclipse Public License v1.0 + * which accompanies this distribution, and is available at + * http://www.eclipse.org/legal/epl-v10.html + * + * Contributors: + * IBM Corporation - initial API and implementation + *******************************************************************************/ +package org.eclipse.wst.html.core.contentmodel.chtml; + + +/** + * In HTML Documents, name and value of an attribute/element/entity + * should be treated ignoring theirs case. However, in XML documents, + * they should be distinguished with sensitiveness of their case. + * CMNode is basically designed to represent DTDs or Schemas for XML + * documents. So, it doesn't have interfaces to retrieve such information. + * However, declarations in the HTML CM should provide such information. + * This intermediate interface is intended to provide whether ignore cases + * or not.<br> + */ +interface HTMLCMNode extends org.eclipse.wst.common.contentmodel.CMNode { + + /** + * Returns <code>true</code>, if declaration is for HTML attribute/element/entity. + * Otherwise, returns <code>false</code>. + * @return boolean + */ + boolean shouldIgnoreCase(); +}
\ No newline at end of file diff --git a/bundles/org.eclipse.wst.html.core/src/org/eclipse/wst/html/core/contentmodel/chtml/HTMLElemDeclImpl.java b/bundles/org.eclipse.wst.html.core/src/org/eclipse/wst/html/core/contentmodel/chtml/HTMLElemDeclImpl.java new file mode 100644 index 0000000000..c1fac6421f --- /dev/null +++ b/bundles/org.eclipse.wst.html.core/src/org/eclipse/wst/html/core/contentmodel/chtml/HTMLElemDeclImpl.java @@ -0,0 +1,380 @@ +/******************************************************************************* + * Copyright (c) 2004 IBM Corporation and others. + * All rights reserved. This program and the accompanying materials + * are made available under the terms of the Eclipse Public License v1.0 + * which accompanies this distribution, and is available at + * http://www.eclipse.org/legal/epl-v10.html + * + * Contributors: + * IBM Corporation - initial API and implementation + *******************************************************************************/ +package org.eclipse.wst.html.core.contentmodel.chtml; + + + +import java.util.Iterator; + +import org.eclipse.wst.common.contentmodel.CMContent; +import org.eclipse.wst.common.contentmodel.CMDataType; +import org.eclipse.wst.common.contentmodel.CMElementDeclaration; +import org.eclipse.wst.common.contentmodel.CMNamedNodeMap; +import org.eclipse.wst.common.contentmodel.CMNode; +import org.eclipse.wst.html.core.HTMLCMProperties; +import org.eclipse.wst.html.core.contentmodel.HTMLAttributeDeclaration; +import org.eclipse.wst.html.core.contentmodel.HTMLElementDeclaration; +import org.eclipse.wst.html.core.contentmodel.HTMLPropertyDeclaration; + +/** + * Base class for all Hed???? classes. + */ +abstract class HTMLElemDeclImpl extends CMContentImpl implements HTMLElementDeclaration, HTMLPropertyDeclaration { + + // DTD + protected CMNamedNodeMapImpl attributes = null; + protected String typeDefinitionName = ComplexTypeDefinitionFactory.CTYPE_EMPTY; + /** Never access this field directly. Instead, use getComplexTypeDefinition method. */ + private ComplexTypeDefinition typeDefinition = null; + protected CMGroupImpl inclusion = null; + protected CMGroupImpl exclusion = null; + // advanced information + protected CMNamedNodeMap prohibitedAncestors = null; + protected int correctionType = CORRECT_NONE; + protected int formatType = FORMAT_HTML; + protected int layoutType = LAYOUT_NONE; + protected int omitType = OMIT_NONE; + protected boolean keepSpaces = false; + protected boolean indentChild = false; + protected ElementCollection elementCollection = null; + protected AttributeCollection attributeCollection = null; + protected final static CMNamedNodeMap EMPTY_MAP = new CMNamedNodeMap() { + public int getLength() { + return 0; + } + + public CMNode getNamedItem(String name) { + return null; + } + + public CMNode item(int index) { + return null; + } + + public Iterator iterator() { + return new Iterator() { + public boolean hasNext() { + return false; + } + + public Object next() { + return null; + } + + public void remove() { + } + }; + } + }; + + /** + * HTMLElemDeclImpl constructor. + * In the HTML DTD, an element declaration has no specification + * for its occurrence. Occurrence is specifed in content model, like + * <code>(LI)+</code>. To avoid confusion (and complexity), + * occurrence of an element declaration is always 1 (it means, min = 1 and + * max = 1). Instead, occurrence of CMGroup represents actual occurrence + * of the content. + * <br> + * @param name java.lang.String + */ + public HTMLElemDeclImpl(String elementName, ElementCollection collection) { + super(elementName, 1, 1); + elementCollection = collection; + attributeCollection = collection.getAttributeCollection(); + } + + /** + */ + protected abstract void createAttributeDeclarations(); + + /** + * + * @return com.ibm.sed.contentmodel.html.ComplexTypeDefinition + */ + private ComplexTypeDefinition createComplexTypeDefinition() { + if (typeDefinitionName.equals(ComplexTypeDefinitionFactory.CTYPE_CDATA) || typeDefinitionName.equals(ComplexTypeDefinitionFactory.CTYPE_EMPTY) || typeDefinitionName.equals(ComplexTypeDefinitionFactory.CTYPE_PCDATA)) + return null; + + ComplexTypeDefinitionFactory factory = ComplexTypeDefinitionFactory.getInstance(); + if (factory == null) + return null; // fatal error. + + ComplexTypeDefinition def = factory.createTypeDefinition(typeDefinitionName, elementCollection); + return def; + } + + /** + * Get an attribute declaration. + * <br> + * @see com.ibm.sed.contentmodel.html.HTMLElementDeclaration + */ + public HTMLAttributeDeclaration getAttributeDeclaration(String attrName) { + if (attributes == null) { + createAttributeDeclarations(); + if (attributes == null) + return null; // fail to create + } + + CMNode cmnode = attributes.getNamedItem(attrName); + if (cmnode == null) { + return null; + } + else { + return (HTMLAttributeDeclaration) cmnode; // already exists. + } + } + + /** + * @see org.eclipse.wst.common.contentmodel.CMElementDeclaration + */ + public CMNamedNodeMap getAttributes() { + if (attributes == null) + createAttributeDeclarations(); // lazy eval. + return attributes; + } + + /** + * Get an instance of complex type definition. + * @return com.ibm.sed.contentmodel.html.ComplexTypeDefinition + */ + private ComplexTypeDefinition getComplexTypeDefinition() { + if (typeDefinition == null) + typeDefinition = createComplexTypeDefinition(); + return typeDefinition; + } + + /** + * Content.<br> + * Element declarations which type is EMPTY or CDATA (maybe PCDATA) + * <strong>MUST</strong> override this method and always return null. + * This default implementation always tries to create a complex type definition + * instance and access to it. + * <br> + * @see org.eclipse.wst.common.contentmodel.CMElementDeclaration + */ + public CMContent getContent() { + ComplexTypeDefinition def = getComplexTypeDefinition(); // lazy eval. + return (def != null) ? def.getContent() : null; + } + + /** + * Content type.<br> + * Element declarations which type is EMPTY or CDATA (maybe PCDATA) + * <strong>MUST</strong> override this method and return an appropriate type. + * This default implementation always tries to create a complex type definition + * instance and access to it. + * <br> + * @see org.eclipse.wst.common.contentmodel.CMElementDeclaration + */ + public int getContentType() { + ComplexTypeDefinition def = getComplexTypeDefinition(); // lazy eval. + return (def != null) ? def.getContentType() : CMElementDeclaration.CDATA; + } + + /** + * @see HTMLElementDeclaration#getCorrectionType + */ + public int getCorrectionType() { + return correctionType; + } + + /** + * HTML element doesn't have any data type. So, this method always + * returns <code>null</code>.<br> + * @see org.eclipse.wst.common.contentmodel.CMElementDeclaration + */ + public CMDataType getDataType() { + return null; + } + + /** + * @see org.eclipse.wst.common.contentmodel.CMElementDeclaration + */ + public String getElementName() { + return getNodeName(); + } + + /** + * Exclusion. + * Almost elements don't have a exclusion. + * Only classes those have exclusion should override this method. + * <br> + * @see com.ibm.sed.contentmodel.html.HTMLElementDeclaration + */ + public CMContent getExclusion() { + return null; + } + + /** + * Default format type is <code>FORMAT_HTML</code>.<br> + */ + public int getFormatType() { + return formatType; + } + + /** + * Inclusion. + * Almost elements don't have a inclusion. + * Only classes those have inclusion should override this method. + * <br> + * @see com.ibm.sed.contentmodel.html.HTMLElementDeclaration + */ + public CMContent getInclusion() { + return null; + } + + /** + */ + public int getLayoutType() { + return layoutType; + } + + /** + * Line break hint is strongly related to layout type. + * Indeed, in the C++DOM, it is determined from layout type only. + * So, this implementation, as the default implementation for all declarations, + * also determines from layout type only.<br> + * @return int + */ + public int getLineBreakHint() { + switch (getLayoutType()) { + case HTMLElementDeclaration.LAYOUT_BLOCK : + return HTMLElementDeclaration.BREAK_BEFORE_START_AND_AFTER_END; + case HTMLElementDeclaration.LAYOUT_BREAK : + return HTMLElementDeclaration.BREAK_AFTER_START; + case HTMLElementDeclaration.LAYOUT_HIDDEN : + return HTMLElementDeclaration.BREAK_BEFORE_START_AND_AFTER_END; + default : + return HTMLElementDeclaration.BREAK_NONE; + } + } + + /** + * No HTML element has local elements. So, this method always + * returns an empty map. + * @see org.eclipse.wst.common.contentmodel.CMElementDeclaration + */ + public CMNamedNodeMap getLocalElements() { + return EMPTY_MAP; + } + + /** + * @see org.eclipse.wst.common.contentmodel.CMNode + */ + public int getNodeType() { + return CMNode.ELEMENT_DECLARATION; + } + + /** + */ + public int getOmitType() { + return omitType; + } + + /** + */ + public CMNamedNodeMap getProhibitedAncestors() { + return EMPTY_MAP; + } + + /** + */ + public boolean supports(String propertyName) { + if (propertyName.equals(HTMLCMProperties.SHOULD_IGNORE_CASE)) { + return true; + } + else if (propertyName.equals(HTMLCMProperties.CONTENT_HINT)) { + ComplexTypeDefinition def = getComplexTypeDefinition(); + return (def != null); + } + else { + PropertyProvider pp = PropertyProviderFactory.getProvider(propertyName); + if (pp == null) + return false; + return pp.supports(this); + } + + } + + /** + */ + public Object getProperty(String propertyName) { + if (propertyName.equals(HTMLCMProperties.SHOULD_IGNORE_CASE)) { + return new Boolean(true); + } + else if (propertyName.equals(HTMLCMProperties.CONTENT_HINT)) { + ComplexTypeDefinition def = getComplexTypeDefinition(); + return (def != null) ? def.getPrimaryCandidate() : null; + } + else { + PropertyProvider pp = PropertyProviderFactory.getProvider(propertyName); + if (pp == null) + return null; + return pp.get(this); + } + } + + /** + * Return element names which terminates this element.<br> + * @return java.util.Iterator + */ + protected Iterator getTerminators() { + return null; + } + + /** + * return true when the element is a JSP element. + */ + public boolean isJSP() { + return false; + } + + /** + * In some elements, such as APPLET, a source generator should indent child + * elements that their parents. That is, a source generator should generate + * source of APPLET and PARAMS like this: + * <PRE> + * <APPLET ...> + * <PARAM ... > + * <PARAM ... > + * </APPLET> + * <PRE> + * @return boolean + */ + public boolean shouldIndentChildSource() { + return indentChild; + } + + /** + * Most of elements can compact spaces in their child text nodes. + * Some special elements should keep them in their source. + * @return boolean + */ + public boolean shouldKeepSpaces() { + return keepSpaces; + } + + /** + * @return boolean + */ + public boolean shouldTerminateAt(HTMLElementDeclaration nextElement) { + Iterator i = getTerminators(); + if (i == null) + return false; + String nextName = nextElement.getElementName(); + while (i.hasNext()) { + if (nextName.equals(i.next())) + return true; + } + return false; + } +}
\ No newline at end of file diff --git a/bundles/org.eclipse.wst.html.core/src/org/eclipse/wst/html/core/contentmodel/chtml/HTMLEntityDeclImpl.java b/bundles/org.eclipse.wst.html.core/src/org/eclipse/wst/html/core/contentmodel/chtml/HTMLEntityDeclImpl.java new file mode 100644 index 0000000000..5d91c853d2 --- /dev/null +++ b/bundles/org.eclipse.wst.html.core/src/org/eclipse/wst/html/core/contentmodel/chtml/HTMLEntityDeclImpl.java @@ -0,0 +1,77 @@ +/******************************************************************************* + * Copyright (c) 2004 IBM Corporation and others. + * All rights reserved. This program and the accompanying materials + * are made available under the terms of the Eclipse Public License v1.0 + * which accompanies this distribution, and is available at + * http://www.eclipse.org/legal/epl-v10.html + * + * Contributors: + * IBM Corporation - initial API and implementation + *******************************************************************************/ +package org.eclipse.wst.html.core.contentmodel.chtml; + +import org.eclipse.wst.common.contentmodel.CMNode; +import org.eclipse.wst.html.core.HTMLCMProperties; +import org.eclipse.wst.html.core.contentmodel.HTMLEntityDeclaration; + + + +/** + */ +class HTMLEntityDeclImpl extends CMNodeImpl implements HTMLEntityDeclaration { + + private java.lang.String value = null; + + /** + * CMEntityDeclImpl constructor comment. + * @param entityName java.lang.String; Entity name. + * @param entityValue java.lang.String; Value string. + */ + public HTMLEntityDeclImpl(String entityName, String entityValue) { + super(entityName); + value = entityValue; + } + + /** + * getName method + * @return java.lang.String + */ + public String getName() { + return getNodeName(); + } + + /** + * Get CMNode type.<br> + * @return int; Always return ENTITY_DECLARATION. + */ + public int getNodeType() { + return CMNode.ENTITY_DECLARATION; + } + + /** + * getValue method + * @return java.lang.String + */ + public String getValue() { + return value; + } + + /** + */ + public boolean supports(String propertyName) { + if (propertyName.equals(HTMLCMProperties.SHOULD_IGNORE_CASE)) + return true; + return super.supports(propertyName); + } + + /** + * Entities in HTML documents are always treated with ignoring cases. + * Because no special entities are defined in JSP 1.0, this method + * can always return <code>true</code>.<br> + */ + public Object getProperty(String propertyName) { + if (propertyName.equals(HTMLCMProperties.SHOULD_IGNORE_CASE)) + return new Boolean(true); + return super.getProperty(propertyName); + } +}
\ No newline at end of file diff --git a/bundles/org.eclipse.wst.html.core/src/org/eclipse/wst/html/core/contentmodel/chtml/HedA.java b/bundles/org.eclipse.wst.html.core/src/org/eclipse/wst/html/core/contentmodel/chtml/HedA.java new file mode 100644 index 0000000000..60aa5ba8f0 --- /dev/null +++ b/bundles/org.eclipse.wst.html.core/src/org/eclipse/wst/html/core/contentmodel/chtml/HedA.java @@ -0,0 +1,99 @@ +/******************************************************************************* + * Copyright (c) 2004 IBM Corporation and others. + * All rights reserved. This program and the accompanying materials + * are made available under the terms of the Eclipse Public License v1.0 + * which accompanies this distribution, and is available at + * http://www.eclipse.org/legal/epl-v10.html + * + * Contributors: + * IBM Corporation - initial API and implementation + *******************************************************************************/ +package org.eclipse.wst.html.core.contentmodel.chtml; + + + +import java.util.Arrays; + +import org.eclipse.wst.common.contentmodel.CMContent; +import org.eclipse.wst.common.contentmodel.CMGroup; +import org.eclipse.wst.common.contentmodel.CMNamedNodeMap; +import org.eclipse.wst.common.contentmodel.CMNode; + +/** + * A. + */ +final class HedA extends HedInlineContainer { + + /** + */ + public HedA(ElementCollection collection) { + super(CHTMLNamespace.ElementName.A, collection); + // CORRECT_EMPTY - GROUP_COMPACT + correctionType = CORRECT_EMPTY; + } + + /** + * %attrs; + * (charset %Charset; #IMPLIED) + * (type %ContentType; #IMPLIED) + * (name CDATA #IMPLIED) + * (href %URI; #IMPLIED) + * (hreflang %LanguageCode; #IMPLIED) + * (target %FrameTarget; #IMPLIED) + * (rel %LinkTypes; #IMPLIED) + * (rev %LinkTypes; #IMPLIED) + * (accesskey %Character; #IMPLIED) + * (directkey %Character; #IMPLIED) + * (shape %Shape; rect) + * (coords %Coords; #IMPLIED) + * (tabindex NUMBER #IMPLIED) + * (onfocus %Script; #IMPLIED) + * (onblur %Script; #IMPLIED) + */ + protected void createAttributeDeclarations() { + if (attributes != null) + return; // already created. + if (attributeCollection == null) + return; // fatal + + attributes = new CMNamedNodeMapImpl(); + + // %attrs; + attributeCollection.getAttrs(attributes); + + String[] names = {CHTMLNamespace.ATTR_NAME_NAME, CHTMLNamespace.ATTR_NAME_HREF,}; + attributeCollection.getDeclarations(attributes, Arrays.asList(names).iterator()); + } + + /** + * Exclusion. + * <code>A</code> has the exclusion. + * It is <code>A</code> itself. + * @see com.ibm.sed.contentmodel.html.HTMLElementDeclaration + */ + public CMContent getExclusion() { + if (exclusion != null) + return exclusion; // already created. + if (elementCollection == null) + return null; + + exclusion = new CMGroupImpl(CMGroup.CHOICE, 1, 1); + CMNode a = elementCollection.getNamedItem(CHTMLNamespace.ElementName.A); + if (a != null) + exclusion.appendChild(a); + + return exclusion; + } + + /** + */ + public CMNamedNodeMap getProhibitedAncestors() { + if (prohibitedAncestors != null) + return prohibitedAncestors; + + String[] names = {CHTMLNamespace.ElementName.A,}; + prohibitedAncestors = elementCollection.getDeclarations(names); + + return prohibitedAncestors; + } +}
\ No newline at end of file diff --git a/bundles/org.eclipse.wst.html.core/src/org/eclipse/wst/html/core/contentmodel/chtml/HedADDRESS.java b/bundles/org.eclipse.wst.html.core/src/org/eclipse/wst/html/core/contentmodel/chtml/HedADDRESS.java new file mode 100644 index 0000000000..3126e0d748 --- /dev/null +++ b/bundles/org.eclipse.wst.html.core/src/org/eclipse/wst/html/core/contentmodel/chtml/HedADDRESS.java @@ -0,0 +1,57 @@ +/******************************************************************************* + * Copyright (c) 2004 IBM Corporation and others. + * All rights reserved. This program and the accompanying materials + * are made available under the terms of the Eclipse Public License v1.0 + * which accompanies this distribution, and is available at + * http://www.eclipse.org/legal/epl-v10.html + * + * Contributors: + * IBM Corporation - initial API and implementation + *******************************************************************************/ +package org.eclipse.wst.html.core.contentmodel.chtml; + + + +import org.eclipse.wst.common.contentmodel.CMNamedNodeMap; + +/** + * ADDRESS. + */ +final class HedADDRESS extends HTMLElemDeclImpl { + + /** + */ + public HedADDRESS(ElementCollection collection) { + super(CHTMLNamespace.ElementName.ADDRESS, collection); + typeDefinitionName = ComplexTypeDefinitionFactory.CTYPE_ADDRESS; + correctionType = CORRECT_EMPTY; + layoutType = LAYOUT_BLOCK; + } + + /** + * %attrs; + */ + protected void createAttributeDeclarations() { + if (attributes != null) + return; // already created. + if (attributeCollection == null) + return; // fatal + + attributes = new CMNamedNodeMapImpl(); + + // %attrs; + attributeCollection.getAttrs(attributes); + } + + /** + */ + public CMNamedNodeMap getProhibitedAncestors() { + if (prohibitedAncestors != null) + return prohibitedAncestors; + + String[] names = {CHTMLNamespace.ElementName.DIR, CHTMLNamespace.ElementName.MENU}; + prohibitedAncestors = elementCollection.getDeclarations(names); + + return prohibitedAncestors; + } +}
\ No newline at end of file diff --git a/bundles/org.eclipse.wst.html.core/src/org/eclipse/wst/html/core/contentmodel/chtml/HedBASE.java b/bundles/org.eclipse.wst.html.core/src/org/eclipse/wst/html/core/contentmodel/chtml/HedBASE.java new file mode 100644 index 0000000000..a8564f192d --- /dev/null +++ b/bundles/org.eclipse.wst.html.core/src/org/eclipse/wst/html/core/contentmodel/chtml/HedBASE.java @@ -0,0 +1,47 @@ +/******************************************************************************* + * Copyright (c) 2004 IBM Corporation and others. + * All rights reserved. This program and the accompanying materials + * are made available under the terms of the Eclipse Public License v1.0 + * which accompanies this distribution, and is available at + * http://www.eclipse.org/legal/epl-v10.html + * + * Contributors: + * IBM Corporation - initial API and implementation + *******************************************************************************/ +package org.eclipse.wst.html.core.contentmodel.chtml; + + + +import java.util.Arrays; + +/** + * BASE. + */ +final class HedBASE extends HedEmpty { + + /** + */ + public HedBASE(ElementCollection collection) { + super(CHTMLNamespace.ElementName.BASE, collection); + // LAYOUT_HIDDEN. + // Because, BASE is GROUP_HIDDEN in the C++DOM/DTDParser.cpp. + layoutType = LAYOUT_HIDDEN; + } + + /** + * BASE. + * (href %URI; #IMPLIED) + * (target %FrameTarget; #IMPLIED) + */ + protected void createAttributeDeclarations() { + if (attributes != null) + return; // already created. + if (attributeCollection == null) + return; // fatal + + attributes = new CMNamedNodeMapImpl(); + + String[] names = {CHTMLNamespace.ATTR_NAME_HREF,}; + attributeCollection.getDeclarations(attributes, Arrays.asList(names).iterator()); + } +}
\ No newline at end of file diff --git a/bundles/org.eclipse.wst.html.core/src/org/eclipse/wst/html/core/contentmodel/chtml/HedBLOCKQUOTE.java b/bundles/org.eclipse.wst.html.core/src/org/eclipse/wst/html/core/contentmodel/chtml/HedBLOCKQUOTE.java new file mode 100644 index 0000000000..e730d080e5 --- /dev/null +++ b/bundles/org.eclipse.wst.html.core/src/org/eclipse/wst/html/core/contentmodel/chtml/HedBLOCKQUOTE.java @@ -0,0 +1,57 @@ +/******************************************************************************* + * Copyright (c) 2004 IBM Corporation and others. + * All rights reserved. This program and the accompanying materials + * are made available under the terms of the Eclipse Public License v1.0 + * which accompanies this distribution, and is available at + * http://www.eclipse.org/legal/epl-v10.html + * + * Contributors: + * IBM Corporation - initial API and implementation + *******************************************************************************/ +package org.eclipse.wst.html.core.contentmodel.chtml; + + + +import org.eclipse.wst.common.contentmodel.CMNamedNodeMap; + +/** + * BLOCKQUOTE. + */ +final class HedBLOCKQUOTE extends HedFlowContainer { + + /** + */ + public HedBLOCKQUOTE(ElementCollection collection) { + super(CHTMLNamespace.ElementName.BLOCKQUOTE, collection); + correctionType = CORRECT_EMPTY; + layoutType = LAYOUT_BLOCK; + } + + /** + * %attrs; + * (cite %URI; #IMPLIED) + */ + protected void createAttributeDeclarations() { + if (attributes != null) + return; // already created. + if (attributeCollection == null) + return; // fatal + + attributes = new CMNamedNodeMapImpl(); + + // %attrs; + attributeCollection.getAttrs(attributes); + } + + /** + */ + public CMNamedNodeMap getProhibitedAncestors() { + if (prohibitedAncestors != null) + return prohibitedAncestors; + + String[] names = {CHTMLNamespace.ElementName.DIR, CHTMLNamespace.ElementName.MENU}; + prohibitedAncestors = elementCollection.getDeclarations(names); + + return prohibitedAncestors; + } +}
\ No newline at end of file diff --git a/bundles/org.eclipse.wst.html.core/src/org/eclipse/wst/html/core/contentmodel/chtml/HedBODY.java b/bundles/org.eclipse.wst.html.core/src/org/eclipse/wst/html/core/contentmodel/chtml/HedBODY.java new file mode 100644 index 0000000000..7b0b2fde86 --- /dev/null +++ b/bundles/org.eclipse.wst.html.core/src/org/eclipse/wst/html/core/contentmodel/chtml/HedBODY.java @@ -0,0 +1,68 @@ +/******************************************************************************* + * Copyright (c) 2004 IBM Corporation and others. + * All rights reserved. This program and the accompanying materials + * are made available under the terms of the Eclipse Public License v1.0 + * which accompanies this distribution, and is available at + * http://www.eclipse.org/legal/epl-v10.html + * + * Contributors: + * IBM Corporation - initial API and implementation + *******************************************************************************/ +package org.eclipse.wst.html.core.contentmodel.chtml; + + + +import java.util.Arrays; +import java.util.Iterator; + +/** + * BODY. + */ +final class HedBODY extends HedFlowContainer { + + private static String[] terminators = {CHTMLNamespace.ElementName.HEAD, CHTMLNamespace.ElementName.BODY, CHTMLNamespace.ElementName.HTML}; + + /** + */ + public HedBODY(ElementCollection collection) { + super(CHTMLNamespace.ElementName.BODY, collection); + layoutType = LAYOUT_BLOCK; + omitType = OMIT_BOTH; + } + + /** + * %attrs; + * %bodycolors; + * (onload %Script; #IMPLIED) + * (onunload %Script; #IMPLIED) + * (background %URI; #IMPLIED) + * (marginwidth %Pixels; #IMPLIED) ... D205514 + * (marginheight %Pixels; #IMPLIED) .. D205514 + * (topmargin, CDATA, #IMPLIED) ...... D205514 + * (bottommargin, CDATA, #IMPLIED) ... D205514 + * (leftmargin, CDATA, #IMPLIED) ..... D205514 + * (rightmargin, CDATA, #IMPLIED) .... D205514 + */ + protected void createAttributeDeclarations() { + if (attributes != null) + return; // already created. + if (attributeCollection == null) + return; // fatal + + attributes = new CMNamedNodeMapImpl(); + + // %attrs; + attributeCollection.getAttrs(attributes); + // %bodycolors; + attributeCollection.getBodycolors(attributes); + + } + + /** + * BODY has terminators. + * @return java.util.Iterator + */ + protected Iterator getTerminators() { + return Arrays.asList(terminators).iterator(); + } +}
\ No newline at end of file diff --git a/bundles/org.eclipse.wst.html.core/src/org/eclipse/wst/html/core/contentmodel/chtml/HedBR.java b/bundles/org.eclipse.wst.html.core/src/org/eclipse/wst/html/core/contentmodel/chtml/HedBR.java new file mode 100644 index 0000000000..62d1e6400d --- /dev/null +++ b/bundles/org.eclipse.wst.html.core/src/org/eclipse/wst/html/core/contentmodel/chtml/HedBR.java @@ -0,0 +1,51 @@ +/******************************************************************************* + * Copyright (c) 2004 IBM Corporation and others. + * All rights reserved. This program and the accompanying materials + * are made available under the terms of the Eclipse Public License v1.0 + * which accompanies this distribution, and is available at + * http://www.eclipse.org/legal/epl-v10.html + * + * Contributors: + * IBM Corporation - initial API and implementation + *******************************************************************************/ +package org.eclipse.wst.html.core.contentmodel.chtml; + +import org.eclipse.wst.html.core.contentmodel.HTMLAttributeDeclaration; + + + +/** + * BR. + */ +final class HedBR extends HedEmpty { + + /** + */ + public HedBR(ElementCollection collection) { + super(CHTMLNamespace.ElementName.BR, collection); + // LAYOUT_BREAK. + // Because, BR is GROUP_BREAK in the C++DOM/DTDParser.cpp. + layoutType = LAYOUT_BREAK; + } + + /** + * BR. + * %coreattrs; + * (clear (left | all | right | none) none) + */ + protected void createAttributeDeclarations() { + if (attributes != null) + return; // already created. + if (attributeCollection == null) + return; // fatal + + attributes = new CMNamedNodeMapImpl(); + + // %coreattrs; + attributeCollection.getCore(attributes); + // clear + HTMLAttributeDeclaration attr = attributeCollection.getDeclaration(CHTMLNamespace.ATTR_NAME_CLEAR); + if (attr != null) + attributes.putNamedItem(CHTMLNamespace.ATTR_NAME_CLEAR, attr); + } +}
\ No newline at end of file diff --git a/bundles/org.eclipse.wst.html.core/src/org/eclipse/wst/html/core/contentmodel/chtml/HedCENTER.java b/bundles/org.eclipse.wst.html.core/src/org/eclipse/wst/html/core/contentmodel/chtml/HedCENTER.java new file mode 100644 index 0000000000..115f7e22c1 --- /dev/null +++ b/bundles/org.eclipse.wst.html.core/src/org/eclipse/wst/html/core/contentmodel/chtml/HedCENTER.java @@ -0,0 +1,55 @@ +/******************************************************************************* + * Copyright (c) 2004 IBM Corporation and others. + * All rights reserved. This program and the accompanying materials + * are made available under the terms of the Eclipse Public License v1.0 + * which accompanies this distribution, and is available at + * http://www.eclipse.org/legal/epl-v10.html + * + * Contributors: + * IBM Corporation - initial API and implementation + *******************************************************************************/ +package org.eclipse.wst.html.core.contentmodel.chtml; + + + +import org.eclipse.wst.common.contentmodel.CMNamedNodeMap; + +/** + * CENTER. + */ +final class HedCENTER extends HedFlowContainer { + + /** + */ + public HedCENTER(ElementCollection collection) { + super(CHTMLNamespace.ElementName.CENTER, collection); + layoutType = LAYOUT_BLOCK; + } + + /** + * %attrs; + */ + protected void createAttributeDeclarations() { + if (attributes != null) + return; // already created. + if (attributeCollection == null) + return; // fatal + + attributes = new CMNamedNodeMapImpl(); + + // %attrs; + attributeCollection.getAttrs(attributes); + } + + /** + */ + public CMNamedNodeMap getProhibitedAncestors() { + if (prohibitedAncestors != null) + return prohibitedAncestors; + + String[] names = {CHTMLNamespace.ElementName.DIR, CHTMLNamespace.ElementName.MENU}; + prohibitedAncestors = elementCollection.getDeclarations(names); + + return prohibitedAncestors; + } +}
\ No newline at end of file diff --git a/bundles/org.eclipse.wst.html.core/src/org/eclipse/wst/html/core/contentmodel/chtml/HedDD.java b/bundles/org.eclipse.wst.html.core/src/org/eclipse/wst/html/core/contentmodel/chtml/HedDD.java new file mode 100644 index 0000000000..d27bd32da5 --- /dev/null +++ b/bundles/org.eclipse.wst.html.core/src/org/eclipse/wst/html/core/contentmodel/chtml/HedDD.java @@ -0,0 +1,56 @@ +/******************************************************************************* + * Copyright (c) 2004 IBM Corporation and others. + * All rights reserved. This program and the accompanying materials + * are made available under the terms of the Eclipse Public License v1.0 + * which accompanies this distribution, and is available at + * http://www.eclipse.org/legal/epl-v10.html + * + * Contributors: + * IBM Corporation - initial API and implementation + *******************************************************************************/ +package org.eclipse.wst.html.core.contentmodel.chtml; + + + +import java.util.Arrays; +import java.util.Iterator; + +/** + * DD. + */ +final class HedDD extends HedFlowContainer { + + private static String[] terminators = {CHTMLNamespace.ElementName.DT, CHTMLNamespace.ElementName.DD}; + + /** + */ + public HedDD(ElementCollection collection) { + super(CHTMLNamespace.ElementName.DD, collection); + correctionType = CORRECT_EMPTY; + layoutType = LAYOUT_BLOCK; + omitType = OMIT_END_DEFAULT; + } + + /** + * %attrs; + */ + protected void createAttributeDeclarations() { + if (attributes != null) + return; // already created. + if (attributeCollection == null) + return; // fatal + + attributes = new CMNamedNodeMapImpl(); + + // %attrs; + attributeCollection.getAttrs(attributes); + } + + /** + * DD has terminators. + * @return java.util.Iterator + */ + protected Iterator getTerminators() { + return Arrays.asList(terminators).iterator(); + } +}
\ No newline at end of file diff --git a/bundles/org.eclipse.wst.html.core/src/org/eclipse/wst/html/core/contentmodel/chtml/HedDIV.java b/bundles/org.eclipse.wst.html.core/src/org/eclipse/wst/html/core/contentmodel/chtml/HedDIV.java new file mode 100644 index 0000000000..95b6c64007 --- /dev/null +++ b/bundles/org.eclipse.wst.html.core/src/org/eclipse/wst/html/core/contentmodel/chtml/HedDIV.java @@ -0,0 +1,62 @@ +/******************************************************************************* + * Copyright (c) 2004 IBM Corporation and others. + * All rights reserved. This program and the accompanying materials + * are made available under the terms of the Eclipse Public License v1.0 + * which accompanies this distribution, and is available at + * http://www.eclipse.org/legal/epl-v10.html + * + * Contributors: + * IBM Corporation - initial API and implementation + *******************************************************************************/ +package org.eclipse.wst.html.core.contentmodel.chtml; + + + +import org.eclipse.wst.common.contentmodel.CMNamedNodeMap; + +/** + * DIV. + */ +final class HedDIV extends HedFlowContainer { + + /** + */ + public HedDIV(ElementCollection collection) { + super(CHTMLNamespace.ElementName.DIV, collection); + layoutType = LAYOUT_BLOCK; + } + + /** + * %attrs; + * %align; + * %reserved; + */ + protected void createAttributeDeclarations() { + if (attributes != null) + return; // already created. + if (attributeCollection == null) + return; // fatal + + attributes = new CMNamedNodeMapImpl(); + + // %attrs; + attributeCollection.getAttrs(attributes); + // %align; + HTMLAttrDeclImpl attr = AttributeCollection.createAlignForParagraph(); + if (attr != null) + attributes.putNamedItem(CHTMLNamespace.ATTR_NAME_ALIGN, attr); + // %reserved; ... empty + } + + /** + */ + public CMNamedNodeMap getProhibitedAncestors() { + if (prohibitedAncestors != null) + return prohibitedAncestors; + + String[] names = {CHTMLNamespace.ElementName.DIR, CHTMLNamespace.ElementName.MENU}; + prohibitedAncestors = elementCollection.getDeclarations(names); + + return prohibitedAncestors; + } +}
\ No newline at end of file diff --git a/bundles/org.eclipse.wst.html.core/src/org/eclipse/wst/html/core/contentmodel/chtml/HedDL.java b/bundles/org.eclipse.wst.html.core/src/org/eclipse/wst/html/core/contentmodel/chtml/HedDL.java new file mode 100644 index 0000000000..9274ddf31f --- /dev/null +++ b/bundles/org.eclipse.wst.html.core/src/org/eclipse/wst/html/core/contentmodel/chtml/HedDL.java @@ -0,0 +1,59 @@ +/******************************************************************************* + * Copyright (c) 2004 IBM Corporation and others. + * All rights reserved. This program and the accompanying materials + * are made available under the terms of the Eclipse Public License v1.0 + * which accompanies this distribution, and is available at + * http://www.eclipse.org/legal/epl-v10.html + * + * Contributors: + * IBM Corporation - initial API and implementation + *******************************************************************************/ +package org.eclipse.wst.html.core.contentmodel.chtml; + + + +import org.eclipse.wst.common.contentmodel.CMNamedNodeMap; + +/** + * DL. + */ +final class HedDL extends HTMLElemDeclImpl { + + /** + */ + public HedDL(ElementCollection collection) { + super(CHTMLNamespace.ElementName.DL, collection); + typeDefinitionName = ComplexTypeDefinitionFactory.CTYPE_DEFINITION_LIST; + correctionType = CORRECT_EMPTY; + layoutType = LAYOUT_BLOCK; + indentChild = true; + } + + /** + * %arrays; + * (compact (compact) #IMPLIED) + */ + protected void createAttributeDeclarations() { + if (attributes != null) + return; // already created. + if (attributeCollection == null) + return; // fatal + attributes = new CMNamedNodeMapImpl(); + + // %attrs; + attributeCollection.getAttrs(attributes); + + } + + /** + */ + public CMNamedNodeMap getProhibitedAncestors() { + if (prohibitedAncestors != null) + return prohibitedAncestors; + + String[] names = {CHTMLNamespace.ElementName.DIR, CHTMLNamespace.ElementName.MENU}; + prohibitedAncestors = elementCollection.getDeclarations(names); + + return prohibitedAncestors; + } +}
\ No newline at end of file diff --git a/bundles/org.eclipse.wst.html.core/src/org/eclipse/wst/html/core/contentmodel/chtml/HedDT.java b/bundles/org.eclipse.wst.html.core/src/org/eclipse/wst/html/core/contentmodel/chtml/HedDT.java new file mode 100644 index 0000000000..6dca71ec97 --- /dev/null +++ b/bundles/org.eclipse.wst.html.core/src/org/eclipse/wst/html/core/contentmodel/chtml/HedDT.java @@ -0,0 +1,56 @@ +/******************************************************************************* + * Copyright (c) 2004 IBM Corporation and others. + * All rights reserved. This program and the accompanying materials + * are made available under the terms of the Eclipse Public License v1.0 + * which accompanies this distribution, and is available at + * http://www.eclipse.org/legal/epl-v10.html + * + * Contributors: + * IBM Corporation - initial API and implementation + *******************************************************************************/ +package org.eclipse.wst.html.core.contentmodel.chtml; + + + +import java.util.Arrays; +import java.util.Iterator; + +/** + * DT. + */ +final class HedDT extends HedInlineContainer { + + private static String[] terminators = {CHTMLNamespace.ElementName.DT, CHTMLNamespace.ElementName.DD}; + + /** + */ + public HedDT(ElementCollection collection) { + super(CHTMLNamespace.ElementName.DT, collection); + correctionType = CORRECT_EMPTY; + layoutType = LAYOUT_BLOCK; + omitType = OMIT_END_DEFAULT; + } + + /** + * %attrs; + */ + protected void createAttributeDeclarations() { + if (attributes != null) + return; // already created. + if (attributeCollection == null) + return; // fatal + + attributes = new CMNamedNodeMapImpl(); + + // %attrs; + attributeCollection.getAttrs(attributes); + } + + /** + * DT has terminators. + * @return java.util.Iterator + */ + protected Iterator getTerminators() { + return Arrays.asList(terminators).iterator(); + } +}
\ No newline at end of file diff --git a/bundles/org.eclipse.wst.html.core/src/org/eclipse/wst/html/core/contentmodel/chtml/HedEmpty.java b/bundles/org.eclipse.wst.html.core/src/org/eclipse/wst/html/core/contentmodel/chtml/HedEmpty.java new file mode 100644 index 0000000000..188c107de3 --- /dev/null +++ b/bundles/org.eclipse.wst.html.core/src/org/eclipse/wst/html/core/contentmodel/chtml/HedEmpty.java @@ -0,0 +1,49 @@ +/******************************************************************************* + * Copyright (c) 2004 IBM Corporation and others. + * All rights reserved. This program and the accompanying materials + * are made available under the terms of the Eclipse Public License v1.0 + * which accompanies this distribution, and is available at + * http://www.eclipse.org/legal/epl-v10.html + * + * Contributors: + * IBM Corporation - initial API and implementation + *******************************************************************************/ +package org.eclipse.wst.html.core.contentmodel.chtml; + + + +import org.eclipse.wst.common.contentmodel.CMContent; +import org.eclipse.wst.common.contentmodel.CMElementDeclaration; + +/** + * Base class for EMPTY type element declarations. + */ +abstract class HedEmpty extends HTMLElemDeclImpl { + + /** + */ + public HedEmpty(String elementName, ElementCollection collection) { + super(elementName, collection); + typeDefinitionName = ComplexTypeDefinitionFactory.CTYPE_EMPTY; + // EMPTY type has no end tag. + omitType = OMIT_END_MUST; + } + + /** + * Content.<br> + * EMPTY type always returns <code>null</code>. + * <br> + * @return org.eclipse.wst.common.contentmodel.CMContent + */ + public CMContent getContent() { + return null; + } + + /** + * Content type.<br> + * @see org.eclipse.wst.common.contentmodel.CMElementDeclaration + */ + public int getContentType() { + return CMElementDeclaration.EMPTY; + } +}
\ No newline at end of file diff --git a/bundles/org.eclipse.wst.html.core/src/org/eclipse/wst/html/core/contentmodel/chtml/HedFORM.java b/bundles/org.eclipse.wst.html.core/src/org/eclipse/wst/html/core/contentmodel/chtml/HedFORM.java new file mode 100644 index 0000000000..3c05641966 --- /dev/null +++ b/bundles/org.eclipse.wst.html.core/src/org/eclipse/wst/html/core/contentmodel/chtml/HedFORM.java @@ -0,0 +1,92 @@ +/******************************************************************************* + * Copyright (c) 2004 IBM Corporation and others. + * All rights reserved. This program and the accompanying materials + * are made available under the terms of the Eclipse Public License v1.0 + * which accompanies this distribution, and is available at + * http://www.eclipse.org/legal/epl-v10.html + * + * Contributors: + * IBM Corporation - initial API and implementation + *******************************************************************************/ +package org.eclipse.wst.html.core.contentmodel.chtml; + + + +import java.util.Arrays; + +import org.eclipse.wst.common.contentmodel.CMContent; +import org.eclipse.wst.common.contentmodel.CMGroup; +import org.eclipse.wst.common.contentmodel.CMNamedNodeMap; +import org.eclipse.wst.common.contentmodel.CMNode; + +/** + * FORM. + */ +final class HedFORM extends HedFlowContainer { + + /** + */ + public HedFORM(ElementCollection collection) { + super(CHTMLNamespace.ElementName.FORM, collection); + layoutType = LAYOUT_BLOCK; + } + + /** + * %attrs; + * (action %URI; #REQUIRED) + * (method (GET|POST) GET) + * (enctype %ContentType; "application/x-www-form-urlencoded") + * (accept %ContentTypes; #IMPLIED) + * (name CDATA #IMPLIED) + * (onsubmit %Script; #IMPLIED) + * (onreset %Script; #IMPLIED) + * (target %FrameTarget; #IMPLIED) + * (accept-charset %Charsets; #IMPLIED) + */ + protected void createAttributeDeclarations() { + if (attributes != null) + return; // already created. + if (attributeCollection == null) + return; // fatal + + attributes = new CMNamedNodeMapImpl(); + + // %attrs; + attributeCollection.getAttrs(attributes); + + String[] names = {CHTMLNamespace.ATTR_NAME_ACTION, CHTMLNamespace.ATTR_NAME_METHOD, CHTMLNamespace.ATTR_NAME_ENCTYPE, CHTMLNamespace.ATTR_NAME_NAME,}; + attributeCollection.getDeclarations(attributes, Arrays.asList(names).iterator()); + } + + /** + * Exclusion. + * <code>FORM</code> has the exclusion. + * It is <code>FORM</code> itself. + * @see com.ibm.sed.contentmodel.html.HTMLElementDeclaration + */ + public CMContent getExclusion() { + if (exclusion != null) + return exclusion; // already created. + if (elementCollection == null) + return null; // fatal + + exclusion = new CMGroupImpl(CMGroup.CHOICE, 1, 1); + CMNode form = elementCollection.getNamedItem(CHTMLNamespace.ElementName.FORM); + if (form != null) + exclusion.appendChild(form); + + return exclusion; + } + + /** + */ + public CMNamedNodeMap getProhibitedAncestors() { + if (prohibitedAncestors != null) + return prohibitedAncestors; + + String[] names = {CHTMLNamespace.ElementName.DIR, CHTMLNamespace.ElementName.FORM, CHTMLNamespace.ElementName.MENU}; + prohibitedAncestors = elementCollection.getDeclarations(names); + + return prohibitedAncestors; + } +}
\ No newline at end of file diff --git a/bundles/org.eclipse.wst.html.core/src/org/eclipse/wst/html/core/contentmodel/chtml/HedFlowContainer.java b/bundles/org.eclipse.wst.html.core/src/org/eclipse/wst/html/core/contentmodel/chtml/HedFlowContainer.java new file mode 100644 index 0000000000..9820507b01 --- /dev/null +++ b/bundles/org.eclipse.wst.html.core/src/org/eclipse/wst/html/core/contentmodel/chtml/HedFlowContainer.java @@ -0,0 +1,26 @@ +/******************************************************************************* + * Copyright (c) 2004 IBM Corporation and others. + * All rights reserved. This program and the accompanying materials + * are made available under the terms of the Eclipse Public License v1.0 + * which accompanies this distribution, and is available at + * http://www.eclipse.org/legal/epl-v10.html + * + * Contributors: + * IBM Corporation - initial API and implementation + *******************************************************************************/ +package org.eclipse.wst.html.core.contentmodel.chtml; + + + +/** + * Base class for (%flow;)* containers. + */ +abstract class HedFlowContainer extends HTMLElemDeclImpl { + + /** + */ + public HedFlowContainer(String elementName, ElementCollection collection) { + super(elementName, collection); + typeDefinitionName = ComplexTypeDefinitionFactory.CTYPE_FLOW_CONTAINER; + } +}
\ No newline at end of file diff --git a/bundles/org.eclipse.wst.html.core/src/org/eclipse/wst/html/core/contentmodel/chtml/HedHEAD.java b/bundles/org.eclipse.wst.html.core/src/org/eclipse/wst/html/core/contentmodel/chtml/HedHEAD.java new file mode 100644 index 0000000000..f22d4f0f57 --- /dev/null +++ b/bundles/org.eclipse.wst.html.core/src/org/eclipse/wst/html/core/contentmodel/chtml/HedHEAD.java @@ -0,0 +1,71 @@ +/******************************************************************************* + * Copyright (c) 2004 IBM Corporation and others. + * All rights reserved. This program and the accompanying materials + * are made available under the terms of the Eclipse Public License v1.0 + * which accompanies this distribution, and is available at + * http://www.eclipse.org/legal/epl-v10.html + * + * Contributors: + * IBM Corporation - initial API and implementation + *******************************************************************************/ +package org.eclipse.wst.html.core.contentmodel.chtml; + + + +import java.util.Arrays; +import java.util.Iterator; + +/** + * HTML. + */ +final class HedHEAD extends HTMLElemDeclImpl { + + private static String[] terminators = {CHTMLNamespace.ElementName.HEAD, CHTMLNamespace.ElementName.BODY, CHTMLNamespace.ElementName.HTML}; + + /** + */ + public HedHEAD(ElementCollection collection) { + super(CHTMLNamespace.ElementName.HEAD, collection); + typeDefinitionName = ComplexTypeDefinitionFactory.CTYPE_HEAD; + layoutType = LAYOUT_HIDDEN; + omitType = OMIT_BOTH; + } + + /** + * Create all attribute declarations. + * This method is called once in the constructor of the super class. + * The <code>HEAD</code> element may have the following attributes: + * <table> + * <tbody> + * <tr> + * <th>NAME</th><th>TYPE</th><th>USAGE</th><th>DEFAULT (INITIAL) VALUE</th><th>MEMO</th> + * </tr> + * <tr> + * <td>%i18n;</td><td>-</td><td>-</td><td>-</td><td>-</td> + * </tr> + * <tr> + * <td>profile</td><td>URI</td><td>#IMPLIED</td><td>N/A</td><td>-</td> + * </tr> + * </tbody> + * </table> + */ + protected void createAttributeDeclarations() { + if (attributes != null) + return; // already created. + if (attributeCollection == null) + return; // fatal + + attributes = new CMNamedNodeMapImpl(); + + // %i18n; + attributeCollection.getI18n(attributes); + } + + /** + * HEAD has terminators. + * @return java.util.Iterator + */ + protected Iterator getTerminators() { + return Arrays.asList(terminators).iterator(); + } +}
\ No newline at end of file diff --git a/bundles/org.eclipse.wst.html.core/src/org/eclipse/wst/html/core/contentmodel/chtml/HedHR.java b/bundles/org.eclipse.wst.html.core/src/org/eclipse/wst/html/core/contentmodel/chtml/HedHR.java new file mode 100644 index 0000000000..c94fd0d6c3 --- /dev/null +++ b/bundles/org.eclipse.wst.html.core/src/org/eclipse/wst/html/core/contentmodel/chtml/HedHR.java @@ -0,0 +1,75 @@ +/******************************************************************************* + * Copyright (c) 2004 IBM Corporation and others. + * All rights reserved. This program and the accompanying materials + * are made available under the terms of the Eclipse Public License v1.0 + * which accompanies this distribution, and is available at + * http://www.eclipse.org/legal/epl-v10.html + * + * Contributors: + * IBM Corporation - initial API and implementation + *******************************************************************************/ +package org.eclipse.wst.html.core.contentmodel.chtml; + + + +import java.util.Arrays; + +import org.eclipse.wst.common.contentmodel.CMAttributeDeclaration; +import org.eclipse.wst.common.contentmodel.CMDataType; +import org.eclipse.wst.common.contentmodel.CMNamedNodeMap; + +/** + * HR. + */ +final class HedHR extends HedEmpty { + + /** + */ + public HedHR(ElementCollection collection) { + super(CHTMLNamespace.ElementName.HR, collection); + layoutType = LAYOUT_BLOCK; + } + + /** + * %attrs + * (align (left|center|right) #IMPLIED) ... should be defined locally. + * (noshade (noshade) #IMPLIED) + * (size %Pixels; #IMPLIED) + * (width %Length; #IMPLIED) + * (color %Color; #IMPLIED) ... D205514 + */ + protected void createAttributeDeclarations() { + if (attributes != null) + return; // already created. + if (attributeCollection == null) + return; // fatal + + attributes = new CMNamedNodeMapImpl(); + + // %attrs; + attributeCollection.getAttrs(attributes); + + // (align (left|center|right) #IMPLIED) ... should be defined locally. + HTMLCMDataTypeImpl atype = new HTMLCMDataTypeImpl(CMDataType.ENUM); + String[] values = {CHTMLNamespace.ATTR_VALUE_LEFT, CHTMLNamespace.ATTR_VALUE_CENTER, CHTMLNamespace.ATTR_VALUE_RIGHT}; + atype.setEnumValues(values); + HTMLAttrDeclImpl attr = new HTMLAttrDeclImpl(CHTMLNamespace.ATTR_NAME_ALIGN, atype, CMAttributeDeclaration.OPTIONAL); + attributes.putNamedItem(CHTMLNamespace.ATTR_NAME_ALIGN, attr); + + // the rest. + String[] names = {CHTMLNamespace.ATTR_NAME_NOSHADE, CHTMLNamespace.ATTR_NAME_SIZE, CHTMLNamespace.ATTR_NAME_WIDTH,}; + attributeCollection.getDeclarations(attributes, Arrays.asList(names).iterator()); + } + + /** + */ + public CMNamedNodeMap getProhibitedAncestors() { + if (prohibitedAncestors != null) + return prohibitedAncestors; + + String[] names = {CHTMLNamespace.ElementName.DIR, CHTMLNamespace.ElementName.MENU}; + prohibitedAncestors = elementCollection.getDeclarations(names); + + return prohibitedAncestors; + } +}
\ No newline at end of file diff --git a/bundles/org.eclipse.wst.html.core/src/org/eclipse/wst/html/core/contentmodel/chtml/HedHTML.java b/bundles/org.eclipse.wst.html.core/src/org/eclipse/wst/html/core/contentmodel/chtml/HedHTML.java new file mode 100644 index 0000000000..c39f6661d6 --- /dev/null +++ b/bundles/org.eclipse.wst.html.core/src/org/eclipse/wst/html/core/contentmodel/chtml/HedHTML.java @@ -0,0 +1,81 @@ +/******************************************************************************* + * Copyright (c) 2004 IBM Corporation and others. + * All rights reserved. This program and the accompanying materials + * are made available under the terms of the Eclipse Public License v1.0 + * which accompanies this distribution, and is available at + * http://www.eclipse.org/legal/epl-v10.html + * + * Contributors: + * IBM Corporation - initial API and implementation + *******************************************************************************/ +package org.eclipse.wst.html.core.contentmodel.chtml; + + + +import java.util.Arrays; +import java.util.Iterator; + +import org.eclipse.wst.html.core.contentmodel.HTMLAttributeDeclaration; + + +/** + * HTML. + */ +final class HedHTML extends HTMLElemDeclImpl { + + private static String[] terminators = {CHTMLNamespace.ElementName.HTML}; + + /** + */ + public HedHTML(ElementCollection collection) { + super(CHTMLNamespace.ElementName.HTML, collection); + typeDefinitionName = ComplexTypeDefinitionFactory.CTYPE_HTML; + layoutType = LAYOUT_HIDDEN; + omitType = OMIT_BOTH; + } + + /** + * Create all attribute declarations. + * This method is called once in the constructor of the super class. + * The <code>HTML</code> element may have the following attributes: + * <table> + * <tbody> + * <tr> + * <th>NAME</th><th>TYPE</th><th>USAGE</th><th>DEFAULT (INITIAL) VALUE</th><th>MEMO</th> + * </tr> + * <tr> + * <td><code>%i18n;</code></td><td>-</td><td>-</td><td>-</td> + * <td>{@link PDCMDocImpl#getAttrDeclarationsI18n}</td> + * </tr> + * <tr> + * <td>version</td><td>CDATA</td><td>#FIXED</td> + * <td>{@link HTML_VERSION_TRANSITIONAL}</td><td>deplecated in HTML4.01</td> + * </tr> + * </tbody> + * </table><br> + * @see com.ibm.sed.contentmodel.html.AbstractHTMLElemDeclImpl + */ + protected void createAttributeDeclarations() { + if (attributes != null) + return; // already created. + if (attributeCollection == null) + return; // fatal + + attributes = new CMNamedNodeMapImpl(); + + // %i18n; + attributeCollection.getI18n(attributes); + // version + HTMLAttributeDeclaration adec = attributeCollection.getDeclaration(CHTMLNamespace.ATTR_NAME_VERSION); + if (adec != null) + attributes.putNamedItem(CHTMLNamespace.ATTR_NAME_VERSION, adec); + } + + /** + * HTML has terminators. + * @return java.util.Iterator + */ + protected Iterator getTerminators() { + return Arrays.asList(terminators).iterator(); + } +}
\ No newline at end of file diff --git a/bundles/org.eclipse.wst.html.core/src/org/eclipse/wst/html/core/contentmodel/chtml/HedHeading.java b/bundles/org.eclipse.wst.html.core/src/org/eclipse/wst/html/core/contentmodel/chtml/HedHeading.java new file mode 100644 index 0000000000..b93ecfa212 --- /dev/null +++ b/bundles/org.eclipse.wst.html.core/src/org/eclipse/wst/html/core/contentmodel/chtml/HedHeading.java @@ -0,0 +1,85 @@ +/******************************************************************************* + * Copyright (c) 2004 IBM Corporation and others. + * All rights reserved. This program and the accompanying materials + * are made available under the terms of the Eclipse Public License v1.0 + * which accompanies this distribution, and is available at + * http://www.eclipse.org/legal/epl-v10.html + * + * Contributors: + * IBM Corporation - initial API and implementation + *******************************************************************************/ +package org.eclipse.wst.html.core.contentmodel.chtml; + + + +import org.eclipse.wst.common.contentmodel.CMNamedNodeMap; + +/** + * H[1-6]. + */ +final class HedHeading extends HedInlineContainer { + + /** + */ + public HedHeading(String elementName, ElementCollection collection) { + super(elementName, collection); + correctionType = CORRECT_EMPTY; + layoutType = LAYOUT_BLOCK; + } + + /** + * Create all attribute declarations. + * This method is called once in the constructor of the super class. + * The <code>H1</code> element may have the following attributes: + * <table> + * <tbody> + * <tr> + * <th>NAME</th><th>TYPE</th><th>USAGE</th><th>DEFAULT (INITIAL) VALUE</th><th>MEMO</th> + * </tr> + * <tr> + * <td>%attrs;</td><td>-</td><td>-</td><td>-</td><td>-</td> + * </tr> + * <tr> + * <td>%align;</td><td>-</td><td>-</td><td>-</td><td>-</td> + * </tr> + * </tbody> + * </table> + * <p><b>%align;</b> means <code>align (left|center|right|justify) #IMPLIED</code>. + * Unfortunately, this <code>align</code> is different from one in + * <code>IMG</code> or <code>TABLE</code>. So, the attribute declaration + * of <code>align</code> should be localy created and it shouldn't be registered + * in a <code>HCMDocImpl</code> instance.</p> + * <p>However, %align is used in sevaral times. I wouldn't write same code + * in many times. So, I add a new utility method into <code>CMUtil</code> + * to create the attribute declaration.</p> + * <br> + * @see com.ibm.sed.contentmodel.html.HTMLElemDeclImpl + */ + protected void createAttributeDeclarations() { + if (attributes != null) + return; // already created. + if (attributeCollection == null) + return; // fatal + + attributes = new CMNamedNodeMapImpl(); + + // %attrs; + attributeCollection.getAttrs(attributes); + // align + HTMLAttrDeclImpl attr = AttributeCollection.createAlignForParagraph(); + if (attr != null) + attributes.putNamedItem(CHTMLNamespace.ATTR_NAME_ALIGN, attr); + } + + /** + */ + public CMNamedNodeMap getProhibitedAncestors() { + if (prohibitedAncestors != null) + return prohibitedAncestors; + + String[] names = {CHTMLNamespace.ElementName.DIR, CHTMLNamespace.ElementName.MENU}; + prohibitedAncestors = elementCollection.getDeclarations(names); + + return prohibitedAncestors; + } +}
\ No newline at end of file diff --git a/bundles/org.eclipse.wst.html.core/src/org/eclipse/wst/html/core/contentmodel/chtml/HedIMG.java b/bundles/org.eclipse.wst.html.core/src/org/eclipse/wst/html/core/contentmodel/chtml/HedIMG.java new file mode 100644 index 0000000000..f6ace06817 --- /dev/null +++ b/bundles/org.eclipse.wst.html.core/src/org/eclipse/wst/html/core/contentmodel/chtml/HedIMG.java @@ -0,0 +1,88 @@ +/******************************************************************************* + * Copyright (c) 2004 IBM Corporation and others. + * All rights reserved. This program and the accompanying materials + * are made available under the terms of the Eclipse Public License v1.0 + * which accompanies this distribution, and is available at + * http://www.eclipse.org/legal/epl-v10.html + * + * Contributors: + * IBM Corporation - initial API and implementation + *******************************************************************************/ +package org.eclipse.wst.html.core.contentmodel.chtml; + + + +import java.util.Arrays; + +import org.eclipse.wst.common.contentmodel.CMAttributeDeclaration; +import org.eclipse.wst.common.contentmodel.CMDataType; +import org.eclipse.wst.common.contentmodel.CMNamedNodeMap; + +/** + * IMG. + */ +final class HedIMG extends HedEmpty { + + /** + */ + public HedIMG(ElementCollection collection) { + super(CHTMLNamespace.ElementName.IMG, collection); + layoutType = LAYOUT_OBJECT; + } + + /** + * IMG. + * %attrs; + * (src %URI; #REQUIRED): should be defined locally. + * (alt %Text; #REQUIRED) + * (longdesc %URI; #IMPLIED) + * (name CDATA #IMPLIED) + * (height %Length; #IMPLIED) + * (width %Length; #IMPLIED) + * (usemap %URI; #IMPLIED) + * (ismap (ismap) #IMPLIED) + * (align %IAlign; #IMPLIED): should be defined locally. + * (border %Pixels; #IMPLIED) + * (hspace %Pixels; #IMPLIED) + * (vspace %Pixels; #IMPLIED) + * (mapfile %URI; #IMPLIED) + * @see com.ibm.sed.contentmodel.html.AbstractHTMLElemDeclImpl + */ + protected void createAttributeDeclarations() { + if (attributes != null) + return; // already created. + if (attributeCollection == null) + return; // fatal + + attributes = new CMNamedNodeMapImpl(); + + // %attrs; + attributeCollection.getAttrs(attributes); + + // (src %URI; #REQUIRED): should be defined locally. + HTMLCMDataTypeImpl atype = null; + HTMLAttrDeclImpl attr = null; + atype = new HTMLCMDataTypeImpl(CMDataType.URI); + attr = new HTMLAttrDeclImpl(CHTMLNamespace.ATTR_NAME_SRC, atype, CMAttributeDeclaration.REQUIRED); + attributes.putNamedItem(CHTMLNamespace.ATTR_NAME_SRC, attr); + + String[] names = {CHTMLNamespace.ATTR_NAME_ALT, CHTMLNamespace.ATTR_NAME_NAME, CHTMLNamespace.ATTR_NAME_HEIGHT, CHTMLNamespace.ATTR_NAME_WIDTH, CHTMLNamespace.ATTR_NAME_BORDER, CHTMLNamespace.ATTR_NAME_HSPACE, CHTMLNamespace.ATTR_NAME_VSPACE,}; + attributeCollection.getDeclarations(attributes, Arrays.asList(names).iterator()); + + // align (local); should be defined locally. + attr = AttributeCollection.createAlignForImage(); + attributes.putNamedItem(CHTMLNamespace.ATTR_NAME_ALIGN, attr); + } + + /** + */ + public CMNamedNodeMap getProhibitedAncestors() { + if (prohibitedAncestors != null) + return prohibitedAncestors; + + String[] names = {CHTMLNamespace.ElementName.PRE}; + prohibitedAncestors = elementCollection.getDeclarations(names); + + return prohibitedAncestors; + } +}
\ No newline at end of file diff --git a/bundles/org.eclipse.wst.html.core/src/org/eclipse/wst/html/core/contentmodel/chtml/HedINPUT.java b/bundles/org.eclipse.wst.html.core/src/org/eclipse/wst/html/core/contentmodel/chtml/HedINPUT.java new file mode 100644 index 0000000000..a4959345ec --- /dev/null +++ b/bundles/org.eclipse.wst.html.core/src/org/eclipse/wst/html/core/contentmodel/chtml/HedINPUT.java @@ -0,0 +1,108 @@ +/******************************************************************************* + * Copyright (c) 2004 IBM Corporation and others. + * All rights reserved. This program and the accompanying materials + * are made available under the terms of the Eclipse Public License v1.0 + * which accompanies this distribution, and is available at + * http://www.eclipse.org/legal/epl-v10.html + * + * Contributors: + * IBM Corporation - initial API and implementation + *******************************************************************************/ +package org.eclipse.wst.html.core.contentmodel.chtml; + + + +import java.util.Arrays; + +import org.eclipse.wst.common.contentmodel.CMAttributeDeclaration; +import org.eclipse.wst.common.contentmodel.CMDataType; + +/** + * INPUT. + */ +final class HedINPUT extends HedEmpty { + + /** + */ + public HedINPUT(ElementCollection collection) { + super(CHTMLNamespace.ElementName.INPUT, collection); + layoutType = LAYOUT_OBJECT; + } + + /** + * INPUT. + * %attrs; + * (type %InputType; TEXT) ... should be defined locally. + * (name CDATA #IMPLIED) + * (value CDATA #IMPLIED) + * (checked (checked) #IMPLIED) + * (disabled (disabled) #IMPLIED) + * (readonly (readonly) #IMPLIED) + * (size CDATA #IMPLIED) ... should be defined locally. + * (maxlength NUMBER #IMPLIED) + * (src %URI; #IMPLIED) + * (alt CDATA #IMPLIED) ... should be defined locally. + * (usemap %URI; #IMPLIED) + * (ismap (ismap) #IMPLIED) + * (tabindex NUMBER #IMPLIED) + * (accesskey %Character; #IMPLIED) + * (onfocus %Script; #IMPLIED) + * (onblur %Script; #IMPLIED) + * (onselect %Script; #IMPLIED) + * (onchange %Script; #IMPLIED) + * (accept %ContentTypes; #IMPLIED) + * (align %IAlign; #IMPLIED) ... should be defined locally. + * (istyle CDATA #IMPLIED) + * <<D215684 + * (width CDATA; #IMPLIED) + * (height CDATA; #IMPLIED) + * (border CDATA; #IMPLIED) + * D215684 + */ + protected void createAttributeDeclarations() { + if (attributes != null) + return; // already created. + if (attributeCollection == null) + return; // fatal + + attributes = new CMNamedNodeMapImpl(); + + // %attrs; + attributeCollection.getAttrs(attributes); + + HTMLCMDataTypeImpl atype = null; + HTMLAttrDeclImpl attr = null; + // (type %InputType; TEXT) ... should be defined locally. + // NOTE: %InputType is ENUM; + // (text | password | checkbox | radio | submit | reset | + // file | hidden | image | button) + atype = new HTMLCMDataTypeImpl(CMDataType.ENUM); + String[] values = {CHTMLNamespace.ATTR_VALUE_TEXT, CHTMLNamespace.ATTR_VALUE_PASSWORD, CHTMLNamespace.ATTR_VALUE_CHECKBOX, CHTMLNamespace.ATTR_VALUE_RADIO, CHTMLNamespace.ATTR_VALUE_SUBMIT, CHTMLNamespace.ATTR_VALUE_RESET, CHTMLNamespace.ATTR_VALUE_HIDDEN,}; + atype.setEnumValues(values); + atype.setImpliedValue(CMDataType.IMPLIED_VALUE_DEFAULT, CHTMLNamespace.ATTR_VALUE_TEXT); + attr = new HTMLAttrDeclImpl(CHTMLNamespace.ATTR_NAME_TYPE, atype, CMAttributeDeclaration.OPTIONAL); + attributes.putNamedItem(CHTMLNamespace.ATTR_NAME_TYPE, attr); + + // (size CDATA #IMPLIED) ... should be defined locally. + atype = new HTMLCMDataTypeImpl(CMDataType.CDATA); + attr = new HTMLAttrDeclImpl(CHTMLNamespace.ATTR_NAME_SIZE, atype, CMAttributeDeclaration.OPTIONAL); + attributes.putNamedItem(CHTMLNamespace.ATTR_NAME_SIZE, attr); + + // (alt CDATA #IMPLIED) ... should be defined locally. + atype = new HTMLCMDataTypeImpl(CMDataType.CDATA); + attr = new HTMLAttrDeclImpl(CHTMLNamespace.ATTR_NAME_ALT, atype, CMAttributeDeclaration.OPTIONAL); + attributes.putNamedItem(CHTMLNamespace.ATTR_NAME_ALT, attr); + + // (align %IAlign; #IMPLIED) ... should be defined locally. + attr = AttributeCollection.createAlignForImage(); + attributes.putNamedItem(CHTMLNamespace.ATTR_NAME_ALIGN, attr); + + // the rest. + String[] names = {CHTMLNamespace.ATTR_NAME_NAME, CHTMLNamespace.ATTR_NAME_VALUE, CHTMLNamespace.ATTR_NAME_CHECKED, CHTMLNamespace.ATTR_NAME_SIZE, CHTMLNamespace.ATTR_NAME_MAXLENGTH, CHTMLNamespace.ATTR_NAME_SRC, CHTMLNamespace.ATTR_NAME_ALT, CHTMLNamespace.ATTR_NAME_ALIGN, CHTMLNamespace.ATTR_NAME_ISTYLE, + //<<D215684 + CHTMLNamespace.ATTR_NAME_WIDTH, CHTMLNamespace.ATTR_NAME_HEIGHT, CHTMLNamespace.ATTR_NAME_BORDER + //<D215684 + }; + attributeCollection.getDeclarations(attributes, Arrays.asList(names).iterator()); + } +}
\ No newline at end of file diff --git a/bundles/org.eclipse.wst.html.core/src/org/eclipse/wst/html/core/contentmodel/chtml/HedInlineContainer.java b/bundles/org.eclipse.wst.html.core/src/org/eclipse/wst/html/core/contentmodel/chtml/HedInlineContainer.java new file mode 100644 index 0000000000..ba04b6673b --- /dev/null +++ b/bundles/org.eclipse.wst.html.core/src/org/eclipse/wst/html/core/contentmodel/chtml/HedInlineContainer.java @@ -0,0 +1,29 @@ +/******************************************************************************* + * Copyright (c) 2004 IBM Corporation and others. + * All rights reserved. This program and the accompanying materials + * are made available under the terms of the Eclipse Public License v1.0 + * which accompanies this distribution, and is available at + * http://www.eclipse.org/legal/epl-v10.html + * + * Contributors: + * IBM Corporation - initial API and implementation + *******************************************************************************/ +package org.eclipse.wst.html.core.contentmodel.chtml; + + + +/** + * Base class for (%inline;)* containers. + */ +abstract class HedInlineContainer extends HTMLElemDeclImpl { + + /** + * HedInlineContainer. + * @param elementName java.lang.String + * @param collection ElementCollection + */ + public HedInlineContainer(String elementName, ElementCollection collection) { + super(elementName, collection); + typeDefinitionName = ComplexTypeDefinitionFactory.CTYPE_INLINE_CONTAINER; + } +}
\ No newline at end of file diff --git a/bundles/org.eclipse.wst.html.core/src/org/eclipse/wst/html/core/contentmodel/chtml/HedLI.java b/bundles/org.eclipse.wst.html.core/src/org/eclipse/wst/html/core/contentmodel/chtml/HedLI.java new file mode 100644 index 0000000000..bfdb17c610 --- /dev/null +++ b/bundles/org.eclipse.wst.html.core/src/org/eclipse/wst/html/core/contentmodel/chtml/HedLI.java @@ -0,0 +1,58 @@ +/******************************************************************************* + * Copyright (c) 2004 IBM Corporation and others. + * All rights reserved. This program and the accompanying materials + * are made available under the terms of the Eclipse Public License v1.0 + * which accompanies this distribution, and is available at + * http://www.eclipse.org/legal/epl-v10.html + * + * Contributors: + * IBM Corporation - initial API and implementation + *******************************************************************************/ +package org.eclipse.wst.html.core.contentmodel.chtml; + + + +import java.util.Arrays; +import java.util.Iterator; + +/** + * LI. + */ +final class HedLI extends HedFlowContainer { + + private static String[] terminators = {CHTMLNamespace.ElementName.LI}; + + /** + */ + public HedLI(ElementCollection collection) { + super(CHTMLNamespace.ElementName.LI, collection); + layoutType = LAYOUT_BLOCK; + omitType = OMIT_END_DEFAULT; + } + + /** + * %attrs; + * (type %LIStyle; #IMPLIED) ... should be defined locally. + * (value NUMBER #IMPLIED) ... should be defined locally. + */ + protected void createAttributeDeclarations() { + if (attributes != null) + return; // already created. + if (attributeCollection == null) + return; // fatal + + attributes = new CMNamedNodeMapImpl(); + + // %attrs; + attributeCollection.getAttrs(attributes); + + } + + /** + * LI has terminators. + * @return java.util.Iterator + */ + protected Iterator getTerminators() { + return Arrays.asList(terminators).iterator(); + } +}
\ No newline at end of file diff --git a/bundles/org.eclipse.wst.html.core/src/org/eclipse/wst/html/core/contentmodel/chtml/HedListItemContainer.java b/bundles/org.eclipse.wst.html.core/src/org/eclipse/wst/html/core/contentmodel/chtml/HedListItemContainer.java new file mode 100644 index 0000000000..96343ea914 --- /dev/null +++ b/bundles/org.eclipse.wst.html.core/src/org/eclipse/wst/html/core/contentmodel/chtml/HedListItemContainer.java @@ -0,0 +1,30 @@ +/******************************************************************************* + * Copyright (c) 2004 IBM Corporation and others. + * All rights reserved. This program and the accompanying materials + * are made available under the terms of the Eclipse Public License v1.0 + * which accompanies this distribution, and is available at + * http://www.eclipse.org/legal/epl-v10.html + * + * Contributors: + * IBM Corporation - initial API and implementation + *******************************************************************************/ +package org.eclipse.wst.html.core.contentmodel.chtml; + + + +/** + * Base class for list item container declarations. + * - OL, UL, MENU, DIR. + */ +abstract class HedListItemContainer extends HTMLElemDeclImpl { + + /** + */ + public HedListItemContainer(String elementName, ElementCollection collection) { + super(elementName, collection); + typeDefinitionName = ComplexTypeDefinitionFactory.CTYPE_LI_CONTAINER; + correctionType = CORRECT_EMPTY; + layoutType = LAYOUT_BLOCK; + indentChild = true; + } +}
\ No newline at end of file diff --git a/bundles/org.eclipse.wst.html.core/src/org/eclipse/wst/html/core/contentmodel/chtml/HedMENU.java b/bundles/org.eclipse.wst.html.core/src/org/eclipse/wst/html/core/contentmodel/chtml/HedMENU.java new file mode 100644 index 0000000000..ff8cc21618 --- /dev/null +++ b/bundles/org.eclipse.wst.html.core/src/org/eclipse/wst/html/core/contentmodel/chtml/HedMENU.java @@ -0,0 +1,87 @@ +/******************************************************************************* + * Copyright (c) 2004 IBM Corporation and others. + * All rights reserved. This program and the accompanying materials + * are made available under the terms of the Eclipse Public License v1.0 + * which accompanies this distribution, and is available at + * http://www.eclipse.org/legal/epl-v10.html + * + * Contributors: + * IBM Corporation - initial API and implementation + *******************************************************************************/ +package org.eclipse.wst.html.core.contentmodel.chtml; + + + +import java.util.Arrays; + +import org.eclipse.wst.common.contentmodel.CMContent; +import org.eclipse.wst.common.contentmodel.CMGroup; +import org.eclipse.wst.common.contentmodel.CMNamedNodeMap; + +/** + * MENU/DIR. + */ +final class HedMENU extends HedListItemContainer { + + /** + */ + public HedMENU(String elementName, ElementCollection collection) { + super(elementName, collection); + } + + /** + * MENU/DIR. + * (compact (compact) #IMPLIED) + */ + protected void createAttributeDeclarations() { + if (attributes != null) + return; // already created. + if (attributeCollection == null) + return; // fatal + + attributes = new CMNamedNodeMapImpl(); + + // %attrs; + attributeCollection.getAttrs(attributes); + + } + + /** + * Exclusion. + * <code>MENU/DIR</code> has the exclusion. + * It is <code>%block;</code>. + * %block; is: + * P | %heading; | %list; | %preformatted; | DL | DIV | CENTER | + * NOSCRIPT | NOFRAMES | BLOCKQUOTE | FORM | ISINDEX | HR | + * TABLE | FIELDSET | ADDRESS. + * %heading; is: H1 | H2 | H3 | H4 | H5 | H6. + * %list; is : UL | OL | DIR | MENU. + * %preformatted; is PRE. + * <br> + * @see com.ibm.sed.contentmodel.html.HTMLElementDeclaration + */ + public CMContent getExclusion() { + if (exclusion != null) + return exclusion; // already created. + if (elementCollection == null) + return null; + + // %block; + exclusion = new CMGroupImpl(CMGroup.CHOICE, 1, 1); + String[] names = {CHTMLNamespace.ElementName.P, CHTMLNamespace.ElementName.H1, CHTMLNamespace.ElementName.H2, CHTMLNamespace.ElementName.H3, CHTMLNamespace.ElementName.H4, CHTMLNamespace.ElementName.H5, CHTMLNamespace.ElementName.H6, CHTMLNamespace.ElementName.UL, CHTMLNamespace.ElementName.OL, CHTMLNamespace.ElementName.DIR, CHTMLNamespace.ElementName.MENU, CHTMLNamespace.ElementName.PRE, CHTMLNamespace.ElementName.DL, CHTMLNamespace.ElementName.DIV, CHTMLNamespace.ElementName.CENTER, CHTMLNamespace.ElementName.BLOCKQUOTE, CHTMLNamespace.ElementName.FORM, CHTMLNamespace.ElementName.HR, CHTMLNamespace.ElementName.ADDRESS}; + elementCollection.getDeclarations(exclusion, Arrays.asList(names).iterator()); + return exclusion; + } + + /** + */ + public CMNamedNodeMap getProhibitedAncestors() { + if (prohibitedAncestors != null) + return prohibitedAncestors; + + String[] names = {CHTMLNamespace.ElementName.DIR, CHTMLNamespace.ElementName.MENU}; + prohibitedAncestors = elementCollection.getDeclarations(names); + + return prohibitedAncestors; + } +}
\ No newline at end of file diff --git a/bundles/org.eclipse.wst.html.core/src/org/eclipse/wst/html/core/contentmodel/chtml/HedMETA.java b/bundles/org.eclipse.wst.html.core/src/org/eclipse/wst/html/core/contentmodel/chtml/HedMETA.java new file mode 100644 index 0000000000..b7eac5d11b --- /dev/null +++ b/bundles/org.eclipse.wst.html.core/src/org/eclipse/wst/html/core/contentmodel/chtml/HedMETA.java @@ -0,0 +1,67 @@ +/******************************************************************************* + * Copyright (c) 2004 IBM Corporation and others. + * All rights reserved. This program and the accompanying materials + * are made available under the terms of the Eclipse Public License v1.0 + * which accompanies this distribution, and is available at + * http://www.eclipse.org/legal/epl-v10.html + * + * Contributors: + * IBM Corporation - initial API and implementation + *******************************************************************************/ +package org.eclipse.wst.html.core.contentmodel.chtml; + + + +import java.util.Arrays; + +import org.eclipse.wst.common.contentmodel.CMAttributeDeclaration; +import org.eclipse.wst.common.contentmodel.CMDataType; +import org.eclipse.wst.html.core.contentmodel.HTMLCMDataType; + +/** + * META. + */ +final class HedMETA extends HedEmpty { + + /** + */ + public HedMETA(ElementCollection collection) { + super(CHTMLNamespace.ElementName.META, collection); + layoutType = LAYOUT_HIDDEN; + } + + /** + * META. + * %i18n; + * (http-equiv NAME #IMPLIED) + * (name NAME #IMPLIED) ... should be defined locally. + * (content CDATA #REQUIRED) + * (scheme CDATA #IMPLIED) + */ + protected void createAttributeDeclarations() { + if (attributes != null) + return; // already created. + if (attributeCollection == null) + return; // fatal + + attributes = new CMNamedNodeMapImpl(); + + // %i18n; + attributeCollection.getI18n(attributes); + + // (name NAME #IMPLIED) ... should be defined locally. + HTMLCMDataTypeImpl atype = new HTMLCMDataTypeImpl(HTMLCMDataType.NAME); + HTMLAttrDeclImpl attr = new HTMLAttrDeclImpl(CHTMLNamespace.ATTR_NAME_NAME, atype, CMAttributeDeclaration.OPTIONAL); + attributes.putNamedItem(CHTMLNamespace.ATTR_NAME_NAME, attr); + + // 249493 + atype = new HTMLCMDataTypeImpl(CMDataType.CDATA); + attr = new HTMLAttrDeclImpl(CHTMLNamespace.ATTR_NAME_CONTENT, atype, CMAttributeDeclaration.OPTIONAL); + attributes.putNamedItem(CHTMLNamespace.ATTR_NAME_CONTENT, attr); + + String[] names = {CHTMLNamespace.ATTR_NAME_HTTP_EQUIV, + // CHTMLNamespace.ATTR_NAME_CONTENT + }; + attributeCollection.getDeclarations(attributes, Arrays.asList(names).iterator()); + } +}
\ No newline at end of file diff --git a/bundles/org.eclipse.wst.html.core/src/org/eclipse/wst/html/core/contentmodel/chtml/HedOL.java b/bundles/org.eclipse.wst.html.core/src/org/eclipse/wst/html/core/contentmodel/chtml/HedOL.java new file mode 100644 index 0000000000..9e0fe9a9f9 --- /dev/null +++ b/bundles/org.eclipse.wst.html.core/src/org/eclipse/wst/html/core/contentmodel/chtml/HedOL.java @@ -0,0 +1,58 @@ +/******************************************************************************* + * Copyright (c) 2004 IBM Corporation and others. + * All rights reserved. This program and the accompanying materials + * are made available under the terms of the Eclipse Public License v1.0 + * which accompanies this distribution, and is available at + * http://www.eclipse.org/legal/epl-v10.html + * + * Contributors: + * IBM Corporation - initial API and implementation + *******************************************************************************/ +package org.eclipse.wst.html.core.contentmodel.chtml; + + + +import org.eclipse.wst.common.contentmodel.CMNamedNodeMap; + +/** + * OL. + */ +final class HedOL extends HedListItemContainer { + + /** + */ + public HedOL(ElementCollection collection) { + super(CHTMLNamespace.ElementName.OL, collection); + } + + /** + * OL. + * (type %OLStyle; #IMPLIED) ... should be defined locally. + * (compact (compact) #IMPLIED) + * (start NUMBER #IMPLIED) + */ + protected void createAttributeDeclarations() { + if (attributes != null) + return; // already created. + if (attributeCollection == null) + return; // fatal + + attributes = new CMNamedNodeMapImpl(); + + // %attrs; + attributeCollection.getAttrs(attributes); + + } + + /** + */ + public CMNamedNodeMap getProhibitedAncestors() { + if (prohibitedAncestors != null) + return prohibitedAncestors; + + String[] names = {CHTMLNamespace.ElementName.DIR, CHTMLNamespace.ElementName.MENU}; + prohibitedAncestors = elementCollection.getDeclarations(names); + + return prohibitedAncestors; + } +}
\ No newline at end of file diff --git a/bundles/org.eclipse.wst.html.core/src/org/eclipse/wst/html/core/contentmodel/chtml/HedOPTION.java b/bundles/org.eclipse.wst.html.core/src/org/eclipse/wst/html/core/contentmodel/chtml/HedOPTION.java new file mode 100644 index 0000000000..6cb7cfbfe7 --- /dev/null +++ b/bundles/org.eclipse.wst.html.core/src/org/eclipse/wst/html/core/contentmodel/chtml/HedOPTION.java @@ -0,0 +1,63 @@ +/******************************************************************************* + * Copyright (c) 2004 IBM Corporation and others. + * All rights reserved. This program and the accompanying materials + * are made available under the terms of the Eclipse Public License v1.0 + * which accompanies this distribution, and is available at + * http://www.eclipse.org/legal/epl-v10.html + * + * Contributors: + * IBM Corporation - initial API and implementation + *******************************************************************************/ +package org.eclipse.wst.html.core.contentmodel.chtml; + + + +import java.util.Arrays; +import java.util.Iterator; + +/** + * OPTION. + */ +final class HedOPTION extends HedPcdata { + + private static String[] terminators = {CHTMLNamespace.ElementName.OPTION}; + + /** + */ + public HedOPTION(ElementCollection collection) { + super(CHTMLNamespace.ElementName.OPTION, collection); + layoutType = LAYOUT_HIDDEN; + omitType = OMIT_END; + } + + /** + * OPTION. + * %attrs; + * (selected (selected) #IMPLIED) + * (disabled (disabled) #IMPLIED) + * (label %Text; #IMPLIED) + * (value CDATA #IMPLIED) + */ + protected void createAttributeDeclarations() { + if (attributes != null) + return; // already created. + if (attributeCollection == null) + return; // fatal + + attributes = new CMNamedNodeMapImpl(); + + // %attrs; + attributeCollection.getAttrs(attributes); + + String[] names = {CHTMLNamespace.ATTR_NAME_SELECTED, CHTMLNamespace.ATTR_NAME_VALUE}; + attributeCollection.getDeclarations(attributes, Arrays.asList(names).iterator()); + } + + /** + * OPTION has terminators. + * @return java.util.Iterator + */ + protected Iterator getTerminators() { + return Arrays.asList(terminators).iterator(); + } +}
\ No newline at end of file diff --git a/bundles/org.eclipse.wst.html.core/src/org/eclipse/wst/html/core/contentmodel/chtml/HedP.java b/bundles/org.eclipse.wst.html.core/src/org/eclipse/wst/html/core/contentmodel/chtml/HedP.java new file mode 100644 index 0000000000..d04ffbcc6b --- /dev/null +++ b/bundles/org.eclipse.wst.html.core/src/org/eclipse/wst/html/core/contentmodel/chtml/HedP.java @@ -0,0 +1,105 @@ +/******************************************************************************* + * Copyright (c) 2004 IBM Corporation and others. + * All rights reserved. This program and the accompanying materials + * are made available under the terms of the Eclipse Public License v1.0 + * which accompanies this distribution, and is available at + * http://www.eclipse.org/legal/epl-v10.html + * + * Contributors: + * IBM Corporation - initial API and implementation + *******************************************************************************/ +package org.eclipse.wst.html.core.contentmodel.chtml; + + + +import java.util.Collection; +import java.util.Iterator; +import java.util.Vector; + +import org.eclipse.wst.common.contentmodel.CMNamedNodeMap; + +/** + * P. + */ +final class HedP extends HedInlineContainer { + + private static Collection terminators = null; + + /** + */ + public HedP(ElementCollection collection) { + super(CHTMLNamespace.ElementName.P, collection); + correctionType = CORRECT_EMPTY; + layoutType = LAYOUT_BLOCK; + omitType = OMIT_END; + } + + /** + * Create all attribute declarations. + * This method is called once in the constructor of the super class. + * The <code>P</code> element may have the following attributes: + * <table> + * <tbody> + * <tr> + * <th>NAME</th><th>TYPE</th><th>USAGE</th><th>DEFAULT (INITIAL) VALUE</th><th>MEMO</th> + * </tr> + * <tr> + * <td>%attrs;</td><td>-</td><td>-</td><td>-</td><td>-</td> + * </tr> + * <tr> + * <td>%align;</td><td>-</td><td>-</td><td>-</td><td>-</td> + * </tr> + * </tbody> + * </table> + * <p><b>%align;</b> means <code>align (left|center|right|justify) #IMPLIED</code>. + * Unfortunately, this <code>align</code> is different from one in + * <code>IMG</code> or <code>TABLE</code>. So, the attribute declaration + * of <code>align</code> should be localy created and it shouldn't be registered + * in a <code>HCMDocImpl</code> instance.</p> + * <p>However, %align is used in sevaral times. I wouldn't write same code + * in many times. So, I add a new utility method into <code>CMUtil</code> + * to create the attribute declaration.</p> + * <br> + * @see com.ibm.sed.contentmodel.html.HTMLElemDeclImpl + */ + protected void createAttributeDeclarations() { + if (attributes != null) + return; // already created. + if (attributeCollection == null) + return; // fatal + attributes = new CMNamedNodeMapImpl(); + // %attrs; + attributeCollection.getAttrs(attributes); + // align + HTMLAttrDeclImpl adec = AttributeCollection.createAlignForParagraph(); + attributes.putNamedItem(CHTMLNamespace.ATTR_NAME_ALIGN, adec); + } + + /** + */ + public CMNamedNodeMap getProhibitedAncestors() { + if (prohibitedAncestors != null) + return prohibitedAncestors; + String[] names = {CHTMLNamespace.ElementName.DIR, CHTMLNamespace.ElementName.MENU}; + prohibitedAncestors = elementCollection.getDeclarations(names); + return prohibitedAncestors; + } + + /** + * Return names of terminators. + * <code>P</code> has terminators. + * @return java.util.Iterator + */ + protected Iterator getTerminators() { + if (terminators != null) + return terminators.iterator(); + //<<D217982 + terminators = new Vector(); + terminators.addAll(elementCollection.getNamesOfBlock()); + terminators.add(CHTMLNamespace.ElementName.LI); + terminators.add(CHTMLNamespace.ElementName.DT); + terminators.add(CHTMLNamespace.ElementName.DD); + //D217982 + return terminators.iterator(); + } +}
\ No newline at end of file diff --git a/bundles/org.eclipse.wst.html.core/src/org/eclipse/wst/html/core/contentmodel/chtml/HedPRE.java b/bundles/org.eclipse.wst.html.core/src/org/eclipse/wst/html/core/contentmodel/chtml/HedPRE.java new file mode 100644 index 0000000000..f82d15ec5b --- /dev/null +++ b/bundles/org.eclipse.wst.html.core/src/org/eclipse/wst/html/core/contentmodel/chtml/HedPRE.java @@ -0,0 +1,91 @@ +/******************************************************************************* + * Copyright (c) 2004 IBM Corporation and others. + * All rights reserved. This program and the accompanying materials + * are made available under the terms of the Eclipse Public License v1.0 + * which accompanies this distribution, and is available at + * http://www.eclipse.org/legal/epl-v10.html + * + * Contributors: + * IBM Corporation - initial API and implementation + *******************************************************************************/ +package org.eclipse.wst.html.core.contentmodel.chtml; + + + +import java.util.Arrays; + +import org.eclipse.wst.common.contentmodel.CMAttributeDeclaration; +import org.eclipse.wst.common.contentmodel.CMContent; +import org.eclipse.wst.common.contentmodel.CMDataType; +import org.eclipse.wst.common.contentmodel.CMGroup; +import org.eclipse.wst.common.contentmodel.CMNamedNodeMap; + +/** + * PRE. + */ +final class HedPRE extends HedInlineContainer { + + /** + * PRE element should keep spaces in its source. + */ + public HedPRE(ElementCollection collection) { + super(CHTMLNamespace.ElementName.PRE, collection); + // CORRECT_EMPTY - GROUP_COMPACT + correctionType = CORRECT_EMPTY; + + keepSpaces = true; + } + + /** + * %attrs; + * (width NUMBER #IMPLIED) ... should be defined locally. + */ + protected void createAttributeDeclarations() { + if (attributes != null) + return; // already created. + if (attributeCollection == null) + return; // fatal + + attributes = new CMNamedNodeMapImpl(); + + // %attrs; + attributeCollection.getAttrs(attributes); + // (width NUMBER #IMPLIED) ... should be defined locally. + HTMLCMDataTypeImpl atype = new HTMLCMDataTypeImpl(CMDataType.NUMBER); + HTMLAttrDeclImpl attr = new HTMLAttrDeclImpl(CHTMLNamespace.ATTR_NAME_WIDTH, atype, CMAttributeDeclaration.OPTIONAL); + attributes.putNamedItem(CHTMLNamespace.ATTR_NAME_WIDTH, attr); + } + + /** + * Exclusion. + * <code>PRE</code> has the exclusion. + * It is <code>%pre.exclusion;</code>. + * %pre.exclusion is: + * IMG | OBJECT | APPLET | BIG | SMALL | SUB | SUP | FONT | BASEFONT + * @see com.ibm.sed.contentmodel.html.HTMLElementDeclaration + */ + public CMContent getExclusion() { + if (exclusion != null) + return exclusion; // already created. + if (elementCollection == null) + return null; + + exclusion = new CMGroupImpl(CMGroup.CHOICE, 1, 1); + String[] names = {CHTMLNamespace.ElementName.IMG,}; + elementCollection.getDeclarations(exclusion, Arrays.asList(names).iterator()); + + return exclusion; + } + + /** + */ + public CMNamedNodeMap getProhibitedAncestors() { + if (prohibitedAncestors != null) + return prohibitedAncestors; + + String[] names = {CHTMLNamespace.ElementName.DIR, CHTMLNamespace.ElementName.MENU}; + prohibitedAncestors = elementCollection.getDeclarations(names); + + return prohibitedAncestors; + } +}
\ No newline at end of file diff --git a/bundles/org.eclipse.wst.html.core/src/org/eclipse/wst/html/core/contentmodel/chtml/HedPcdata.java b/bundles/org.eclipse.wst.html.core/src/org/eclipse/wst/html/core/contentmodel/chtml/HedPcdata.java new file mode 100644 index 0000000000..07460073d7 --- /dev/null +++ b/bundles/org.eclipse.wst.html.core/src/org/eclipse/wst/html/core/contentmodel/chtml/HedPcdata.java @@ -0,0 +1,47 @@ +/******************************************************************************* + * Copyright (c) 2004 IBM Corporation and others. + * All rights reserved. This program and the accompanying materials + * are made available under the terms of the Eclipse Public License v1.0 + * which accompanies this distribution, and is available at + * http://www.eclipse.org/legal/epl-v10.html + * + * Contributors: + * IBM Corporation - initial API and implementation + *******************************************************************************/ +package org.eclipse.wst.html.core.contentmodel.chtml; + + + +import org.eclipse.wst.common.contentmodel.CMContent; +import org.eclipse.wst.common.contentmodel.CMElementDeclaration; + +/** + * Base class for PCDATA type element declarations.<br> + */ +abstract class HedPcdata extends HTMLElemDeclImpl { + + /** + */ + public HedPcdata(String elementName, ElementCollection collection) { + super(elementName, collection); + typeDefinitionName = ComplexTypeDefinitionFactory.CTYPE_PCDATA; + } + + /** + * Content.<br> + * PCDATA type always returns <code>null</code>. + * <br> + * @return org.eclipse.wst.common.contentmodel.CMContent + */ + public CMContent getContent() { + return null; + } + + /** + * Content type.<br> + * @see org.eclipse.wst.common.contentmodel.CMElementDeclaration + */ + public int getContentType() { + return CMElementDeclaration.PCDATA; + } +}
\ No newline at end of file diff --git a/bundles/org.eclipse.wst.html.core/src/org/eclipse/wst/html/core/contentmodel/chtml/HedSELECT.java b/bundles/org.eclipse.wst.html.core/src/org/eclipse/wst/html/core/contentmodel/chtml/HedSELECT.java new file mode 100644 index 0000000000..cc844f8c88 --- /dev/null +++ b/bundles/org.eclipse.wst.html.core/src/org/eclipse/wst/html/core/contentmodel/chtml/HedSELECT.java @@ -0,0 +1,65 @@ +/******************************************************************************* + * Copyright (c) 2004 IBM Corporation and others. + * All rights reserved. This program and the accompanying materials + * are made available under the terms of the Eclipse Public License v1.0 + * which accompanies this distribution, and is available at + * http://www.eclipse.org/legal/epl-v10.html + * + * Contributors: + * IBM Corporation - initial API and implementation + *******************************************************************************/ +package org.eclipse.wst.html.core.contentmodel.chtml; + + + +import java.util.Arrays; + +import org.eclipse.wst.common.contentmodel.CMAttributeDeclaration; +import org.eclipse.wst.common.contentmodel.CMDataType; + +/** + * SELECT. + */ +final class HedSELECT extends HTMLElemDeclImpl { + + /** + */ + public HedSELECT(ElementCollection collection) { + super(CHTMLNamespace.ElementName.SELECT, collection); + typeDefinitionName = ComplexTypeDefinitionFactory.CTYPE_SELECT; + layoutType = LAYOUT_OBJECT; + indentChild = true; + } + + /** + * %attrs; + * %reserved; + * (name CDATA #IMPLIED) + * (size NUMBER #IMPLIED) ... should be defined locally. + * (multiple (multiple) #IMPLIED) + * (disabled (disabled) #IMPLIED) + * (tabindex NUMBER #IMPLIED) + * (onfocus %Script; #IMPLIED) + * (onblur %Script; #IMPLIED) + * (onchange %Script; #IMPLIED) + */ + protected void createAttributeDeclarations() { + if (attributes != null) + return; // already created. + if (attributeCollection == null) + return; // fatal + + attributes = new CMNamedNodeMapImpl(); + + // %attrs; + attributeCollection.getAttrs(attributes); + + // (size NUMBER #IMPLIED) ... should be defined locally. + HTMLCMDataTypeImpl atype = new HTMLCMDataTypeImpl(CMDataType.NUMBER); + HTMLAttrDeclImpl attr = new HTMLAttrDeclImpl(CHTMLNamespace.ATTR_NAME_SIZE, atype, CMAttributeDeclaration.OPTIONAL); + attributes.putNamedItem(CHTMLNamespace.ATTR_NAME_SIZE, attr); + + String[] names = {CHTMLNamespace.ATTR_NAME_NAME, CHTMLNamespace.ATTR_NAME_MULTIPLE,}; + attributeCollection.getDeclarations(attributes, Arrays.asList(names).iterator()); + } +}
\ No newline at end of file diff --git a/bundles/org.eclipse.wst.html.core/src/org/eclipse/wst/html/core/contentmodel/chtml/HedSSIBase.java b/bundles/org.eclipse.wst.html.core/src/org/eclipse/wst/html/core/contentmodel/chtml/HedSSIBase.java new file mode 100644 index 0000000000..fd64d4a315 --- /dev/null +++ b/bundles/org.eclipse.wst.html.core/src/org/eclipse/wst/html/core/contentmodel/chtml/HedSSIBase.java @@ -0,0 +1,52 @@ +/******************************************************************************* + * Copyright (c) 2004 IBM Corporation and others. + * All rights reserved. This program and the accompanying materials + * are made available under the terms of the Eclipse Public License v1.0 + * which accompanies this distribution, and is available at + * http://www.eclipse.org/legal/epl-v10.html + * + * Contributors: + * IBM Corporation - initial API and implementation + *******************************************************************************/ +package org.eclipse.wst.html.core.contentmodel.chtml; + +import org.eclipse.wst.html.core.HTMLCMProperties; +import org.eclipse.wst.html.core.contentmodel.HTMLElementDeclaration; + + + + +/** + * Base class for SSI declarations. + */ +abstract class HedSSIBase extends HedEmpty { + + /** + */ + public HedSSIBase(String elementName, ElementCollection collection) { + super(elementName, collection); + layoutType = LAYOUT_OBJECT; + } + + /** + */ + public int getFormatType() { + return HTMLElementDeclaration.FORMAT_SSI; + } + + /** + */ + public boolean supports(String propName) { + if (propName.equals(HTMLCMProperties.IS_SSI)) + return true; + return super.supports(propName); + } + + /* + */ + public Object getProperty(String propName) { + if (propName.equals(HTMLCMProperties.IS_SSI)) + return new Boolean(true); + return super.getProperty(propName); + } +}
\ No newline at end of file diff --git a/bundles/org.eclipse.wst.html.core/src/org/eclipse/wst/html/core/contentmodel/chtml/HedSSIConfig.java b/bundles/org.eclipse.wst.html.core/src/org/eclipse/wst/html/core/contentmodel/chtml/HedSSIConfig.java new file mode 100644 index 0000000000..a98fb71bf6 --- /dev/null +++ b/bundles/org.eclipse.wst.html.core/src/org/eclipse/wst/html/core/contentmodel/chtml/HedSSIConfig.java @@ -0,0 +1,45 @@ +/******************************************************************************* + * Copyright (c) 2004 IBM Corporation and others. + * All rights reserved. This program and the accompanying materials + * are made available under the terms of the Eclipse Public License v1.0 + * which accompanies this distribution, and is available at + * http://www.eclipse.org/legal/epl-v10.html + * + * Contributors: + * IBM Corporation - initial API and implementation + *******************************************************************************/ +package org.eclipse.wst.html.core.contentmodel.chtml; + + + +import java.util.Arrays; + +/** + * SSI:CONFIG. + */ +final class HedSSIConfig extends HedSSIBase { + + /** + */ + public HedSSIConfig(ElementCollection collection) { + super(CHTMLNamespace.ElementName.SSI_CONFIG, collection); + } + + /** + * SSI:CONFIG. + * (errmsg CDATA #IMPLIED) + * (sizefmt CDATA #IMPLIED) + * (timefmt CDATA #IMPLIED) + */ + protected void createAttributeDeclarations() { + if (attributes != null) + return; // already created. + if (attributeCollection == null) + return; // fatal + + attributes = new CMNamedNodeMapImpl(); + + String[] names = {CHTMLNamespace.ATTR_NAME_ERRMSG, CHTMLNamespace.ATTR_NAME_SIZEFMT, CHTMLNamespace.ATTR_NAME_TIMEFMT}; + attributeCollection.getDeclarations(attributes, Arrays.asList(names).iterator()); + } +}
\ No newline at end of file diff --git a/bundles/org.eclipse.wst.html.core/src/org/eclipse/wst/html/core/contentmodel/chtml/HedSSIEcho.java b/bundles/org.eclipse.wst.html.core/src/org/eclipse/wst/html/core/contentmodel/chtml/HedSSIEcho.java new file mode 100644 index 0000000000..5e58a49256 --- /dev/null +++ b/bundles/org.eclipse.wst.html.core/src/org/eclipse/wst/html/core/contentmodel/chtml/HedSSIEcho.java @@ -0,0 +1,43 @@ +/******************************************************************************* + * Copyright (c) 2004 IBM Corporation and others. + * All rights reserved. This program and the accompanying materials + * are made available under the terms of the Eclipse Public License v1.0 + * which accompanies this distribution, and is available at + * http://www.eclipse.org/legal/epl-v10.html + * + * Contributors: + * IBM Corporation - initial API and implementation + *******************************************************************************/ +package org.eclipse.wst.html.core.contentmodel.chtml; + + + +import java.util.Arrays; + +/** + * SSI:ECHO. + */ +final class HedSSIEcho extends HedSSIBase { + + /** + */ + public HedSSIEcho(ElementCollection collection) { + super(CHTMLNamespace.ElementName.SSI_ECHO, collection); + } + + /** + * SSI:ECHO + * (var CDATA #IMPLIED) + */ + protected void createAttributeDeclarations() { + if (attributes != null) + return; // already created. + if (attributeCollection == null) + return; // fatal + + attributes = new CMNamedNodeMapImpl(); + + String[] names = {CHTMLNamespace.ATTR_NAME_VAR}; + attributeCollection.getDeclarations(attributes, Arrays.asList(names).iterator()); + } +}
\ No newline at end of file diff --git a/bundles/org.eclipse.wst.html.core/src/org/eclipse/wst/html/core/contentmodel/chtml/HedSSIExec.java b/bundles/org.eclipse.wst.html.core/src/org/eclipse/wst/html/core/contentmodel/chtml/HedSSIExec.java new file mode 100644 index 0000000000..7ddc7c6d00 --- /dev/null +++ b/bundles/org.eclipse.wst.html.core/src/org/eclipse/wst/html/core/contentmodel/chtml/HedSSIExec.java @@ -0,0 +1,44 @@ +/******************************************************************************* + * Copyright (c) 2004 IBM Corporation and others. + * All rights reserved. This program and the accompanying materials + * are made available under the terms of the Eclipse Public License v1.0 + * which accompanies this distribution, and is available at + * http://www.eclipse.org/legal/epl-v10.html + * + * Contributors: + * IBM Corporation - initial API and implementation + *******************************************************************************/ +package org.eclipse.wst.html.core.contentmodel.chtml; + + + +import java.util.Arrays; + +/** + * SSI:EXEC. + */ +final class HedSSIExec extends HedSSIBase { + + /** + */ + public HedSSIExec(ElementCollection collection) { + super(CHTMLNamespace.ElementName.SSI_EXEC, collection); + } + + /** + * SSI:EXEC + * (cgi %URI; #IMPLIED) + * (cmd CDATA #IMPLIED) + */ + protected void createAttributeDeclarations() { + if (attributes != null) + return; // already created. + if (attributeCollection == null) + return; // fatal + + attributes = new CMNamedNodeMapImpl(); + + String[] names = {CHTMLNamespace.ATTR_NAME_CGI, CHTMLNamespace.ATTR_NAME_CMD}; + attributeCollection.getDeclarations(attributes, Arrays.asList(names).iterator()); + } +}
\ No newline at end of file diff --git a/bundles/org.eclipse.wst.html.core/src/org/eclipse/wst/html/core/contentmodel/chtml/HedSSIFlastmod.java b/bundles/org.eclipse.wst.html.core/src/org/eclipse/wst/html/core/contentmodel/chtml/HedSSIFlastmod.java new file mode 100644 index 0000000000..1e5eac975a --- /dev/null +++ b/bundles/org.eclipse.wst.html.core/src/org/eclipse/wst/html/core/contentmodel/chtml/HedSSIFlastmod.java @@ -0,0 +1,44 @@ +/******************************************************************************* + * Copyright (c) 2004 IBM Corporation and others. + * All rights reserved. This program and the accompanying materials + * are made available under the terms of the Eclipse Public License v1.0 + * which accompanies this distribution, and is available at + * http://www.eclipse.org/legal/epl-v10.html + * + * Contributors: + * IBM Corporation - initial API and implementation + *******************************************************************************/ +package org.eclipse.wst.html.core.contentmodel.chtml; + + + +import java.util.Arrays; + +/** + * SSI:FLASTMOD. + */ +final class HedSSIFlastmod extends HedSSIBase { + + /** + */ + public HedSSIFlastmod(ElementCollection collection) { + super(CHTMLNamespace.ElementName.SSI_FLASTMOD, collection); + } + + /** + * SSI:FLASTMOD + * (file %URI; #IMPLIED) + * (virtual %URI #IMPLIED) + */ + protected void createAttributeDeclarations() { + if (attributes != null) + return; // already created. + if (attributeCollection == null) + return; // fatal + + attributes = new CMNamedNodeMapImpl(); + + String[] names = {CHTMLNamespace.ATTR_NAME_FILE, CHTMLNamespace.ATTR_NAME_VIRTUAL}; + attributeCollection.getDeclarations(attributes, Arrays.asList(names).iterator()); + } +}
\ No newline at end of file diff --git a/bundles/org.eclipse.wst.html.core/src/org/eclipse/wst/html/core/contentmodel/chtml/HedSSIFsize.java b/bundles/org.eclipse.wst.html.core/src/org/eclipse/wst/html/core/contentmodel/chtml/HedSSIFsize.java new file mode 100644 index 0000000000..b3acb6d5e9 --- /dev/null +++ b/bundles/org.eclipse.wst.html.core/src/org/eclipse/wst/html/core/contentmodel/chtml/HedSSIFsize.java @@ -0,0 +1,44 @@ +/******************************************************************************* + * Copyright (c) 2004 IBM Corporation and others. + * All rights reserved. This program and the accompanying materials + * are made available under the terms of the Eclipse Public License v1.0 + * which accompanies this distribution, and is available at + * http://www.eclipse.org/legal/epl-v10.html + * + * Contributors: + * IBM Corporation - initial API and implementation + *******************************************************************************/ +package org.eclipse.wst.html.core.contentmodel.chtml; + + + +import java.util.Arrays; + +/** + * SSI:FSIZE. + */ +final class HedSSIFsize extends HedSSIBase { + + /** + */ + public HedSSIFsize(ElementCollection collection) { + super(CHTMLNamespace.ElementName.SSI_FSIZE, collection); + } + + /** + * SSI:FSIZE + * (file %URI; #IMPLIED) + * (virtual %URI #IMPLIED) + */ + protected void createAttributeDeclarations() { + if (attributes != null) + return; // already created. + if (attributeCollection == null) + return; // fatal + + attributes = new CMNamedNodeMapImpl(); + + String[] names = {CHTMLNamespace.ATTR_NAME_FILE, CHTMLNamespace.ATTR_NAME_VIRTUAL}; + attributeCollection.getDeclarations(attributes, Arrays.asList(names).iterator()); + } +}
\ No newline at end of file diff --git a/bundles/org.eclipse.wst.html.core/src/org/eclipse/wst/html/core/contentmodel/chtml/HedSSIInclude.java b/bundles/org.eclipse.wst.html.core/src/org/eclipse/wst/html/core/contentmodel/chtml/HedSSIInclude.java new file mode 100644 index 0000000000..0a06ca7815 --- /dev/null +++ b/bundles/org.eclipse.wst.html.core/src/org/eclipse/wst/html/core/contentmodel/chtml/HedSSIInclude.java @@ -0,0 +1,44 @@ +/******************************************************************************* + * Copyright (c) 2004 IBM Corporation and others. + * All rights reserved. This program and the accompanying materials + * are made available under the terms of the Eclipse Public License v1.0 + * which accompanies this distribution, and is available at + * http://www.eclipse.org/legal/epl-v10.html + * + * Contributors: + * IBM Corporation - initial API and implementation + *******************************************************************************/ +package org.eclipse.wst.html.core.contentmodel.chtml; + + + +import java.util.Arrays; + +/** + * SSI:INCLUDE. + */ +final class HedSSIInclude extends HedSSIBase { + + /** + */ + public HedSSIInclude(ElementCollection collection) { + super(CHTMLNamespace.ElementName.SSI_INCLUDE, collection); + } + + /** + * SSI:INCLUDE + * (file %URI; #IMPLIED) + * (virtual %URI #IMPLIED) + */ + protected void createAttributeDeclarations() { + if (attributes != null) + return; // already created. + if (attributeCollection == null) + return; // fatal + + attributes = new CMNamedNodeMapImpl(); + + String[] names = {CHTMLNamespace.ATTR_NAME_FILE, CHTMLNamespace.ATTR_NAME_VIRTUAL}; + attributeCollection.getDeclarations(attributes, Arrays.asList(names).iterator()); + } +}
\ No newline at end of file diff --git a/bundles/org.eclipse.wst.html.core/src/org/eclipse/wst/html/core/contentmodel/chtml/HedSSIPrintenv.java b/bundles/org.eclipse.wst.html.core/src/org/eclipse/wst/html/core/contentmodel/chtml/HedSSIPrintenv.java new file mode 100644 index 0000000000..ff252708b2 --- /dev/null +++ b/bundles/org.eclipse.wst.html.core/src/org/eclipse/wst/html/core/contentmodel/chtml/HedSSIPrintenv.java @@ -0,0 +1,48 @@ +/******************************************************************************* + * Copyright (c) 2004 IBM Corporation and others. + * All rights reserved. This program and the accompanying materials + * are made available under the terms of the Eclipse Public License v1.0 + * which accompanies this distribution, and is available at + * http://www.eclipse.org/legal/epl-v10.html + * + * Contributors: + * IBM Corporation - initial API and implementation + *******************************************************************************/ +package org.eclipse.wst.html.core.contentmodel.chtml; + + + +import org.eclipse.wst.common.contentmodel.CMNamedNodeMap; + +/** + * SSI:PRINTENV. + */ +final class HedSSIPrintenv extends HedSSIBase { + + /** + */ + public HedSSIPrintenv(ElementCollection collection) { + super(CHTMLNamespace.ElementName.SSI_PRINTENV, collection); + } + + /** + */ + protected void createAttributeDeclarations() { + if (attributes != null) + return; // already created. + if (attributeCollection == null) + return; // fatal + + attributes = new CMNamedNodeMapImpl(); + } + + /** + * SSI:PRINTENV has no attributes. So, this method should + * always return <code>null</code>. + * Note: Since somebody doesn't expect null is returned, return the empty attribute + * like a custom tag which doesn't have attributes + */ + public CMNamedNodeMap getAttributes() { + return super.getAttributes(); + } +}
\ No newline at end of file diff --git a/bundles/org.eclipse.wst.html.core/src/org/eclipse/wst/html/core/contentmodel/chtml/HedSSISet.java b/bundles/org.eclipse.wst.html.core/src/org/eclipse/wst/html/core/contentmodel/chtml/HedSSISet.java new file mode 100644 index 0000000000..30210913c8 --- /dev/null +++ b/bundles/org.eclipse.wst.html.core/src/org/eclipse/wst/html/core/contentmodel/chtml/HedSSISet.java @@ -0,0 +1,44 @@ +/******************************************************************************* + * Copyright (c) 2004 IBM Corporation and others. + * All rights reserved. This program and the accompanying materials + * are made available under the terms of the Eclipse Public License v1.0 + * which accompanies this distribution, and is available at + * http://www.eclipse.org/legal/epl-v10.html + * + * Contributors: + * IBM Corporation - initial API and implementation + *******************************************************************************/ +package org.eclipse.wst.html.core.contentmodel.chtml; + + + +import java.util.Arrays; + +/** + * SSI:SET. + */ +final class HedSSISet extends HedSSIBase { + + /** + */ + public HedSSISet(ElementCollection collection) { + super(CHTMLNamespace.ElementName.SSI_SET, collection); + } + + /** + * SSI:SET + * (var CDATA #IMPLIED) + * (value CDATA #IMPLIED) + */ + protected void createAttributeDeclarations() { + if (attributes != null) + return; // already created. + if (attributeCollection == null) + return; // fatal + + attributes = new CMNamedNodeMapImpl(); + + String[] names = {CHTMLNamespace.ATTR_NAME_VAR, CHTMLNamespace.ATTR_NAME_VALUE}; + attributeCollection.getDeclarations(attributes, Arrays.asList(names).iterator()); + } +}
\ No newline at end of file diff --git a/bundles/org.eclipse.wst.html.core/src/org/eclipse/wst/html/core/contentmodel/chtml/HedTEXTAREA.java b/bundles/org.eclipse.wst.html.core/src/org/eclipse/wst/html/core/contentmodel/chtml/HedTEXTAREA.java new file mode 100644 index 0000000000..229e52b71a --- /dev/null +++ b/bundles/org.eclipse.wst.html.core/src/org/eclipse/wst/html/core/contentmodel/chtml/HedTEXTAREA.java @@ -0,0 +1,62 @@ +/******************************************************************************* + * Copyright (c) 2004 IBM Corporation and others. + * All rights reserved. This program and the accompanying materials + * are made available under the terms of the Eclipse Public License v1.0 + * which accompanies this distribution, and is available at + * http://www.eclipse.org/legal/epl-v10.html + * + * Contributors: + * IBM Corporation - initial API and implementation + *******************************************************************************/ +package org.eclipse.wst.html.core.contentmodel.chtml; + + + +import java.util.Arrays; + +/** + * TEXTAREA. + */ +final class HedTEXTAREA extends HedPcdata { + + /** + * TEXTAREA should keep spaces in its source. + */ + public HedTEXTAREA(ElementCollection collection) { + super(CHTMLNamespace.ElementName.TEXTAREA, collection); + layoutType = LAYOUT_OBJECT; + + keepSpaces = true; + } + + /** + * TEXTAREA. + * %attrs; + * %reserved; ... empty + * (name CDATA #IMPLIED) + * (rows NUMBER #REQUIRED) + * (cols NUMBER #REQUIRED) + * (disabled (disabled) #IMPLIED) + * (readonly (readonly) #IMPLIED) + * (tabindex NUMBER #IMPLIED) + * (accesskey %Character; #IMPLIED) + * (onfocus %Script; #IMPLIED) + * (onblur %Script; #IMPLIED) + * (onselect %Script; #IMPLIED) + * (onchange %Script; #IMPLIED) + * (istyle CDATA #IMPLIED) + */ + protected void createAttributeDeclarations() { + if (attributes != null) + return; // already created. + if (attributeCollection == null) + return; // fatal + attributes = new CMNamedNodeMapImpl(); + + // %attrs; + attributeCollection.getAttrs(attributes); + + String[] names = {CHTMLNamespace.ATTR_NAME_NAME, CHTMLNamespace.ATTR_NAME_ROWS, CHTMLNamespace.ATTR_NAME_COLS, CHTMLNamespace.ATTR_NAME_ISTYLE}; + attributeCollection.getDeclarations(attributes, Arrays.asList(names).iterator()); + } +}
\ No newline at end of file diff --git a/bundles/org.eclipse.wst.html.core/src/org/eclipse/wst/html/core/contentmodel/chtml/HedTITLE.java b/bundles/org.eclipse.wst.html.core/src/org/eclipse/wst/html/core/contentmodel/chtml/HedTITLE.java new file mode 100644 index 0000000000..545848b40d --- /dev/null +++ b/bundles/org.eclipse.wst.html.core/src/org/eclipse/wst/html/core/contentmodel/chtml/HedTITLE.java @@ -0,0 +1,69 @@ +/******************************************************************************* + * Copyright (c) 2004 IBM Corporation and others. + * All rights reserved. This program and the accompanying materials + * are made available under the terms of the Eclipse Public License v1.0 + * which accompanies this distribution, and is available at + * http://www.eclipse.org/legal/epl-v10.html + * + * Contributors: + * IBM Corporation - initial API and implementation + *******************************************************************************/ +package org.eclipse.wst.html.core.contentmodel.chtml; + + + +import java.util.Arrays; + +import org.eclipse.wst.common.contentmodel.CMContent; +import org.eclipse.wst.common.contentmodel.CMGroup; + +/** + * TITLE. + */ +final class HedTITLE extends HedPcdata { + + /** + */ + public HedTITLE(ElementCollection collection) { + super(CHTMLNamespace.ElementName.TITLE, collection); + layoutType = LAYOUT_HIDDEN; + } + + /** + * TITLE. + * %i18n; + */ + protected void createAttributeDeclarations() { + if (attributes != null) + return; // already created. + if (attributeCollection == null) + return; // fatal + + attributes = new CMNamedNodeMapImpl(); + + // %i18n; + attributeCollection.getI18n(attributes); + } + + /** + * Exclusion. + * <code>TITLE</code> has the exclusion. + * It is <code>%head.misc;</code>. + * %head.misc; is <code>SCRIPT|STYLE|META|LINK|OBJECT</code>. + * <br> + * @see com.ibm.sed.contentmodel.html.HTMLElementDeclaration + */ + public CMContent getExclusion() { + if (exclusion != null) + return exclusion; // already created. + if (elementCollection == null) + return null; + + // (SCRIPT|STYLE|META|LINK|OBJECT) + exclusion = new CMGroupImpl(CMGroup.CHOICE, 1, 1); + + String[] names = {CHTMLNamespace.ElementName.META,}; + elementCollection.getDeclarations(exclusion, Arrays.asList(names).iterator()); + return exclusion; + } +}
\ No newline at end of file diff --git a/bundles/org.eclipse.wst.html.core/src/org/eclipse/wst/html/core/contentmodel/chtml/HedUL.java b/bundles/org.eclipse.wst.html.core/src/org/eclipse/wst/html/core/contentmodel/chtml/HedUL.java new file mode 100644 index 0000000000..e7a23c0226 --- /dev/null +++ b/bundles/org.eclipse.wst.html.core/src/org/eclipse/wst/html/core/contentmodel/chtml/HedUL.java @@ -0,0 +1,57 @@ +/******************************************************************************* + * Copyright (c) 2004 IBM Corporation and others. + * All rights reserved. This program and the accompanying materials + * are made available under the terms of the Eclipse Public License v1.0 + * which accompanies this distribution, and is available at + * http://www.eclipse.org/legal/epl-v10.html + * + * Contributors: + * IBM Corporation - initial API and implementation + *******************************************************************************/ +package org.eclipse.wst.html.core.contentmodel.chtml; + + + +import org.eclipse.wst.common.contentmodel.CMNamedNodeMap; + +/** + * UL. + */ +final class HedUL extends HedListItemContainer { + + /** + */ + public HedUL(ElementCollection collection) { + super(CHTMLNamespace.ElementName.UL, collection); + } + + /** + * UL. + * (type %ULStyle; #IMPLIED) ... should be defined locally. + * (compact (compact) #IMPLIED) + */ + protected void createAttributeDeclarations() { + if (attributes != null) + return; // already created. + if (attributeCollection == null) + return; // fatal + + attributes = new CMNamedNodeMapImpl(); + + // %attrs; + attributeCollection.getAttrs(attributes); + + } + + /** + */ + public CMNamedNodeMap getProhibitedAncestors() { + if (prohibitedAncestors != null) + return prohibitedAncestors; + + String[] names = {CHTMLNamespace.ElementName.DIR, CHTMLNamespace.ElementName.MENU}; + prohibitedAncestors = elementCollection.getDeclarations(names); + + return prohibitedAncestors; + } +}
\ No newline at end of file diff --git a/bundles/org.eclipse.wst.html.core/src/org/eclipse/wst/html/core/contentmodel/chtml/PropertyProvider.java b/bundles/org.eclipse.wst.html.core/src/org/eclipse/wst/html/core/contentmodel/chtml/PropertyProvider.java new file mode 100644 index 0000000000..db31375b90 --- /dev/null +++ b/bundles/org.eclipse.wst.html.core/src/org/eclipse/wst/html/core/contentmodel/chtml/PropertyProvider.java @@ -0,0 +1,26 @@ +/******************************************************************************* + * Copyright (c) 2004 IBM Corporation and others. + * All rights reserved. This program and the accompanying materials + * are made available under the terms of the Eclipse Public License v1.0 + * which accompanies this distribution, and is available at + * http://www.eclipse.org/legal/epl-v10.html + * + * Contributors: + * IBM Corporation - initial API and implementation + *******************************************************************************/ +package org.eclipse.wst.html.core.contentmodel.chtml; + +import org.eclipse.wst.html.core.contentmodel.HTMLElementDeclaration; + + + +/** + * PropertyProvider class. + * This class is intended to be used in HTMLElementDeclaration instances. + */ +interface PropertyProvider { + + boolean supports(HTMLElementDeclaration edecl); + + Object get(HTMLElementDeclaration edecl); +}
\ No newline at end of file diff --git a/bundles/org.eclipse.wst.html.core/src/org/eclipse/wst/html/core/contentmodel/chtml/PropertyProviderFactory.java b/bundles/org.eclipse.wst.html.core/src/org/eclipse/wst/html/core/contentmodel/chtml/PropertyProviderFactory.java new file mode 100644 index 0000000000..5512025995 --- /dev/null +++ b/bundles/org.eclipse.wst.html.core/src/org/eclipse/wst/html/core/contentmodel/chtml/PropertyProviderFactory.java @@ -0,0 +1,363 @@ +/******************************************************************************* + * Copyright (c) 2004 IBM Corporation and others. + * All rights reserved. This program and the accompanying materials + * are made available under the terms of the Eclipse Public License v1.0 + * which accompanies this distribution, and is available at + * http://www.eclipse.org/legal/epl-v10.html + * + * Contributors: + * IBM Corporation - initial API and implementation + *******************************************************************************/ +package org.eclipse.wst.html.core.contentmodel.chtml; + +import java.util.Hashtable; + +import org.eclipse.wst.common.contentmodel.annotation.AnnotationMap; +import org.eclipse.wst.html.core.HTMLCMProperties; +import org.eclipse.wst.html.core.contentmodel.HTMLElementDeclaration; +import org.eclipse.wst.html.core.contentmodel.HTMLPropertyDeclaration; + +/** + * The factory object of PropertyProvider. + */ +final class PropertyProviderFactory { + + + /** + * DefaultProvider is intended to be used for unknown properties. + * It always returns null value for any properties. + */ + class DefaultProvider implements PropertyProvider { + public DefaultProvider() { + super(); + } + + public boolean supports(HTMLElementDeclaration edecl) { + return false; + } + + public Object get(HTMLElementDeclaration edecl) { + return null; + } + } + + abstract class AbstractElementPropertyProvider implements PropertyProvider { + protected AbstractElementPropertyProvider() { + super(); + } + + public boolean supports(HTMLElementDeclaration edecl) { + return (edecl != null); + } + + public Object get(HTMLElementDeclaration edecl) { + if (!(edecl instanceof HTMLPropertyDeclaration)) + return null; + return getElementProperty((HTMLPropertyDeclaration)edecl); + } + + abstract protected Object getElementProperty(HTMLPropertyDeclaration decl); + } + + /* + * "tagInfo" + * gets documentation for the element + */ + class PPTagInfo extends AbstractElementPropertyProvider { + private final static String htmlAnnotationLoc = "platform:/plugin/org.eclipse.wst.html.core/data/htmref.xml"; //$NON-NLS-1$ + protected AnnotationMap fAnnotationMap = null; + + public PPTagInfo() { + super(); + } + + /** + * Gets the annotationMap. + * @return Returns a AnnotationMap + */ + protected AnnotationMap getAnnotationMap() { + if (fAnnotationMap == null) { + fAnnotationMap = new AnnotationMap(); + try { + fAnnotationMap.load(htmlAnnotationLoc); + } + catch (Exception e) { + // no annotation available + } + } + return fAnnotationMap; + } + + protected Object getElementProperty(HTMLPropertyDeclaration decl) { + if (decl instanceof HTMLElementDeclaration) { + return getAnnotationMap().getProperty(((HTMLElementDeclaration)decl).getElementName(), "tagInfo"); //$NON-NLS-1$ + } else { + return null; + } + } + } + + /* + * "shouldKeepSpace" + */ + class PPShouldKeepSpace extends AbstractElementPropertyProvider { + public PPShouldKeepSpace() { + super(); + } + + protected Object getElementProperty(HTMLPropertyDeclaration decl) { + return new Boolean(decl.shouldKeepSpaces()); + } + } + + /* + * "shouldIndentChildSource" + */ + class PPShouldIndentChildSource extends AbstractElementPropertyProvider { + public PPShouldIndentChildSource() { + super(); + } + + protected Object getElementProperty(HTMLPropertyDeclaration decl) { + return new Boolean(decl.shouldIndentChildSource()); + } + } + + /* + * "terminators" + */ + class PPTerminators extends AbstractElementPropertyProvider { + public PPTerminators() { + super(); + } + + protected Object getElementProperty(HTMLPropertyDeclaration decl) { + if (decl == null) + return null; + if (! (decl instanceof HTMLElemDeclImpl)) return null; + return ((HTMLElemDeclImpl)decl).getTerminators(); + } + } + + /* + * "prohibitedAncestors" + */ + class PPProhibitedAncestors extends AbstractElementPropertyProvider { + public PPProhibitedAncestors() { + super(); + } + + protected Object getElementProperty(HTMLPropertyDeclaration decl) { + return decl.getProhibitedAncestors(); + } + } + + /* + * "isJSP" + */ + class PPIsJSP extends AbstractElementPropertyProvider { + public PPIsJSP() { + super(); + } + + protected Object getElementProperty(HTMLPropertyDeclaration decl) { + return new Boolean(decl.isJSP()); + } + } + + /* + * "isXHTML" + * HTMLElementDeclaration itself never represent any XHTML element declaration. + * So, this property must be always false. + */ + class PPIsXHTML extends AbstractElementPropertyProvider { + public PPIsXHTML() { + super(); + } + + protected Object getElementProperty(HTMLPropertyDeclaration decl) { + return new Boolean(false); + } + } + + /* + * "isSSI" + * Each declaration class for SSI elements must provide this property itself, + * and then return true. Other declaration must always return false. + */ + class PPIsSSI extends AbstractElementPropertyProvider { + public PPIsSSI() { + super(); + } + + protected Object getElementProperty(HTMLPropertyDeclaration decl) { + return new Boolean(false); + } + } + + /* + * "lineBreakHint" + */ + class PPLineBreakHint extends AbstractElementPropertyProvider { + public PPLineBreakHint() { + super(); + } + + protected Object getElementProperty(HTMLPropertyDeclaration decl) { + String hint = HTMLCMProperties.Values.BREAK_NONE; + switch (decl.getLineBreakHint()) { + case HTMLElementDeclaration.BREAK_AFTER_START : + hint = HTMLCMProperties.Values.BREAK_AFTER_START; + break; + case HTMLElementDeclaration.BREAK_BEFORE_START_AND_AFTER_END : + hint = HTMLCMProperties.Values.BREAK_BEFORE_START_AND_AFTER_END; + break; + case HTMLElementDeclaration.BREAK_NONE : + // nothing to do + default : + break; + } + return hint; + } + } + + /* + * "layoutType" + */ + class PPLayoutType extends AbstractElementPropertyProvider { + public PPLayoutType() { + super(); + } + + protected Object getElementProperty(HTMLPropertyDeclaration decl) { + String type = HTMLCMProperties.Values.LAYOUT_NONE; + switch (decl.getLayoutType()) { + case HTMLElementDeclaration.LAYOUT_BLOCK : + type = HTMLCMProperties.Values.LAYOUT_BLOCK; + break; + case HTMLElementDeclaration.LAYOUT_BREAK : + type = HTMLCMProperties.Values.LAYOUT_BREAK; + break; + case HTMLElementDeclaration.LAYOUT_HIDDEN : + type = HTMLCMProperties.Values.LAYOUT_HIDDEN; + break; + case HTMLElementDeclaration.LAYOUT_OBJECT : + type = HTMLCMProperties.Values.LAYOUT_OBJECT; + break; + case HTMLElementDeclaration.LAYOUT_WRAP : + type = HTMLCMProperties.Values.LAYOUT_WRAP; + break; + case HTMLElementDeclaration.LAYOUT_NONE : + // nothing to do. + default : + break; + } + return type; + } + } + + /* + * "omitType" + */ + class PPOmitType extends AbstractElementPropertyProvider { + public PPOmitType() { + super(); + } + + protected Object getElementProperty(HTMLPropertyDeclaration decl) { + String type = HTMLCMProperties.Values.OMIT_NONE; + switch (decl.getOmitType()) { + case HTMLElementDeclaration.OMIT_BOTH : + type = HTMLCMProperties.Values.OMIT_BOTH; + break; + case HTMLElementDeclaration.OMIT_END : + type = HTMLCMProperties.Values.OMIT_END; + break; + case HTMLElementDeclaration.OMIT_END_DEFAULT : + type = HTMLCMProperties.Values.OMIT_END_DEFAULT; + break; + case HTMLElementDeclaration.OMIT_END_MUST : + type = HTMLCMProperties.Values.OMIT_END_MUST; + break; + case HTMLElementDeclaration.OMIT_NONE : + // nothing to do. + default : + break; + } + return type; + } + } + + /* + * "inclusion" + */ + class PPInclusion extends AbstractElementPropertyProvider { + public PPInclusion() { + super(); + } + + protected Object getElementProperty(HTMLPropertyDeclaration decl) { + return decl.getInclusion(); + } + } + + public static PropertyProvider getProvider(String propName) { + PropertyProviderFactory factory = getInstance(); + PropertyProvider pp = (PropertyProvider) factory.registry.get(propName); + if (pp != null) + return pp; + + pp = factory.create(propName); + if (pp == null) + return factory.defaultProvider; + + factory.registry.put(propName, pp); + return pp; + } + + private static PropertyProviderFactory instance = null; + + private synchronized static PropertyProviderFactory getInstance() { + if (instance != null) + return instance; + instance = new PropertyProviderFactory(); + return instance; + } + + private Hashtable registry = new Hashtable(); + private PropertyProvider defaultProvider = new DefaultProvider(); + + private PropertyProviderFactory() { + super(); + } + + private PropertyProvider create(String propName) { + PropertyProvider pp = null; + if (propName.equals(HTMLCMProperties.IS_JSP)) + pp = new PPIsJSP(); + else if (propName.equals(HTMLCMProperties.IS_XHTML)) + pp = new PPIsXHTML(); + else if (propName.equals(HTMLCMProperties.IS_SSI)) + pp = new PPIsSSI(); + else if (propName.equals(HTMLCMProperties.LAYOUT_TYPE)) + pp = new PPLayoutType(); + else if (propName.equals(HTMLCMProperties.LINE_BREAK_HINT)) + pp = new PPLineBreakHint(); + else if (propName.equals(HTMLCMProperties.PROHIBITED_ANCESTORS)) + pp = new PPProhibitedAncestors(); + else if (propName.equals(HTMLCMProperties.SHOULD_KEEP_SPACE)) + pp = new PPShouldKeepSpace(); + else if (propName.equals(HTMLCMProperties.SHOULD_INDENT_CHILD_SOURCE)) + pp = new PPShouldIndentChildSource(); + else if (propName.equals(HTMLCMProperties.TERMINATORS)) + pp = new PPTerminators(); + else if (propName.equals(HTMLCMProperties.TAGINFO)) + pp = new PPTagInfo(); + else if (propName.equals(HTMLCMProperties.OMIT_TYPE)) + pp = new PPOmitType(); + else if (propName.equals(HTMLCMProperties.INCLUSION)) + pp = new PPInclusion(); + + return pp; + } +}
\ No newline at end of file diff --git a/bundles/org.eclipse.wst.html.core/src/org/eclipse/wst/html/core/contentmodel/ssi/SSICMDocumentFactory.java b/bundles/org.eclipse.wst.html.core/src/org/eclipse/wst/html/core/contentmodel/ssi/SSICMDocumentFactory.java new file mode 100644 index 0000000000..66fbaf1bb7 --- /dev/null +++ b/bundles/org.eclipse.wst.html.core/src/org/eclipse/wst/html/core/contentmodel/ssi/SSICMDocumentFactory.java @@ -0,0 +1,158 @@ +/******************************************************************************* + * Copyright (c) 2004 IBM Corporation and others. + * All rights reserved. This program and the accompanying materials + * are made available under the terms of the Eclipse Public License v1.0 + * which accompanies this distribution, and is available at + * http://www.eclipse.org/legal/epl-v10.html + * + * Contributors: + * IBM Corporation - initial API and implementation + *******************************************************************************/ +package org.eclipse.wst.html.core.contentmodel.ssi; + +import java.util.Hashtable; +import java.util.Iterator; + +import org.eclipse.wst.common.contentmodel.CMDocument; +import org.eclipse.wst.common.contentmodel.CMElementDeclaration; +import org.eclipse.wst.common.contentmodel.CMNamedNodeMap; +import org.eclipse.wst.common.contentmodel.CMNamespace; +import org.eclipse.wst.common.contentmodel.CMNode; +import org.eclipse.wst.html.core.HTML40Namespace; +import org.eclipse.wst.html.core.contentmodel.HTMLCMDocumentFactory; +import org.eclipse.wst.sse.core.contentmodel.CMDocType; + +/** + * CMDocument factory for SSI documents. + */ +public final class SSICMDocumentFactory { + + private final static String PREFIX = "SSI";//$NON-NLS-1$ + private final static String DOC_TYPE_NAME = "SSI";//$NON-NLS-1$ + + static class CMNamespaceImpl implements CMNamespace { + public CMNamespaceImpl() { + super(); + } + + public String getPrefix() { + return PREFIX; + } + + public String getURI() { + return ""; //$NON-NLS-1$ + } + + public String getNodeName() { + return DOC_TYPE_NAME; + } + + public int getNodeType() { + return CMNode.NAME_SPACE; + } + + public boolean supports(String propertyName) { + return false; + } + + public Object getProperty(String propertyName) { + return null; + } + + } + + static class CMDocImpl implements CMDocument { + private static CMDocument hcm = HTMLCMDocumentFactory.getCMDocument(CMDocType.HTML_DOC_TYPE); + + static class Elements implements CMNamedNodeMap { + private static String[] names = {HTML40Namespace.ElementName.SSI_CONFIG, HTML40Namespace.ElementName.SSI_ECHO, HTML40Namespace.ElementName.SSI_EXEC, HTML40Namespace.ElementName.SSI_FSIZE, HTML40Namespace.ElementName.SSI_FLASTMOD, HTML40Namespace.ElementName.SSI_INCLUDE, HTML40Namespace.ElementName.SSI_PRINTENV, HTML40Namespace.ElementName.SSI_SET}; + private Hashtable map = new Hashtable(); + + public Elements() { + CMNamedNodeMap elems = hcm.getElements(); + for (int i = 0; i < names.length; i++) { + String name = names[i]; + CMElementDeclaration dec = (CMElementDeclaration) elems.getNamedItem(name); + if (dec != null) + map.put(name, dec); + } + } + + public int getLength() { + return map.size(); + } + + public CMNode getNamedItem(String name) { + String cooked = getCanonicalName(name); + if (!map.containsKey(cooked)) + return null; + return (CMNode) map.get(cooked); + } + + public CMNode item(int index) { + Iterator iter = iterator(); + while (iter.hasNext()) { + Object node = iter.next(); + if (--index < 0) + return (CMNode) node; + } + return null; + } + + public Iterator iterator() { + return map.values().iterator(); + } + + private String getCanonicalName(String rawName) { + return rawName.toUpperCase(); + } + } + + static private Elements elements = new Elements(); + + + public CMDocImpl() { + super(); + } + + public String getNodeName() { + return ""; //$NON-NLS-1$ + } + + public int getNodeType() { + return CMNode.DOCUMENT; + } + + public CMNamedNodeMap getElements() { + return elements; + } + + public CMNamedNodeMap getEntities() { + return null; + } + + public CMNamespace getNamespace() { + return ssins; + } + + public Object getProperty(String propertyName) { + return null; + } + + public boolean supports(String propertyName) { + return false; + } + } + + private static CMNamespace ssins = new CMNamespaceImpl(); + private static CMDocument mycm = new CMDocImpl(); + + private SSICMDocumentFactory() { + super(); + } + + public static CMDocument getCMDocument() { + return mycm; + } + +}
\ No newline at end of file diff --git a/bundles/org.eclipse.wst.html.core/src/org/eclipse/wst/html/core/document/DocumentStyleImpl.java b/bundles/org.eclipse.wst.html.core/src/org/eclipse/wst/html/core/document/DocumentStyleImpl.java new file mode 100644 index 0000000000..77b9001c58 --- /dev/null +++ b/bundles/org.eclipse.wst.html.core/src/org/eclipse/wst/html/core/document/DocumentStyleImpl.java @@ -0,0 +1,96 @@ +/******************************************************************************* + * Copyright (c) 2004 IBM Corporation and others. + * All rights reserved. This program and the accompanying materials + * are made available under the terms of the Eclipse Public License v1.0 + * which accompanies this distribution, and is available at + * http://www.eclipse.org/legal/epl-v10.html + * + * Contributors: + * IBM Corporation - initial API and implementation + *******************************************************************************/ +/* + * Created on Sep 2, 2003 + * + * To change the template for this generated file go to + * Window>Preferences>Java>Code Generation>Code and Comments + */ +package org.eclipse.wst.html.core.document; + +import org.eclipse.wst.css.core.adapters.IStyleSheetListAdapter; +import org.eclipse.wst.sse.core.INodeAdapter; +import org.eclipse.wst.xml.core.document.XMLDocument; +import org.eclipse.wst.xml.core.document.XMLModel; +import org.eclipse.wst.xml.core.internal.document.DocumentImpl; +import org.w3c.dom.DOMException; +import org.w3c.dom.Element; +import org.w3c.dom.Node; +import org.w3c.dom.css.CSSStyleDeclaration; +import org.w3c.dom.css.DocumentCSS; +import org.w3c.dom.stylesheets.StyleSheetList; + +/** + * @author davidw + * + * To change the template for this generated type comment go to + * Window>Preferences>Java>Code Generation>Code and Comments + */ +public class DocumentStyleImpl extends DocumentImpl implements XMLDocument, DocumentCSS { + public DocumentStyleImpl() { + super(); + } + + public DocumentStyleImpl(DocumentImpl that) { + super(that); + } + + public CSSStyleDeclaration getOverrideStyle(Element element, String pseudoName) { + INodeAdapter adapter = getAdapterFor(IStyleSheetListAdapter.class); + if (adapter == null) + return null; + return ((IStyleSheetListAdapter) adapter).getOverrideStyle(element, pseudoName); + } + + public StyleSheetList getStyleSheets() { + INodeAdapter adapter = getAdapterFor(IStyleSheetListAdapter.class); + if (adapter == null) + return null; + return ((IStyleSheetListAdapter) adapter).getStyleSheets(); + } + + protected void releaseStyleSheets() { + INodeAdapter adapter = getExistingAdapter(IStyleSheetListAdapter.class); + if (adapter == null) + return; + ((IStyleSheetListAdapter) adapter).releaseStyleSheets(); + } + + /** + * createElement method + * @return org.w3c.dom.Element + * @param tagName java.lang.String + */ + public Element createElement(String tagName) throws DOMException { + checkTagNameValidity(tagName); + + ElementStyleImpl element = new ElementStyleImpl(); + element.setOwnerDocument(this); + element.setTagName(tagName); + return element; + } + + /** + * cloneNode method + * @return org.w3c.dom.Node + * @param deep boolean + */ + public Node cloneNode(boolean deep) { + DocumentStyleImpl cloned = new DocumentStyleImpl(this); + if (deep) + cloned.importChildNodes(this, true); + return cloned; + } + + protected void setModel(XMLModel model) { + super.setModel(model); + } +}
\ No newline at end of file diff --git a/bundles/org.eclipse.wst.html.core/src/org/eclipse/wst/html/core/document/ElementStyleImpl.java b/bundles/org.eclipse.wst.html.core/src/org/eclipse/wst/html/core/document/ElementStyleImpl.java new file mode 100644 index 0000000000..6d97898507 --- /dev/null +++ b/bundles/org.eclipse.wst.html.core/src/org/eclipse/wst/html/core/document/ElementStyleImpl.java @@ -0,0 +1,73 @@ +/******************************************************************************* + * Copyright (c) 2004 IBM Corporation and others. + * All rights reserved. This program and the accompanying materials + * are made available under the terms of the Eclipse Public License v1.0 + * which accompanies this distribution, and is available at + * http://www.eclipse.org/legal/epl-v10.html + * + * Contributors: + * IBM Corporation - initial API and implementation + *******************************************************************************/ +/* + * Created on Sep 2, 2003 + * + * To change the template for this generated file go to + * Window>Preferences>Java>Code Generation>Code and Comments + */ +package org.eclipse.wst.html.core.document; + +import org.eclipse.wst.css.core.adapters.IStyleDeclarationAdapter; +import org.eclipse.wst.css.core.adapters.IStyleSheetAdapter; +import org.eclipse.wst.sse.core.INodeAdapter; +import org.eclipse.wst.xml.core.document.XMLElement; +import org.eclipse.wst.xml.core.internal.document.ElementImpl; +import org.w3c.dom.Document; +import org.w3c.dom.Node; +import org.w3c.dom.css.CSSStyleDeclaration; +import org.w3c.dom.css.ElementCSSInlineStyle; +import org.w3c.dom.stylesheets.LinkStyle; +import org.w3c.dom.stylesheets.StyleSheet; + +public class ElementStyleImpl extends ElementImpl implements XMLElement, ElementCSSInlineStyle, LinkStyle { + public ElementStyleImpl() { + super(); + } + + public ElementStyleImpl(ElementImpl that) { + super(that); + } + + public StyleSheet getSheet() { + INodeAdapter adapter = getAdapterFor(IStyleSheetAdapter.class); + if (adapter == null) + return null; + if (!(adapter instanceof IStyleSheetAdapter)) + return null; + return ((IStyleSheetAdapter) adapter).getSheet(); + } + + public CSSStyleDeclaration getStyle() { + INodeAdapter adapter = getAdapterFor(IStyleDeclarationAdapter.class); + if (adapter == null) + return null; + if (!(adapter instanceof IStyleDeclarationAdapter)) + return null; + return ((IStyleDeclarationAdapter) adapter).getStyle(); + } + + protected void setOwnerDocument(Document ownerDocument) { + super.setOwnerDocument(ownerDocument); + } + + protected void setTagName(String tagName) { + super.setTagName(tagName); + } + + public Node cloneNode(boolean deep) { + ElementImpl cloned = new ElementStyleImpl(this); + if (deep) + cloneChildNodes(cloned, deep); + return cloned; + } + +}
\ No newline at end of file diff --git a/bundles/org.eclipse.wst.html.core/src/org/eclipse/wst/html/core/document/HTMLConverter.java b/bundles/org.eclipse.wst.html.core/src/org/eclipse/wst/html/core/document/HTMLConverter.java new file mode 100644 index 0000000000..c2bf955cc4 --- /dev/null +++ b/bundles/org.eclipse.wst.html.core/src/org/eclipse/wst/html/core/document/HTMLConverter.java @@ -0,0 +1,309 @@ +/******************************************************************************* + * Copyright (c) 2004 IBM Corporation and others. + * All rights reserved. This program and the accompanying materials + * are made available under the terms of the Eclipse Public License v1.0 + * which accompanies this distribution, and is available at + * http://www.eclipse.org/legal/epl-v10.html + * + * Contributors: + * IBM Corporation - initial API and implementation + *******************************************************************************/ +package org.eclipse.wst.html.core.document; + +import java.io.ByteArrayInputStream; +import java.io.IOException; +import java.io.InputStream; +import java.io.OutputStream; +import java.io.UnsupportedEncodingException; + +import org.eclipse.core.resources.IFile; +import org.eclipse.core.runtime.CoreException; +import org.eclipse.core.runtime.Platform; +import org.eclipse.wst.html.core.cleanup.HTMLCleanupProcessorImpl; +import org.eclipse.wst.sse.core.IModelManager; +import org.eclipse.wst.sse.core.IModelManagerPlugin; +import org.eclipse.wst.sse.core.IStructuredModel; +import org.eclipse.wst.sse.core.cleanup.IStructuredCleanupPreferences; +import org.eclipse.wst.sse.core.preferences.CommonModelPreferenceNames; +import org.eclipse.wst.sse.core.text.IStructuredDocument; +import org.eclipse.wst.xml.core.document.XMLDocument; +import org.eclipse.wst.xml.core.document.XMLDocumentType; +import org.eclipse.wst.xml.core.document.XMLModel; +import org.w3c.dom.Document; +import org.w3c.dom.Element; +import org.w3c.dom.Node; +import org.w3c.dom.ProcessingInstruction; +import org.w3c.dom.Text; + +/** + */ +public class HTMLConverter { + + /** + */ + public HTMLConverter() { + super(); + + } + + public void cleanupModel(XMLModel model) { + if (model == null) + return; + + HTMLCleanupProcessorImpl processor = new HTMLCleanupProcessorImpl(); + IStructuredCleanupPreferences pref = processor.getCleanupPreferences(); + + // backup options + boolean compressEmptyElementTags = pref.getCompressEmptyElementTags(); + boolean insertRequiredAttrs = pref.getInsertRequiredAttrs(); + boolean insertMissingTags = pref.getInsertMissingTags(); + boolean quoteAttrValues = pref.getQuoteAttrValues(); + boolean formatSource = pref.getFormatSource(); + int tagNameCase = pref.getTagNameCase(); + int attrNameCase = pref.getAttrNameCase(); + + // setup options + pref.setCompressEmptyElementTags(true); + pref.setInsertRequiredAttrs(true); + pref.setInsertMissingTags(true); + pref.setQuoteAttrValues(true); + pref.setFormatSource(false); + if (model.getDocument().isXMLType()) { // XHTML + pref.setTagNameCase(CommonModelPreferenceNames.LOWER); + pref.setAttrNameCase(CommonModelPreferenceNames.LOWER); + } + else { + pref.setTagNameCase(CommonModelPreferenceNames.ASIS); + pref.setAttrNameCase(CommonModelPreferenceNames.ASIS); + } + + processor.cleanupModel(model); + + // set back options + pref.setCompressEmptyElementTags(compressEmptyElementTags); + pref.setInsertRequiredAttrs(insertRequiredAttrs); + pref.setInsertMissingTags(insertMissingTags); + pref.setQuoteAttrValues(quoteAttrValues); + pref.setFormatSource(formatSource); + pref.setTagNameCase(tagNameCase); + pref.setAttrNameCase(attrNameCase); + } + + /** + * declaratoin: "data" for XML declaration, such as "version=\"1.0\"" + * publicId: publicId for DOCTYPE declaration + */ + public void convert(XMLModel model, String declaration, String publicId) { + if (model == null) + return; + setDeclaration(model, declaration, publicId); + cleanupModel(model); + } + + /** + * declaratoin: "data" for XML declaration, such as "version=\"1.0\"" + * publicId: publicId for DOCTYPE declaration + */ + public void convert(InputStream input, OutputStream output, String declaration, String publicId) throws UnsupportedEncodingException, IOException, CoreException { + XMLModel model = readModel(input); + if (model == null) + return; + try { + convert(model, declaration, publicId); + writeModel(model, output); + } + finally { + if (model != null) + model.releaseFromEdit(); + } + } + + /** + * declaratoin: "data" for XML declaration, such as "version=\"1.0\"" + * publicId: publicId for DOCTYPE declaration + */ + public void convert(IFile file, String declaration, String publicId) throws IOException, CoreException { + XMLModel model = readModel(file); + if (model == null) + return; + try { + convert(model, declaration, publicId); + writeModel(model, file); + } + finally { + if (model != null) + model.releaseFromEdit(); + } + } + + /** + */ + private static IModelManager getModelManager() { + return ((IModelManagerPlugin) Platform.getPlugin(IModelManagerPlugin.ID)).getModelManager(); + } + + /** + */ + private static void insertBreak(XMLModel model, Node node) { + if (model == null || node == null) + return; + if (node.getNodeType() == Node.TEXT_NODE) + return; + + // get delimiter string + IStructuredDocument structuredDocument = model.getStructuredDocument(); + if (structuredDocument == null) + return; + String delim = structuredDocument.getLineDelimiter(); + if (delim == null || delim.length() == 0) + return; + + Node parent = node.getParentNode(); + if (parent == null) + return; + Document document = node.getOwnerDocument(); + if (document == null) + return; + Text text = document.createTextNode(delim); + parent.insertBefore(text, node); + } + + /** + */ + private XMLModel readModel(InputStream input) throws IOException, UnsupportedEncodingException { + if (input == null) + return null; + // create temporary model + String id = input.toString() + ".html"; //$NON-NLS-1$ + IModelManager manager = getModelManager(); + IStructuredModel model = manager.getModelForEdit(id, input, null); + if (!(model instanceof XMLModel)) { + if (model == null) + model.releaseFromEdit(); + return null; + } + return (XMLModel) model; + } + + /** + */ + private XMLModel readModel(IFile file) throws IOException, CoreException { + if (file == null) + return null; + IModelManager manager = getModelManager(); + IStructuredModel model = manager.getModelForEdit(file); + if (!(model instanceof XMLModel)) { + if (model != null) + model.releaseFromEdit(); + return null; + } + return (XMLModel) model; + } + + /** + */ + public void setDeclaration(XMLModel model, String declaration, String publicId) { + if (model == null) + return; + XMLDocument document = model.getDocument(); + if (document == null) + return; + + try { + model.aboutToChangeModel(); + + ProcessingInstruction pi = null; + Node child = document.getFirstChild(); + if (child != null && child.getNodeType() == Node.PROCESSING_INSTRUCTION_NODE) { + String target = child.getNodeName(); + if (target != null && target.equals("xml")) { //$NON-NLS-1$ + pi = (ProcessingInstruction) child; + child = child.getNextSibling(); + } + } + XMLDocumentType docType = (XMLDocumentType) document.getDoctype(); + + if (declaration != null) { + if (pi != null) { + pi.setData(declaration); + } + else { + pi = document.createProcessingInstruction("xml", declaration); //$NON-NLS-1$ + document.insertBefore(pi, child); + insertBreak(model, child); + } + } + + if (publicId != null) { + HTMLDocumentTypeEntry entry = HTMLDocumentTypeRegistry.getInstance().getEntry(publicId); + String name = (entry != null ? entry.getName() : null); + if (name == null || name.length() == 0) + name = "HTML"; // default //$NON-NLS-1$ + if (docType != null) { + if (!name.equals(docType.getName())) { // replace + Node parent = docType.getParentNode(); + child = docType; + docType = (XMLDocumentType) document.createDoctype(name); + parent.insertBefore(docType, child); + parent.removeChild(child); + } + } + else { + docType = (XMLDocumentType) document.createDoctype(name); + document.insertBefore(docType, child); + insertBreak(model, child); + } + docType.setPublicId(publicId); + if (entry != null) { + String systemId = entry.getSystemId(); + if (systemId != null) + docType.setSystemId(systemId); + String namespaceURI = entry.getNamespaceURI(); + if (namespaceURI != null) { + Element element = document.getDocumentElement(); + if (element != null) { + element.setAttribute("xmlns", namespaceURI); //$NON-NLS-1$ + } + } + } + } + } + finally { + model.changedModel(); + } + } + + /** + */ + private void writeModel(XMLModel model, OutputStream output) throws UnsupportedEncodingException, IOException, CoreException { + if (model == null || output == null) + return; + model.save(); + } + + /** + */ + private void writeModel(XMLModel model, IFile file) throws IOException, CoreException { + if (model == null || file == null) + return; + IStructuredDocument structuredDocument = model.getStructuredDocument(); + if (structuredDocument == null) + return; + //ByteArrayOutputStream output = null; + ByteArrayInputStream input = null; + try { + //output = new + // ByteArrayOutputStream(structuredDocument.getLength()); + model.save(); + //input = new ByteArrayInputStream(output.toByteArray()); + //file.setContents(input, true, true, null); + } + finally { + // if (output != null) + // output.close(); + if (input != null) + input.close(); + } + + } +}
\ No newline at end of file diff --git a/bundles/org.eclipse.wst.html.core/src/org/eclipse/wst/html/core/document/HTMLDocumentTypeAdapter.java b/bundles/org.eclipse.wst.html.core/src/org/eclipse/wst/html/core/document/HTMLDocumentTypeAdapter.java new file mode 100644 index 0000000000..f51a30a9ed --- /dev/null +++ b/bundles/org.eclipse.wst.html.core/src/org/eclipse/wst/html/core/document/HTMLDocumentTypeAdapter.java @@ -0,0 +1,294 @@ +/******************************************************************************* + * Copyright (c) 2004 IBM Corporation and others. + * All rights reserved. This program and the accompanying materials + * are made available under the terms of the Eclipse Public License v1.0 + * which accompanies this distribution, and is available at + * http://www.eclipse.org/legal/epl-v10.html + * + * Contributors: + * IBM Corporation - initial API and implementation + *******************************************************************************/ +package org.eclipse.wst.html.core.document; + + + +import org.eclipse.core.resources.IFile; +import org.eclipse.core.resources.IProject; +import org.eclipse.core.resources.IResource; +import org.eclipse.wst.sse.core.INodeNotifier; +import org.eclipse.wst.sse.core.util.ResourceUtil; +import org.eclipse.wst.sse.ui.contentproperties.ContentSettings; +import org.eclipse.wst.sse.ui.contentproperties.ContentSettingsChangeSubject; +import org.eclipse.wst.sse.ui.contentproperties.IContentSettings; +import org.eclipse.wst.sse.ui.contentproperties.IContentSettingsListener; +import org.eclipse.wst.xml.core.document.DocumentTypeAdapter; +import org.eclipse.wst.xml.core.document.XMLDocument; +import org.eclipse.wst.xml.core.document.XMLDocumentType; +import org.eclipse.wst.xml.core.document.XMLModel; +import org.eclipse.wst.xml.core.internal.document.DocumentTypeAdapterImpl; +import org.w3c.dom.DOMImplementation; +import org.w3c.dom.Document; +import org.w3c.dom.DocumentType; +import org.w3c.dom.Node; + +/** + */ +public class HTMLDocumentTypeAdapter extends DocumentTypeAdapterImpl implements IContentSettingsListener, HTMLDocumentTypeConstants { + + private HTMLDocumentTypeAdapterFactory factory = null; + private HTMLDocumentTypeEntry entry = null; + private boolean isXMLType = false; + private final static String XML = "xml"; //$NON-NLS-1$ + private final static String XHTML = "xhtml"; //$NON-NLS-1$ + private final static String WML = "wml"; //$NON-NLS-1$ + + + /** + */ + protected HTMLDocumentTypeAdapter() { + super(); + } + + /** + */ + protected HTMLDocumentTypeAdapter(XMLDocument document, HTMLDocumentTypeAdapterFactory factory) { + super(document); + + this.factory = factory; + + // initialize + documentTypeChanged(); + + ContentSettingsChangeSubject.getSubject().addListener(this); + } + + /** + */ + public void contentSettingsChanged(IResource resource) { + if (resource == null) + return; + XMLDocument document = getDocument(); + if (document == null) + return; + XMLModel model = document.getModel(); + if (model == null) + return; + IFile file = ResourceUtil.getFileFor(model); + if (file == null) + return; + IProject project = file.getProject(); + if (project == null) + return; + if (!project.equals(resource.getProject())) + return; + documentTypeChanged(); + } + + /** + */ + private void documentTypeChanged() { + XMLDocument document = getDocument(); + if (document == null) + return; // error + XMLModel model = document.getModel(); + if (model == null) + return; // error + if (model.isReinitializationNeeded()) { + // we're may be looping. Even if not, + // if we're going to be reinitialized, + // no need to worry about document type + // this pass. + return; + } + IFile file = ResourceUtil.getFileFor(model); + + // find DOCTYPE delcaration and Public ID + String publicId = null; + DocumentType newDocumentType = findDocumentType(document); + if (newDocumentType != null) { + publicId = newDocumentType.getPublicId(); + } else { + // lookup default set by contentsettings + publicId = getDefaultPublicId(file); + } + + // lookup DOCTYPE registry + HTMLDocumentTypeEntry newEntry = null; + if (publicId != null) { + newEntry = HTMLDocumentTypeRegistry.getInstance().getEntry(publicId); + } + + boolean newXMLType = (newEntry != null ? newEntry.isXMLType() : false); + boolean newWMLType = (newEntry != null ? newEntry.isWMLType() : false); + + if (!newXMLType) { + // find XML declaration + if (findXMLNode(document) != null) { + newXMLType = true; + } + + // check file extension + if (file != null) { + String ext = file.getFileExtension(); + if (ext != null && ext.equalsIgnoreCase(XHTML)) { + newXMLType = true; + } + + if (ext != null && ext.equalsIgnoreCase(WML)) { + newXMLType = true; + newWMLType = true; + } + } + + } + + if (newEntry == null) { + // lookup system default + if (newXMLType && newDocumentType == null) { + // use default XHTML, if it's XML and no document type + // declared + if (newWMLType) + newEntry = HTMLDocumentTypeRegistry.getInstance().getDefaultEntry(HTMLDocumentTypeRegistry.DEFAULT_WML); + else + newEntry = HTMLDocumentTypeRegistry.getInstance().getDefaultEntry(HTMLDocumentTypeRegistry.DEFAULT_XHTML); + + } else { + newEntry = HTMLDocumentTypeRegistry.getInstance().getDefaultEntry(HTMLDocumentTypeRegistry.DEFAULT_HTML); + } + if (newEntry == null) + return; // error + } + + if (newDocumentType == null) { + DocumentType oldDocumentType = getDocumentType(); + if (oldDocumentType == null || oldDocumentType.getName() != newEntry.getName()) { + // create implicit DocumentType + DOMImplementation impl = document.getImplementation(); + if (impl != null) { + String name = newEntry.getName(); + publicId = newEntry.getPublicId(); + String systemId = newEntry.getSystemId(); + newDocumentType = impl.createDocumentType(name, publicId, systemId); + } + } + } + + boolean notify = false; + if (this.entry != null) { // do not notify on initialization + notify = (newEntry != this.entry || newXMLType != this.isXMLType); + } + + if (newDocumentType != null) + setDocumentType(newDocumentType); + this.entry = newEntry; + this.isXMLType = newXMLType; + + if (notify) + notifyDocumentTypeChanged(); + } + + /** + */ + private XMLDocumentType findDocumentType(XMLDocument document) { + XMLDocumentType documentType = (XMLDocumentType) document.getDoctype(); + if (documentType != null && documentType.getExistingAdapter(DocumentTypeAdapter.class) == null) { + // watch future changes + documentType.addAdapter(this); + } + return documentType; + } + + /** + */ + private Node findXMLNode(Document document) { + for (Node child = document.getFirstChild(); child != null; child = child.getNextSibling()) { + if (child.getNodeType() != Node.PROCESSING_INSTRUCTION_NODE) + continue; + String target = child.getNodeName(); + if (target != null && target.equals(XML)) { + return child; + } + } + return null; + } + + /** + */ + public int getAttrNameCase() { + if (isXMLType()) + return LOWER_CASE; // XHTML + return this.factory.getAttrNameCase(); + } + + /** + */ + private String getDefaultPublicId(IFile file) { + if (file == null) + return null; + IProject project = file.getProject(); + if (project == null) + return null; + IContentSettings settings = ContentSettings.getInstance(); + if (settings == null) + return null; + String publicId = settings.getProperty(file, IContentSettings.HTML_DOCUMENT_TYPE); + if (publicId == null || publicId.length() == 0) { + // look up project default + publicId = settings.getProperty(project, IContentSettings.HTML_DOCUMENT_TYPE); + } + return publicId; + } + + /** + */ + public int getTagNameCase() { + if (isXMLType()) + return LOWER_CASE; // XHTML + return this.factory.getTagNameCase(); + } + + /** + */ + public boolean hasFeature(String feature) { + if (feature == null) + return false; + if (feature.equals(HTML)) + return true; + if (feature.equals(SSI)) + return true; + if (feature.equals(FRAMESET)) { + if (this.entry == null) + return false; + return this.entry.hasFrameset(); + } + return false; + } + + /** + */ + public boolean isXMLType() { + return this.isXMLType; + } + + /** + */ + public void notifyChanged(INodeNotifier notifier, int eventType, Object changedFeature, Object oldValue, Object newValue, int pos) { + if (notifier == null) + return; + if (notifier instanceof XMLDocument) { + if (eventType != INodeNotifier.STRUCTURE_CHANGED) + return; + } else { + if (eventType != INodeNotifier.CHANGE) + return; + } + documentTypeChanged(); + } + + /** + */ + public void release() { + ContentSettingsChangeSubject.getSubject().removeListener(this); + super.release(); + } +}
\ No newline at end of file diff --git a/bundles/org.eclipse.wst.html.core/src/org/eclipse/wst/html/core/document/HTMLDocumentTypeAdapterFactory.java b/bundles/org.eclipse.wst.html.core/src/org/eclipse/wst/html/core/document/HTMLDocumentTypeAdapterFactory.java new file mode 100644 index 0000000000..a6cd10121e --- /dev/null +++ b/bundles/org.eclipse.wst.html.core/src/org/eclipse/wst/html/core/document/HTMLDocumentTypeAdapterFactory.java @@ -0,0 +1,136 @@ +/******************************************************************************* + * Copyright (c) 2004 IBM Corporation and others. + * All rights reserved. This program and the accompanying materials + * are made available under the terms of the Eclipse Public License v1.0 + * which accompanies this distribution, and is available at + * http://www.eclipse.org/legal/epl-v10.html + * + * Contributors: + * IBM Corporation - initial API and implementation + *******************************************************************************/ +package org.eclipse.wst.html.core.document; + + + +import org.eclipse.core.runtime.Preferences; +import org.eclipse.wst.html.core.HTMLCorePlugin; +import org.eclipse.wst.sse.core.AdapterFactory; +import org.eclipse.wst.sse.core.INodeAdapter; +import org.eclipse.wst.sse.core.INodeNotifier; +import org.eclipse.wst.sse.core.preferences.CommonModelPreferenceNames; +import org.eclipse.wst.xml.core.document.DocumentTypeAdapter; +import org.eclipse.wst.xml.core.document.XMLDocument; + +/** + */ +public class HTMLDocumentTypeAdapterFactory implements AdapterFactory, Preferences.IPropertyChangeListener, CommonModelPreferenceNames { + + private static HTMLDocumentTypeAdapterFactory instance = null; + private int tagNameCase = DocumentTypeAdapter.UPPER_CASE; + private int attrNameCase = DocumentTypeAdapter.LOWER_CASE; + //private IPreferenceStore store = null; + private Preferences preferences = null; + + /** + */ + private HTMLDocumentTypeAdapterFactory() { + super(); + this.preferences = HTMLCorePlugin.getDefault().getPluginPreferences(); + //this.store = CommonPreferencesPlugin.getDefault().getPreferenceStore(ContentTypeRegistry.HTML_ID); + if (this.preferences != null) { + updateCases(); // initialize + this.preferences.addPropertyChangeListener(this); + } + } + + /** + * Method that returns the adapter associated with the given object. + * It may be a singleton or not ... depending on the needs of the INodeAdapter ... + * but in general it is recommended for an adapter to be stateless, + * so the efficiencies of a singleton can be gained. + * + * The implementation of this method should call addAdapter on the adapted + * object with the correct instance of the adapter. + */ + public INodeAdapter adapt(INodeNotifier notifier) { + INodeAdapter adapter = notifier.getExistingAdapter(DocumentTypeAdapter.class); + if (adapter != null) + return adapter; + if (!(notifier instanceof XMLDocument)) + return null; + adapter = new HTMLDocumentTypeAdapter((XMLDocument) notifier, this); + notifier.addAdapter(adapter); + return adapter; + } + + /** + */ + public int getAttrNameCase() { + return this.attrNameCase; + } + + /** + * Insert the method's description here. + * @return com.ibm.iwt.css.adapters.HTMLStyleSelectorAdapterFactory + */ + public synchronized static HTMLDocumentTypeAdapterFactory getInstance() { + if (instance == null) + instance = new HTMLDocumentTypeAdapterFactory(); + return instance; + } + + /** + */ + public int getTagNameCase() { + return this.tagNameCase; + } + + /** + */ + public boolean isFactoryForType(Object type) { + return (type == DocumentTypeAdapter.class); + } + + /** + */ + public void propertyChange(Preferences.PropertyChangeEvent event) { + if (event == null) + return; + String property = event.getProperty(); + if (property == null) + return; + + if (property.equals(TAG_NAME_CASE) || property.equals(ATTR_NAME_CASE)) { + updateCases(); + } + } + + /** + */ + private void updateCases() { + this.tagNameCase = DocumentTypeAdapter.UPPER_CASE; + this.attrNameCase = DocumentTypeAdapter.LOWER_CASE; + + if (this.preferences == null) + return; + + if (this.preferences.getInt(TAG_NAME_CASE) == LOWER) { + this.tagNameCase = DocumentTypeAdapter.LOWER_CASE; + } + if (this.preferences.getInt(ATTR_NAME_CASE) == UPPER) { + this.attrNameCase = DocumentTypeAdapter.UPPER_CASE; + } + } + + /** + */ + public void release() { + } + + /** + * Overriding copy method + */ + public AdapterFactory copy() { + return getInstance(); + } +}
\ No newline at end of file diff --git a/bundles/org.eclipse.wst.html.core/src/org/eclipse/wst/html/core/document/HTMLDocumentTypeConstants.java b/bundles/org.eclipse.wst.html.core/src/org/eclipse/wst/html/core/document/HTMLDocumentTypeConstants.java new file mode 100644 index 0000000000..e44e5ec2fc --- /dev/null +++ b/bundles/org.eclipse.wst.html.core/src/org/eclipse/wst/html/core/document/HTMLDocumentTypeConstants.java @@ -0,0 +1,19 @@ +/******************************************************************************* + * Copyright (c) 2004 IBM Corporation and others. + * All rights reserved. This program and the accompanying materials + * are made available under the terms of the Eclipse Public License v1.0 + * which accompanies this distribution, and is available at + * http://www.eclipse.org/legal/epl-v10.html + * + * Contributors: + * IBM Corporation - initial API and implementation + *******************************************************************************/ +package org.eclipse.wst.html.core.document; + +public interface HTMLDocumentTypeConstants { + + public final static String HTML = "HTML"; //$NON-NLS-1$ + public final static String FRAMESET = "FRAMESET"; //$NON-NLS-1$ + public final static String SSI = "SSI"; //$NON-NLS-1$ + +}
\ No newline at end of file diff --git a/bundles/org.eclipse.wst.html.core/src/org/eclipse/wst/html/core/document/HTMLDocumentTypeEntry.java b/bundles/org.eclipse.wst.html.core/src/org/eclipse/wst/html/core/document/HTMLDocumentTypeEntry.java new file mode 100644 index 0000000000..b353c93b78 --- /dev/null +++ b/bundles/org.eclipse.wst.html.core/src/org/eclipse/wst/html/core/document/HTMLDocumentTypeEntry.java @@ -0,0 +1,127 @@ +/******************************************************************************* + * Copyright (c) 2004 IBM Corporation and others. + * All rights reserved. This program and the accompanying materials + * are made available under the terms of the Eclipse Public License v1.0 + * which accompanies this distribution, and is available at + * http://www.eclipse.org/legal/epl-v10.html + * + * Contributors: + * IBM Corporation - initial API and implementation + *******************************************************************************/ +package org.eclipse.wst.html.core.document; + + + +/** + */ +public class HTMLDocumentTypeEntry { + + private String name; + private String publicId; + private String systemId; + private String namespaceURI; + private boolean isXMLType; + private boolean isXHTMLType; + private boolean isWMLType; + private boolean hasFrameset; + private String displayName; + private boolean isDefaultXHTML; + private boolean isDefaultWML; + private static String XHTML_NAME = "html"; //$NON-NLS-1$ + private static String HTML_NAME = "HTML"; //$NON-NLS-1$ + private static String WML_NAME = "wml"; //$NON-NLS-1$ + + /** + */ + private HTMLDocumentTypeEntry() { + super(); + } + + /** + */ + public HTMLDocumentTypeEntry(String name, String publicId, String systemId, String namespaceURI, boolean isXHTMLType, boolean hasFrameset, String displayName, boolean isDefaultXHTML, boolean isDefaultWML, boolean isWMLType) { + super(); + + if (name != null && name.length() > 0) { + this.name = name; + } + else { + if (isXMLType) + this.name = XHTML_NAME;// need code for wml? + else + this.name = HTML_NAME; + } + this.publicId = publicId; + this.systemId = systemId; + this.namespaceURI = namespaceURI; + this.isXMLType = isXHTMLType | isWMLType; + this.hasFrameset = hasFrameset; + this.displayName = displayName; + this.isDefaultXHTML = isDefaultXHTML; + this.isDefaultWML = isDefaultWML; + this.isXHTMLType = isXHTMLType; + this.isWMLType = isWMLType; + } + + /** + */ + public final String getName() { + return this.name; + } + + /** + */ + public final String getNamespaceURI() { + return this.namespaceURI; + } + + /** + */ + public final String getPublicId() { + return this.publicId; + } + + /** + */ + public final String getSystemId() { + return this.systemId; + } + + /** + */ + public final boolean isXMLType() { + return this.isXMLType; + } + + /** + */ + public final boolean hasFrameset() { + return this.hasFrameset; + } + + /** + */ + public final String getDisplayName() { + return this.displayName; + } + + /** + */ + public final boolean isDefaultXHTML() { + return this.isDefaultXHTML; + } + + public final boolean isDefaultWML() { + return this.isDefaultWML; + } + + + public final boolean isXHTMLType() { + return isXHTMLType; + } + + public final boolean isWMLType() { + return isWMLType; + } + +}
\ No newline at end of file diff --git a/bundles/org.eclipse.wst.html.core/src/org/eclipse/wst/html/core/document/HTMLDocumentTypeRegistry.java b/bundles/org.eclipse.wst.html.core/src/org/eclipse/wst/html/core/document/HTMLDocumentTypeRegistry.java new file mode 100644 index 0000000000..9b18366831 --- /dev/null +++ b/bundles/org.eclipse.wst.html.core/src/org/eclipse/wst/html/core/document/HTMLDocumentTypeRegistry.java @@ -0,0 +1,139 @@ +/******************************************************************************* + * Copyright (c) 2004 IBM Corporation and others. + * All rights reserved. This program and the accompanying materials + * are made available under the terms of the Eclipse Public License v1.0 + * which accompanies this distribution, and is available at + * http://www.eclipse.org/legal/epl-v10.html + * + * Contributors: + * IBM Corporation - initial API and implementation + *******************************************************************************/ +package org.eclipse.wst.html.core.document; + + + +import java.util.Enumeration; +import java.util.Hashtable; + +/** + */ +public class HTMLDocumentTypeRegistry { + + private static HTMLDocumentTypeRegistry instance = null; + private Hashtable entries = null; + private HTMLDocumentTypeEntry defaultEntry = null; + private HTMLDocumentTypeEntry defaultXHTMLEntry = null; + private HTMLDocumentTypeEntry defaultWMLEntry = null; + private HTMLDocumentTypeEntry defaultCHTMLEntry = null; + + final static int DEFAULT_HTML = 0; + final static int DEFAULT_XHTML = 1; + final static int DEFAULT_WML = 2; + final static int DEFAULT_CHTML = 3; + + public static final String CHTML_PUBLIC_ID = "-//W3C//DTD Compact HTML 1.0 Draft//EN";//$NON-NLS-1$ + + /** + */ + private HTMLDocumentTypeRegistry() { + super(); + + this.entries = new Hashtable(); + // HTML 4.01 + String name = "HTML";//$NON-NLS-1$ + String publicId = "-//W3C//DTD HTML 4.01 Transitional//EN";//$NON-NLS-1$ + String displayName = "HTML 4.01 Transitional"; //$NON-NLS-1$ + this.defaultEntry = new HTMLDocumentTypeEntry(name, publicId, null, null, false, false, displayName, false, false, false); + this.entries.put(publicId, this.defaultEntry); + publicId = "-//W3C//DTD HTML 4.01//EN";//$NON-NLS-1$ + displayName = "HTML 4.01 Strict"; //$NON-NLS-1$ + this.entries.put(publicId, new HTMLDocumentTypeEntry(name, publicId, null, null, false, false, displayName, false, false, false)); + publicId = "-//W3C//DTD HTML 4.01 Frameset//EN";//$NON-NLS-1$ + displayName = "HTML 4.01 Frameset"; //$NON-NLS-1$ + this.entries.put(publicId, new HTMLDocumentTypeEntry(name, publicId, null, null, false, true, displayName, false, false, false)); + // CHTML + name = "HTML";//$NON-NLS-1$ + publicId = CHTML_PUBLIC_ID; + displayName = "Compact HTML 1.0 Draft"; //$NON-NLS-1$ + this.defaultCHTMLEntry = new HTMLDocumentTypeEntry(name, publicId, null, null, false, false, displayName, false, false, false); + this.entries.put(publicId, this.defaultCHTMLEntry); + + HTMLDocumentTypeRegistryReader reader = new HTMLDocumentTypeRegistryReader(); + if (reader != null) + reader.readRegistry(this); + } + + /** + */ + void regist(String pid, HTMLDocumentTypeEntry doctype) { + if (pid == null || doctype == null) + return; + this.entries.put(pid, doctype); + if (this.defaultXHTMLEntry == null) { + if (doctype.isDefaultXHTML()) + this.defaultXHTMLEntry = doctype; + } + if (this.defaultWMLEntry == null) { + if (doctype.isDefaultWML()) + this.defaultWMLEntry = doctype; + } + } + + /** + * + */ + public HTMLDocumentTypeEntry getDefaultEntry(int type) { + HTMLDocumentTypeEntry entry = null; + switch (type) { + case DEFAULT_XHTML : + entry = this.defaultXHTMLEntry; + break; + case DEFAULT_WML : + entry = this.defaultWMLEntry; + break; + case DEFAULT_CHTML : + entry = this.defaultCHTMLEntry; + break; + case DEFAULT_HTML : + default : + entry = this.defaultEntry; + break; + } + return entry; + } + + /** + * + */ + public HTMLDocumentTypeEntry getDefaultEntry() { + return this.defaultEntry; + } + + /** + */ + public HTMLDocumentTypeEntry getXHTMLDefaultEntry() { + return this.defaultXHTMLEntry; + } + + /** + */ + public Enumeration getEntries() { + return this.entries.elements(); + } + + /** + */ + public HTMLDocumentTypeEntry getEntry(String publicId) { + if (publicId == null) + return null; + return (HTMLDocumentTypeEntry) this.entries.get(publicId); + } + + /** + */ + public synchronized static HTMLDocumentTypeRegistry getInstance() { + if (instance == null) + instance = new HTMLDocumentTypeRegistry(); + return instance; + } +}
\ No newline at end of file diff --git a/bundles/org.eclipse.wst.html.core/src/org/eclipse/wst/html/core/document/HTMLDocumentTypeRegistryReader.java b/bundles/org.eclipse.wst.html.core/src/org/eclipse/wst/html/core/document/HTMLDocumentTypeRegistryReader.java new file mode 100644 index 0000000000..297b7a759d --- /dev/null +++ b/bundles/org.eclipse.wst.html.core/src/org/eclipse/wst/html/core/document/HTMLDocumentTypeRegistryReader.java @@ -0,0 +1,108 @@ +/******************************************************************************* + * Copyright (c) 2004 IBM Corporation and others. + * All rights reserved. This program and the accompanying materials + * are made available under the terms of the Eclipse Public License v1.0 + * which accompanies this distribution, and is available at + * http://www.eclipse.org/legal/epl-v10.html + * + * Contributors: + * IBM Corporation - initial API and implementation + *******************************************************************************/ +package org.eclipse.wst.html.core.document; + +import org.eclipse.core.runtime.IConfigurationElement; +import org.eclipse.core.runtime.IExtensionPoint; +import org.eclipse.core.runtime.IPluginRegistry; +import org.eclipse.core.runtime.Platform; +import org.eclipse.wst.sse.core.IModelManagerPlugin; + +/** + */ +class HTMLDocumentTypeRegistryReader { + + // + private final static String PLUGIN_ID = IModelManagerPlugin.ID; //$NON-NLS-1$ + private final static String EXTENSION_POINT_ID = "documentTypes"; //$NON-NLS-1$ + private final static String TAG_NAME = "documentType"; //$NON-NLS-1$ + private final static String ATT_PID = "publicID"; //$NON-NLS-1$ + private final static String ATT_SID = "systemID"; //$NON-NLS-1$ + private final static String ATT_IS_XHTML = "isXHTML"; //$NON-NLS-1$ + private final static String ATT_IS_WML = "isWML"; //$NON-NLS-1$ + private final static String ATT_HAS_FRAMESET = "hasFrameset"; //$NON-NLS-1$ + private final static String ATT_NSURI = "namespaceURI"; //$NON-NLS-1$ + private final static String ATT_ENAME = "elementName"; //$NON-NLS-1$ + private final static String ATT_DNAME = "displayName"; //$NON-NLS-1$ + private final static String ATT_IS_DEFAULT_XHTML = "defaultXHTML"; //$NON-NLS-1$ + private final static String ATT_IS_DEFAULT_WML = "defaultWML"; //$NON-NLS-1$ + private final static String ATV_TRUE = "true"; //$NON-NLS-1$ + private final static String ATV_NULL_STRING = ""; //$NON-NLS-1$ + + /** + */ + HTMLDocumentTypeRegistryReader() { + super(); + } + + /** + */ + void readRegistry(HTMLDocumentTypeRegistry reg) { + if (reg == null) + return; + IPluginRegistry pluginRegistry = Platform.getPluginRegistry(); + IExtensionPoint point = pluginRegistry.getExtensionPoint(PLUGIN_ID, EXTENSION_POINT_ID); + if (point != null) { + IConfigurationElement[] elements = point.getConfigurationElements(); + for (int i = 0; i < elements.length; i++) { + HTMLDocumentTypeEntry doctype = readElement(elements[i]); + // null can be returned if there's an error reading the element + if (doctype != null) { + reg.regist(doctype.getPublicId(), doctype); + } + } + } + } + + /** + */ + private HTMLDocumentTypeEntry readElement(IConfigurationElement element) { + HTMLDocumentTypeEntry doctype = null; + String pid = null; + String sid = null; + String nsuri = null; + String root = null; + boolean xhtml = true; + boolean frameset = false; + String dname = null; + boolean defaultXhtml = false; + boolean defaultWML = false; + boolean isWML = false; + + if (element.getName().equals(TAG_NAME)) { + pid = element.getAttribute(ATT_PID); + // publicID attribute is mandatory. + if (pid == null || pid.equals(ATV_NULL_STRING)) + return null; + + sid = element.getAttribute(ATT_SID); + nsuri = element.getAttribute(ATT_NSURI); + root = element.getAttribute(ATT_ENAME); + xhtml = getBoolean(element, ATT_IS_XHTML); + frameset = getBoolean(element, ATT_HAS_FRAMESET); + dname = element.getAttribute(ATT_DNAME); + defaultXhtml = getBoolean(element, ATT_IS_DEFAULT_XHTML); + defaultWML = getBoolean(element, ATT_IS_DEFAULT_WML); + isWML = getBoolean(element, ATT_IS_WML); + doctype = new HTMLDocumentTypeEntry(root, pid, sid, nsuri, xhtml, frameset, dname, defaultXhtml, defaultWML, isWML); + } + return doctype; + } + + /** + */ + private boolean getBoolean(IConfigurationElement element, String att) { + String value = element.getAttribute(att); + if (value != null && value.equals(ATV_TRUE)) + return true; + return false; + } +}
\ No newline at end of file diff --git a/bundles/org.eclipse.wst.html.core/src/org/eclipse/wst/html/core/document/HTMLModelParserAdapter.java b/bundles/org.eclipse.wst.html.core/src/org/eclipse/wst/html/core/document/HTMLModelParserAdapter.java new file mode 100644 index 0000000000..e8b4fb3593 --- /dev/null +++ b/bundles/org.eclipse.wst.html.core/src/org/eclipse/wst/html/core/document/HTMLModelParserAdapter.java @@ -0,0 +1,354 @@ +/******************************************************************************* + * Copyright (c) 2004 IBM Corporation and others. + * All rights reserved. This program and the accompanying materials + * are made available under the terms of the Eclipse Public License v1.0 + * which accompanies this distribution, and is available at + * http://www.eclipse.org/legal/epl-v10.html + * + * Contributors: + * IBM Corporation - initial API and implementation + *******************************************************************************/ +package org.eclipse.wst.html.core.document; + + + +import org.eclipse.wst.common.contentmodel.CMContent; +import org.eclipse.wst.common.contentmodel.CMElementDeclaration; +import org.eclipse.wst.common.contentmodel.CMGroup; +import org.eclipse.wst.common.contentmodel.CMNode; +import org.eclipse.wst.common.contentmodel.CMNodeList; +import org.eclipse.wst.html.core.HTML40Namespace; +import org.eclipse.wst.html.core.HTMLCMProperties; +import org.eclipse.wst.html.core.contentmodel.HTMLElementDeclaration; +import org.eclipse.wst.sse.core.INodeNotifier; +import org.eclipse.wst.xml.core.document.TagAdapter; +import org.eclipse.wst.xml.core.document.XMLElement; +import org.eclipse.wst.xml.core.document.XMLText; +import org.eclipse.wst.xml.core.internal.document.CMNodeUtil; +import org.eclipse.wst.xml.core.internal.document.ModelParserAdapter; +import org.w3c.dom.Document; +import org.w3c.dom.Element; +import org.w3c.dom.Node; + +/** + * HTMLDocumentImpl class + */ +public class HTMLModelParserAdapter implements ModelParserAdapter { + /** + * note: I made public, temparily, so could be used by JSPLoader + */ + protected HTMLModelParserAdapter() { + super(); + } + + private boolean shouldTerminateAt(CMElementDeclaration parent, CMElementDeclaration child) { + if (!parent.supports(HTMLCMProperties.TERMINATORS)) + return false; + java.util.Iterator i = (java.util.Iterator) parent.getProperty(HTMLCMProperties.TERMINATORS); + if (i == null) + return false; + String nextName = child.getElementName(); + while (i.hasNext()) { + // NOTE: CMElementDeclaration of child is not always HTMLCMElementDeclaration. + // It might be one of based on DTD (for XHTML element). So, comparison must + // be performed ignoring case. + // -- 3/20/2002 + String terminator = (String) i.next(); + if (terminator == null) + continue; + if (nextName.equalsIgnoreCase(terminator)) + return true; + } + return false; + } + + /** + */ + public boolean canContain(Element element, Node child) { + if (element == null || child == null) + return false; + XMLElement impl = (XMLElement) element; + + if (child.getNodeType() == Node.ELEMENT_NODE) { + if (!impl.isGlobalTag()) + return true; // non HTML tag + XMLElement childElement = (XMLElement) child; + + CMElementDeclaration myDec = CMNodeUtil.getElementDeclaration(element); + if (myDec == null) + return true; + //if (!(myDec instanceof HTMLElementDeclaration)) return true; + if (myDec.getContentType() == CMElementDeclaration.EMPTY) + return false; + + if (!childElement.isGlobalTag()) + return true; // non HTML tag + CMElementDeclaration childDec = CMNodeUtil.getElementDeclaration(childElement); + if (childDec == null) + return true; + //if (!(childDec instanceof HTMLElementDeclaration)) return true; + + if (myDec instanceof HTMLElementDeclaration) { + if (((Boolean) ((HTMLElementDeclaration) myDec).getProperty(HTMLCMProperties.IS_JSP)).booleanValue()) + return true; + } + if (shouldTerminateAt(myDec, childDec) && !isValidChild(myDec, childDec)) { + return false; + } + + String tagName = impl.getTagName(); + if (tagName == null) + return true; + String childName = childElement.getTagName(); + if (childName == null) + return true; + if (!impl.hasStartTag() && !impl.hasEndTag()) { + // implicit element + if (tagName.equalsIgnoreCase(childElement.getTagName())) + return false; + if (tagName.equalsIgnoreCase(HTML40Namespace.ElementName.HEAD)) { + if (!childName.equalsIgnoreCase(HTML40Namespace.ElementName.META) && !childName.equalsIgnoreCase(HTML40Namespace.ElementName.TITLE) && !childName.equalsIgnoreCase(HTML40Namespace.ElementName.LINK) && !childName.equalsIgnoreCase(HTML40Namespace.ElementName.STYLE) && !childName.equalsIgnoreCase(HTML40Namespace.ElementName.BASE) && !childName.equalsIgnoreCase(HTML40Namespace.ElementName.ISINDEX)) { + return false; + } + } + + Node parent = element.getParentNode(); + if (parent != null && parent.getNodeType() == Node.ELEMENT_NODE) { + XMLElement parentElement = (XMLElement) parent; + if (!parentElement.hasStartTag() && !parentElement.hasEndTag()) { + if (!canContain(parentElement, child)) + return false; + } + } + return true; + } + + // contexual termination for TABLE content tags + boolean isTableContent = false; + if (childName.equalsIgnoreCase(HTML40Namespace.ElementName.TBODY) || childName.equalsIgnoreCase(HTML40Namespace.ElementName.THEAD) || childName.equalsIgnoreCase(HTML40Namespace.ElementName.TFOOT)) { + if (tagName.equalsIgnoreCase(HTML40Namespace.ElementName.TABLE)) + return true; + isTableContent = true; + } + else if (childName.equalsIgnoreCase(HTML40Namespace.ElementName.TR)) { + if (tagName.equalsIgnoreCase(HTML40Namespace.ElementName.TBODY) || tagName.equalsIgnoreCase(HTML40Namespace.ElementName.THEAD) || tagName.equalsIgnoreCase(HTML40Namespace.ElementName.TFOOT) || tagName.equalsIgnoreCase(HTML40Namespace.ElementName.TABLE)) + return true; + isTableContent = true; + } + else if (childName.equalsIgnoreCase(HTML40Namespace.ElementName.TD) || childName.equalsIgnoreCase(HTML40Namespace.ElementName.TH)) { + if (tagName.equalsIgnoreCase(HTML40Namespace.ElementName.TR) || tagName.equalsIgnoreCase(HTML40Namespace.ElementName.TBODY) || tagName.equalsIgnoreCase(HTML40Namespace.ElementName.THEAD) || tagName.equalsIgnoreCase(HTML40Namespace.ElementName.TFOOT) || tagName.equalsIgnoreCase(HTML40Namespace.ElementName.TABLE)) + return true; + isTableContent = true; + } + if (isTableContent) { + // TABLE content tags should terminate non TABLE content tags, + // if in TABLE + for (Node parent = element.getParentNode(); parent != null; parent = parent.getParentNode()) { + if (parent.getNodeType() != Node.ELEMENT_NODE) + break; + XMLElement parentElement = (XMLElement) parent; + String parentName = parentElement.getTagName(); + if (parentName == null) + continue; + if (parentName.equalsIgnoreCase(HTML40Namespace.ElementName.TABLE)) + return false; + } + } + if (tagName.equalsIgnoreCase(HTML40Namespace.ElementName.EMBED)) { + if (!childName.equalsIgnoreCase(HTML40Namespace.ElementName.NOEMBED)) + return false; + } + } + else if (child.getNodeType() == Node.TEXT_NODE) { + String tagName = impl.getTagName(); + if (tagName != null && tagName.equalsIgnoreCase(HTML40Namespace.ElementName.EMBED)) { + XMLText text = (XMLText) child; + if (!text.isWhitespace()) + return false; + } + } + else if (child.getNodeType() == Node.DOCUMENT_TYPE_NODE) { + if (impl.isImplicitTag()) + return false; + } + + return true; + } + + /** + */ + public boolean canBeImplicitTag(Element element) { + return false; + } + + /** + */ + public boolean canBeImplicitTag(Element element, Node child) { + return false; + } + + /** + */ + public Element createCommentElement(Document document, String data, boolean isJSPTag) { + if (document == null || data == null || data.length() == 0) + return null; + + return createMetaElement(document, data, isJSPTag); + } + + /** + * This routine create an implicit Element for given parent and child, + * such as HTML, BODY, HEAD, and TBODY for HTML document. + */ + public Element createImplicitElement(Document document, Node parent, Node child) { + return null; + } + + /** + */ + private Element createMetaElement(Document document, String data, boolean isJSPTag) { + if (data == null || data.length() == 0) + return null; + + TagScanner scanner = new TagScanner(data, 0, true); // one line + String name = scanner.nextName(); + if (name == null || !name.equalsIgnoreCase(MetaData.METADATA)) + return null; + + String type = null; + boolean isStartSpan = false; + boolean isEndSpan = false; + name = scanner.nextName(); + while (name != null) { + String value = scanner.nextValue(); + if (name.equalsIgnoreCase(MetaData.TYPE)) { + if (value == null) + return null; + if (value.equalsIgnoreCase(MetaData.DESIGNER_CONTROL)) { + type = MetaData.DESIGNER_CONTROL; + } + else if (value.equalsIgnoreCase(MetaData.DYNAMIC_DATA)) { + type = MetaData.DYNAMIC_DATA; + } + else if (value.equalsIgnoreCase(MetaData.AUTHOR_TIME_VISUAL)) { + type = MetaData.AUTHOR_TIME_VISUAL; + } + else if (value.equalsIgnoreCase(MetaData.ANNOTATION)) { + type = MetaData.ANNOTATION; + } + else { + return null; + } + } + else if (name.equalsIgnoreCase(MetaData.STARTSPAN)) { + isStartSpan = true; + } + else if (name.equalsIgnoreCase(MetaData.ENDSPAN)) { + if (!isStartSpan) + isEndSpan = true; + } + name = scanner.nextName(); + } + if (type == null) + return null; + if (!isStartSpan && !isEndSpan) + return null; + String metaData = null; + int offset = scanner.getNextOffset(); // skip new line + if (offset < data.length()) + metaData = data.substring(offset); + if (metaData == null) + metaData = new String(); + + XMLElement element = (XMLElement) document.createElement(MetaData.PREFIX + type); + + MetaDataAdapter adapter = new MetaDataAdapter(type); + if (isStartSpan) { + if (metaData != null) + adapter.setData(metaData); + } + else { + if (metaData != null) + adapter.setEndData(metaData); + } + element.addAdapter(adapter); + adapter.setElement(element); + element.setJSPTag(isJSPTag); + + return element; + } + + /** + */ + public String getFindRootName(String tagName) { + if (tagName == null) + return null; + // tag matching should not beyond TABLE tag except BODY tag + if (tagName.equalsIgnoreCase(HTML40Namespace.ElementName.BODY)) + return null; + return HTML40Namespace.ElementName.TABLE; + } + + /** + */ + public boolean isAdapterForType(Object type) { + return (type == ModelParserAdapter.class); + } + + /** + */ + public boolean isEndTag(XMLElement element) { + TagAdapter adapter = (TagAdapter) element.getExistingAdapter(TagAdapter.class); + if (adapter != null) + return adapter.isEndTag(); + return element.isEndTag(); + } + + /** + */ + public void notifyChanged(INodeNotifier notifier, int eventType, Object changedFeature, Object oldValue, Object newValue, int pos) { + } + + private static boolean isValidChild(CMElementDeclaration parent, CMElementDeclaration child) { + if (parent == null || child == null) + return false; + CMContent content = parent.getContent(); + if (content == null) + return false; + return isChild(content, child); + } + + /** + */ + private static boolean isChild(CMContent content, CMElementDeclaration target) { + switch (content.getNodeType()) { + case CMNode.ELEMENT_DECLARATION : + return isSameDeclaration((CMElementDeclaration) content, target); + case CMNode.GROUP : + CMNodeList children = ((CMGroup) content).getChildNodes(); + for (int i = 0; i < children.getLength(); i++) { + CMNode child = children.item(i); + switch (child.getNodeType()) { + case CMNode.ELEMENT_DECLARATION : + if (isSameDeclaration((CMElementDeclaration) child, target)) + return true; + continue; // Go next child. + case CMNode.GROUP : + if (isChild((CMContent) child, target)) + return true; + continue; // Go next child. + default : + continue; // Go next child. + } + } + } + return false; + } + + /** + */ + private static boolean isSameDeclaration(CMElementDeclaration aDec, CMElementDeclaration otherDec) { + return aDec.getElementName() == otherDec.getElementName(); + } + +}
\ No newline at end of file diff --git a/bundles/org.eclipse.wst.html.core/src/org/eclipse/wst/html/core/document/HTMLModelParserAdapterFactory.java b/bundles/org.eclipse.wst.html.core/src/org/eclipse/wst/html/core/document/HTMLModelParserAdapterFactory.java new file mode 100644 index 0000000000..07a145fae7 --- /dev/null +++ b/bundles/org.eclipse.wst.html.core/src/org/eclipse/wst/html/core/document/HTMLModelParserAdapterFactory.java @@ -0,0 +1,70 @@ +/******************************************************************************* + * Copyright (c) 2004 IBM Corporation and others. + * All rights reserved. This program and the accompanying materials + * are made available under the terms of the Eclipse Public License v1.0 + * which accompanies this distribution, and is available at + * http://www.eclipse.org/legal/epl-v10.html + * + * Contributors: + * IBM Corporation - initial API and implementation + *******************************************************************************/ +package org.eclipse.wst.html.core.document; + + + +import org.eclipse.wst.sse.core.AdapterFactory; +import org.eclipse.wst.sse.core.INodeAdapter; +import org.eclipse.wst.sse.core.INodeNotifier; +import org.eclipse.wst.xml.core.internal.document.ModelParserAdapter; + +/** + */ +public class HTMLModelParserAdapterFactory implements AdapterFactory { + + private static HTMLModelParserAdapterFactory instance = null; + + /** + */ + private HTMLModelParserAdapterFactory() { + super(); + } + + /** + * Method that returns the adapter associated with the given object. + * It may be a singleton or not ... depending on the needs of the INodeAdapter ... + * but in general it is recommended for an adapter to be stateless, + * so the efficiencies of a singleton can be gained. + * + * The implementation of this method should call addAdapter on the adapted + * object with the correct instance of the adapter. + */ + public INodeAdapter adapt(INodeNotifier notifier) { + return new HTMLModelParserAdapter(); + } + + /** + */ + public synchronized static HTMLModelParserAdapterFactory getInstance() { + if (instance == null) + instance = new HTMLModelParserAdapterFactory(); + return instance; + } + + /** + */ + public boolean isFactoryForType(Object type) { + return (type == ModelParserAdapter.class); + } + + /** + */ + public void release() { + } + + /** + * Overriding copy method + */ + public AdapterFactory copy() { + return getInstance(); + } +}
\ No newline at end of file diff --git a/bundles/org.eclipse.wst.html.core/src/org/eclipse/wst/html/core/document/MetaData.java b/bundles/org.eclipse.wst.html.core/src/org/eclipse/wst/html/core/document/MetaData.java new file mode 100644 index 0000000000..31e732edcb --- /dev/null +++ b/bundles/org.eclipse.wst.html.core/src/org/eclipse/wst/html/core/document/MetaData.java @@ -0,0 +1,28 @@ +/******************************************************************************* + * Copyright (c) 2004 IBM Corporation and others. + * All rights reserved. This program and the accompanying materials + * are made available under the terms of the Eclipse Public License v1.0 + * which accompanies this distribution, and is available at + * http://www.eclipse.org/legal/epl-v10.html + * + * Contributors: + * IBM Corporation - initial API and implementation + *******************************************************************************/ +package org.eclipse.wst.html.core.document; + + + +/** + */ +public interface MetaData { + + static final String METADATA = "METADATA";//$NON-NLS-1$ + static final String TYPE = "type";//$NON-NLS-1$ + static final String STARTSPAN = "startspan";//$NON-NLS-1$ + static final String ENDSPAN = "endspan";//$NON-NLS-1$ + static final String DESIGNER_CONTROL = "DesignerControl";//$NON-NLS-1$ + static final String DYNAMIC_DATA = "DynamicData";//$NON-NLS-1$ + static final String AUTHOR_TIME_VISUAL = "AuthorTimeVisual";//$NON-NLS-1$ + static final String ANNOTATION = "Annotation";//$NON-NLS-1$ + static final String PREFIX = "METADATA:";//$NON-NLS-1$ +}
\ No newline at end of file diff --git a/bundles/org.eclipse.wst.html.core/src/org/eclipse/wst/html/core/document/MetaDataAdapter.java b/bundles/org.eclipse.wst.html.core/src/org/eclipse/wst/html/core/document/MetaDataAdapter.java new file mode 100644 index 0000000000..a509467ea3 --- /dev/null +++ b/bundles/org.eclipse.wst.html.core/src/org/eclipse/wst/html/core/document/MetaDataAdapter.java @@ -0,0 +1,283 @@ +/******************************************************************************* + * Copyright (c) 2004 IBM Corporation and others. + * All rights reserved. This program and the accompanying materials + * are made available under the terms of the Eclipse Public License v1.0 + * which accompanies this distribution, and is available at + * http://www.eclipse.org/legal/epl-v10.html + * + * Contributors: + * IBM Corporation - initial API and implementation + *******************************************************************************/ +package org.eclipse.wst.html.core.document; + + + +import java.util.Iterator; + +import org.eclipse.wst.sse.core.INodeNotifier; +import org.eclipse.wst.sse.core.text.IStructuredDocument; +import org.eclipse.wst.sse.core.text.IStructuredDocumentRegion; +import org.eclipse.wst.sse.core.text.ITextRegion; +import org.eclipse.wst.sse.core.text.ITextRegionList; +import org.eclipse.wst.xml.core.document.TagAdapter; +import org.eclipse.wst.xml.core.document.XMLElement; +import org.eclipse.wst.xml.core.document.XMLModel; +import org.eclipse.wst.xml.core.jsp.model.parser.temp.XMLJSPRegionContexts; +import org.eclipse.wst.xml.core.parser.XMLRegionContext; + +/** + */ +public class MetaDataAdapter implements TagAdapter, MetaData { + + private XMLElement element = null; + private String type = null; + private String data = null; + private String endData = null; + + /** + */ + public MetaDataAdapter(String type) { + super(); + + if (type != null) { + if (type.equals(ANNOTATION)) { + this.type = ANNOTATION; + } + else if (type.equals(AUTHOR_TIME_VISUAL)) { + this.type = AUTHOR_TIME_VISUAL; + } + else { + this.type = type; + } + } + } + + /** + */ + private String getData(IStructuredDocumentRegion flatNode) { + if (flatNode == null) + return null; + ITextRegionList regions = flatNode.getRegions(); + if (regions == null) + return null; + + String data = null; + Iterator e = regions.iterator(); + while (e.hasNext()) { + ITextRegion region = (ITextRegion) e.next(); + String regionType = region.getType(); + if (regionType == XMLRegionContext.XML_COMMENT_TEXT || regionType == XMLJSPRegionContexts.JSP_COMMENT_TEXT) { + data = flatNode.getText(region); + break; + } + } + if (data == null) + return null; + int length = data.length(); + int offset = 0; + for (; offset < length; offset++) { + char c = data.charAt(offset); + if (c == '\r' || c == '\n') { + offset++; + break; + } + } + for (; offset < length; offset++) { + char c = data.charAt(offset); + if (c != '\r' && c != '\n') { + break; + } + } + return data.substring(offset); + } + + /** + */ + public String getData() { + if (this.element == null) + return null; + IStructuredDocumentRegion flatNode = this.element.getStartStructuredDocumentRegion(); + if (flatNode == null) + return null; + if (this.data != null) + return this.data; + return getData(flatNode); + } + + /** + */ + private String getDelimiter(XMLModel model) { + String delim = null; + if (model != null) { + IStructuredDocument structuredDocument = model.getStructuredDocument(); + if (structuredDocument != null) + delim = structuredDocument.getLineDelimiter(); + } + if (delim == null) + delim = "\r\n";//$NON-NLS-1$ + return delim; + } + + /** + */ + public String getEndData() { + if (this.element == null) + return null; + IStructuredDocumentRegion flatNode = this.element.getEndStructuredDocumentRegion(); + if (flatNode == null) + return null; + if (this.endData != null) + return this.endData; + return getData(flatNode); + } + + /** + */ + public String getEndTag(XMLElement element) { + StringBuffer buffer = new StringBuffer(); + if (element.isJSPTag()) + buffer.append("<%--");//$NON-NLS-1$ + else + buffer.append("<!--");//$NON-NLS-1$ + buffer.append(METADATA); + buffer.append(' '); + buffer.append(TYPE); + buffer.append("=\"");//$NON-NLS-1$ + buffer.append(this.type); + buffer.append("\" ");//$NON-NLS-1$ + buffer.append(MetaData.ENDSPAN); + String data = getEndData(); + if (data != null && data.length() > 0) { + String delim = getDelimiter(element.getModel()); + buffer.append(delim); + buffer.append(data); + buffer.append(delim); + } + if (element.isJSPTag()) + buffer.append("--%>");//$NON-NLS-1$ + else + buffer.append("-->");//$NON-NLS-1$ + + return buffer.toString(); + } + + /** + */ + public String getStartTag(XMLElement element) { + StringBuffer buffer = new StringBuffer(); + if (element.isJSPTag()) + buffer.append("<%--");//$NON-NLS-1$ + else + buffer.append("<!--");//$NON-NLS-1$ + buffer.append(METADATA); + buffer.append(' '); + buffer.append(TYPE); + buffer.append("=\"");//$NON-NLS-1$ + buffer.append(this.type); + buffer.append("\" ");//$NON-NLS-1$ + buffer.append(MetaData.STARTSPAN); + String data = getData(); + if (data != null && data.length() > 0) { + String delim = getDelimiter(element.getModel()); + buffer.append(delim); + buffer.append(data); + buffer.append(delim); + } + if (element.isJSPTag()) + buffer.append("--%>");//$NON-NLS-1$ + else + buffer.append("-->");//$NON-NLS-1$ + + return buffer.toString(); + } + + /** + */ + public String getType() { + return this.type; + } + + /** + */ + public boolean isAdapterForType(Object type) { + return (type == TagAdapter.class || type == MetaDataAdapter.class); + } + + /** + */ + public boolean isEndTag() { + if (this.element == null) + return false; + if (this.element.hasStartTag()) + return false; + if (this.element.hasEndTag()) + return true; + if (this.data != null) + return false; + return (this.endData != null); + } + + /** + */ + public boolean isRuntimeContainer() { + return (this.type == ANNOTATION || this.type == AUTHOR_TIME_VISUAL); + } + + /** + */ + public void notifyChanged(INodeNotifier notifier, int eventType, Object changedFeature, Object oldValue, Object newValue, int pos) { + } + + /** + */ + public void setData(String data) { + this.data = data; + + if (this.element != null) + this.element.notifyStartTagChanged(); + } + + /** + */ + public void setEndData(String data) { + this.endData = data; + + if (this.element != null) + this.element.notifyEndTagChanged(); + } + + /** + */ + public void setElement(XMLElement element) { + this.element = element; + + if (this.element != null) { + this.element.setCommentTag(true); + if (this.type != MetaData.ANNOTATION) { + this.element.setJSPTag(true); + } + } + } + + /** + */ + public void setRuntimeSource(String source) { + if (source == null) + return; + if (this.element == null) + return; + if (isRuntimeContainer()) + return; + + XMLModel model = this.element.getModel(); + if (model == null) + return; + IStructuredDocument structuredDocument = model.getStructuredDocument(); + if (structuredDocument == null) + return; + int offset = this.element.getStartEndOffset(); + int end = this.element.getEndStartOffset(); + int length = end - offset; + structuredDocument.replaceText(model, offset, length, source); + } +}
\ No newline at end of file diff --git a/bundles/org.eclipse.wst.html.core/src/org/eclipse/wst/html/core/document/TagScanner.java b/bundles/org.eclipse.wst.html.core/src/org/eclipse/wst/html/core/document/TagScanner.java new file mode 100644 index 0000000000..b099e55f3a --- /dev/null +++ b/bundles/org.eclipse.wst.html.core/src/org/eclipse/wst/html/core/document/TagScanner.java @@ -0,0 +1,166 @@ +/******************************************************************************* + * Copyright (c) 2004 IBM Corporation and others. + * All rights reserved. This program and the accompanying materials + * are made available under the terms of the Eclipse Public License v1.0 + * which accompanies this distribution, and is available at + * http://www.eclipse.org/legal/epl-v10.html + * + * Contributors: + * IBM Corporation - initial API and implementation + *******************************************************************************/ +package org.eclipse.wst.html.core.document; + + + +/** + */ +class TagScanner { + + private String tag = null; + private int offset = 0; + private int length = 0; + private boolean oneLine = false; + + /** + */ + TagScanner(String tag, int offset) { + super(); + + this.tag = tag; + this.offset = offset; + if (tag != null) + this.length = tag.length(); + } + + /** + */ + TagScanner(String tag, int offset, boolean oneLine) { + this(tag, offset); + + this.oneLine = oneLine; + } + + /** + */ + int getNextOffset() { + for (; this.offset < this.length; this.offset++) { + char c = this.tag.charAt(this.offset); + if (!isEnd(c)) + break; + } + return this.offset; + } + + /** + */ + int getOffset() { + return this.offset; + } + + /** + */ + private final boolean isEnd(char c) { + return (this.oneLine && (c == '\r' || c == '\n')); + } + + /** + */ + private static boolean isEqual(char c) { + return (c == '='); + } + + /** + */ + private static boolean isQuote(char c) { + return (c == '"' || c == '\''); + } + + /** + */ + private static boolean isSpace(char c) { + return Character.isWhitespace(c); + } + + /** + */ + private char nextChar() { + for (; this.offset < this.length; this.offset++) { + char c = this.tag.charAt(this.offset); + if (isEnd(c)) + break; + if (!isSpace(c)) + return c; + } + return 0; + } + + /** + */ + String nextName() { + if (this.tag == null) + return null; + if (this.offset >= this.length) + return null; + + if (nextChar() == 0) + return null; + + int nameOffset = this.offset; + for (; this.offset < this.length; this.offset++) { + char c = this.tag.charAt(this.offset); + if (isEnd(c) || isSpace(c)) + break; + if (isEqual(c) && this.offset > nameOffset) + break; + } + if (this.offset == nameOffset) + return null; + + return this.tag.substring(nameOffset, this.offset); + } + + /** + */ + String nextValue() { + if (this.tag == null) + return null; + if (this.offset >= this.length) + return null; + + char seperator = nextChar(); + if (!isEqual(seperator)) + return null; + this.offset++; // skip '=' + char quote = nextChar(); + if (quote == 0) + return null; + if (isQuote(quote)) + this.offset++; + else + quote = 0; + + int valueOffset = this.offset; + for (; this.offset < this.length; this.offset++) { + char c = this.tag.charAt(this.offset); + if (isEnd(c)) { + quote = 0; + break; + } + if (quote == 0) { + if (isSpace(c)) + break; + } + else { + if (c == quote) + break; + } + } + int valueEnd = this.offset; + if (quote != 0 && this.offset < this.length) + this.offset++; + if (valueEnd == valueOffset) + return null; + + return this.tag.substring(valueOffset, valueEnd); + } +}
\ No newline at end of file diff --git a/bundles/org.eclipse.wst.html.core/src/org/eclipse/wst/html/core/document/UnknownTagAdapter.java b/bundles/org.eclipse.wst.html.core/src/org/eclipse/wst/html/core/document/UnknownTagAdapter.java new file mode 100644 index 0000000000..d320ac9305 --- /dev/null +++ b/bundles/org.eclipse.wst.html.core/src/org/eclipse/wst/html/core/document/UnknownTagAdapter.java @@ -0,0 +1,82 @@ +/******************************************************************************* + * Copyright (c) 2004 IBM Corporation and others. + * All rights reserved. This program and the accompanying materials + * are made available under the terms of the Eclipse Public License v1.0 + * which accompanies this distribution, and is available at + * http://www.eclipse.org/legal/epl-v10.html + * + * Contributors: + * IBM Corporation - initial API and implementation + *******************************************************************************/ +package org.eclipse.wst.html.core.document; + + + +import org.eclipse.wst.sse.core.INodeNotifier; +import org.eclipse.wst.xml.core.document.TagAdapter; +import org.eclipse.wst.xml.core.document.XMLElement; + +/** + */ +public class UnknownTagAdapter implements TagAdapter { + + private String startTag = null; + private String endTag = null; + + /** + */ + public UnknownTagAdapter() { + super(); + } + + /** + */ + public String getEndTag(XMLElement element) { + String tag = null; + if (this.endTag != null) { + tag = this.endTag; + this.endTag = null; + } + return tag; + } + + /** + */ + public String getStartTag(XMLElement element) { + String tag = null; + if (this.startTag != null) { + tag = this.startTag; + this.startTag = null; + } + return tag; + } + + /** + */ + public boolean isAdapterForType(Object type) { + return (type == TagAdapter.class); + } + + /** + */ + public boolean isEndTag() { + return false; + } + + /** + */ + public void notifyChanged(INodeNotifier notifier, int eventType, Object changedFeature, Object oldValue, Object newValue, int pos) { + } + + /** + */ + public void setEndTag(String endTag) { + this.endTag = endTag; + } + + /** + */ + public void setStartTag(String startTag) { + this.startTag = startTag; + } +}
\ No newline at end of file diff --git a/bundles/org.eclipse.wst.html.core/src/org/eclipse/wst/html/core/document/XMLStyleModelImpl.java b/bundles/org.eclipse.wst.html.core/src/org/eclipse/wst/html/core/document/XMLStyleModelImpl.java new file mode 100644 index 0000000000..62ea67e7ad --- /dev/null +++ b/bundles/org.eclipse.wst.html.core/src/org/eclipse/wst/html/core/document/XMLStyleModelImpl.java @@ -0,0 +1,67 @@ +/******************************************************************************* + * Copyright (c) 2001, 2004 IBM Corporation and others. + * All rights reserved. This program and the accompanying materials + * are made available under the terms of the Eclipse Public License v1.0 + * which accompanies this distribution, and is available at + * http://www.eclipse.org/legal/epl-v10.html + * + * Contributors: + * IBM Corporation - initial API and implementation + *******************************************************************************/ +/* + * Created on Sep 2, 2003 + * + * To change the template for this generated file go to + * Window>Preferences>Java>Code Generation>Code and Comments + */ +package org.eclipse.wst.html.core.document; + +import org.eclipse.wst.xml.core.internal.document.XMLModelImpl; +import org.w3c.dom.Document; + +/** + * @author davidw + * + * To change the template for this generated type comment go to + * Window>Preferences>Java>Code Generation>Code and Comments + */ +public class XMLStyleModelImpl extends XMLModelImpl { + public XMLStyleModelImpl() { + // remember, the document is created in super constructor, + // via internalCreateDocument + super(); + } + + public void releaseFromEdit() { + releaseStyleSheets(); + super.releaseFromEdit(); + } + + /** + */ + public void releaseFromRead() { + releaseStyleSheets(); + super.releaseFromRead(); + } + + private void releaseStyleSheets() { + if (!isShared()) { + Document doc = getDocument(); + if (doc instanceof DocumentStyleImpl) { + ((DocumentStyleImpl) doc).releaseStyleSheets(); + } + } + } + + /** + * createDocument method + * @return org.w3c.dom.Document + */ + protected Document internalCreateDocument() { + DocumentStyleImpl document = new DocumentStyleImpl(); + document.setModel(this); + return document; + } + + +}
\ No newline at end of file diff --git a/bundles/org.eclipse.wst.html.core/src/org/eclipse/wst/html/core/encoding/HTMLDocumentCharsetDetector.java b/bundles/org.eclipse.wst.html.core/src/org/eclipse/wst/html/core/encoding/HTMLDocumentCharsetDetector.java new file mode 100644 index 0000000000..01f8808e0d --- /dev/null +++ b/bundles/org.eclipse.wst.html.core/src/org/eclipse/wst/html/core/encoding/HTMLDocumentCharsetDetector.java @@ -0,0 +1,42 @@ +/******************************************************************************* + * Copyright (c) 2004 IBM Corporation and others. + * All rights reserved. This program and the accompanying materials + * are made available under the terms of the Eclipse Public License v1.0 + * which accompanies this distribution, and is available at + * http://www.eclipse.org/legal/epl-v10.html + * + * Contributors: + * IBM Corporation - initial API and implementation + *******************************************************************************/ +package org.eclipse.wst.html.core.encoding; + +import org.eclipse.jface.text.IDocument; +import org.eclipse.wst.html.core.internal.contenttype.HTMLResourceEncodingDetector; +import org.eclipse.wst.sse.core.document.DocumentReader; +import org.eclipse.wst.sse.core.document.IDocumentCharsetDetector; + +/** + * This class parses beginning portion of HTML file to get the encoding value + * in a META tag. Example: + * <META http-equiv="Content-Type" content="text/html; charset=ISO-8859-1"> + * + * Note: even though, technically, a META tag must come in a <HEAD>tag, we + * don't check for that, under the assumption that whatever, or whereever, the + * the first <META>tag is, it is the one intended to be used by the user, and + * they may just be trying to repair the error. The HTML validator will tell + * them if its in the wrong location. + * + */ +public class HTMLDocumentCharsetDetector extends HTMLResourceEncodingDetector implements IDocumentCharsetDetector { + + + public HTMLDocumentCharsetDetector() { + super(); + } + + public void set(IDocument document) { + set(new DocumentReader(document, 0)); + + + } +}
\ No newline at end of file diff --git a/bundles/org.eclipse.wst.html.core/src/org/eclipse/wst/html/core/encoding/HTMLDocumentLoader.java b/bundles/org.eclipse.wst.html.core/src/org/eclipse/wst/html/core/encoding/HTMLDocumentLoader.java new file mode 100644 index 0000000000..57f112e458 --- /dev/null +++ b/bundles/org.eclipse.wst.html.core/src/org/eclipse/wst/html/core/encoding/HTMLDocumentLoader.java @@ -0,0 +1,166 @@ +/******************************************************************************* + * Copyright (c) 2004 IBM Corporation and others. + * All rights reserved. This program and the accompanying materials + * are made available under the terms of the Eclipse Public License v1.0 + * which accompanies this distribution, and is available at + * http://www.eclipse.org/legal/epl-v10.html + * + * Contributors: + * IBM Corporation - initial API and implementation + *******************************************************************************/ +package org.eclipse.wst.html.core.encoding; + +import java.util.ArrayList; +import java.util.List; + +import org.eclipse.jface.text.IDocumentPartitioner; +import org.eclipse.wst.common.encoding.ContentTypeEncodingPreferences; +import org.eclipse.wst.common.encoding.EncodingGuesser; +import org.eclipse.wst.common.encoding.content.IContentTypeIdentifier; +import org.eclipse.wst.html.core.document.HTMLDocumentTypeAdapterFactory; +import org.eclipse.wst.html.core.document.HTMLModelParserAdapterFactory; +import org.eclipse.wst.html.core.htmlcss.HTMLStyleSelectorAdapterFactory; +import org.eclipse.wst.html.core.htmlcss.StyleAdapterFactory; +import org.eclipse.wst.html.core.internal.text.rules.StructuredTextPartitionerForHTML; +import org.eclipse.wst.html.core.modelquery.ModelQueryAdapterFactoryForHTML; +import org.eclipse.wst.sse.core.AdapterFactory; +import org.eclipse.wst.sse.core.INodeNotifier; +import org.eclipse.wst.sse.core.IStructuredModel; +import org.eclipse.wst.sse.core.PropagatingAdapter; +import org.eclipse.wst.sse.core.document.AbstractDocumentLoader; +import org.eclipse.wst.sse.core.document.IDocumentCharsetDetector; +import org.eclipse.wst.sse.core.document.IDocumentLoader; +import org.eclipse.wst.sse.core.document.IEncodedDocument; +import org.eclipse.wst.sse.core.document.StructuredDocumentFactory; +import org.eclipse.wst.sse.core.internal.text.BasicStructuredDocument; +import org.eclipse.wst.sse.core.parser.BlockMarker; +import org.eclipse.wst.sse.core.parser.RegionParser; +import org.eclipse.wst.sse.core.text.IStructuredDocument; +import org.eclipse.wst.xml.core.document.XMLModel; +import org.eclipse.wst.xml.core.internal.parser.XMLSourceParser; +import org.eclipse.wst.xml.core.internal.parser.XMLStructuredDocumentReParser; +import org.eclipse.wst.xml.core.internal.propagate.PropagatingAdapterFactoryImpl; +import org.eclipse.wst.xml.core.parser.XMLRegionContext; + +public class HTMLDocumentLoader extends AbstractDocumentLoader { + + public HTMLDocumentLoader() { + super(); + } + + /** + * Convenience method to add tag names using BlockMarker object + */ + protected void addHTMLishTag(XMLSourceParser parser, String tagname) { + //DMW: Nitin, perhaps we should provide some convenience methods + // in the parser itself? e.g. addCaseInsensitiveBlockedTag(tagname) + BlockMarker bm = new BlockMarker(tagname, null, XMLRegionContext.BLOCK_TEXT, false); + parser.addBlockMarker(bm); + } + + /** + * Default encoding. For HTML, there is no spec. + */ + protected String getSpecDefaultEncoding() { + return null; + } + + /** + * @return java.lang.String + * @param string + * byte[] + * @param length + * int + * + * Do automatic encoding detection by guess + */ + protected String getEncodingNameByGuess(byte[] string, int length) { + final String ianaEnc = EncodingGuesser.guessEncoding(string, length); + return ianaEnc; + } + + /* + * @see AbstractLoader#createNewStructuredDocument() + */ + protected IEncodedDocument newEncodedDocument() { + IStructuredDocument structuredDocument = StructuredDocumentFactory.getNewStructuredDocumentInstance(getParser()); + ((BasicStructuredDocument) structuredDocument).setReParser(new XMLStructuredDocumentReParser()); + + return structuredDocument; + } + + /* + * @see ModelLoader#getParser() + */ + public RegionParser getParser() { + XMLSourceParser parser = new XMLSourceParser(); + // for the "static HTML" case, we need to initialize + // Blocktags here. + addHTMLishTag(parser, "script"); //$NON-NLS-1$ + addHTMLishTag(parser, "style"); //$NON-NLS-1$ + return parser; + } + + /** + * This method must return those factories which must be attached to the + * structuredModel before content is applied. + */ + public List getAdapterFactories() { + List result = new ArrayList(); + AdapterFactory factory = null; + factory = StyleAdapterFactory.getInstance(); + result.add(factory); + factory = HTMLStyleSelectorAdapterFactory.getInstance(); + result.add(factory); + factory = HTMLDocumentTypeAdapterFactory.getInstance(); + result.add(factory); + factory = HTMLModelParserAdapterFactory.getInstance(); + result.add(factory); + // + factory = new ModelQueryAdapterFactoryForHTML(); + result.add(factory); + + factory = new PropagatingAdapterFactoryImpl(); + result.add(factory); + + + return result; + } + + protected String getPreferredNewLineDelimiter() { + return ContentTypeEncodingPreferences.getPreferredNewLineDelimiter(IContentTypeIdentifier.ContentTypeID_HTML); + } + + public IDocumentCharsetDetector getDocumentEncodingDetector() { + if (fDocumentEncodingDetector == null) { + fDocumentEncodingDetector = new HTMLDocumentCharsetDetector(); + } + return fDocumentEncodingDetector; + } + + protected void preLoadAdapt(IStructuredModel structuredModel) { + // * TODO - how to best handle model requirements + // * if/when document already loaded? + // DMW: just added this preload on 8/16/2002 + // I noticed the ProagatingAdapterFactory was being added, + // that that the ProagatingAdapterAdapter was not being + // preload adapted -- I'm assuing it ALWAYS has to be. + XMLModel domModel = (XMLModel) structuredModel; + // if there is a model in the adapter, this will adapt it to + // first node. After that the PropagatingAdater spreads over the + // children being + // created. Each time that happends, a side effect is to + // also "spread" sprecific registered adapters, + // they two can propigate is needed. + ((INodeNotifier) domModel.getDocument()).getAdapterFor(PropagatingAdapter.class); + } + + public IDocumentPartitioner getDefaultDocumentPartitioner() { + return new StructuredTextPartitionerForHTML(); + } + + public IDocumentLoader newInstance() { + return new HTMLDocumentLoader(); + } + +}
\ No newline at end of file diff --git a/bundles/org.eclipse.wst.html.core/src/org/eclipse/wst/html/core/encoding/HTMLModelLoader.java b/bundles/org.eclipse.wst.html.core/src/org/eclipse/wst/html/core/encoding/HTMLModelLoader.java new file mode 100644 index 0000000000..8f2cc454df --- /dev/null +++ b/bundles/org.eclipse.wst.html.core/src/org/eclipse/wst/html/core/encoding/HTMLModelLoader.java @@ -0,0 +1,114 @@ +/******************************************************************************* + * Copyright (c) 2004 IBM Corporation and others. + * All rights reserved. This program and the accompanying materials + * are made available under the terms of the Eclipse Public License v1.0 + * which accompanies this distribution, and is available at + * http://www.eclipse.org/legal/epl-v10.html + * + * Contributors: + * IBM Corporation - initial API and implementation + *******************************************************************************/ +package org.eclipse.wst.html.core.encoding; + +import java.util.ArrayList; +import java.util.List; + +import org.eclipse.wst.html.core.document.HTMLDocumentTypeAdapterFactory; +import org.eclipse.wst.html.core.document.HTMLModelParserAdapterFactory; +import org.eclipse.wst.html.core.document.XMLStyleModelImpl; +import org.eclipse.wst.html.core.htmlcss.HTMLStyleSelectorAdapterFactory; +import org.eclipse.wst.html.core.htmlcss.StyleAdapterFactory; +import org.eclipse.wst.html.core.modelquery.ModelQueryAdapterFactoryForHTML; +import org.eclipse.wst.sse.core.AbstractModelLoader; +import org.eclipse.wst.sse.core.AdapterFactory; +import org.eclipse.wst.sse.core.INodeNotifier; +import org.eclipse.wst.sse.core.IStructuredModel; +import org.eclipse.wst.sse.core.ModelLoader; +import org.eclipse.wst.sse.core.PropagatingAdapter; +import org.eclipse.wst.sse.core.document.IDocumentLoader; +import org.eclipse.wst.sse.core.parser.BlockMarker; +import org.eclipse.wst.sse.core.util.Debug; +import org.eclipse.wst.xml.core.document.XMLModel; +import org.eclipse.wst.xml.core.internal.DebugAdapterFactory; +import org.eclipse.wst.xml.core.internal.parser.XMLSourceParser; +import org.eclipse.wst.xml.core.internal.propagate.PropagatingAdapterFactoryImpl; +import org.eclipse.wst.xml.core.parser.XMLRegionContext; + +public class HTMLModelLoader extends AbstractModelLoader { + + + public HTMLModelLoader() { + super(); + } + + /** + * Convenience method to add tag names using BlockMarker object + */ + protected void addHTMLishTag(XMLSourceParser parser, String tagname) { + //DMW: Nitin, perhaps we should provide some convenience methods + // in the parser itself? e.g. addCaseInsensitiveBlockedTag(tagname) + BlockMarker bm = new BlockMarker(tagname, null, XMLRegionContext.BLOCK_TEXT, false); + parser.addBlockMarker(bm); + } + + public IStructuredModel newModel() { + XMLStyleModelImpl model = new XMLStyleModelImpl(); + return model; + } + + /** + * This method must return those factories which must be attached to the + * structuredModel before content is applied. + */ + public List getAdapterFactories() { + List result = new ArrayList(); + AdapterFactory factory = null; + factory = StyleAdapterFactory.getInstance(); + result.add(factory); + factory = HTMLStyleSelectorAdapterFactory.getInstance(); + result.add(factory); + factory = HTMLDocumentTypeAdapterFactory.getInstance(); + result.add(factory); + factory = HTMLModelParserAdapterFactory.getInstance(); + result.add(factory); + // + factory = new ModelQueryAdapterFactoryForHTML(); + result.add(factory); + + factory = new PropagatingAdapterFactoryImpl(); + result.add(factory); + + + return result; + } + + protected void preLoadAdapt(IStructuredModel structuredModel) { + super.preLoadAdapt(structuredModel); + // DMW: just added this preload on 8/16/2002 + // I noticed the ProagatingAdapterFactory was being added, + // that that the ProagatingAdapterAdapter was not being + // preload adapted -- I'm assuing it ALWAYS has to be. + XMLModel domModel = (XMLModel) structuredModel; + // if there is a model in the adapter, this will adapt it to + // first node. After that the PropagatingAdater spreads over the + // children being + // created. Each time that happends, a side effect is to + // also "spread" sprecific registered adapters, + // they two can propigate is needed. + ((INodeNotifier) domModel.getDocument()).getAdapterFor(PropagatingAdapter.class); + if (Debug.debugNotificationAndEvents) { + PropagatingAdapter propagatingAdapter = (PropagatingAdapter) ((INodeNotifier) domModel.getDocument()).getAdapterFor(PropagatingAdapter.class); + propagatingAdapter.addAdaptOnCreateFactory(new DebugAdapterFactory()); + } } + + public ModelLoader newInstance() { + return new HTMLModelLoader(); + } + + public IDocumentLoader getDocumentLoader() { + if (documentLoaderInstance == null) { + documentLoaderInstance = new HTMLDocumentLoader(); + } + return documentLoaderInstance; + } +}
\ No newline at end of file diff --git a/bundles/org.eclipse.wst.html.core/src/org/eclipse/wst/html/core/format/EmbeddedCSSFormatter.java b/bundles/org.eclipse.wst.html.core/src/org/eclipse/wst/html/core/format/EmbeddedCSSFormatter.java new file mode 100644 index 0000000000..1ed9273904 --- /dev/null +++ b/bundles/org.eclipse.wst.html.core/src/org/eclipse/wst/html/core/format/EmbeddedCSSFormatter.java @@ -0,0 +1,90 @@ +/******************************************************************************* + * Copyright (c) 2004 IBM Corporation and others. + * All rights reserved. This program and the accompanying materials + * are made available under the terms of the Eclipse Public License v1.0 + * which accompanies this distribution, and is available at + * http://www.eclipse.org/legal/epl-v10.html + * + * Contributors: + * IBM Corporation - initial API and implementation + *******************************************************************************/ +package org.eclipse.wst.html.core.format; + + + +import org.eclipse.wst.css.core.adapters.IStyleSheetAdapter; +import org.eclipse.wst.css.core.document.ICSSModel; +import org.eclipse.wst.css.core.document.ICSSNode; +import org.eclipse.wst.css.core.format.CSSSourceFormatter; +import org.eclipse.wst.html.core.HTMLFormatContraints; +import org.eclipse.wst.sse.core.INodeAdapter; +import org.eclipse.wst.sse.core.INodeNotifier; +import org.eclipse.wst.xml.core.document.XMLNode; +import org.eclipse.wst.xml.core.document.XMLText; + +// nakamori_TODO: check and remove + +public class EmbeddedCSSFormatter extends HTMLFormatter { + + //private AdapterFactory factory = new CSSSourceFormatterFactory(CSSSourceFormatter.class, true); + /** + */ + protected EmbeddedCSSFormatter() { + super(); + } + + /** + */ + protected void formatNode(XMLNode node, HTMLFormatContraints contraints) { + if (node == null) + return; + XMLText text = (XMLText) node; + + String source = getCSSContent(node); + if (source == null) { // fallback + source = text.getSource(); + } + + int offset = text.getStartOffset(); + int length = text.getEndOffset() - offset; + replaceSource(text.getModel(), offset, length, source); + setWidth(contraints, source); + } + + /** + */ + private String getCSSContent(XMLNode text) { + ICSSModel model = getCSSModel(text); + if (model == null) + return null; + ICSSNode document = model.getDocument(); + if (document == null) + return null; + INodeNotifier notifier = (INodeNotifier) document; + INodeAdapter adapter = notifier.getAdapterFor(CSSSourceFormatter.class); + if (adapter == null) + return null; + CSSSourceFormatter formatter = (CSSSourceFormatter) adapter; + StringBuffer buffer = formatter.format(document); + if (buffer == null) + return null; + return buffer.toString(); + } + + /** + */ + private ICSSModel getCSSModel(XMLNode text) { + if (text == null) + return null; + INodeNotifier notifier = (INodeNotifier) text.getParentNode(); + if (notifier == null) + return null; + INodeAdapter adapter = notifier.getAdapterFor(IStyleSheetAdapter.class); + if (adapter == null) + return null; + if (!(adapter instanceof IStyleSheetAdapter)) + return null; + IStyleSheetAdapter styleAdapter = (IStyleSheetAdapter) adapter; + return styleAdapter.getModel(); + } +}
\ No newline at end of file diff --git a/bundles/org.eclipse.wst.html.core/src/org/eclipse/wst/html/core/format/HTMLElementFormatter.java b/bundles/org.eclipse.wst.html.core/src/org/eclipse/wst/html/core/format/HTMLElementFormatter.java new file mode 100644 index 0000000000..983ba21ad2 --- /dev/null +++ b/bundles/org.eclipse.wst.html.core/src/org/eclipse/wst/html/core/format/HTMLElementFormatter.java @@ -0,0 +1,333 @@ +/******************************************************************************* + * Copyright (c) 2004 IBM Corporation and others. + * All rights reserved. This program and the accompanying materials + * are made available under the terms of the Eclipse Public License v1.0 + * which accompanies this distribution, and is available at + * http://www.eclipse.org/legal/epl-v10.html + * + * Contributors: + * IBM Corporation - initial API and implementation + *******************************************************************************/ +package org.eclipse.wst.html.core.format; + +import java.util.Iterator; + +import org.eclipse.wst.css.core.adapters.IStyleDeclarationAdapter; +import org.eclipse.wst.css.core.document.ICSSModel; +import org.eclipse.wst.css.core.document.ICSSNode; +import org.eclipse.wst.css.core.format.CSSSourceFormatter; +import org.eclipse.wst.html.core.HTMLFormatContraints; +import org.eclipse.wst.sse.core.INodeAdapter; +import org.eclipse.wst.sse.core.INodeNotifier; +import org.eclipse.wst.sse.core.text.IStructuredDocumentRegion; +import org.eclipse.wst.sse.core.text.ITextRegion; +import org.eclipse.wst.sse.core.text.ITextRegionList; +import org.eclipse.wst.xml.core.document.XMLElement; +import org.eclipse.wst.xml.core.document.XMLNode; +import org.eclipse.wst.xml.core.format.IStructuredFormatPreferencesXML; +import org.eclipse.wst.xml.core.jsp.model.parser.temp.XMLJSPRegionContexts; +import org.eclipse.wst.xml.core.parser.XMLRegionContext; +import org.w3c.dom.Attr; +import org.w3c.dom.NamedNodeMap; + +// nakamori_TODO: check and remove CSS formatting + +public class HTMLElementFormatter extends HTMLFormatter implements XMLRegionContext, XMLJSPRegionContexts { + + /** + */ + protected HTMLElementFormatter() { + super(); + } + + /** + */ + private void compressTailingSpaces(IStructuredDocumentRegion flatNode, ITextRegion region) { + int offset = region.getTextEnd(); + int count = region.getEnd() - offset; + if (count == 1) { + String source = flatNode.getFullText(region); + int start = region.getStart(); + if (source != null && source.charAt(offset - start) == ' ') { + // nothing to do + return; + } + } + replaceSource(flatNode, offset, count, " ");//$NON-NLS-1$ + } + + /** + */ + private void formatEndTag(XMLElement element, HTMLFormatContraints contraints) { + IStructuredDocumentRegion endStructuredDocumentRegion = element.getEndStructuredDocumentRegion(); + if (endStructuredDocumentRegion == null) + return; + + if (element.isJSPTag() || element.isCommentTag()) { + String endTag = endStructuredDocumentRegion.getText(); + if (endTag != null && endTag.length() > 0) { + setWidth(contraints, endTag); + } + return; + } + + ITextRegion prevRegion = null; + ITextRegionList regions = endStructuredDocumentRegion.getRegions(); + Iterator e = regions.iterator(); + while (e.hasNext()) { + ITextRegion region = (ITextRegion) e.next(); + if (region == null) + continue; + String regionType = region.getType(); + if (regionType == XML_TAG_NAME || regionType == JSP_ROOT_TAG_NAME || regionType == JSP_DIRECTIVE_NAME) { + if (prevRegion != null && prevRegion.getType() == XML_END_TAG_OPEN) { + removeTailingSpaces(endStructuredDocumentRegion, prevRegion); + } + } + else if (regionType == XML_TAG_CLOSE) { + if (prevRegion != null && (prevRegion.getType() == XML_TAG_NAME || prevRegion.getType() == JSP_ROOT_TAG_NAME)) { + removeTailingSpaces(endStructuredDocumentRegion, prevRegion); + } + } + prevRegion = region; + } + if (prevRegion != null && (prevRegion.getType() == XML_TAG_NAME || prevRegion.getType() == JSP_ROOT_TAG_NAME)) { + removeTailingSpaces(endStructuredDocumentRegion, prevRegion); + } + + String newEndTag = endStructuredDocumentRegion.getText(); + if (newEndTag != null && newEndTag.length() > 0) { + setWidth(contraints, newEndTag); + } + } + + /** + */ + protected void formatNode(XMLNode node, HTMLFormatContraints contraints) { + if (node == null) + return; + XMLElement element = (XMLElement) node; + + formatStartTag(element, contraints); + + formatChildNodes(element, contraints); + + formatEndTag(element, contraints); + } + + /** + */ + private void formatStartTag(XMLElement element, HTMLFormatContraints contraints) { + IStructuredDocumentRegion startStructuredDocumentRegion = element.getStartStructuredDocumentRegion(); + if (startStructuredDocumentRegion == null) + return; + + // We should format attributes in JSPTag? + //if (element.isJSPTag() || element.isCommentTag()) { + if (element.isCommentTag()) { + String startTag = startStructuredDocumentRegion.getText(); + if (startTag != null && startTag.length() > 0) { + setWidth(contraints, startTag); + } + return; + } + + // first process style attribute + if (element.isGlobalTag()) { + Attr attr = element.getAttributeNode("style");//$NON-NLS-1$ + if (attr != null) + formatStyleAttr(attr); + } + boolean insertBreak = false; + insertBreak = ((IStructuredFormatPreferencesXML) getFormatPreferences()).getSplitMultiAttrs(); + + if (insertBreak) { + NamedNodeMap attributes = element.getAttributes(); + if (attributes == null || attributes.getLength() < 2) + insertBreak = false; + } + String breakSpaces = getBreakSpaces(element); + String indent = getIndent(); + if (indent != null && indent.length() > 0) { + breakSpaces += indent; + } + ITextRegion lastBreakRegion = null; + + ITextRegion prevRegion = null; + ITextRegionList regions = startStructuredDocumentRegion.getRegions(); + Iterator e = regions.iterator(); + while (e.hasNext()) { + ITextRegion region = (ITextRegion) e.next(); + if (region == null) + continue; + + ITextRegion breakRegion = null; + + String regionType = region.getType(); + if (regionType == XML_TAG_NAME || regionType == JSP_ROOT_TAG_NAME || regionType == JSP_DIRECTIVE_NAME) { + if (prevRegion != null && prevRegion.getType() == XML_TAG_OPEN) { + removeTailingSpaces(startStructuredDocumentRegion, prevRegion); + } + breakRegion = region; + } + else if (regionType == XML_TAG_ATTRIBUTE_NAME) { + if (prevRegion != null && (prevRegion.getType() == XML_TAG_ATTRIBUTE_NAME || prevRegion.getType() == XML_TAG_ATTRIBUTE_EQUALS)) { + // attribute name without value + breakRegion = prevRegion; + } + } + else if (regionType == XML_TAG_ATTRIBUTE_EQUALS) { + if (prevRegion != null && prevRegion.getType() == XML_TAG_ATTRIBUTE_NAME) { + removeTailingSpaces(startStructuredDocumentRegion, prevRegion); + } + } + else if (regionType == XML_TAG_ATTRIBUTE_VALUE) { + if (prevRegion != null && prevRegion.getType() == XML_TAG_ATTRIBUTE_EQUALS) { + removeTailingSpaces(startStructuredDocumentRegion, prevRegion); + } + breakRegion = region; + } + else if (regionType == XML_TAG_CLOSE || regionType == XML_EMPTY_TAG_CLOSE) { + if (prevRegion != null && (prevRegion.getType() == XML_TAG_ATTRIBUTE_NAME || prevRegion.getType() == XML_TAG_ATTRIBUTE_EQUALS)) { + // attribute name without value + breakRegion = prevRegion; + } + } + + if (breakRegion != null) { + int end = breakRegion.getTextEnd(); + if (lastBreakRegion != null) { + int offset = lastBreakRegion.getEnd(); + int count = end - offset; + if (insertBreak || !isWidthAvailable(contraints, count + 1)) { + replaceTailingSpaces(startStructuredDocumentRegion, lastBreakRegion, breakSpaces); + setWidth(contraints, breakSpaces); + } + else { + compressTailingSpaces(startStructuredDocumentRegion, lastBreakRegion); + addWidth(contraints, 1); + } + addWidth(contraints, count); + } + else { + addWidth(contraints, end); + } + lastBreakRegion = breakRegion; + } + + prevRegion = region; + } + if (prevRegion != null && (prevRegion.getType() == XML_TAG_ATTRIBUTE_NAME || prevRegion.getType() == XML_TAG_ATTRIBUTE_EQUALS)) { + // attribute name without value + int end = prevRegion.getTextEnd(); + if (lastBreakRegion != null) { + int offset = lastBreakRegion.getEnd(); + int count = end - offset; + if (insertBreak || !isWidthAvailable(contraints, count + 1)) { + replaceTailingSpaces(startStructuredDocumentRegion, lastBreakRegion, breakSpaces); + setWidth(contraints, breakSpaces); + } + else { + compressTailingSpaces(startStructuredDocumentRegion, lastBreakRegion); + addWidth(contraints, 1); + } + addWidth(contraints, count); + } + else { + addWidth(contraints, end); + } + lastBreakRegion = prevRegion; + } + + if (lastBreakRegion != null) { + int offset = lastBreakRegion.getTextEnd(); + int count = startStructuredDocumentRegion.getLength() - offset; + if (prevRegion != null && prevRegion.getType() == XML_EMPTY_TAG_CLOSE) { + compressTailingSpaces(startStructuredDocumentRegion, lastBreakRegion); + count++; + } + else + removeTailingSpaces(startStructuredDocumentRegion, lastBreakRegion); + addWidth(contraints, count); + } + else { + addWidth(contraints, startStructuredDocumentRegion.getLength()); + } + } + + /** + */ + private void formatStyleAttr(Attr attr) { + if (attr == null) + return; + String value = getCSSValue(attr); + if (value == null) + return; + String oldValue = ((XMLNode) attr).getValueSource(); + if (oldValue != null && value.equals(oldValue)) + return; + attr.setValue(value); + } + + /** + */ + private ICSSModel getCSSModel(Attr attr) { + if (attr == null) + return null; + INodeNotifier notifier = (INodeNotifier) attr.getOwnerElement(); + if (notifier == null) + return null; + INodeAdapter adapter = notifier.getAdapterFor(IStyleDeclarationAdapter.class); + if (adapter == null) + return null; + if (!(adapter instanceof IStyleDeclarationAdapter)) + return null; + IStyleDeclarationAdapter styleAdapter = (IStyleDeclarationAdapter) adapter; + return styleAdapter.getModel(); + } + + /** + */ + private String getCSSValue(Attr attr) { + ICSSModel model = getCSSModel(attr); + if (model == null) + return null; + ICSSNode document = model.getDocument(); + if (document == null) + return null; + INodeNotifier notifier = (INodeNotifier) document; + INodeAdapter adapter = notifier.getAdapterFor(CSSSourceFormatter.class); + if (adapter == null) + return null; + CSSSourceFormatter formatter = (CSSSourceFormatter) adapter; + StringBuffer buffer = formatter.format(document); + if (buffer == null) + return null; + return buffer.toString(); + } + + /** + */ + private void removeTailingSpaces(IStructuredDocumentRegion flatNode, ITextRegion region) { + int offset = region.getTextEnd(); + int count = region.getEnd() - offset; + if (count <= 0) + return; + replaceSource(flatNode, offset, count, null); + } + + /** + */ + private void replaceTailingSpaces(IStructuredDocumentRegion flatNode, ITextRegion region, String spaces) { + int offset = region.getTextEnd(); + int count = region.getEnd() - offset; + if (count == spaces.length()) { + String source = flatNode.getFullText(region); + if (source != null && source.endsWith(spaces)) { + // nothing to do + return; + } + } + replaceSource(flatNode, offset, count, spaces); + } +}
\ No newline at end of file diff --git a/bundles/org.eclipse.wst.html.core/src/org/eclipse/wst/html/core/format/HTMLFormatContraintsImpl.java b/bundles/org.eclipse.wst.html.core/src/org/eclipse/wst/html/core/format/HTMLFormatContraintsImpl.java new file mode 100644 index 0000000000..06c61cac56 --- /dev/null +++ b/bundles/org.eclipse.wst.html.core/src/org/eclipse/wst/html/core/format/HTMLFormatContraintsImpl.java @@ -0,0 +1,42 @@ +/******************************************************************************* + * Copyright (c) 2004 IBM Corporation and others. + * All rights reserved. This program and the accompanying materials + * are made available under the terms of the Eclipse Public License v1.0 + * which accompanies this distribution, and is available at + * http://www.eclipse.org/legal/epl-v10.html + * + * Contributors: + * IBM Corporation - initial API and implementation + *******************************************************************************/ +package org.eclipse.wst.html.core.format; + +import org.eclipse.wst.html.core.HTMLFormatContraints; +import org.eclipse.wst.sse.core.format.StructuredFormatContraints; + +/** + * @deprecated + * Please un-deprecate this if Page Designer thinks they are needed. + */ +public class HTMLFormatContraintsImpl extends StructuredFormatContraints implements HTMLFormatContraints { + protected int fAvailableLineWidth; + + /** + * @deprecated + * It's very hard to keep the available line width accurate. + * Sometimes a node wants to start on a new line, sometimes it doesn't. + * It's best for the node to figure out the available line width on the fly. + */ + public int getAvailableLineWidth() { + return fAvailableLineWidth; + } + + /** + * @deprecated + * It's very hard to keep the available line width accurate. + * Sometimes a node wants to start on a new line, sometimes it doesn't. + * It's best for the node to figure out the available line width on the fly. + */ + public void setAvailableLineWidth(int availableLineWidth) { + fAvailableLineWidth = availableLineWidth; + } +}
\ No newline at end of file diff --git a/bundles/org.eclipse.wst.html.core/src/org/eclipse/wst/html/core/format/HTMLFormatProcessorImpl.java b/bundles/org.eclipse.wst.html.core/src/org/eclipse/wst/html/core/format/HTMLFormatProcessorImpl.java new file mode 100644 index 0000000000..d5e8132bfd --- /dev/null +++ b/bundles/org.eclipse.wst.html.core/src/org/eclipse/wst/html/core/format/HTMLFormatProcessorImpl.java @@ -0,0 +1,67 @@ +/******************************************************************************* + * Copyright (c) 2004 IBM Corporation and others. + * All rights reserved. This program and the accompanying materials + * are made available under the terms of the Eclipse Public License v1.0 + * which accompanies this distribution, and is available at + * http://www.eclipse.org/legal/epl-v10.html + * + * Contributors: + * IBM Corporation - initial API and implementation + *******************************************************************************/ +package org.eclipse.wst.html.core.format; + +import org.eclipse.core.runtime.Platform; +import org.eclipse.core.runtime.Preferences; +import org.eclipse.wst.html.core.HTMLCorePlugin; +import org.eclipse.wst.sse.core.IModelManagerPlugin; +import org.eclipse.wst.sse.core.format.IStructuredFormatPreferences; +import org.eclipse.wst.sse.core.format.IStructuredFormatter; +import org.eclipse.wst.sse.core.preferences.CommonModelPreferenceNames; +import org.eclipse.wst.xml.core.format.FormatProcessorXML; +import org.eclipse.wst.xml.core.format.IStructuredFormatPreferencesXML; +import org.eclipse.wst.xml.core.format.StructuredFormatPreferencesXML; +import org.w3c.dom.Node; + +public class HTMLFormatProcessorImpl extends FormatProcessorXML { + protected String getFileExtension() { + return "html"; //$NON-NLS-1$ + } + + protected IStructuredFormatter getFormatter(Node node) { + IStructuredFormatter formatter = HTMLFormatterFactory.getInstance().createFormatter(node, getFormatPreferences()); + + return formatter; + } + + public IStructuredFormatPreferences getFormatPreferences() { + if (fFormatPreferences == null) { + fFormatPreferences = new StructuredFormatPreferencesXML(); + + Preferences preferences = HTMLCorePlugin.getDefault().getPluginPreferences(); + if (preferences != null) { + fFormatPreferences.setLineWidth(preferences.getInt(CommonModelPreferenceNames.LINE_WIDTH)); + ((IStructuredFormatPreferencesXML) fFormatPreferences).setSplitMultiAttrs(preferences.getBoolean(CommonModelPreferenceNames.SPLIT_MULTI_ATTRS)); + fFormatPreferences.setClearAllBlankLines(preferences.getBoolean(CommonModelPreferenceNames.CLEAR_ALL_BLANK_LINES)); + + if (preferences.getBoolean(CommonModelPreferenceNames.INDENT_USING_TABS)) + fFormatPreferences.setIndent("\t"); //$NON-NLS-1$ + else { + int tabWidth = getModelManagerPlugin().getPluginPreferences().getInt(CommonModelPreferenceNames.TAB_WIDTH); + String indent = ""; //$NON-NLS-1$ + for (int i = 0; i < tabWidth; i++) { + indent += " "; //$NON-NLS-1$ + } + fFormatPreferences.setIndent(indent); + } + } + } + + return fFormatPreferences; + } + + private IModelManagerPlugin getModelManagerPlugin() { + + IModelManagerPlugin plugin = (IModelManagerPlugin) Platform.getPlugin(IModelManagerPlugin.ID); + return plugin; + } +}
\ No newline at end of file diff --git a/bundles/org.eclipse.wst.html.core/src/org/eclipse/wst/html/core/format/HTMLFormatter.java b/bundles/org.eclipse.wst.html.core/src/org/eclipse/wst/html/core/format/HTMLFormatter.java new file mode 100644 index 0000000000..1cc89110ce --- /dev/null +++ b/bundles/org.eclipse.wst.html.core/src/org/eclipse/wst/html/core/format/HTMLFormatter.java @@ -0,0 +1,659 @@ +/******************************************************************************* + * Copyright (c) 2004 IBM Corporation and others. + * All rights reserved. This program and the accompanying materials + * are made available under the terms of the Eclipse Public License v1.0 + * which accompanies this distribution, and is available at + * http://www.eclipse.org/legal/epl-v10.html + * + * Contributors: + * IBM Corporation - initial API and implementation + *******************************************************************************/ +package org.eclipse.wst.html.core.format; + + + +import org.eclipse.core.runtime.IProgressMonitor; +import org.eclipse.core.runtime.Platform; +import org.eclipse.core.runtime.Preferences; +import org.eclipse.jface.text.BadLocationException; +import org.eclipse.wst.common.contentmodel.CMElementDeclaration; +import org.eclipse.wst.common.contentmodel.modelquery.ModelQuery; +import org.eclipse.wst.html.core.HTMLCMProperties; +import org.eclipse.wst.html.core.HTMLCorePlugin; +import org.eclipse.wst.html.core.HTMLFormatContraints; +import org.eclipse.wst.sse.core.IModelManagerPlugin; +import org.eclipse.wst.sse.core.format.IStructuredFormatContraints; +import org.eclipse.wst.sse.core.format.IStructuredFormatPreferences; +import org.eclipse.wst.sse.core.format.IStructuredFormatter; +import org.eclipse.wst.sse.core.preferences.CommonModelPreferenceNames; +import org.eclipse.wst.sse.core.text.IStructuredDocument; +import org.eclipse.wst.sse.core.text.IStructuredDocumentRegion; +import org.eclipse.wst.xml.core.document.XMLElement; +import org.eclipse.wst.xml.core.document.XMLModel; +import org.eclipse.wst.xml.core.document.XMLNode; +import org.eclipse.wst.xml.core.format.IStructuredFormatPreferencesXML; +import org.eclipse.wst.xml.core.format.StructuredFormatPreferencesXML; +import org.eclipse.wst.xml.core.modelquery.ModelQueryUtil; +import org.w3c.dom.Document; +import org.w3c.dom.Element; +import org.w3c.dom.Node; + +public class HTMLFormatter implements IStructuredFormatter { + + private static final String HTML_NAME = "html";//$NON-NLS-1$ + private static final String BODY_NAME = "BODY";//$NON-NLS-1$ + + /** + */ + protected void addWidth(HTMLFormatContraints contraints, int width) { + if (contraints == null) + return; + if (!splitLines() || getLineWidth() < 0) + return; + + int availableWidth = contraints.getAvailableLineWidth() - width; + if (availableWidth < 0) + availableWidth = 0; + contraints.setAvailableLineWidth(availableWidth); + } + + /** + */ + protected boolean canFormatChild(Node node) { + while (node != null) { + if (node.getNodeType() != Node.ELEMENT_NODE) + return true; + CMElementDeclaration decl = getElementDeclaration((Element) node); + if (decl != null) { + if (decl.getContentType() == CMElementDeclaration.CDATA) + return false; + if (decl.supports(HTMLCMProperties.SHOULD_KEEP_SPACE)) { + boolean shouldKeepSpace = ((Boolean) decl.getProperty(HTMLCMProperties.SHOULD_KEEP_SPACE)).booleanValue(); + if (shouldKeepSpace) + return false; + } + } + node = node.getParentNode(); + } + return false; + } + + /** + */ + protected boolean canInsertBreakAfter(CMElementDeclaration decl) { + if (decl == null) + return false; + if (!decl.supports(HTMLCMProperties.LINE_BREAK_HINT)) + return false; + String hint = (String) decl.getProperty(HTMLCMProperties.LINE_BREAK_HINT); + if (hint == null) + return false; + return (hint.equals(HTMLCMProperties.Values.BREAK_BEFORE_START_AND_AFTER_END) || hint.equals(HTMLCMProperties.Values.BREAK_AFTER_START)); + } + + /** + */ + protected boolean canInsertBreakAfter(Node node) { + if (node == null) + return false; + Node parent = node.getParentNode(); + if (parent == null) + return false; + Node next = node.getNextSibling(); + + if (parent.getNodeType() == Node.DOCUMENT_NODE) { + if (node.getNodeType() == Node.ELEMENT_NODE) { + // do not insert break after unclosed tag + if (!((XMLElement) node).isClosed()) + return false; + } + return true; + } + else if (parent.getNodeType() == Node.ELEMENT_NODE) { + XMLElement element = (XMLElement) parent; + // do not insert break before missing end tag + if (next == null && element.getEndStructuredDocumentRegion() == null) + return false; + + // insert line break under non-HTML elements including JSP elements + if (element.getPrefix() != null) + return true; + + CMElementDeclaration decl = getElementDeclaration(element); + if (decl != null) { + if (decl.getContentType() == CMElementDeclaration.ELEMENT) + return true; + String tagName = element.getTagName(); + // special for direct children under BODY + if (tagName != null && tagName.equalsIgnoreCase(BODY_NAME)) + return true; + } + } + + if (node.getNodeType() == Node.ELEMENT_NODE) { + XMLElement element = (XMLElement) node; + CMElementDeclaration decl = getElementDeclaration(element); + if (canInsertBreakAfter(decl)) { + // spcial for BR + return canFormatChild(parent); + } + } + if (next != null && next.getNodeType() == Node.ELEMENT_NODE) { + CMElementDeclaration decl = getElementDeclaration((Element) next); + if (canInsertBreakBefore(decl)) + return true; + } + return false; + } + + /** + */ + protected boolean canInsertBreakBefore(CMElementDeclaration decl) { + if (decl == null) + return false; + if (!decl.supports(HTMLCMProperties.LINE_BREAK_HINT)) + return false; + String hint = (String) decl.getProperty(HTMLCMProperties.LINE_BREAK_HINT); + if (hint == null) + return false; + return hint.equals(HTMLCMProperties.Values.BREAK_BEFORE_START_AND_AFTER_END); + } + + /** + */ + protected boolean canInsertBreakBefore(Node node) { + if (node == null) + return false; + Node parent = node.getParentNode(); + if (parent == null) + return false; + Node prev = node.getPreviousSibling(); + + if (parent.getNodeType() == Node.DOCUMENT_NODE) { + if (prev == null) + return false; + return true; + } + else if (parent.getNodeType() == Node.ELEMENT_NODE) { + XMLElement element = (XMLElement) parent; + // do not insert break after missing start tag + if (prev == null && element.getStartStructuredDocumentRegion() == null) + return false; + + // insert line break under non-HTML elements including JSP elements + if (element.getPrefix() != null) + return true; + + CMElementDeclaration decl = getElementDeclaration(element); + if (decl != null) { + if (decl.getContentType() == CMElementDeclaration.ELEMENT) + return true; + String tagName = element.getTagName(); + // special for direct children under BODY + if (tagName != null && tagName.equalsIgnoreCase(BODY_NAME)) + return true; + } + } + + if (node.getNodeType() == Node.ELEMENT_NODE) { + CMElementDeclaration decl = getElementDeclaration((Element) node); + if (canInsertBreakBefore(decl)) + return true; + } + if (prev != null && prev.getNodeType() == Node.ELEMENT_NODE) { + CMElementDeclaration decl = getElementDeclaration((Element) prev); + if (canInsertBreakAfter(decl)) { + // spcial for BR + return canFormatChild(parent); + } + } + return false; + } + + /** + */ + public void format(Node node) { + format(node, getFormatContraints()); + } + + /** + */ + public void format(Node node, IStructuredFormatContraints contraints) { + if (node instanceof XMLNode && contraints instanceof HTMLFormatContraints) + format((XMLNode) node, (HTMLFormatContraints) contraints); + } + + public void format(XMLNode node, HTMLFormatContraints contraints) { + if (node == null) + return; + if (node.getParentNode() == null) + return; // do not format removed node + + setWidth(contraints, node); + + if (canInsertBreakBefore(node)) + insertBreakBefore(node, contraints); + + formatNode(node, contraints); + + if (canInsertBreakAfter(node)) + insertBreakAfter(node, contraints); + } + + /** + */ + protected void formatChildNodes(XMLNode node, HTMLFormatContraints contraints) { + if (node == null) + return; + if (!node.hasChildNodes()) + return; + + // concat adjacent texts + node.normalize(); + + // disable sibling indent during formatting all the children + boolean indent = false; + if (contraints != null) { + indent = contraints.getFormatWithSiblingIndent(); + contraints.setFormatWithSiblingIndent(false); + } + + boolean insertBreak = true; + XMLNode child = (XMLNode) node.getFirstChild(); + while (child != null) { + if (child.getParentNode() != node) + break; + XMLNode next = (XMLNode) child.getNextSibling(); + + if (insertBreak && canInsertBreakBefore(child)) { + insertBreakBefore(child, contraints); + } + + IStructuredFormatter formatter = HTMLFormatterFactory.getInstance().createFormatter(child, getFormatPreferences()); + if (formatter != null) { + if (formatter instanceof HTMLFormatter) { + HTMLFormatter htmlFormatter = (HTMLFormatter) formatter; + htmlFormatter.formatNode(child, contraints); + } + else { + formatter.format(child); + } + } + + if (canInsertBreakAfter(child)) { + insertBreakAfter(child, contraints); + insertBreak = false; // not to insert twice + } + else { + insertBreak = true; + } + + child = next; + } + + if (contraints != null) + contraints.setFormatWithSiblingIndent(indent); + } + + /** + */ + protected void formatNode(XMLNode node, HTMLFormatContraints contraints) { + if (node == null) + return; + + if (node.hasChildNodes()) { // container + formatChildNodes(node, contraints); + } + else { // leaf + IStructuredDocumentRegion flatNode = node.getStartStructuredDocumentRegion(); + if (flatNode != null) { + String source = flatNode.getText(); + if (source != null && source.length() > 0) { + setWidth(contraints, source); + } + } + } + } + + /** + */ + protected String getBreakSpaces(Node node) { + if (node == null) + return null; + StringBuffer buffer = new StringBuffer(); + + String delim = ((XMLNode) node).getModel().getStructuredDocument().getLineDelimiter(); + if (delim != null && delim.length() > 0) + buffer.append(delim); + + String indent = getIndent(); + if (indent != null && indent.length() > 0) { + for (Node parent = node.getParentNode(); parent != null; parent = parent.getParentNode()) { + if (parent.getNodeType() != Node.ELEMENT_NODE) + break; + // ignore omitted tag + if (((XMLNode) parent).getStartStructuredDocumentRegion() == null) + continue; + + XMLElement element = (XMLElement) parent; + if (element.getPrefix() != null) { + String localName = element.getLocalName(); + // special for html:html + if (localName != null && !localName.equals(HTML_NAME)) { + buffer.append(indent); + } + continue; + } + + CMElementDeclaration decl = getElementDeclaration(element); + if (decl != null && decl.supports(HTMLCMProperties.SHOULD_INDENT_CHILD_SOURCE)) { + boolean shouldIndent = ((Boolean) decl.getProperty(HTMLCMProperties.SHOULD_INDENT_CHILD_SOURCE)).booleanValue(); + if (shouldIndent) + buffer.append(indent); + } + + } + } + + return buffer.toString(); + } + + /** + */ + protected String getIndent() { + return getFormatPreferences().getIndent(); + } + + /** + */ + protected int getLineWidth() { + return getFormatPreferences().getLineWidth(); + } + + /** + */ + protected CMElementDeclaration getElementDeclaration(Element element) { + if (element == null) + return null; + Document document = element.getOwnerDocument(); + if (document == null) + return null; + ModelQuery modelQuery = ModelQueryUtil.getModelQuery(document); + if (modelQuery == null) + return null; + return modelQuery.getCMElementDeclaration(element); + } + + /** + */ + protected void insertBreakAfter(XMLNode node, HTMLFormatContraints contraints) { + if (node == null) + return; + if (node.getNodeType() == Node.TEXT_NODE) + return; + Node parent = node.getParentNode(); + if (parent == null) + return; + Node next = node.getNextSibling(); + + String spaces = null; + if (next == null) { // last spaces + // use parent indent for the end tag + spaces = getBreakSpaces(parent); + } + else if (next.getNodeType() == Node.TEXT_NODE) { + if (contraints != null && contraints.getFormatWithSiblingIndent()) { + XMLNode text = (XMLNode) next; + IStructuredFormatter formatter = HTMLFormatterFactory.getInstance().createFormatter(text, getFormatPreferences()); + if (formatter instanceof HTMLTextFormatter) { + HTMLTextFormatter textFormatter = (HTMLTextFormatter) formatter; + textFormatter.formatText(text, contraints, HTMLTextFormatter.FORMAT_HEAD); + } + } + return; + } + else { + spaces = getBreakSpaces(node); + } + if (spaces == null || spaces.length() == 0) + return; + + replaceSource(node.getModel(), node.getEndOffset(), 0, spaces); + setWidth(contraints, spaces); + } + + /** + */ + protected void insertBreakBefore(XMLNode node, HTMLFormatContraints contraints) { + if (node == null) + return; + if (node.getNodeType() == Node.TEXT_NODE) + return; + Node parent = node.getParentNode(); + if (parent == null) + return; + Node prev = node.getPreviousSibling(); + + String spaces = null; + if (prev != null && prev.getNodeType() == Node.TEXT_NODE) { + if (contraints != null && contraints.getFormatWithSiblingIndent()) { + XMLNode text = (XMLNode) prev; + IStructuredFormatter formatter = HTMLFormatterFactory.getInstance().createFormatter(text, getFormatPreferences()); + if (formatter instanceof HTMLTextFormatter) { + HTMLTextFormatter textFormatter = (HTMLTextFormatter) formatter; + textFormatter.formatText(text, contraints, HTMLTextFormatter.FORMAT_TAIL); + } + } + return; + } + else { + spaces = getBreakSpaces(node); + } + if (spaces == null || spaces.length() == 0) + return; + + replaceSource(node.getModel(), node.getStartOffset(), 0, spaces); + setWidth(contraints, spaces); + } + + /** + */ + protected boolean isWidthAvailable(HTMLFormatContraints contraints, int width) { + if (contraints == null) + return true; + if (!splitLines() || getLineWidth() < 0) + return true; + return (contraints.getAvailableLineWidth() >= width); + } + + /** + */ + protected boolean keepBlankLines(HTMLFormatContraints contraints) { + if (contraints == null) + return true; + return (!contraints.getClearAllBlankLines()); + } + + /** + */ + protected void replaceSource(IStructuredDocumentRegion flatNode, int offset, int length, String source) { + if (flatNode == null) + return; + IStructuredDocument structuredDocument = flatNode.getParentDocument(); + if (structuredDocument == null) + return; + if (source == null) + source = new String(); + int startOffset = flatNode.getStartOffset(); + if (structuredDocument.containsReadOnly(startOffset + offset, length)) + return; + // We use 'structuredDocument' as the requester object just so this and the other + // format-related 'repalceText' (in replaceSource) can use the same requester. + // Otherwise, if requester is not identical, + // the undo group gets "broken" into multiple pieces based + // on the requesters being different. Technically, any unique, common + // requester object would work. + structuredDocument.replaceText(structuredDocument, startOffset + offset, length, source); + } + + /** + */ + protected void replaceSource(XMLModel model, int offset, int length, String source) { + if (model == null) + return; + IStructuredDocument structuredDocument = model.getStructuredDocument(); + if (structuredDocument == null) + return; + if (source == null) + source = new String(); + if (structuredDocument.containsReadOnly(offset, length)) + return; + // We use 'structuredDocument' as the requester object just so this and the other + // format-related 'repalceText' (in replaceSource) can use the same requester. + // Otherwise, if requester is not identical, + // the undo group gets "broken" into multiple pieces based + // on the requesters being different. Technically, any unique, common + // requester object would work. + structuredDocument.replaceText(structuredDocument, offset, length, source); + } + + /** + */ + protected void setWidth(HTMLFormatContraints contraints, String source) { + if (contraints == null) + return; + if (source == null) + return; + int length = source.length(); + if (length == 0) + return; + + if (!splitLines()) + return; + int lineWidth = getLineWidth(); + if (lineWidth < 0) + return; + + int offset = source.lastIndexOf('\n'); + int offset2 = source.lastIndexOf('\r'); + if (offset2 > offset) + offset = offset2; + if (offset >= 0) + offset++; + + int availableWidth = 0; + if (offset >= 0) { + availableWidth = lineWidth - (length - offset); + } + else { + availableWidth = contraints.getAvailableLineWidth() - length; + } + if (availableWidth < 0) + availableWidth = 0; + contraints.setAvailableLineWidth(availableWidth); + } + + /** + */ + protected void setWidth(HTMLFormatContraints contraints, Node node) { + if (contraints == null) + return; + if (node == null) + return; + IStructuredDocument structuredDocument = ((XMLNode) node).getStructuredDocument(); + if (structuredDocument == null) + return; // error + + if (!splitLines()) + return; + int lineWidth = getLineWidth(); + if (lineWidth < 0) + return; + + int offset = ((XMLNode) node).getStartOffset(); + int line = structuredDocument.getLineOfOffset(offset); + int lineOffset = 0; + try { + lineOffset = structuredDocument.getLineOffset(line); + } + catch (BadLocationException ex) { + return; // error + } + if (lineOffset > offset) + return; // error + + int availableWidth = lineWidth - (offset - lineOffset); + if (availableWidth < 0) + availableWidth = 0; + + contraints.setAvailableLineWidth(availableWidth); + } + + /** + */ + protected boolean splitLines() { + return true;//getFormatPreferences().getSplitLines(); + } + + protected IStructuredFormatPreferences fFormatPreferences = null; + protected HTMLFormatContraints fFormatContraints = null; + protected IProgressMonitor fProgressMonitor = null; + + //public void format(XMLNode node, FormatContraints formatContraints) { + // if (formatContraints.getFormatWithSiblingIndent()) + // formatContraints.setCurrentIndent(getSiblingIndent(node)); + // + // formatNode(node, formatContraints); + //} + + public void setFormatPreferences(IStructuredFormatPreferences formatPreferences) { + fFormatPreferences = formatPreferences; + } + + public IStructuredFormatPreferences getFormatPreferences() { + if (fFormatPreferences == null) { + fFormatPreferences = new StructuredFormatPreferencesXML(); + + Preferences preferences = HTMLCorePlugin.getDefault().getPluginPreferences(); + if (preferences != null) { + fFormatPreferences.setLineWidth(preferences.getInt(CommonModelPreferenceNames.LINE_WIDTH)); + ((IStructuredFormatPreferencesXML) fFormatPreferences).setSplitMultiAttrs(preferences.getBoolean(CommonModelPreferenceNames.SPLIT_MULTI_ATTRS)); + fFormatPreferences.setClearAllBlankLines(preferences.getBoolean(CommonModelPreferenceNames.CLEAR_ALL_BLANK_LINES)); + + if (preferences.getBoolean(CommonModelPreferenceNames.INDENT_USING_TABS)) + fFormatPreferences.setIndent("\t"); //$NON-NLS-1$ + else { + int tabWidth = getModelManagerPlugin().getPluginPreferences().getInt(CommonModelPreferenceNames.TAB_WIDTH); + String indent = ""; //$NON-NLS-1$ + for (int i = 0; i < tabWidth; i++) { + indent += " "; //$NON-NLS-1$ + } + fFormatPreferences.setIndent(indent); + } + } + } + + return fFormatPreferences; + } + + public IStructuredFormatContraints getFormatContraints() { + if (fFormatContraints == null) { + fFormatContraints = new HTMLFormatContraintsImpl(); + + fFormatContraints.setAvailableLineWidth(getFormatPreferences().getLineWidth()); + fFormatContraints.setClearAllBlankLines(getFormatPreferences().getClearAllBlankLines()); + } + + return fFormatContraints; + } + + public void setProgressMonitor(IProgressMonitor progressMonitor) { + fProgressMonitor = progressMonitor; + } + + private IModelManagerPlugin getModelManagerPlugin() { + + IModelManagerPlugin plugin = (IModelManagerPlugin) Platform.getPlugin(IModelManagerPlugin.ID); + return plugin; + } +}
\ No newline at end of file diff --git a/bundles/org.eclipse.wst.html.core/src/org/eclipse/wst/html/core/format/HTMLFormatterFactory.java b/bundles/org.eclipse.wst.html.core/src/org/eclipse/wst/html/core/format/HTMLFormatterFactory.java new file mode 100644 index 0000000000..79d0cc740a --- /dev/null +++ b/bundles/org.eclipse.wst.html.core/src/org/eclipse/wst/html/core/format/HTMLFormatterFactory.java @@ -0,0 +1,115 @@ +/******************************************************************************* + * Copyright (c) 2004 IBM Corporation and others. + * All rights reserved. This program and the accompanying materials + * are made available under the terms of the Eclipse Public License v1.0 + * which accompanies this distribution, and is available at + * http://www.eclipse.org/legal/epl-v10.html + * + * Contributors: + * IBM Corporation - initial API and implementation + *******************************************************************************/ +package org.eclipse.wst.html.core.format; + +import org.eclipse.core.runtime.Platform; +import org.eclipse.core.runtime.Preferences; +import org.eclipse.wst.html.core.HTMLCorePlugin; +import org.eclipse.wst.sse.core.IModelManagerPlugin; +import org.eclipse.wst.sse.core.format.IStructuredFormatPreferences; +import org.eclipse.wst.sse.core.format.IStructuredFormatter; +import org.eclipse.wst.sse.core.preferences.CommonModelPreferenceNames; +import org.eclipse.wst.xml.core.format.IStructuredFormatPreferencesXML; +import org.eclipse.wst.xml.core.format.StructuredFormatPreferencesXML; +import org.w3c.dom.Node; + +// nakamori_TODO: check and remove CSS formatting + +class HTMLFormatterFactory { + private static HTMLFormatterFactory fInstance = null; + protected IStructuredFormatPreferencesXML fFormatPreferences = null; + + static synchronized HTMLFormatterFactory getInstance() { + if (fInstance == null) { + fInstance = new HTMLFormatterFactory(); + } + return fInstance; + } + + protected IStructuredFormatter createFormatter(Node node, IStructuredFormatPreferences formatPreferences) { + IStructuredFormatter formatter = null; + + switch (node.getNodeType()) { + case Node.ELEMENT_NODE : + formatter = new HTMLElementFormatter(); + break; + case Node.TEXT_NODE : + if (isEmbeddedCSS(node)) { + formatter = new EmbeddedCSSFormatter(); + } + else { + formatter = new HTMLTextFormatter(); + } + break; + default : + formatter = new HTMLFormatter(); + break; + } + + // init FormatPreferences + formatter.setFormatPreferences(formatPreferences); + + return formatter; + } + + /** + */ + private boolean isEmbeddedCSS(Node node) { + if (node == null) + return false; + Node parent = node.getParentNode(); + if (parent == null) + return false; + if (parent.getNodeType() != Node.ELEMENT_NODE) + return false; + String name = parent.getNodeName(); + if (name == null) + return false; + return name.equalsIgnoreCase("STYLE");//$NON-NLS-1$ + } + + + private HTMLFormatterFactory() { + super(); + } + + protected IStructuredFormatPreferencesXML getFormatPreferences() { + if (fFormatPreferences == null) { + fFormatPreferences = new StructuredFormatPreferencesXML(); + + Preferences preferences = HTMLCorePlugin.getDefault().getPluginPreferences(); + if (preferences != null) { + fFormatPreferences.setLineWidth(preferences.getInt(CommonModelPreferenceNames.LINE_WIDTH)); + fFormatPreferences.setSplitMultiAttrs(preferences.getBoolean(CommonModelPreferenceNames.SPLIT_MULTI_ATTRS)); + fFormatPreferences.setClearAllBlankLines(preferences.getBoolean(CommonModelPreferenceNames.CLEAR_ALL_BLANK_LINES)); + + if (preferences.getBoolean(CommonModelPreferenceNames.INDENT_USING_TABS)) + fFormatPreferences.setIndent("\t"); //$NON-NLS-1$ + else { + int tabWidth = getModelManagerPlugin().getPluginPreferences().getInt(CommonModelPreferenceNames.TAB_WIDTH); + String indent = ""; //$NON-NLS-1$ + for (int i = 0; i < tabWidth; i++) { + indent += " "; //$NON-NLS-1$ + } + fFormatPreferences.setIndent(indent); + } + } + } + + return fFormatPreferences; + } + + private IModelManagerPlugin getModelManagerPlugin() { + + IModelManagerPlugin plugin = (IModelManagerPlugin) Platform.getPlugin(IModelManagerPlugin.ID); + return plugin; + } +}
\ No newline at end of file diff --git a/bundles/org.eclipse.wst.html.core/src/org/eclipse/wst/html/core/format/HTMLStructuredFormattingStrategyImpl.java b/bundles/org.eclipse.wst.html.core/src/org/eclipse/wst/html/core/format/HTMLStructuredFormattingStrategyImpl.java new file mode 100644 index 0000000000..9ce048679d --- /dev/null +++ b/bundles/org.eclipse.wst.html.core/src/org/eclipse/wst/html/core/format/HTMLStructuredFormattingStrategyImpl.java @@ -0,0 +1,60 @@ +/******************************************************************************* + * Copyright (c) 2004 IBM Corporation and others. + * All rights reserved. This program and the accompanying materials + * are made available under the terms of the Eclipse Public License v1.0 + * which accompanies this distribution, and is available at + * http://www.eclipse.org/legal/epl-v10.html + * + * Contributors: + * IBM Corporation - initial API and implementation + *******************************************************************************/ +package org.eclipse.wst.html.core.format; + +import org.eclipse.core.runtime.IProgressMonitor; +import org.eclipse.jface.text.source.ISourceViewer; +import org.eclipse.wst.sse.core.IStructuredModel; +import org.eclipse.wst.sse.core.format.IStructuredFormatProcessor; +import org.eclipse.wst.sse.core.format.IStructuredFormattingStrategy; + +public class HTMLStructuredFormattingStrategyImpl implements IStructuredFormattingStrategy { + + private String fInitialIndentation; + private ISourceViewer fViewer; + protected IProgressMonitor fProgressMonitor = null; + + /** + * Constructor for HTMLStructuredFormattingStrategyImpl. + */ + public HTMLStructuredFormattingStrategyImpl(ISourceViewer viewer) { + fViewer = viewer; + } + + /** + * @see org.eclipse.jface.text.formatter.IFormattingStrategy#formatterStarts(java.lang.String) + */ + public void formatterStarts(String initialIndentation) { + fInitialIndentation = initialIndentation; + } + + /** + * @see org.eclipse.jface.text.formatter.IFormattingStrategy#format(java.lang.String, boolean, java.lang.String, int) + */ + public String format(String content, boolean isLineStart, String indentation, int[] positions) { + return content; + } + + public void format(IStructuredModel model, int start, int length, boolean isLineStart, String indentation, int[] positions) { + IStructuredFormatProcessor formatProcessor = new HTMLFormatProcessorImpl(); + formatProcessor.formatModel(model, start, length); + } + + /** + * @see org.eclipse.jface.text.formatter.IFormattingStrategy#formatterStops() + */ + public void formatterStops() { + } + + public void setProgressMonitor(IProgressMonitor progressMonitor) { + fProgressMonitor = progressMonitor; + } +}
\ No newline at end of file diff --git a/bundles/org.eclipse.wst.html.core/src/org/eclipse/wst/html/core/format/HTMLTextFormatter.java b/bundles/org.eclipse.wst.html.core/src/org/eclipse/wst/html/core/format/HTMLTextFormatter.java new file mode 100644 index 0000000000..dd0650abfb --- /dev/null +++ b/bundles/org.eclipse.wst.html.core/src/org/eclipse/wst/html/core/format/HTMLTextFormatter.java @@ -0,0 +1,281 @@ +/******************************************************************************* + * Copyright (c) 2004 IBM Corporation and others. + * All rights reserved. This program and the accompanying materials + * are made available under the terms of the Eclipse Public License v1.0 + * which accompanies this distribution, and is available at + * http://www.eclipse.org/legal/epl-v10.html + * + * Contributors: + * IBM Corporation - initial API and implementation + *******************************************************************************/ +package org.eclipse.wst.html.core.format; + + + +import org.eclipse.wst.common.contentmodel.CMElementDeclaration; +import org.eclipse.wst.html.core.HTMLCMProperties; +import org.eclipse.wst.html.core.HTMLFormatContraints; +import org.eclipse.wst.sse.core.text.IStructuredDocumentRegion; +import org.eclipse.wst.xml.core.document.XMLElement; +import org.eclipse.wst.xml.core.document.XMLNode; +import org.eclipse.wst.xml.core.document.XMLText; +import org.eclipse.wst.xml.core.jsp.model.parser.temp.XMLJSPRegionContexts; +import org.eclipse.wst.xml.core.parser.XMLRegionContext; +import org.w3c.dom.Element; +import org.w3c.dom.Node; + +public class HTMLTextFormatter extends HTMLFormatter { + + public static int FORMAT_ALL = 0; + public static int FORMAT_HEAD = 1; + public static int FORMAT_TAIL = 2; + + /** + */ + protected HTMLTextFormatter() { + super(); + } + + /** + */ + private boolean canFormatText(XMLText text) { + if (text == null) + return false; + + IStructuredDocumentRegion flatNode = text.getFirstStructuredDocumentRegion(); + if (flatNode != null) { + String type = flatNode.getType(); + if (type == XMLJSPRegionContexts.JSP_CONTENT || type == XMLRegionContext.BLOCK_TEXT) + return false; + } + + Node parent = text.getParentNode(); + if (parent != null && parent.getNodeType() == Node.ELEMENT_NODE) { + XMLElement element = (XMLElement) parent; + if (!element.isGlobalTag() && !text.isWhitespace()) + return false; + } + + return canFormatChild(parent); + } + + /** + */ + private boolean canRemoveHeadingSpaces(XMLNode node) { + if (node == null) + return false; + if (node.getPreviousSibling() != null) + return false; + Node parent = node.getParentNode(); + if (parent == null || parent.getNodeType() != Node.ELEMENT_NODE) + return false; + + CMElementDeclaration decl = getElementDeclaration((Element) parent); + if (decl == null || (!decl.supports(HTMLCMProperties.LINE_BREAK_HINT))) + return false; + String hint = (String) decl.getProperty(HTMLCMProperties.LINE_BREAK_HINT); + return hint.equals(HTMLCMProperties.Values.BREAK_BEFORE_START_AND_AFTER_END); + } + + /** + */ + private boolean canRemoveTailingSpaces(XMLNode node) { + if (node == null) + return false; + if (node.getNextSibling() != null) + return false; + Node parent = node.getParentNode(); + if (parent == null || parent.getNodeType() != Node.ELEMENT_NODE) + return false; + + CMElementDeclaration decl = getElementDeclaration((Element) parent); + if (decl == null || (!decl.supports(HTMLCMProperties.LINE_BREAK_HINT))) + return false; + String hint = (String) decl.getProperty(HTMLCMProperties.LINE_BREAK_HINT); + return hint.equals(HTMLCMProperties.Values.BREAK_BEFORE_START_AND_AFTER_END); + } + + /** + */ + protected void formatNode(XMLNode node, HTMLFormatContraints contraints) { + formatText(node, contraints, FORMAT_ALL); // full format + } + + /** + */ + protected void formatText(XMLNode node, HTMLFormatContraints contraints, int mode) { + if (node == null) + return; + Node parent = node.getParentNode(); + if (parent == null) + return; + + XMLText text = (XMLText) node; + String source = text.getSource(); + + if (!canFormatText(text)) { + setWidth(contraints, source); + return; + } + + int offset = text.getStartOffset(); + int length = text.getEndOffset() - offset; + + // format adjacent text at once + if (mode == FORMAT_HEAD) { + Node next = node.getNextSibling(); + while (next != null && next.getNodeType() == Node.TEXT_NODE) { + XMLText nextText = (XMLText) next; + length += (nextText.getEndOffset() - nextText.getStartOffset()); + String nextSource = nextText.getSource(); + if (nextSource != null && nextSource.length() > 0) { + if (source == null) + source = nextSource; + else + source += nextSource; + } + next = next.getNextSibling(); + } + } + else if (mode == FORMAT_TAIL) { + Node prev = node.getPreviousSibling(); + while (prev != null && prev.getNodeType() == Node.TEXT_NODE) { + XMLText prevText = (XMLText) prev; + offset = prevText.getStartOffset(); + length += (prevText.getEndOffset() - offset); + String prevSource = prevText.getSource(); + if (prevSource != null && prevSource.length() > 0) { + if (source == null) + source = prevSource; + else + source = prevSource + source; + } + prev = prev.getPreviousSibling(); + } + } + + SpaceConverter converter = new SpaceConverter(source, keepBlankLines(contraints)); + + int wordLength = converter.nextWord(); + if (wordLength == 0) { // only spaces + if (!converter.hasSpaces()) + return; // empty + boolean removeSpaces = false; + if (parent.getNodeType() == Node.ELEMENT_NODE) { + // check if tags are omitted + XMLNode element = (XMLNode) parent; + if (node.getPreviousSibling() == null && element.getStartStructuredDocumentRegion() == null) { + removeSpaces = true; + } + else if (node.getNextSibling() == null && element.getEndStructuredDocumentRegion() == null) { + removeSpaces = true; + } + } + if (removeSpaces) { + converter.replaceSpaces(null); + } + else if (!isWidthAvailable(contraints, 2) || canInsertBreakAfter(node) || canInsertBreakBefore(node)) { + String spaces = null; + if (node.getNextSibling() == null) { // last spaces + // use parent indent for the end tag + spaces = getBreakSpaces(parent); + } + else { + spaces = getBreakSpaces(node); + } + converter.replaceSpaces(spaces); + setWidth(contraints, spaces); + } + else if (canRemoveHeadingSpaces(node) || canRemoveTailingSpaces(node)) { + converter.replaceSpaces(null); + } + else { + converter.compressSpaces(); + addWidth(contraints, 1); + } + } + else { + String breakSpaces = null; + + // format heading spaces + boolean hasSpaces = converter.hasSpaces(); + if (mode == FORMAT_TAIL) { + // keep spaces as is + addWidth(contraints, converter.getSpaceCount()); + } + else if ((hasSpaces && !isWidthAvailable(contraints, wordLength + 1)) || canInsertBreakBefore(node)) { + breakSpaces = getBreakSpaces(node); + converter.replaceSpaces(breakSpaces); + setWidth(contraints, breakSpaces); + } + else { + if (hasSpaces) { + if (canRemoveHeadingSpaces(node)) { + converter.replaceSpaces(null); + } + else { + converter.compressSpaces(); + addWidth(contraints, 1); + } + } + } + addWidth(contraints, wordLength); + + // format middle + wordLength = converter.nextWord(); + while (wordLength > 0) { + if (mode != FORMAT_ALL) { + // keep spaces as is + addWidth(contraints, converter.getSpaceCount()); + } + else if (!isWidthAvailable(contraints, wordLength + 1)) { + if (breakSpaces == null) + breakSpaces = getBreakSpaces(node); + converter.replaceSpaces(breakSpaces); + setWidth(contraints, breakSpaces); + } + else { + converter.compressSpaces(); + addWidth(contraints, 1); + } + addWidth(contraints, wordLength); + wordLength = converter.nextWord(); + } + + // format tailing spaces + hasSpaces = converter.hasSpaces(); + if (mode == FORMAT_HEAD) { + // keep spaces as is + addWidth(contraints, converter.getSpaceCount()); + } + else if ((hasSpaces && !isWidthAvailable(contraints, 2)) || canInsertBreakAfter(node)) { + if (node.getNextSibling() == null) { // last test + // use parent indent for the end tag + breakSpaces = getBreakSpaces(parent); + } + else { + if (breakSpaces == null) + breakSpaces = getBreakSpaces(node); + } + converter.replaceSpaces(breakSpaces); + setWidth(contraints, breakSpaces); + } + else { + if (hasSpaces) { + if (canRemoveTailingSpaces(node)) { + converter.replaceSpaces(null); + } + else { + converter.compressSpaces(); + addWidth(contraints, 1); + } + } + } + } + + if (converter.isModified()) { + source = converter.getSource(); + replaceSource(text.getModel(), offset, length, source); + } + } +}
\ No newline at end of file diff --git a/bundles/org.eclipse.wst.html.core/src/org/eclipse/wst/html/core/format/SpaceConverter.java b/bundles/org.eclipse.wst.html.core/src/org/eclipse/wst/html/core/format/SpaceConverter.java new file mode 100644 index 0000000000..08b3016bd1 --- /dev/null +++ b/bundles/org.eclipse.wst.html.core/src/org/eclipse/wst/html/core/format/SpaceConverter.java @@ -0,0 +1,233 @@ +/******************************************************************************* + * Copyright (c) 2004 IBM Corporation and others. + * All rights reserved. This program and the accompanying materials + * are made available under the terms of the Eclipse Public License v1.0 + * which accompanies this distribution, and is available at + * http://www.eclipse.org/legal/epl-v10.html + * + * Contributors: + * IBM Corporation - initial API and implementation + *******************************************************************************/ +package org.eclipse.wst.html.core.format; + + + +final class SpaceConverter { + + private String source = null; + private int length = 0; + private int startOffset = 0; + private int endOffset = 0; + private int spaceCount = 0; + private int wordCount = 0; + private StringBuffer buffer = null; + private int lastOffset = 0; + private boolean keepBlankLines = false; + + /** + */ + public SpaceConverter(String source) { + super(); + + if (source == null) { + this.source = new String(); + } + else { + this.source = source; + this.length = source.length(); + } + } + + /** + */ + public SpaceConverter(String source, boolean keepBlankLines) { + super(); + + if (source == null) { + this.source = new String(); + } + else { + this.source = source; + this.length = source.length(); + } + this.keepBlankLines = keepBlankLines; + } + + /** + */ + public void compressSpaces() { + if (this.spaceCount == 0) + return; + if (this.spaceCount == 1 && this.source.charAt(this.startOffset) == ' ') + return; + + if (this.buffer == null) + this.buffer = new StringBuffer(); + if (this.startOffset > this.lastOffset) { + this.buffer.append(this.source.substring(this.lastOffset, this.startOffset)); + } + + this.buffer.append(' '); + + this.lastOffset = this.startOffset + this.spaceCount; + } + + /** + */ + public String getSource() { + if (this.buffer == null) + this.buffer = new StringBuffer(); + if (this.length > this.lastOffset) { + this.buffer.append(this.source.substring(this.lastOffset, this.length)); + } + return this.buffer.toString(); + } + + /** + */ + public int getSpaceCount() { + return this.spaceCount; + } + + /** + */ + public boolean hasSpaces() { + return (this.spaceCount > 0); + } + + /** + */ + public boolean isModified() { + return (this.buffer != null); + } + + /** + * Add number of the old blank lines to new space string + */ + private static String mergeBlankLines(String newSpaces, String oldSpaces) { + if (newSpaces == null || newSpaces.length() == 0) + return newSpaces; + if (oldSpaces == null) + return newSpaces; + + // count old new lines + int newLineCount = 0; + int oldLength = oldSpaces.length(); + for (int i = 0; i < oldLength; i++) { + char c = oldSpaces.charAt(i); + if (c == '\r') { + newLineCount++; + if (i + 1 < oldLength) { + c = oldSpaces.charAt(i + 1); + if (c == '\n') + i++; + } + } + else { + if (c == '\n') + newLineCount++; + } + } + if (newLineCount < 2) + return newSpaces; // no blank line + + // here assuming newSpaces starts with a new line if any + String delim = null; + char d = newSpaces.charAt(0); + if (d == '\r') { + if (newSpaces.length() > 1 && newSpaces.charAt(1) == '\n') + delim = "\r\n";//$NON-NLS-1$ + else + delim = "\r";//$NON-NLS-1$ + } + else { + if (d == '\n') + delim = "\n";//$NON-NLS-1$ + else + return newSpaces; // no new line + } + + newLineCount--; + StringBuffer buffer = new StringBuffer(newSpaces.length() + newLineCount * 2); + while (newLineCount > 0) { + buffer.append(delim); + newLineCount--; + } + buffer.append(newSpaces); + return buffer.toString(); + } + + /** + */ + public int nextWord() { + if (this.endOffset == this.length) { + this.startOffset = this.endOffset; + this.spaceCount = 0; + this.wordCount = 0; + return 0; + } + + this.startOffset = this.endOffset; + int i = this.startOffset; + for (; i < this.length; i++) { + if (!Character.isWhitespace(this.source.charAt(i))) + break; + } + this.spaceCount = i - this.startOffset; + + int wordOffset = i; + for (; i < this.length; i++) { + if (Character.isWhitespace(this.source.charAt(i))) + break; + } + this.wordCount = i - wordOffset; + this.endOffset = i; + + return this.wordCount; + } + + /** + */ + public void replaceSpaces(String spaces) { + int spaceLength = (spaces != null ? spaces.length() : 0); + String oldSpaces = null; + if (spaceLength == this.spaceCount) { + if (spaceLength == 0) + return; + if (this.startOffset == 0) { + if (this.source.startsWith(spaces)) + return; + } + else if (this.endOffset == this.length) { + if (this.source.endsWith(spaces)) + return; + } + else { + int textOffset = this.startOffset + this.spaceCount; + oldSpaces = this.source.substring(this.startOffset, textOffset); + if (oldSpaces.equals(spaces)) + return; + } + } + if (this.keepBlankLines && this.spaceCount > 0) { + if (oldSpaces == null) { + int textOffset = this.startOffset + this.spaceCount; + oldSpaces = this.source.substring(this.startOffset, textOffset); + } + if (oldSpaces != null) { + spaces = mergeBlankLines(spaces, oldSpaces); + } + } + + if (this.buffer == null) + this.buffer = new StringBuffer(); + if (this.startOffset > this.lastOffset) { + this.buffer.append(this.source.substring(this.lastOffset, this.startOffset)); + } + + if (spaceLength > 0) + this.buffer.append(spaces); + + this.lastOffset = this.startOffset + this.spaceCount; + } +}
\ No newline at end of file diff --git a/bundles/org.eclipse.wst.html.core/src/org/eclipse/wst/html/core/htmlcss/AbstractCSSModelAdapter.java b/bundles/org.eclipse.wst.html.core/src/org/eclipse/wst/html/core/htmlcss/AbstractCSSModelAdapter.java new file mode 100644 index 0000000000..ca925c56e4 --- /dev/null +++ b/bundles/org.eclipse.wst.html.core/src/org/eclipse/wst/html/core/htmlcss/AbstractCSSModelAdapter.java @@ -0,0 +1,105 @@ +/******************************************************************************* + * Copyright (c) 2004 IBM Corporation and others. + * All rights reserved. This program and the accompanying materials + * are made available under the terms of the Eclipse Public License v1.0 + * which accompanies this distribution, and is available at + * http://www.eclipse.org/legal/epl-v10.html + * + * Contributors: + * IBM Corporation - initial API and implementation + *******************************************************************************/ +package org.eclipse.wst.html.core.htmlcss; + +import java.util.Collection; +import java.util.Iterator; + +import org.eclipse.wst.common.encoding.content.IContentTypeIdentifier; +import org.eclipse.wst.css.core.adapters.ICSSModelAdapter; +import org.eclipse.wst.css.core.document.ICSSModel; +import org.eclipse.wst.css.core.internal.document.CSSModelImpl; +import org.eclipse.wst.sse.core.INodeAdapter; +import org.eclipse.wst.sse.core.INodeNotifier; +import org.eclipse.wst.sse.core.IStructuredModel; +import org.eclipse.wst.xml.core.document.XMLNode; +import org.w3c.dom.Element; + +/** + */ +public abstract class AbstractCSSModelAdapter implements ICSSModelAdapter { + private final static String CSS_ID = IContentTypeIdentifier.ContentTypeID_CSS; + + private Element element = null; + private ICSSModel model = null; + + /** + */ + AbstractCSSModelAdapter() { + super(); + } + + /** + */ + protected ICSSModel createModel() { + // create embedded CSS model (not for external CSS) + if (getElement() == null) + return null; + IStructuredModel baseModel = ((XMLNode) getElement()).getModel(); + ICSSModel newModel = (ICSSModel) baseModel.getModelManager().createUnManagedStructuredModelFor(CSS_ID); + ((CSSModelImpl) newModel).setOwnerDOMNode(getElement()); + return newModel; + } + + /** + */ + public Element getElement() { + return this.element; + } + + /** + */ + protected ICSSModel getExistingModel() { + return this.model; + } + + /** + */ + protected void notifyStyleChanged(Element target) { + INodeNotifier notifier = (INodeNotifier) target; + if (notifier == null) + return; + Collection adapters = notifier.getAdapters(); + if (adapters == null) + return; + Iterator it = adapters.iterator(); + if (it == null) + return; + while (it.hasNext()) { + INodeAdapter adapter = (INodeAdapter) it.next(); + if (adapter instanceof StyleListener) { + StyleListener listener = (StyleListener) adapter; + listener.styleChanged(); + } + } + } + + /** + */ + void setElement(Element element) { + this.element = element; + } + + /** + * check + * 1. If attributes of element is valid (type,rel ...) + * 2. If content model supports this element / attribute (future ?) + */ + protected boolean isValidAttribute() { + return (getElement() != null); + } + + /** + */ + protected void setModel(ICSSModel model) { + this.model = model; + } +}
\ No newline at end of file diff --git a/bundles/org.eclipse.wst.html.core/src/org/eclipse/wst/html/core/htmlcss/AbstractStyleSheetAdapter.java b/bundles/org.eclipse.wst.html.core/src/org/eclipse/wst/html/core/htmlcss/AbstractStyleSheetAdapter.java new file mode 100644 index 0000000000..6823541f6a --- /dev/null +++ b/bundles/org.eclipse.wst.html.core/src/org/eclipse/wst/html/core/htmlcss/AbstractStyleSheetAdapter.java @@ -0,0 +1,238 @@ +/******************************************************************************* + * Copyright (c) 2004 IBM Corporation and others. + * All rights reserved. This program and the accompanying materials + * are made available under the terms of the Eclipse Public License v1.0 + * which accompanies this distribution, and is available at + * http://www.eclipse.org/legal/epl-v10.html + * + * Contributors: + * IBM Corporation - initial API and implementation + *******************************************************************************/ +package org.eclipse.wst.html.core.htmlcss; + +import java.util.Collection; +import java.util.HashSet; +import java.util.Iterator; + +import org.eclipse.wst.css.core.adapters.IModelProvideAdapter; +import org.eclipse.wst.css.core.adapters.IStyleSheetAdapter; +import org.eclipse.wst.css.core.document.ICSSModel; +import org.eclipse.wst.css.core.document.ICSSNode; +import org.eclipse.wst.css.core.document.ICSSSelector; +import org.eclipse.wst.css.core.event.ICSSStyleListener; +import org.eclipse.wst.css.core.util.ImportedCollector; +import org.eclipse.wst.sse.core.INodeAdapter; +import org.eclipse.wst.sse.core.INodeNotifier; +import org.eclipse.wst.xml.core.document.XMLModel; +import org.eclipse.wst.xml.core.document.XMLModelNotifier; +import org.eclipse.wst.xml.core.document.XMLNode; +import org.w3c.dom.Document; +import org.w3c.dom.Element; +import org.w3c.dom.Node; +import org.w3c.dom.stylesheets.DocumentStyle; +import org.w3c.dom.stylesheets.StyleSheet; +import org.w3c.dom.stylesheets.StyleSheetList; +import org.w3c.dom.traversal.DocumentTraversal; +import org.w3c.dom.traversal.NodeFilter; +import org.w3c.dom.traversal.NodeIterator; + +/** + */ +public abstract class AbstractStyleSheetAdapter extends AbstractCSSModelAdapter implements ICSSStyleListener, IStyleSheetAdapter { + + // this variable to hold the class is just a VAJava trick. + // it improves performance in VAJava by minimizing class loading. + private final Class StyleSheetAdapterClass = IStyleSheetAdapter.class; + private Collection styleChangedNodes; + + /** + */ + protected AbstractStyleSheetAdapter() { + super(); + } + + /** + */ + protected ICSSModel createModel() { + ICSSModel newModel = super.createModel(); + if (newModel != null) { + // get ModelProvideAdapter + IModelProvideAdapter adapter = (IModelProvideAdapter) ((INodeNotifier) getElement()).getAdapterFor(IModelProvideAdapter.class); + // notify adapter + if (adapter != null) + adapter.modelProvided(newModel); + } + return newModel; + } + + /** + */ + public StyleSheet getSheet() { + ICSSModel model = getModel(); + if (model == null) + return null; + return (StyleSheet) model.getDocument(); + } + + /** + * Allowing the INodeAdapter to compare itself against the type + * allows it to return true in more than one case. + */ + public boolean isAdapterForType(Object type) { + return (type == StyleSheetAdapterClass); + } + + /** + */ + public void released() { + ICSSModel currentModel = getModel(); + + // get ModelProvideAdapter + IModelProvideAdapter adapter = (IModelProvideAdapter) ((INodeNotifier) getElement()).getAdapterFor(IModelProvideAdapter.class); + + setElement(null); + setModel(null); + + if (adapter != null) + adapter.modelReleased(currentModel); + + if (currentModel != null) + currentModel.releaseFromRead(); + } + + /** + */ + public void removed() { + ICSSModel currentModel = getModel(); + + setModel(null); + + // get ModelProvideAdapter + IModelProvideAdapter adapter = (IModelProvideAdapter) ((INodeNotifier) getElement()).getAdapterFor(IModelProvideAdapter.class); + if (adapter != null) + adapter.modelRemoved(currentModel); + + if (currentModel != null) + currentModel.releaseFromRead(); + } + + /** + * @param srcModel com.ibm.sed.css.model.interfaces.ICSSModel + * @param removed com.ibm.sed.css.model.interfaces.ICSSSelector[] + * @param added com.ibm.sed.css.model.interfaces.ICSSSelector[] + * @param media java.lang.String + */ + public void styleChanged(ICSSModel srcModel, ICSSSelector[] removed, ICSSSelector[] added, String media) { + Element element = getElement(); + if (element == null) + return; // might released + Document doc = element.getOwnerDocument(); + if (doc == null) + return; // error + + // to notify GEF tree + if (doc instanceof INodeNotifier) { + Collection adapters = ((INodeNotifier) doc).getAdapters(); + if (adapters == null) + return; + Iterator it = adapters.iterator(); + if (it == null) + return; + while (it.hasNext()) { + INodeAdapter adapter = (INodeAdapter) it.next(); + if (adapter instanceof ICSSStyleListener) { + ((ICSSStyleListener) adapter).styleChanged(srcModel, removed, added, media); + } + } + } + // + + if (styleChangedNodes == null) { + styleChangedNodes = new HashSet(); + } + + try { + int removedSelNum = removed != null ? removed.length : 0; + int addedSelNum = added != null ? added.length : 0; + + NodeIterator iter = ((DocumentTraversal) doc).createNodeIterator(doc, NodeFilter.SHOW_ELEMENT, null, true); + Node node; + while ((node = iter.nextNode()) != null) { + if (node.getNodeType() == Node.ELEMENT_NODE) { + Element elm = (Element) node; + boolean match = false; + int i; + for (i = 0; i < removedSelNum && !match; i++) { + match = removed[i].match(elm, null); + } + for (i = 0; i < addedSelNum && !match; i++) { + match = added[i].match(elm, null); + } + if (match) { + if (!styleChangedNodes.contains(elm)) + styleChangedNodes.add(elm); + // notifyStyleChanged(elm); + } + } + } + } + catch (ClassCastException ex) { + // Document doesn't implement DocumentTraversal... + } + + } + + /** + * @param srcModel com.ibm.sed.css.model.interfaces.ICSSModel + */ + public void styleUpdate(ICSSModel srcModel) { + XMLNode node = (XMLNode) getElement(); + if (node == null) + return; + XMLModel model = node.getModel(); + if (model == null) + return; + XMLModelNotifier notifier = model.getModelNotifier(); + if (notifier == null) + return; + + // before updating, all sub-models should be loaded! + DocumentStyle document = (DocumentStyle) model.getDocument(); + StyleSheetList styles = document.getStyleSheets(); + if (styles != null) { + int n = styles.getLength(); + ImportedCollector trav = new ImportedCollector(); + for (int i = 0; i < n; i++) { + org.w3c.dom.stylesheets.StyleSheet sheet = styles.item(i); + if (sheet instanceof ICSSNode) + trav.apply((ICSSNode) sheet); + } + } + + // flash style changed events + if (styleChangedNodes != null) { + Object[] elements = styleChangedNodes.toArray(); + for (int i = 0; elements != null && i < elements.length; i++) + notifyStyleChanged((Element) elements[i]); + styleChangedNodes.clear(); + } + + // to notify GEF tree + if (document instanceof INodeNotifier) { + Collection adapters = ((INodeNotifier) document).getAdapters(); + if (adapters == null) + return; + Iterator it = adapters.iterator(); + if (it == null) + return; + while (it.hasNext()) { + INodeAdapter adapter = (INodeAdapter) it.next(); + if (adapter instanceof ICSSStyleListener) { + ((ICSSStyleListener) adapter).styleUpdate(srcModel); + } + } + } + + notifier.propertyChanged(node); + } +}
\ No newline at end of file diff --git a/bundles/org.eclipse.wst.html.core/src/org/eclipse/wst/html/core/htmlcss/CSSQueryContext.java b/bundles/org.eclipse.wst.html.core/src/org/eclipse/wst/html/core/htmlcss/CSSQueryContext.java new file mode 100644 index 0000000000..2bd84f382e --- /dev/null +++ b/bundles/org.eclipse.wst.html.core/src/org/eclipse/wst/html/core/htmlcss/CSSQueryContext.java @@ -0,0 +1,137 @@ +/******************************************************************************* + * Copyright (c) 2004 IBM Corporation and others. + * All rights reserved. This program and the accompanying materials + * are made available under the terms of the Eclipse Public License v1.0 + * which accompanies this distribution, and is available at + * http://www.eclipse.org/legal/epl-v10.html + * + * Contributors: + * IBM Corporation - initial API and implementation + *******************************************************************************/ +package org.eclipse.wst.html.core.htmlcss; + + + +import java.util.Enumeration; + +import org.eclipse.wst.css.core.document.ICSSStyleDeclItem; +import org.eclipse.wst.css.core.document.ICSSStyleDeclaration; +import org.eclipse.wst.css.core.document.ICSSValue; +import org.eclipse.wst.css.core.internal.contentmodel.PropCMProperty; +import org.eclipse.wst.css.core.util.CSSLinkConverter; +import org.eclipse.wst.css.core.util.declaration.CSSPropertyContext; + +/** + */ +class CSSQueryContext extends CSSPropertyContext { + + /** + */ + public CSSQueryContext() { + super(); + } + + /** + */ + public CSSQueryContext(ICSSStyleDeclaration decl) { + super(decl); + } + + /** + * + */ + public void applyFull(ICSSStyleDeclaration decl) { + if (decl == null) + return; + Enumeration keys = fProperties.keys(); + while (keys.hasMoreElements()) { + Object key = keys.nextElement(); + Object val = fProperties.get(key); + + if (val instanceof CSSQueryDeclarationData) { + ICSSStyleDeclItem declItem = ((CSSQueryDeclarationData) val).getDeclItem(); + if (declItem.getLength() <= 0) { + ICSSStyleDeclItem itemToRemove = decl.getDeclItemNode(key.toString()); + if (itemToRemove != null) { + decl.removeDeclItemNode(itemToRemove); + } + } + else { + decl.setDeclItemNode(declItem); + } + } + else { + String value = (val instanceof ICSSValue) ? ((ICSSValue) val).getCSSValueText() : val.toString(); + + if (value == null || value.length() <= 0) { + ICSSStyleDeclItem itemToRemove = decl.getDeclItemNode(key.toString()); + if (itemToRemove != null) { + decl.removeDeclItemNode(itemToRemove); + } + } + else { + decl.setProperty(key.toString(), value, null); + } + } + } + } + + /** + */ + private boolean check(String propName, boolean important, int specificity) { + Object current = fProperties.get(propName); + if (current != null && current instanceof CSSQueryValueData) { + CSSQueryValueData currentValue = (CSSQueryValueData) current; + if ((!important && currentValue.important) || (currentValue.getSpecificity() > specificity)) { + return false; + } + } + return true; + } + + /** + */ + public void overrideWithExpand(ICSSStyleDeclaration decl, int specificity) { + if (decl == null) + return; + + CSSLinkConverter conv = new CSSLinkConverter(decl.getOwnerDocument().getModel()); + + int nProperties = decl.getLength(); + for (int i = 0; i < nProperties; i++) { + String propName = decl.item(i); + if (propName != null) { + String propN = propName.trim().toLowerCase(); + if (propN.length() != 0) { + PropCMProperty prop = PropCMProperty.getInstanceOf(propN); + String priority = decl.getPropertyPriority(propName); + boolean important = priority != null && priority.length() > 0; + if (prop != null && prop.isShorthand()) { + // expand shorthand property + CSSQueryContext context = new CSSQueryContext(); + expandToLeaf(prop, decl.getPropertyValue(propName), context); + + Enumeration properties = context.properties(); + while (properties.hasMoreElements()) { + propN = properties.nextElement().toString(); + if (check(propN, important, specificity)) { + fProperties.put(propN, new CSSQueryValueData(conv.toAbsolute(context.get(propN)), important, specificity)); + } + } + } + else { + if (check(propN, important, specificity)) { + ICSSStyleDeclItem declItem = (ICSSStyleDeclItem) decl.getDeclItemNode(propName).cloneNode(true); + int nValues = declItem.getLength(); + for (int j = 0; j < nValues; j++) { + conv.toAbsolute(declItem.item(j)); + } + declItem.setPriority(null); + fProperties.put(propN, new CSSQueryDeclarationData(declItem, important, specificity)); + } + } + } + } + } + } +}
\ No newline at end of file diff --git a/bundles/org.eclipse.wst.html.core/src/org/eclipse/wst/html/core/htmlcss/CSSQueryDeclarationData.java b/bundles/org.eclipse.wst.html.core/src/org/eclipse/wst/html/core/htmlcss/CSSQueryDeclarationData.java new file mode 100644 index 0000000000..2b42b8d943 --- /dev/null +++ b/bundles/org.eclipse.wst.html.core/src/org/eclipse/wst/html/core/htmlcss/CSSQueryDeclarationData.java @@ -0,0 +1,44 @@ +/******************************************************************************* + * Copyright (c) 2004 IBM Corporation and others. + * All rights reserved. This program and the accompanying materials + * are made available under the terms of the Eclipse Public License v1.0 + * which accompanies this distribution, and is available at + * http://www.eclipse.org/legal/epl-v10.html + * + * Contributors: + * IBM Corporation - initial API and implementation + *******************************************************************************/ +package org.eclipse.wst.html.core.htmlcss; + +import org.eclipse.wst.css.core.document.ICSSStyleDeclItem; + + + +/** + */ +public class CSSQueryDeclarationData extends CSSQueryValueData { + + + ICSSStyleDeclItem declItem; + + public CSSQueryDeclarationData(ICSSStyleDeclItem declItem, boolean imp, int specificity) { + super(null, imp, specificity); + this.declItem = declItem; + } + + /** + */ + ICSSStyleDeclItem getDeclItem() { + return declItem; + } + + /** + */ + public String toString() { + if (value == null && declItem != null) { + value = declItem.getCSSValueText(); + } + return value; + } + +}
\ No newline at end of file diff --git a/bundles/org.eclipse.wst.html.core/src/org/eclipse/wst/html/core/htmlcss/CSSQueryTraverser.java b/bundles/org.eclipse.wst.html.core/src/org/eclipse/wst/html/core/htmlcss/CSSQueryTraverser.java new file mode 100644 index 0000000000..9cddce0c46 --- /dev/null +++ b/bundles/org.eclipse.wst.html.core/src/org/eclipse/wst/html/core/htmlcss/CSSQueryTraverser.java @@ -0,0 +1,115 @@ +/******************************************************************************* + * Copyright (c) 2004 IBM Corporation and others. + * All rights reserved. This program and the accompanying materials + * are made available under the terms of the Eclipse Public License v1.0 + * which accompanies this distribution, and is available at + * http://www.eclipse.org/legal/epl-v10.html + * + * Contributors: + * IBM Corporation - initial API and implementation + *******************************************************************************/ +package org.eclipse.wst.html.core.htmlcss; + + + +import org.eclipse.wst.css.core.document.ICSSNode; +import org.eclipse.wst.css.core.document.ICSSSelector; +import org.eclipse.wst.css.core.document.ICSSSelectorList; +import org.eclipse.wst.css.core.document.ICSSStyleDeclaration; +import org.eclipse.wst.css.core.document.ICSSStyleRule; +import org.eclipse.wst.css.core.util.AbstractCssTraverser; +import org.eclipse.wst.css.core.util.CSSStyleDeclarationFactory; +import org.w3c.dom.Element; +import org.w3c.dom.css.ElementCSSInlineStyle; + +/** + */ +public class CSSQueryTraverser extends AbstractCssTraverser { + + private Element element; + private String pseudoName; + private CSSQueryContext context = null; + ICSSStyleDeclaration decl = null; + + /** + */ + public ICSSStyleDeclaration getDeclaration() { + try { + ICSSStyleDeclaration inlineStyle = (ICSSStyleDeclaration) ((ElementCSSInlineStyle) element).getStyle(); + if (inlineStyle != null) { + if (context == null) { + context = new CSSQueryContext(); + } + context.overrideWithExpand(inlineStyle, 10000); + // style attribute's specificity is 100 (in CSS2 spec.) and + // our implement use 100 as base number (see CSSSelector.java) + } + } + catch (ClassCastException ex) { + // element is not ElementCSSInlineStyle ??? + } + if (context == null) + return null; + + if (decl == null) + decl = CSSStyleDeclarationFactory.getInstance().createStyleDeclaration(); + context.applyFull(decl); + return decl; + } + + /** + */ + private void overwriteDeclaration(ICSSStyleDeclaration d, int specificity) { + if (d == null) + return; + if (context == null) + context = new CSSQueryContext(); + context.overrideWithExpand(d, specificity); + } + + /** + */ + protected short postNode(ICSSNode node) { + return TRAV_CONT; + } + + /** + */ + protected short preNode(ICSSNode node) { + if (node instanceof ICSSStyleRule) { + // style rule + ICSSStyleRule style = (ICSSStyleRule) node; + ICSSSelectorList list = style.getSelectors(); + int nSelectors = list.getLength(); + int maxSpecificity = -1; + for (int iSelector = 0; iSelector < nSelectors; iSelector++) { + // Check each Selector Lists + ICSSSelector selector = list.getSelector(iSelector); + int specificity = selector.getSpecificity(); + if (maxSpecificity < specificity && selector.match(element, pseudoName)) { + maxSpecificity = specificity; + } + } + if (maxSpecificity >= 0) { + // apply this style to the element + overwriteDeclaration((ICSSStyleDeclaration) style.getStyle(), maxSpecificity); + } + return TRAV_PRUNE; + } + return TRAV_CONT; + } + + /** + */ + private void resetContext() { + context = null; + } + + /** + */ + public void setElement(Element element, String pseudoName) { + this.element = element; + this.pseudoName = pseudoName; + resetContext(); + } +}
\ No newline at end of file diff --git a/bundles/org.eclipse.wst.html.core/src/org/eclipse/wst/html/core/htmlcss/CSSQueryValueData.java b/bundles/org.eclipse.wst.html.core/src/org/eclipse/wst/html/core/htmlcss/CSSQueryValueData.java new file mode 100644 index 0000000000..26f56b700e --- /dev/null +++ b/bundles/org.eclipse.wst.html.core/src/org/eclipse/wst/html/core/htmlcss/CSSQueryValueData.java @@ -0,0 +1,47 @@ +/******************************************************************************* + * Copyright (c) 2004 IBM Corporation and others. + * All rights reserved. This program and the accompanying materials + * are made available under the terms of the Eclipse Public License v1.0 + * which accompanies this distribution, and is available at + * http://www.eclipse.org/legal/epl-v10.html + * + * Contributors: + * IBM Corporation - initial API and implementation + *******************************************************************************/ +package org.eclipse.wst.html.core.htmlcss; + +import org.eclipse.wst.css.core.util.declaration.ValueData; + + + +/** + */ +class CSSQueryValueData extends ValueData { + + private int specificity; + + /** + */ + public CSSQueryValueData() { + super(); + } + + /** + */ + public CSSQueryValueData(String val, boolean imp) { + super(val, imp); + } + + /** + */ + public CSSQueryValueData(String val, boolean imp, int specificity) { + super(val, imp); + this.specificity = specificity; + } + + /** + */ + int getSpecificity() { + return specificity; + } +}
\ No newline at end of file diff --git a/bundles/org.eclipse.wst.html.core/src/org/eclipse/wst/html/core/htmlcss/HTMLDocumentAdapter.java b/bundles/org.eclipse.wst.html.core/src/org/eclipse/wst/html/core/htmlcss/HTMLDocumentAdapter.java new file mode 100644 index 0000000000..a2ecc232dc --- /dev/null +++ b/bundles/org.eclipse.wst.html.core/src/org/eclipse/wst/html/core/htmlcss/HTMLDocumentAdapter.java @@ -0,0 +1,398 @@ +/******************************************************************************* + * Copyright (c) 2004 IBM Corporation and others. + * All rights reserved. This program and the accompanying materials + * are made available under the terms of the Eclipse Public License v1.0 + * which accompanies this distribution, and is available at + * http://www.eclipse.org/legal/epl-v10.html + * + * Contributors: + * IBM Corporation - initial API and implementation + *******************************************************************************/ +package org.eclipse.wst.html.core.htmlcss; + + + +import java.util.ArrayList; +import java.util.Collection; +import java.util.Enumeration; +import java.util.Iterator; +import java.util.List; +import java.util.Vector; + +import org.eclipse.wst.css.core.adapters.IStyleSheetAdapter; +import org.eclipse.wst.css.core.adapters.IStyleSheetListAdapter; +import org.eclipse.wst.css.core.document.ICSSImportRule; +import org.eclipse.wst.css.core.document.ICSSModel; +import org.eclipse.wst.css.core.document.ICSSNode; +import org.eclipse.wst.css.core.util.CSSClassTraverser; +import org.eclipse.wst.css.core.util.ImportRuleCollector; +import org.eclipse.wst.html.core.HTML40Namespace; +import org.eclipse.wst.html.core.contentmodel.JSP11Namespace; +import org.eclipse.wst.sse.core.INodeAdapter; +import org.eclipse.wst.sse.core.INodeNotifier; +import org.eclipse.wst.xml.core.document.XMLElement; +import org.w3c.dom.Document; +import org.w3c.dom.Element; +import org.w3c.dom.Node; +import org.w3c.dom.css.CSSStyleDeclaration; +import org.w3c.dom.stylesheets.StyleSheet; +import org.w3c.dom.stylesheets.StyleSheetList; + + + +/** + */ +public class HTMLDocumentAdapter implements IStyleSheetListAdapter, StyleSheetList { + + private Document document = null; + private Vector styleAdapters = null; + private Vector oldStyleAdapters = null; + + /** + */ + HTMLDocumentAdapter() { + super(); + } + + /** + */ + private void addStyleSheet(Element node) { + XMLElement element = (XMLElement) node; + String tagName = element.getTagName(); + if (tagName == null) + return; + boolean isContainer = false; + if (tagName.equalsIgnoreCase(HTML40Namespace.ElementName.HTML) || tagName.equalsIgnoreCase(HTML40Namespace.ElementName.HEAD) || tagName.equalsIgnoreCase(HTML40Namespace.ElementName.NOSCRIPT) || tagName.equalsIgnoreCase(HTML40Namespace.ElementName.BASE) || tagName.equalsIgnoreCase(JSP11Namespace.ElementName.ROOT) || (!element.isGlobalTag() && element.isContainer())) { + isContainer = true; + } + else if (element.isCommentTag()) { + Node parent = element.getParentNode(); + if (parent == element.getOwnerDocument()) { + // This condition is too severe, actually do not work for JSF template. + // But above (! globalTag() && isContainer()) cover JSF template + tpl template + isContainer = true; + } + else if (parent.getNodeType() == Node.ELEMENT_NODE) { + tagName = ((Element) parent).getTagName(); + if (tagName != null && tagName.equalsIgnoreCase(HTML40Namespace.ElementName.HEAD)) { + isContainer = true; + } + } + } + + else { + String localName = element.getLocalName(); + if (localName != null && localName.equalsIgnoreCase(HTML40Namespace.ElementName.HTML)) { + // taglib html tag + isContainer = true; + } + else { + INodeNotifier notifier = element; + INodeAdapter adapter = notifier.getAdapterFor(IStyleSheetAdapter.class); + if (adapter != null && adapter instanceof IStyleSheetAdapter) { + this.styleAdapters.addElement(adapter); + } + } + } + if (isContainer) { + INodeNotifier notifier = element; + if (notifier.getExistingAdapter(IStyleSheetListAdapter.class) == null) { + notifier.addAdapter(this); + } + for (Node child = element.getFirstChild(); child != null; child = child.getNextSibling()) { + if (child.getNodeType() != Node.ELEMENT_NODE) + continue; + addStyleSheet((Element) child); + } + } + } + + /** + */ + void childReplaced() { + if (this.styleAdapters == null) + return; + + // backup old adapters to be released on updating in getStyleSheets() + this.oldStyleAdapters = this.styleAdapters; + // invalidate the list + this.styleAdapters = null; + + notifyStyleSheetsChanged(this.document); + } + + /** + */ + public Enumeration getClasses() { + StyleSheetList sheetList = getStyleSheets(); + int nSheets = sheetList.getLength(); + + final ArrayList classes = new ArrayList(); + + CSSClassTraverser traverser = new CSSClassTraverser(); + traverser.setTraverseImported(true); + + for (int i = 0; i < nSheets; i++) { + org.w3c.dom.stylesheets.StyleSheet sheet = sheetList.item(i); + if (sheet instanceof ICSSNode) { + traverser.apply((ICSSNode) sheet); + } + } + classes.addAll(traverser.getClassNames()); + + return new Enumeration() { + int i = 0; + + public boolean hasMoreElements() { + return i < classes.size(); + } + + public Object nextElement() { + return classes.get(i++); + } + }; + } + + /** + */ + private List getValidAdapters() { + Vector validAdapters = new Vector(); + if (this.styleAdapters != null) { + Iterator i = this.styleAdapters.iterator(); + while (i.hasNext()) { + Object obj = i.next(); + if (obj instanceof AbstractStyleSheetAdapter && ((AbstractStyleSheetAdapter) obj).isValidAttribute()) { + validAdapters.add(obj); + } + } + } + return validAdapters; + } + + /** + */ + public int getLength() { + return getValidAdapters().size(); + } + + /** + */ + public CSSStyleDeclaration getOverrideStyle(Element element, String pseudoName) { + StyleSheetList ssl = getStyleSheets(); + int numStyles = ssl.getLength(); + + CSSQueryTraverser query = new CSSQueryTraverser(); + query.setTraverseImported(true); + query.setTraverseImportFirst(true); + query.setElement(element, pseudoName); + + for (int i = 0; i < numStyles; i++) { + // loop for styles (<style> and <link>) + org.w3c.dom.stylesheets.StyleSheet ss = ssl.item(i); + + try { + query.apply((ICSSNode) ss); + } + catch (ClassCastException ex) { + // I can handle only CSS style + } + } + + return query.getDeclaration(); + } + + /** + */ + public StyleSheetList getStyleSheets() { + if (this.styleAdapters == null) { + if (this.document == null) + return null; + + this.styleAdapters = new Vector(); + for (Node child = this.document.getFirstChild(); child != null; child = child.getNextSibling()) { + if (child.getNodeType() != Node.ELEMENT_NODE) + continue; + addStyleSheet((Element) child); + } + + removeOldStyleSheets(); + } + return this; + } + + /** + * Allowing the INodeAdapter to compare itself against the type + * allows it to return true in more than one case. + */ + public boolean isAdapterForType(Object type) { + return (type == IStyleSheetListAdapter.class); + } + + /** + */ + public StyleSheet item(int index) { + if (this.styleAdapters == null) + return null; + + List validAdapters = getValidAdapters(); + + if (index < 0 || index >= validAdapters.size()) + return null; + org.w3c.dom.stylesheets.StyleSheet sheet = ((IStyleSheetAdapter) validAdapters.get(index)).getSheet(); + if (sheet == null) {// for LINK element whose link is broken + ICSSModel model = ((AbstractStyleSheetAdapter) this.styleAdapters.elementAt(index)).createModel(); + sheet = ((model != null) ? (StyleSheet) model.getDocument() : null); + } + return sheet; + } + + /** + */ + public void notifyChanged(INodeNotifier notifier, int eventType, Object changedFeature, Object oldValue, Object newValue, int pos) { + Node node = null; + switch (eventType) { + case INodeNotifier.ADD : + node = (Node) newValue; + break; + case INodeNotifier.REMOVE : + node = (Node) oldValue; + break; + case INodeNotifier.CHANGE : + node = (Node) notifier; + break; + default : + break; + } + if (node == null || node.getNodeType() != Node.ELEMENT_NODE) + return; + XMLElement element = (XMLElement) node; + String tagName = element.getTagName(); + if (tagName == null) + return; + + if (eventType == INodeNotifier.CHANGE) { + if (tagName.equalsIgnoreCase(HTML40Namespace.ElementName.BASE)) { + refreshAdapters(); + } + } + else { + if (tagName.equalsIgnoreCase(HTML40Namespace.ElementName.HTML) || tagName.equalsIgnoreCase(HTML40Namespace.ElementName.HEAD) || tagName.equalsIgnoreCase(HTML40Namespace.ElementName.STYLE) || tagName.equalsIgnoreCase(HTML40Namespace.ElementName.LINK) || tagName.equalsIgnoreCase(HTML40Namespace.ElementName.NOSCRIPT) || tagName.equalsIgnoreCase(JSP11Namespace.ElementName.ROOT) || element.isCommentTag() || (!element.isGlobalTag() && element.isContainer())) { + childReplaced(); + } + else if (tagName.equalsIgnoreCase(HTML40Namespace.ElementName.BASE)) { + refreshAdapters(); + } + else { + String localName = element.getLocalName(); + if (localName != null && localName.equalsIgnoreCase(HTML40Namespace.ElementName.HTML)) { + // taglib html tag + childReplaced(); + } + } + } + } + + /** + * reload LINK / @import if BASE changed + */ + private void refreshAdapters() { + Iterator iAdapter = this.styleAdapters.iterator(); + while (iAdapter.hasNext()) { + Object adapter = iAdapter.next(); + if (adapter instanceof LinkElementAdapter) { + ((LinkElementAdapter) adapter).refreshSheet(); + } + else if (adapter instanceof StyleElementAdapter) { + ICSSModel model = ((StyleElementAdapter) adapter).getModel(); + ImportRuleCollector trav = new ImportRuleCollector(); + trav.apply(model); + Iterator iRule = trav.getRules().iterator(); + while (iRule.hasNext()) { + ICSSImportRule rule = (ICSSImportRule) iRule.next(); + rule.refreshStyleSheet(); + } + } + } + } + + /** + */ + private void notifyStyleSheetsChanged(Document target) { + INodeNotifier notifier = (INodeNotifier) target; + if (notifier == null) + return; + Collection adapters = notifier.getAdapters(); + if (adapters == null) + return; + Iterator it = adapters.iterator(); + if (it == null) + return; + while (it.hasNext()) { + INodeAdapter adapter = (INodeAdapter) it.next(); + if (adapter instanceof StyleListener) { + StyleListener listener = (StyleListener) adapter; + listener.styleChanged(); + } + } + } + + /** + */ + private void releaseOldStyleSheets() { + if (this.oldStyleAdapters == null) + return; + Iterator it = this.oldStyleAdapters.iterator(); + while (it.hasNext()) { + IStyleSheetAdapter adapter = (IStyleSheetAdapter) it.next(); + if (adapter == null) + continue; + // if the same adapter is in the current list, + // do not release + if (this.styleAdapters != null && this.styleAdapters.contains(adapter)) + continue; + adapter.released(); + } + this.oldStyleAdapters = null; + } + + /** + */ + public void releaseStyleSheets() { + releaseOldStyleSheets(); + + if (this.styleAdapters == null) + return; + Iterator it = this.styleAdapters.iterator(); + while (it.hasNext()) { + IStyleSheetAdapter adapter = (IStyleSheetAdapter) it.next(); + if (adapter != null) + adapter.released(); + } + this.styleAdapters = null; + } + + /** + */ + private void removeOldStyleSheets() { + if (this.oldStyleAdapters == null) + return; + Iterator it = this.oldStyleAdapters.iterator(); + while (it.hasNext()) { + IStyleSheetAdapter adapter = (IStyleSheetAdapter) it.next(); + if (adapter == null) + continue; + // if the same adapter is in the current list, + // do not release + if (this.styleAdapters != null && this.styleAdapters.contains(adapter)) + continue; + adapter.removed(); + } + this.oldStyleAdapters = null; + } + + /** + */ + void setDocument(Document document) { + this.document = document; + } +}
\ No newline at end of file diff --git a/bundles/org.eclipse.wst.html.core/src/org/eclipse/wst/html/core/htmlcss/HTMLStyleSelectorAdapter.java b/bundles/org.eclipse.wst.html.core/src/org/eclipse/wst/html/core/htmlcss/HTMLStyleSelectorAdapter.java new file mode 100644 index 0000000000..d7a8426848 --- /dev/null +++ b/bundles/org.eclipse.wst.html.core/src/org/eclipse/wst/html/core/htmlcss/HTMLStyleSelectorAdapter.java @@ -0,0 +1,154 @@ +/******************************************************************************* + * Copyright (c) 2004 IBM Corporation and others. + * All rights reserved. This program and the accompanying materials + * are made available under the terms of the Eclipse Public License v1.0 + * which accompanies this distribution, and is available at + * http://www.eclipse.org/legal/epl-v10.html + * + * Contributors: + * IBM Corporation - initial API and implementation + *******************************************************************************/ +package org.eclipse.wst.html.core.htmlcss; + + + +import java.util.StringTokenizer; + +import org.eclipse.wst.css.core.adapters.IStyleSelectorAdapter; +import org.eclipse.wst.css.core.document.ICSSSimpleSelector; +import org.eclipse.wst.sse.core.INodeNotifier; +import org.w3c.dom.Element; + +/** + * Insert the type's description here. + */ +public class HTMLStyleSelectorAdapter implements IStyleSelectorAdapter { + + static private HTMLStyleSelectorAdapter instance; + private Object toMatch = IStyleSelectorAdapter.class; + + /** + * Insert the method's description here. + * @return com.ibm.sed.model.html.css.HTMLStyleSelectorAdapter + */ + public synchronized static HTMLStyleSelectorAdapter getInstance() { + if (instance == null) { + instance = new HTMLStyleSelectorAdapter(); + } + return instance; + } + + /** + * @see com.ibm.sed.model.INodeAdapter + */ + public boolean isAdapterForType(Object type) { + return type == toMatch; + } + + /** + * @see com.ibm.sed.css.adapters.IStyleSelectorAdapter + */ + public boolean match(ICSSSimpleSelector selector, Element element, String pseudoName) { + if (element == null) + return false; + int i; + String key; + + // PseudoName + i = selector.getNumOfPseudoNames(); + if (i > 0) { + if (pseudoName == null || pseudoName.length() == 0) + return false; + for (i = i - 1; i >= 0; i--) { + if (pseudoName.equalsIgnoreCase(selector.getPseudoName(i))) { + break; + } + } + if (i < 0) + return false; + } + + // check tag name + if (!selector.isUniversal() && !element.getNodeName().equalsIgnoreCase(selector.getName())) + return false; + + // check id + i = selector.getNumOfIDs(); + if (i > 0) { + if (i > 1) + return false; + key = element.getAttribute("id");//$NON-NLS-1$ + if (key == null) + return false; + if (!selector.getID(0).equals(key)) + return false; + } + + // check class + i = selector.getNumOfClasses(); + if (i > 0) { + key = element.getAttribute("class");//$NON-NLS-1$ + if (key == null) + return false; + StringTokenizer tokenizer = new StringTokenizer(key); + for (i = i - 1; i >= 0; i--) { + boolean ok = false; + while (tokenizer.hasMoreTokens()) { + if (selector.getClass(i).equals(tokenizer.nextToken())) { + ok = true; + break; + } + } + if (!ok) + return false; + } + } + + // check attributes + for (i = selector.getNumOfAttributes() - 1; i >= 0; i--) { + StringTokenizer tokenizer = new StringTokenizer(selector.getAttribute(i), "=~| \t\r\n\f");//$NON-NLS-1$ + int countTokens = tokenizer.countTokens(); + if (countTokens > 0) { + String attrValue = element.getAttribute(tokenizer.nextToken()); + if (attrValue == null) + return false; + if (countTokens > 1) { + String token = tokenizer.nextToken("= \t\r\n\f");//$NON-NLS-1$ + StringTokenizer attrValueTokenizer = null; + if (token.equals("~")) {//$NON-NLS-1$ + attrValueTokenizer = new StringTokenizer(attrValue); + } + else if (token.equals("|")) {//$NON-NLS-1$ + attrValueTokenizer = new StringTokenizer(attrValue, "-");//$NON-NLS-1$ + } + if (attrValueTokenizer != null) { + if (tokenizer.hasMoreTokens()) { + token = tokenizer.nextToken(); + boolean ok = false; + while (attrValueTokenizer.hasMoreTokens()) { + if (token.equals(attrValueTokenizer.nextToken())) { + ok = true; + break; + } + } + if (!ok) + return false; + } + } + else { + if (!attrValue.equals(token)) + return false; + } + } + } + } + + return true; + } + + /** + * @see com.ibm.sed.model.INodeAdapter + */ + public void notifyChanged(INodeNotifier notifier, int eventType, Object changedFeature, Object oldValue, Object newValue, int pos) { + } +}
\ No newline at end of file diff --git a/bundles/org.eclipse.wst.html.core/src/org/eclipse/wst/html/core/htmlcss/HTMLStyleSelectorAdapterFactory.java b/bundles/org.eclipse.wst.html.core/src/org/eclipse/wst/html/core/htmlcss/HTMLStyleSelectorAdapterFactory.java new file mode 100644 index 0000000000..3829934936 --- /dev/null +++ b/bundles/org.eclipse.wst.html.core/src/org/eclipse/wst/html/core/htmlcss/HTMLStyleSelectorAdapterFactory.java @@ -0,0 +1,81 @@ +/******************************************************************************* + * Copyright (c) 2004 IBM Corporation and others. + * All rights reserved. This program and the accompanying materials + * are made available under the terms of the Eclipse Public License v1.0 + * which accompanies this distribution, and is available at + * http://www.eclipse.org/legal/epl-v10.html + * + * Contributors: + * IBM Corporation - initial API and implementation + *******************************************************************************/ +package org.eclipse.wst.html.core.htmlcss; + + + +import org.eclipse.wst.css.core.adapters.IStyleSelectorAdapter; +import org.eclipse.wst.sse.core.AdapterFactory; +import org.eclipse.wst.sse.core.INodeAdapter; +import org.eclipse.wst.sse.core.INodeNotifier; + +/** + * Insert the type's description here. + */ +public class HTMLStyleSelectorAdapterFactory implements AdapterFactory { + + private static HTMLStyleSelectorAdapterFactory instance; + private Object toMatch = IStyleSelectorAdapter.class; + + /** + * CSSModelProvideAdapterFactory constructor comment. + */ + public HTMLStyleSelectorAdapterFactory() { + super(); + } + + /** + * Method that returns the adapter associated with the given object. + * It may be a singleton or not ... depending on the needs of the INodeAdapter ... + * but in general it is recommended for an adapter to be stateless, + * so the efficiencies of a singleton can be gained. + * + * The implementation of this method should call addAdapter on the adapted + * object with the correct instance of the adapter. + */ + public INodeAdapter adapt(INodeNotifier notifier) { + INodeAdapter adapter = notifier.getExistingAdapter(IStyleSelectorAdapter.class); + if (adapter != null) + return adapter; + adapter = HTMLStyleSelectorAdapter.getInstance(); + notifier.addAdapter(adapter); + return adapter; + } + + /** + * Insert the method's description here. + * @return com.ibm.iwt.css.adapters.HTMLStyleSelectorAdapterFactory + */ + public synchronized static HTMLStyleSelectorAdapterFactory getInstance() { + if (instance == null) + instance = new HTMLStyleSelectorAdapterFactory(); + return instance; + } + + /** + * isFactoryForType method comment. + */ + public boolean isFactoryForType(Object type) { + return type == toMatch; + } + + public void release() { + // default is to do nothing + } + + /** + * Overriding copy method + */ + public AdapterFactory copy() { + return getInstance(); + } + +}
\ No newline at end of file diff --git a/bundles/org.eclipse.wst.html.core/src/org/eclipse/wst/html/core/htmlcss/LinkElementAdapter.java b/bundles/org.eclipse.wst.html.core/src/org/eclipse/wst/html/core/htmlcss/LinkElementAdapter.java new file mode 100644 index 0000000000..9b412c22a0 --- /dev/null +++ b/bundles/org.eclipse.wst.html.core/src/org/eclipse/wst/html/core/htmlcss/LinkElementAdapter.java @@ -0,0 +1,276 @@ +/******************************************************************************* + * Copyright (c) 2004 IBM Corporation and others. + * All rights reserved. This program and the accompanying materials + * are made available under the terms of the Eclipse Public License v1.0 + * which accompanies this distribution, and is available at + * http://www.eclipse.org/legal/epl-v10.html + * + * Contributors: + * IBM Corporation - initial API and implementation + *******************************************************************************/ +package org.eclipse.wst.html.core.htmlcss; +import java.io.IOException; +import java.io.UnsupportedEncodingException; + +import org.eclipse.core.runtime.IPath; +import org.eclipse.core.runtime.Path; +import org.eclipse.wst.common.encoding.content.IContentTypeIdentifier; +import org.eclipse.wst.css.core.adapters.IModelProvideAdapter; +import org.eclipse.wst.css.core.adapters.IStyleSheetListAdapter; +import org.eclipse.wst.css.core.document.ICSSModel; +import org.eclipse.wst.sse.core.INodeNotifier; +import org.eclipse.wst.sse.core.IStructuredModel; +import org.eclipse.wst.sse.core.util.URIResolver; +import org.eclipse.wst.xml.core.document.XMLModel; +import org.eclipse.wst.xml.core.document.XMLNode; +import org.w3c.dom.Attr; +import org.w3c.dom.Document; +import org.w3c.dom.Element; + +/** + */ +public class LinkElementAdapter extends AbstractStyleSheetAdapter { + + private final static String CSS_ID = IContentTypeIdentifier.ContentTypeID_CSS; + private boolean replaceModel = true; + // this variable to hold the class is just a VAJava trick. + // it improves performance in VAJava by minimizing class loading. + private final Class ModelProvideAdapterClass = IModelProvideAdapter.class; + + /** + */ + protected LinkElementAdapter() { + super(); + } + + /** + */ + private void attrReplaced() { + this.replaceModel = true; + + Element element = getElement(); + if (element == null) + return; // error + Document document = element.getOwnerDocument(); + if (document == null) + return; // error + INodeNotifier notifier = (INodeNotifier) document; + HTMLDocumentAdapter adapter = (HTMLDocumentAdapter) notifier.getAdapterFor(IStyleSheetListAdapter.class); + if (adapter == null) + return; + adapter.childReplaced(); + } + + /** + * + * @return com.ibm.sed.css.model.interfaces.ICSSModel + */ + protected ICSSModel createModel() { + // create phantom(broken link) external CSS model + if (getElement() == null) + return null; + IStructuredModel baseModel = ((XMLNode) getElement()).getModel(); + ICSSModel newModel = (ICSSModel) baseModel.getModelManager().createUnManagedStructuredModelFor(CSS_ID); + + // calculate base location and set + // get resolver in Model + URIResolver resolver = baseModel.getResolver(); + + // resolve to absolute url : this need not exact location of css file. It is important that absurl is not null. + String ref = getElement().getAttribute(org.eclipse.wst.html.core.HTML40Namespace.ATTR_NAME_HREF); + String absurl = (resolver != null && ref != null) ? resolver.getLocationByURI(ref, true) : null; + if ((absurl == null) || (absurl.length() == 0)) { + IPath basePath = new Path(baseModel.getBaseLocation()); + URLHelper helper = new URLHelper(basePath.removeLastSegments(1).toString()); + absurl = helper.toAbsolute(ref == null ? "" : ref);//$NON-NLS-1$ + } + if ((absurl == null) || (absurl.length() == 0)) { + absurl = ref; + } + if (absurl == null) { + absurl = "";//$NON-NLS-1$ + } + newModel.setBaseLocation(absurl); + + // set style listener + newModel.addStyleListener(this); + + return newModel; + } + + /** + */ + public ICSSModel getModel() { + ICSSModel model = getExistingModel(); + if (this.replaceModel) { + ICSSModel oldModel = model; + + model = retrieveModel(); + setModel(model); + + // release old model + if (oldModel != null) { + // get ModelProvideAdapter + IModelProvideAdapter adapter = (IModelProvideAdapter) ((INodeNotifier) getElement()).getAdapterFor(IModelProvideAdapter.class); + adapter.modelRemoved(oldModel); + + oldModel.releaseFromRead(); + + } + this.replaceModel = false; + } + return model; + } + + /** + */ + public void notifyChanged(INodeNotifier notifier, int eventType, Object changedFeature, Object oldValue, Object newValue, int pos) { + if (eventType != INodeNotifier.CHANGE) + return; + Attr attr = (Attr) changedFeature; + if (attr == null) + return; + String name = attr.getName(); + if (name.equalsIgnoreCase("rel") || //$NON-NLS-1$ + name.equalsIgnoreCase("type") || //$NON-NLS-1$ + name.equalsIgnoreCase("href")) {//$NON-NLS-1$ + attrReplaced(); + } + } + + /** + */ + public void refreshSheet() { + if (!replaceModel) { + removed(); + replaceModel = true; + + XMLNode node = (XMLNode) getElement(); + if (node != null) { + node.notify(INodeNotifier.CHANGE, getElement().getAttributeNode(org.eclipse.wst.html.core.HTML40Namespace.ATTR_NAME_HREF), null, null, node.getStartOffset()); + } + } + } + + /** + */ + public void released() { + ICSSModel model = getExistingModel(); + if (model != null) { + try { + // get ModelProvideAdapter + IModelProvideAdapter adapter = (IModelProvideAdapter) ((INodeNotifier) getElement()).getAdapterFor(IModelProvideAdapter.class); + + // set element to null first, so that no document wide updates + setElement(null); + setModel(null); + + if (adapter != null) + adapter.modelReleased(model); + } + finally { + model.releaseFromRead(); + } + } + this.replaceModel = false; + } + + /** + */ + public void removed() { + ICSSModel model = getExistingModel(); + if (model != null) { + try { + setModel(null); + + // get ModelProvideAdapter + IModelProvideAdapter adapter = (IModelProvideAdapter) ((INodeNotifier) getElement()).getAdapterFor(IModelProvideAdapter.class); + if (adapter != null) + adapter.modelRemoved(model); + } + finally { + model.releaseFromRead(); + } + } + this.replaceModel = false; + } + + /** + */ + protected boolean isValidAttribute() { + Element element = getElement(); + if (element == null) + return false; + String rel = element.getAttribute("rel");//$NON-NLS-1$ + if (rel == null || !rel.equalsIgnoreCase("stylesheet"))//$NON-NLS-1$ + return false; + String type = element.getAttribute("type");//$NON-NLS-1$ + if (type != null && !type.equalsIgnoreCase("text/css"))//$NON-NLS-1$ + return false; + String href = element.getAttribute("href");//$NON-NLS-1$ + if (href == null || href.length() == 0) + return false; + return true; + } + + /** + */ + private ICSSModel retrieveModel() { + if (!isValidAttribute()) { + return null; + } + + // null,attr check is done in isValidAttribute() + Element element = getElement(); + String href = element.getAttribute("href");//$NON-NLS-1$ + + XMLModel baseModel = ((XMLNode) element).getModel(); + if (baseModel == null) + return null; + Object id = baseModel.getId(); + if (!(id instanceof String)) + return null; + //String base = (String)id; + + // get ModelProvideAdapter + IModelProvideAdapter adapter = (IModelProvideAdapter) ((INodeNotifier) getElement()).getAdapterFor(ModelProvideAdapterClass); + + URLModelProvider provider = new URLModelProvider(); + try { + IStructuredModel newModel = provider.getModelForRead(baseModel, href); + if (newModel == null) + return null; + if (!(newModel instanceof ICSSModel)) { + newModel.releaseFromRead(); + return null; + } + + // notify adapter + if (adapter != null) + adapter.modelProvided(newModel); + + return (ICSSModel) newModel; + } + catch (UnsupportedEncodingException e) { + } + catch (IOException e) { + } + + return null; + } + + /** + */ + protected void setModel(ICSSModel model) { + ICSSModel oldModel = getExistingModel(); + if (model == oldModel) + return; + super.setModel(model); + if (this.replaceModel) + this.replaceModel = false; + if (oldModel != null) + oldModel.removeStyleListener(this); + if (model != null) + model.addStyleListener(this); + } +}
\ No newline at end of file diff --git a/bundles/org.eclipse.wst.html.core/src/org/eclipse/wst/html/core/htmlcss/StyleAdapterFactory.java b/bundles/org.eclipse.wst.html.core/src/org/eclipse/wst/html/core/htmlcss/StyleAdapterFactory.java new file mode 100644 index 0000000000..30d88ad643 --- /dev/null +++ b/bundles/org.eclipse.wst.html.core/src/org/eclipse/wst/html/core/htmlcss/StyleAdapterFactory.java @@ -0,0 +1,162 @@ +/******************************************************************************* + * Copyright (c) 2004 IBM Corporation and others. + * All rights reserved. This program and the accompanying materials + * are made available under the terms of the Eclipse Public License v1.0 + * which accompanies this distribution, and is available at + * http://www.eclipse.org/legal/epl-v10.html + * + * Contributors: + * IBM Corporation - initial API and implementation + *******************************************************************************/ +package org.eclipse.wst.html.core.htmlcss; + + + +import org.eclipse.wst.common.contentmodel.CMAttributeDeclaration; +import org.eclipse.wst.common.contentmodel.CMDocument; +import org.eclipse.wst.common.contentmodel.CMElementDeclaration; +import org.eclipse.wst.common.contentmodel.CMNamedNodeMap; +import org.eclipse.wst.common.contentmodel.modelquery.ModelQuery; +import org.eclipse.wst.css.core.adapters.IStyleDeclarationAdapter; +import org.eclipse.wst.css.core.adapters.IStyleSheetAdapter; +import org.eclipse.wst.css.core.adapters.IStyleSheetListAdapter; +import org.eclipse.wst.html.core.HTML40Namespace; +import org.eclipse.wst.sse.core.AdapterFactory; +import org.eclipse.wst.sse.core.INodeAdapter; +import org.eclipse.wst.sse.core.INodeNotifier; +import org.eclipse.wst.xml.core.modelquery.ModelQueryUtil; +import org.w3c.dom.Document; +import org.w3c.dom.Element; +import org.w3c.dom.Node; + +/** + */ +public class StyleAdapterFactory implements AdapterFactory { + + private static StyleAdapterFactory instance = null; + + // private static String CSS_CONTENT_TYPE = "text/css";//$NON-NLS-1$ + /** + */ + private StyleAdapterFactory() { + super(); + } + + /** + */ + public INodeAdapter adapt(INodeNotifier notifier) { + if (notifier == null) + return null; + + Node node = (Node) notifier; + short nodeType = node.getNodeType(); + if (nodeType == Node.DOCUMENT_NODE) { + INodeAdapter adapter = notifier.getExistingAdapter(IStyleSheetListAdapter.class); + if (adapter != null) + return adapter; + HTMLDocumentAdapter newAdapter = new HTMLDocumentAdapter(); + newAdapter.setDocument((Document) node); + notifier.addAdapter(newAdapter); + return newAdapter; + } + if (nodeType != Node.ELEMENT_NODE) + return null; + + Element element = (Element) node; + String tagName = element.getTagName(); + if (tagName.equalsIgnoreCase(HTML40Namespace.ElementName.STYLE)) { + if (!isTagAvailable(element.getOwnerDocument(), HTML40Namespace.ElementName.STYLE)) { + return null; + } + // String type = element.getAttribute(HTML40Namespace.ATTR_NAME_TYPE); + // if (type != null && ! type.equalsIgnoreCase(CSS_CONTENT_TYPE)) { + // return null; + // } + INodeAdapter adapter = notifier.getExistingAdapter(IStyleSheetAdapter.class); + if (adapter != null) + return adapter; + StyleElementAdapter newAdapter = new StyleElementAdapter(); + newAdapter.setElement(element); + notifier.addAdapter(newAdapter); + return newAdapter; + } + else if (tagName.equalsIgnoreCase(HTML40Namespace.ElementName.LINK)) { + if (!isTagAvailable(element.getOwnerDocument(), HTML40Namespace.ElementName.LINK)) { + return null; + } + INodeAdapter adapter = notifier.getExistingAdapter(IStyleSheetAdapter.class); + if (adapter != null) + return adapter; + LinkElementAdapter newAdapter = new LinkElementAdapter(); + newAdapter.setElement(element); + notifier.addAdapter(newAdapter); + return newAdapter; + } + + INodeAdapter adapter = notifier.getExistingAdapter(IStyleDeclarationAdapter.class); + if (adapter != null) + return adapter; + + if (!isAttributeAvailable(element, HTML40Namespace.ATTR_NAME_STYLE)) { + return null; + } + StyleAttrAdapter newAdapter = new StyleAttrAdapter(); + newAdapter.setElement(element); + notifier.addAdapter(newAdapter); + return newAdapter; + } + + /** + */ + public synchronized static StyleAdapterFactory getInstance() { + if (instance == null) + instance = new StyleAdapterFactory(); + return instance; + } + + /** + */ + public boolean isFactoryForType(Object type) { + return (type == IStyleSheetAdapter.class || type == IStyleDeclarationAdapter.class || type == IStyleSheetListAdapter.class); + } + + public void release() { + // default is to do nothing + } + + private static boolean isTagAvailable(Document document, String elementName) { + ModelQuery modelQuery = ModelQueryUtil.getModelQuery(document); + if (modelQuery != null) { + CMDocument cmdoc = modelQuery.getCorrespondingCMDocument(document); + CMNamedNodeMap map = cmdoc.getElements(); + if ((CMElementDeclaration) map.getNamedItem(elementName) != null) { + return true; + } + } + + return false; + } + + private static boolean isAttributeAvailable(Element element, String attrName) { + ModelQuery modelQuery = ModelQueryUtil.getModelQuery(element.getOwnerDocument()); + if (modelQuery != null) { + CMElementDeclaration decl = modelQuery.getCMElementDeclaration(element); + if (decl != null) { + CMNamedNodeMap map = decl.getAttributes(); + if ((CMAttributeDeclaration) map.getNamedItem(attrName) != null) { + return true; + } + } + } + + return false; + } + + /** + * Overriding Object's clone() method + */ + public AdapterFactory copy() { + return getInstance(); + } + +}
\ No newline at end of file diff --git a/bundles/org.eclipse.wst.html.core/src/org/eclipse/wst/html/core/htmlcss/StyleAttrAdapter.java b/bundles/org.eclipse.wst.html.core/src/org/eclipse/wst/html/core/htmlcss/StyleAttrAdapter.java new file mode 100644 index 0000000000..145da41a34 --- /dev/null +++ b/bundles/org.eclipse.wst.html.core/src/org/eclipse/wst/html/core/htmlcss/StyleAttrAdapter.java @@ -0,0 +1,248 @@ +/******************************************************************************* + * Copyright (c) 2004 IBM Corporation and others. + * All rights reserved. This program and the accompanying materials + * are made available under the terms of the Eclipse Public License v1.0 + * which accompanies this distribution, and is available at + * http://www.eclipse.org/legal/epl-v10.html + * + * Contributors: + * IBM Corporation - initial API and implementation + *******************************************************************************/ +package org.eclipse.wst.html.core.htmlcss; + + + +import org.eclipse.wst.css.core.adapters.IStyleDeclarationAdapter; +import org.eclipse.wst.css.core.document.ICSSModel; +import org.eclipse.wst.css.core.internal.parser.CSSSourceParser; +import org.eclipse.wst.sse.core.INodeNotifier; +import org.eclipse.wst.sse.core.events.IStructuredDocumentListener; +import org.eclipse.wst.sse.core.events.NewDocumentEvent; +import org.eclipse.wst.sse.core.events.NoChangeEvent; +import org.eclipse.wst.sse.core.events.RegionChangedEvent; +import org.eclipse.wst.sse.core.events.RegionsReplacedEvent; +import org.eclipse.wst.sse.core.events.StructuredDocumentRegionsReplacedEvent; +import org.eclipse.wst.sse.core.parser.RegionParser; +import org.eclipse.wst.sse.core.text.IStructuredDocument; +import org.eclipse.wst.sse.core.text.IStructuredDocumentRegion; +import org.eclipse.wst.sse.core.text.IStructuredDocumentRegionList; +import org.eclipse.wst.xml.core.document.XMLNode; +import org.w3c.dom.Attr; +import org.w3c.dom.Document; +import org.w3c.dom.Element; +import org.w3c.dom.css.CSSStyleDeclaration; + +/** + */ +public class StyleAttrAdapter extends AbstractCSSModelAdapter implements IStructuredDocumentListener, IStyleDeclarationAdapter { + + private boolean ignoreNotification = false; + private final static String STYLE = "style";//$NON-NLS-1$ + + /** + */ + StyleAttrAdapter() { + super(); + } + + /** + */ + public ICSSModel getModel() { + ICSSModel model = getExistingModel(); + if (model == null && isModelNecessary()) { + model = createModel(); + if (model == null) + return null; + + IStructuredDocument structuredDocument = model.getStructuredDocument(); + if (structuredDocument == null) + return null; + + RegionParser parser = structuredDocument.getParser(); + if (parser instanceof CSSSourceParser) { + ((CSSSourceParser)parser).setParserMode(CSSSourceParser.MODE_DECLARATION); + } else { + return null; + } + + structuredDocument.addDocumentChangedListener(this); + + setModel(model); // need to set before valueChanged() + valueChanged(); + } + if (model != null && !isModelNecessary()) { + model = null; + valueChanged(); + } + return model; + } + + /** + */ + public CSSStyleDeclaration getStyle() { + ICSSModel model = getModel(); + if (model == null) + return null; + return (CSSStyleDeclaration) model.getDocument(); + } + + /** + * Allowing the INodeAdapter to compare itself against the type + * allows it to return true in more than one case. + */ + public boolean isAdapterForType(Object type) { + return (type == IStyleDeclarationAdapter.class); + } + + /** + */ + public void newModel(NewDocumentEvent event) { + if (event == null) + return; + if (event.getOriginalSource() == this) + return; + + setValue(); + } + + /** + */ + public void noChange(NoChangeEvent structuredDocumentEvent) { + } + + /** + */ + public void nodesReplaced(StructuredDocumentRegionsReplacedEvent event) { + if (event == null) + return; + if (event.getOriginalSource() == this) + return; + + setValue(); + } + + /** + */ + public void notifyChanged(INodeNotifier notifier, int eventType, Object changedFeature, Object oldValue, Object newValue, int pos) { + if (this.ignoreNotification) + return; + + if (eventType != INodeNotifier.CHANGE) + return; + Attr attr = (Attr) changedFeature; + if (attr == null) + return; + String name = attr.getName(); + if (name.equalsIgnoreCase(STYLE)) { + valueChanged(); + } + } + + /** + */ + public void regionChanged(RegionChangedEvent event) { + if (event == null) + return; + if (event.getOriginalSource() == this) + return; + + setValue(); + } + + /** + */ + public void regionsReplaced(RegionsReplacedEvent event) { + if (event == null) + return; + if (event.getOriginalSource() == this) + return; + + setValue(); + } + + /** + */ + private void setValue() { + Element element = getElement(); + if (element == null) + return; + ICSSModel model = getExistingModel(); + if (model == null) + return; + IStructuredDocument structuredDocument = model.getStructuredDocument(); + if (structuredDocument == null) + return; + + String value = null; + IStructuredDocumentRegionList flatNodes = structuredDocument.getRegionList(); + if (flatNodes != null) { + int count = flatNodes.getLength(); + if (count > 0) { + StringBuffer buffer = new StringBuffer(); + for (int i = 0; i < count; i++) { + IStructuredDocumentRegion flatNode = flatNodes.item(i); + if (flatNode == null) + continue; + buffer.append(flatNode.getText()); + } + value = buffer.toString(); + } + } + + this.ignoreNotification = true; + if (value == null || value.length() == 0) { + element.removeAttribute(STYLE); + } + else { + Attr attr = element.getAttributeNode(STYLE); + if (attr != null) { + ((XMLNode) attr).setValueSource(value); + } + else { + Document document = element.getOwnerDocument(); + attr = document.createAttribute(STYLE); + ((XMLNode) attr).setValueSource(value); + element.setAttributeNode(attr); + } + } + this.ignoreNotification = false; + + notifyStyleChanged(element); + } + + /** + */ + private void valueChanged() { + Element element = getElement(); + if (element == null) + return; + if (!isModelNecessary()) { // removed + setModel(null); + + notifyStyleChanged(element); + return; + } + + ICSSModel model = getExistingModel(); + if (model == null) + return; // defer + IStructuredDocument structuredDocument = model.getStructuredDocument(); + if (structuredDocument == null) + return; // error + + String value = null; + Attr attr = element.getAttributeNode(org.eclipse.wst.html.core.HTML40Namespace.ATTR_NAME_STYLE); + if (attr != null) + value = ((XMLNode) attr).getValueSource(); + structuredDocument.setText(this, value); + + notifyStyleChanged(element); + } + + /** + * @return boolean + */ + private boolean isModelNecessary() { + return getElement() != null && getElement().getAttributeNode(org.eclipse.wst.html.core.HTML40Namespace.ATTR_NAME_STYLE) != null; + } +}
\ No newline at end of file diff --git a/bundles/org.eclipse.wst.html.core/src/org/eclipse/wst/html/core/htmlcss/StyleElementAdapter.java b/bundles/org.eclipse.wst.html.core/src/org/eclipse/wst/html/core/htmlcss/StyleElementAdapter.java new file mode 100644 index 0000000000..5ab5c17b30 --- /dev/null +++ b/bundles/org.eclipse.wst.html.core/src/org/eclipse/wst/html/core/htmlcss/StyleElementAdapter.java @@ -0,0 +1,411 @@ +/******************************************************************************* + * Copyright (c) 2004 IBM Corporation and others. + * All rights reserved. This program and the accompanying materials + * are made available under the terms of the Eclipse Public License v1.0 + * which accompanies this distribution, and is available at + * http://www.eclipse.org/legal/epl-v10.html + * + * Contributors: + * IBM Corporation - initial API and implementation + *******************************************************************************/ +package org.eclipse.wst.html.core.htmlcss; + + + +import org.eclipse.wst.css.core.adapters.IModelProvideAdapter; +import org.eclipse.wst.css.core.adapters.IStyleSheetListAdapter; +import org.eclipse.wst.css.core.document.ICSSModel; +import org.eclipse.wst.html.core.HTML40Namespace; +import org.eclipse.wst.sse.core.INodeNotifier; +import org.eclipse.wst.sse.core.events.IStructuredDocumentListener; +import org.eclipse.wst.sse.core.events.NewDocumentEvent; +import org.eclipse.wst.sse.core.events.NoChangeEvent; +import org.eclipse.wst.sse.core.events.RegionChangedEvent; +import org.eclipse.wst.sse.core.events.RegionsReplacedEvent; +import org.eclipse.wst.sse.core.events.StructuredDocumentRegionsReplacedEvent; +import org.eclipse.wst.sse.core.text.IStructuredDocument; +import org.eclipse.wst.sse.core.text.IStructuredDocumentRegion; +import org.eclipse.wst.sse.core.text.IStructuredDocumentRegionList; +import org.eclipse.wst.xml.core.document.XMLModel; +import org.eclipse.wst.xml.core.document.XMLNode; +import org.w3c.dom.Attr; +import org.w3c.dom.Document; +import org.w3c.dom.Element; +import org.w3c.dom.Node; + +/** + */ +public class StyleElementAdapter extends AbstractStyleSheetAdapter implements IStructuredDocumentListener { + + private boolean replaceModel = true; + private boolean ignoreNotification = false; + + /** + */ + protected StyleElementAdapter() { + super(); + } + + /** + * Preparation of applying changes from CSS sub-model to HTML model + */ + private void changeStructuredDocumentRegion(IStructuredDocumentRegion flatNode) { + if (flatNode == null) + return; + Element element = getElement(); + if (element == null) + return; + ICSSModel model = getExistingModel(); + if (model == null) + return; + IStructuredDocument structuredDocument = model.getStructuredDocument(); + if (structuredDocument == null) + return; + + // get old content length + Node child = element.getFirstChild(); + if (child == null || child.getNodeType() != Node.TEXT_NODE) + return; + XMLNode content = (XMLNode) child; + int oldLength = content.getEndOffset() - content.getStartOffset(); + + // get new content length + int newLength = 0; + IStructuredDocumentRegionList flatNodes = structuredDocument.getRegionList(); + if (flatNodes != null) { + int count = flatNodes.getLength(); + if (count > 0) { + IStructuredDocumentRegion last = flatNodes.item(count - 1); + if (last != null) + newLength = last.getEnd(); + } + } + + int offset = flatNode.getStart(); + int end = flatNode.getEnd(); + int diff = oldLength - newLength; + int length = end - offset + diff; + String data = flatNode.getText(); + + replaceData(offset, length, data); + } + + /** + * Apply changes from HTML model to CSS sub-model + */ + private void contentChanged() { + Element element = getElement(); + if (element == null) + return; + ICSSModel model = getExistingModel(); + if (model == null) + return; + IStructuredDocument structuredDocument = model.getStructuredDocument(); + if (structuredDocument == null) + return; + + String data = null; + Node child = element.getFirstChild(); + if (child != null && child.getNodeType() == Node.TEXT_NODE && child.getNextSibling() == null) { + data = child.getNodeValue(); + } + if (data == null) + data = "";//$NON-NLS-1$ + + // minimize replace range + int start = 0, end = 0; + String oldData = structuredDocument.get(); + if (oldData == null) + oldData = "";//$NON-NLS-1$ + + // search differenct character position from first + for (; start < oldData.length() && start < data.length(); start++) + if (oldData.charAt(start) != data.charAt(start)) + break; + + if (start == oldData.length() && start == data.length()) + return; // no change + else if (start == oldData.length()) { + structuredDocument.replaceText(getRequesterH2C(), start, 0, data.substring(start)); // append text to last + } + else if (start == data.length()) { + structuredDocument.replaceText(getRequesterH2C(), start, oldData.length() - start, ""); // remove text of last //$NON-NLS-1$ + } + else { + // search differenct character position from last + for (; start < oldData.length() - end && start < data.length() - end; end++) { + if (oldData.charAt(oldData.length() - end - 1) != data.charAt(data.length() - end - 1)) + break; + } + structuredDocument.replaceText(getRequesterH2C(), start, oldData.length() - end - start, data.substring(start, data.length() - end)); + } + + } + + /** + */ + public ICSSModel getModel() { + ICSSModel model = getExistingModel(); + if (this.replaceModel) { + ICSSModel oldModel = model; + model = createModel(); + + setModel(model); // need to set before contentChanged() + contentChanged(); + + if (oldModel != null) { + // get ModelProvideAdapter + IModelProvideAdapter adapter = (IModelProvideAdapter) ((INodeNotifier) getElement()).getAdapterFor(IModelProvideAdapter.class); + if (adapter != null) { + adapter.modelRemoved(oldModel); + } + } + + this.replaceModel = false; + } + return model; + } + + /** + */ + protected boolean isValidAttribute() { + Element element = getElement(); + if (element == null) { + return false; + } + String type = element.getAttribute(HTML40Namespace.ATTR_NAME_TYPE); + if (type != null && !type.equalsIgnoreCase("text/css")) { //$NON-NLS-1$ + return false; + } + return true; + } + + /** + */ + protected ICSSModel createModel() { + if (!isValidAttribute()) { + return null; + } + + ICSSModel model = super.createModel(); + IStructuredDocument structuredDocument = model.getStructuredDocument(); + if (structuredDocument == null) + return null; + structuredDocument.addDocumentChangedListener(this); + + return model; + } + + /** + */ + // public ICSSModel getModel() { + // ICSSModel model = getExistingModel(); + // if (model == null) { + // model = createModel(); + // if (model == null) return null; + // IStructuredDocument structuredDocument = model.getStructuredDocument(); + // if (structuredDocument == null) return null; + // structuredDocument.addModelChangedListener(this); + // setModel(model); // need to set before contentChanged() + // contentChanged(); + // } + // return model; + // } + /** + */ + private Object getRequesterH2C() { + return (getElement() != null && ((XMLNode) getElement()).getModel() != null) ? (Object) ((XMLNode) getElement()).getModel() : this; + } + + /** + */ + private Object getRequesterC2H() { + return (getModel() != null) ? (Object) getModel() : this; + } + + /** + * Implementing IStructuredDocumentListener's method + * Event from CSS Flat Model + */ + public void newModel(NewDocumentEvent event) { + if (event == null) + return; + if (event.getOriginalSource() == getRequesterH2C()) + return; + IStructuredDocument structuredDocument = event.getStructuredDocument(); + if (structuredDocument == null) + return; + IStructuredDocumentRegionList flatNodes = structuredDocument.getRegionList(); + if (flatNodes == null) + return; + + replaceStructuredDocumentRegions(flatNodes, null); + } + + /** + * Implementing IStructuredDocumentListener's method + * Event from CSS Flat Model + */ + public void noChange(NoChangeEvent structuredDocumentEvent) { + } + + /** + * Implementing IStructuredDocumentListener's method + * Event from CSS Flat Model + */ + public void nodesReplaced(StructuredDocumentRegionsReplacedEvent event) { + if (event == null) + return; + if (event.getOriginalSource() == getRequesterH2C()) + return; + IStructuredDocumentRegionList oldStructuredDocumentRegions = event.getOldStructuredDocumentRegions(); + IStructuredDocumentRegionList newStructuredDocumentRegions = event.getNewStructuredDocumentRegions(); + if (oldStructuredDocumentRegions == null && newStructuredDocumentRegions == null) + return; + + replaceStructuredDocumentRegions(newStructuredDocumentRegions, oldStructuredDocumentRegions); + } + + /** + * Overriding INodeAdapter's method + * Event from <STYLE> element + */ + public void notifyChanged(INodeNotifier notifier, int eventType, Object changedFeature, Object oldValue, Object newValue, int pos) { + if (this.ignoreNotification) + return; + + if (eventType == INodeNotifier.ADD || eventType == INodeNotifier.REMOVE || eventType == INodeNotifier.CONTENT_CHANGED) { + contentChanged(); + } + else if (eventType == INodeNotifier.CHANGE) { + Attr attr = (Attr) changedFeature; + if (attr == null) + return; + String name = attr.getName(); + if (name.equalsIgnoreCase("type")) { //$NON-NLS-1$ + this.replaceModel = true; + + Element element = getElement(); + if (element == null) { + return; + } + Document document = element.getOwnerDocument(); + if (document == null) { + return; + } + HTMLDocumentAdapter adapter = (HTMLDocumentAdapter) ((INodeNotifier) document).getAdapterFor(IStyleSheetListAdapter.class); + if (adapter != null) { + adapter.childReplaced(); + } + } + } + } + + /** + * Implementing IStructuredDocumentListener's method + * Event from CSS Flat Model + */ + public void regionChanged(RegionChangedEvent event) { + if (event == null) + return; + if (event.getOriginalSource() == getRequesterH2C()) + return; + IStructuredDocumentRegion flatNode = event.getStructuredDocumentRegion(); + if (flatNode == null) + return; + + changeStructuredDocumentRegion(flatNode); + } + + /** + * Implementing IStructuredDocumentListener's method + * Event from CSS Flat Model + */ + public void regionsReplaced(RegionsReplacedEvent event) { + if (event == null) + return; + if (event.getOriginalSource() == getRequesterH2C()) + return; + IStructuredDocumentRegion flatNode = event.getStructuredDocumentRegion(); + if (flatNode == null) + return; + + changeStructuredDocumentRegion(flatNode); + } + + /** + * Apply changes from CSS sub-model to HTML model + */ + private void replaceData(int offset, int length, String data) { + XMLNode element = (XMLNode) getElement(); + if (element == null) + return; + XMLModel ownerModel = element.getModel(); + if (ownerModel == null) + return; + IStructuredDocument structuredDocument = ownerModel.getStructuredDocument(); + if (structuredDocument == null) + return; + IStructuredDocumentRegion flatNode = element.getStartStructuredDocumentRegion(); + if (flatNode == null) + return; + + int contentOffset = flatNode.getEndOffset(); + if (data == null) + data = "";//$NON-NLS-1$ + + this.ignoreNotification = true; + structuredDocument.replaceText(getRequesterC2H(), contentOffset + offset, length, data); + this.ignoreNotification = false; + } + + /** + * Preparation of applying changes from CSS sub-model to HTML model + */ + private void replaceStructuredDocumentRegions(IStructuredDocumentRegionList newStructuredDocumentRegions, IStructuredDocumentRegionList oldStructuredDocumentRegions) { + int offset = 0; + int length = 0; + if (oldStructuredDocumentRegions != null) { + int count = oldStructuredDocumentRegions.getLength(); + if (count > 0) { + IStructuredDocumentRegion first = oldStructuredDocumentRegions.item(0); + if (first != null) + offset = first.getStart(); + IStructuredDocumentRegion last = oldStructuredDocumentRegions.item(count - 1); + if (last != null) + length = last.getEnd() - offset; + } + } + String data = null; + if (newStructuredDocumentRegions != null) { + int count = newStructuredDocumentRegions.getLength(); + if (count > 0) { + StringBuffer buffer = new StringBuffer(); + for (int i = 0; i < count; i++) { + IStructuredDocumentRegion flatNode = newStructuredDocumentRegions.item(i); + if (flatNode == null) + continue; + buffer.append(flatNode.getText()); + if (i == 0) + offset = flatNode.getStart(); + } + data = buffer.toString(); + } + } + + replaceData(offset, length, data); + } + + /** + */ + protected void setModel(ICSSModel model) { + ICSSModel oldModel = getExistingModel(); + if (model == oldModel) + return; + super.setModel(model); + if (oldModel != null) + oldModel.removeStyleListener(this); + if (model != null) + model.addStyleListener(this); + } +}
\ No newline at end of file diff --git a/bundles/org.eclipse.wst.html.core/src/org/eclipse/wst/html/core/htmlcss/StyleListener.java b/bundles/org.eclipse.wst.html.core/src/org/eclipse/wst/html/core/htmlcss/StyleListener.java new file mode 100644 index 0000000000..c6d78326b3 --- /dev/null +++ b/bundles/org.eclipse.wst.html.core/src/org/eclipse/wst/html/core/htmlcss/StyleListener.java @@ -0,0 +1,22 @@ +/******************************************************************************* + * Copyright (c) 2004 IBM Corporation and others. + * All rights reserved. This program and the accompanying materials + * are made available under the terms of the Eclipse Public License v1.0 + * which accompanies this distribution, and is available at + * http://www.eclipse.org/legal/epl-v10.html + * + * Contributors: + * IBM Corporation - initial API and implementation + *******************************************************************************/ +package org.eclipse.wst.html.core.htmlcss; + + + +/** + */ +public interface StyleListener { + + /** + */ + void styleChanged(); +}
\ No newline at end of file diff --git a/bundles/org.eclipse.wst.html.core/src/org/eclipse/wst/html/core/htmlcss/URLHelper.java b/bundles/org.eclipse.wst.html.core/src/org/eclipse/wst/html/core/htmlcss/URLHelper.java new file mode 100644 index 0000000000..e62dd0de09 --- /dev/null +++ b/bundles/org.eclipse.wst.html.core/src/org/eclipse/wst/html/core/htmlcss/URLHelper.java @@ -0,0 +1,33 @@ +/******************************************************************************* + * Copyright (c) 2004 IBM Corporation and others. + * All rights reserved. This program and the accompanying materials + * are made available under the terms of the Eclipse Public License v1.0 + * which accompanies this distribution, and is available at + * http://www.eclipse.org/legal/epl-v10.html + * + * Contributors: + * IBM Corporation - initial API and implementation + *******************************************************************************/ +package org.eclipse.wst.html.core.htmlcss; + +/** + * @deprecated - use com.ibm.sse.model.css.util.URLHelper + */ +public class URLHelper extends org.eclipse.wst.css.core.util.URLHelper { + + /** + * @param baseUrl + */ + public URLHelper(String baseUrl) { + super(baseUrl); + } + + /** + * @param baseUrl + * @param docRoot + */ + public URLHelper(String baseUrl, String docRoot) { + super(baseUrl, docRoot); + } + +} diff --git a/bundles/org.eclipse.wst.html.core/src/org/eclipse/wst/html/core/htmlcss/URLModelProvider.java b/bundles/org.eclipse.wst.html.core/src/org/eclipse/wst/html/core/htmlcss/URLModelProvider.java new file mode 100644 index 0000000000..df26d79a2f --- /dev/null +++ b/bundles/org.eclipse.wst.html.core/src/org/eclipse/wst/html/core/htmlcss/URLModelProvider.java @@ -0,0 +1,448 @@ +/******************************************************************************* + * Copyright (c) 2004 IBM Corporation and others. + * All rights reserved. This program and the accompanying materials + * are made available under the terms of the Eclipse Public License v1.0 + * which accompanies this distribution, and is available at + * http://www.eclipse.org/legal/epl-v10.html + * + * Contributors: + * IBM Corporation - initial API and implementation + *******************************************************************************/ +package org.eclipse.wst.html.core.htmlcss; + + + +import java.io.FileInputStream; +import java.io.FileNotFoundException; +import java.io.IOException; +import java.io.InputStream; +import java.io.UnsupportedEncodingException; +import java.nio.charset.UnsupportedCharsetException; + +import org.eclipse.core.resources.IContainer; +import org.eclipse.core.resources.IFile; +import org.eclipse.core.resources.IProject; +import org.eclipse.core.resources.IResource; +import org.eclipse.core.resources.IWorkspaceRoot; +import org.eclipse.core.resources.ResourcesPlugin; +import org.eclipse.core.runtime.CoreException; +import org.eclipse.core.runtime.IPath; +import org.eclipse.core.runtime.Path; +import org.eclipse.core.runtime.Platform; +import org.eclipse.wst.common.encoding.EncodingRule; +import org.eclipse.wst.html.core.document.HTMLDocumentTypeConstants; +import org.eclipse.wst.sse.core.IModelManager; +import org.eclipse.wst.sse.core.IModelManagerPlugin; +import org.eclipse.wst.sse.core.IStructuredModel; +import org.eclipse.wst.sse.core.exceptions.ResourceAlreadyExists; +import org.eclipse.wst.sse.core.exceptions.ResourceInUse; +import org.eclipse.wst.sse.core.util.PathHelper; +import org.eclipse.wst.sse.core.util.ProjectResolver; +import org.eclipse.wst.sse.core.util.URIResolver; +import org.eclipse.wst.xml.core.document.DocumentTypeAdapter; +import org.eclipse.wst.xml.core.document.XMLDocument; +import org.eclipse.wst.xml.core.document.XMLModel; +import org.w3c.dom.NamedNodeMap; +import org.w3c.dom.Node; +import org.w3c.dom.NodeList; + +// TODO when this class is removed from .core, PathHelper and URLHelper class +// also can be removed. + +/** + */ +public class URLModelProvider { + + private static final int GET_MODEL_FOR_READ = 1; + // private static final int GET_NEW_MODEL_FOR_READ = 2; + private static final int GET_MODEL_FOR_EDIT = 3; + // private static final int GET_NEW_MODEL_FOR_EDIT = 4; + // private static final int READ_BUFFER_SIZE = 4096; + // IModelManager + private IModelManager modelManager = null; + + /** + */ + public URLModelProvider() { + super(); + + // obtain model manager + IModelManagerPlugin plugin = (IModelManagerPlugin) Platform.getPlugin(IModelManagerPlugin.ID); + modelManager = plugin.getModelManager(); + } + + /** + * Calculate ID from a filename. This must be same as + * FileModelProvider.calculateId(IFile) + */ + private static String calculateId(IPath fullIPath) { + return fullIPath.toString(); + } + + /** + * <code>baseModel</code>: the model containing the link + * <code>ref</code>: the link URL string + */ + private IStructuredModel getCommonModelFor(final IStructuredModel baseModel, final String ref, final int which) throws IOException { + // first, create absolute url + String absURL = resolveURI(baseModel, ref, true); + if ((absURL == null) || (absURL.length() == 0)) { + return null; + } + + // need to remove file:// scheme if necessary + // see com.ibm.sed.util.ProjectResolver.getLocationByURI() + try { + final java.net.URL aURL = new java.net.URL(absURL); + // An actual URL was given, only file:/// is supported + // resolve it by finding the file it points to + if (!aURL.getProtocol().equals("platform")) { //$NON-NLS-1$ + if (aURL.getProtocol().equals("file") && (aURL.getHost().equals("localhost") || aURL.getHost().length() == 0)) {//$NON-NLS-2$//$NON-NLS-1$ + absURL = aURL.getFile(); + final IPath ipath = new Path(absURL); + // if path has a device, and if it begins with + // IPath.SEPARATOR, remove it + final String device = ipath.getDevice(); + if ((device != null) && (device.length() > 0)) { + if (device.charAt(0) == IPath.SEPARATOR) { + final String newDevice = device.substring(1); + absURL = ipath.setDevice(newDevice).toString(); + } + } + + } + } + } + catch (java.net.MalformedURLException mfuExc) { + } + + + // next, decide project + IProject project = null; + final IPath fullIPath = new Path(absURL); + IWorkspaceRoot workspace = ResourcesPlugin.getWorkspace().getRoot(); + IContainer container = workspace.getContainerForLocation(fullIPath); + if (container != null) { + // fullIPath doesn't exist in workspace + project = container.getProject(); + } + + // If HTML document has a link to an extern CSS which is not in + // IProject + // workspace.getContainerForLoation() may return null. We need to take + // care + // of this case + + // now, get absURL's IFile + if ((project != null) && (project.getLocation().isPrefixOf(fullIPath) == false)) { + // it's at outside of Project + return null; + } + + IStructuredModel model = null; + if (project != null) { + IPath filePath = fullIPath.removeFirstSegments(project.getLocation().segmentCount()); + IFile file = (filePath != null && !filePath.isEmpty()) ? project.getFile(filePath) : null; + if (file == null) { + return null; + } + + // obtain model + if (which == GET_MODEL_FOR_EDIT) { + model = getModelForEdit(file); + } + else if (which == GET_MODEL_FOR_READ) { + model = getModelForRead(file); + } + + // setting synchronization stamp is IModelManager's client's + // responsibility + if (model != null && model.getSynchronizationStamp() == IResource.NULL_STAMP) + model.resetSynchronizationStamp(file); + } + else { + String id = null; + InputStream inStream = null; + // obtain resolver + URIResolver resolver = (project != null) ? (URIResolver) project.getAdapter(URIResolver.class) : null; + if (resolver == null) { + // ProjectResolver can take care of the case if project is + // null. + resolver = new ProjectResolver(project); + } + if (resolver == null) { + return null; + } + + // there is no project. we can't expect IProject help to create + // id/inputStream + java.io.File file = fullIPath.toFile(); + + // obatin id + id = calculateId(fullIPath); + + // obtain InputStream + try { + inStream = new FileInputStream(file); + } + catch (FileNotFoundException fnfe) { + // the file does not exist, or we don't have read permission + return null; + } + + // obtain model + try { + if (which == GET_MODEL_FOR_EDIT) { + model = getModelManager().getModelForEdit(id, inStream, resolver); + } + else if (which == GET_MODEL_FOR_READ) { + model = getModelManager().getModelForRead(id, inStream, resolver); + } + } + catch (UnsupportedEncodingException ue) { + } + catch (IOException ioe) { + } + finally { + // close now ! + if (inStream != null) { + inStream.close(); + } + } + } + + + // set locationid + if (model != null && model.getBaseLocation() == null) { + model.setBaseLocation(fullIPath.toString()); + } + + return model; + } + + /** + * <code>baseModel</code>: the model containing the link + * <code>ref</code>: the link URL string + */ + public IStructuredModel getModelForEdit(IStructuredModel baseModel, String ref) throws IOException { + return getCommonModelFor(baseModel, ref, GET_MODEL_FOR_EDIT); + } + + /** + */ + private IStructuredModel getModelForEdit(IFile file) throws IOException { + if (file == null) + return null; + IModelManager manager = getModelManager(); + + // create a fake InputStream + IStructuredModel model = null; + try { + model = manager.getModelForEdit(file); + } + catch (UnsupportedCharsetException ex) { + try { + model = manager.getModelForEdit(file, EncodingRule.FORCE_DEFAULT); + } + catch (IOException ioe) { + } + catch (CoreException ce) { + } + } + catch (CoreException ce) { + } + return model; + } + + /** + * <code>baseModel</code>: the model containing the link + * <code>ref</code>: the link URL string + */ + public IStructuredModel getModelForRead(IStructuredModel baseModel, String ref) throws UnsupportedEncodingException, IOException { + return getCommonModelFor(baseModel, ref, GET_MODEL_FOR_READ); + } + + /** + */ + private IStructuredModel getModelForRead(IFile file) throws IOException { + if (file == null) + return null; + IModelManager manager = getModelManager(); + + // create a fake InputStream + IStructuredModel model = null; + try { + model = manager.getModelForRead(file); + } + catch (UnsupportedCharsetException ex) { + try { + model = manager.getModelForRead(file, EncodingRule.FORCE_DEFAULT); + } + catch (IOException ioe) { + } + catch (CoreException ce) { + } + } + catch (CoreException ce) { + } + return model; + } + + /** + */ + private IModelManager getModelManager() { + return modelManager; + } + + public IStructuredModel getNewModelForEdit(IFile iFile) { + if (iFile == null) + return null; + IModelManager manager = getModelManager(); + if (manager == null) + return null; + + IStructuredModel model = null; + try { + model = manager.getNewModelForEdit(iFile, false); + } + catch (IOException ex) { + } + catch (ResourceInUse riu) { + } + catch (ResourceAlreadyExists rae) { + } + catch (CoreException ce) { + } + return model; + } + + public IStructuredModel getNewModelForRead(IFile iFile) { + if (iFile == null) + return null; + IModelManager manager = getModelManager(); + if (manager == null) + return null; + + IStructuredModel model = null; + try { + model = manager.getNewModelForEdit(iFile, false); + } + catch (IOException ex) { + } + catch (ResourceInUse riu) { + } + catch (ResourceAlreadyExists rae) { + } + catch (CoreException ce) { + } + return model; + } + + /** + * Utility to check the model is HTML family or not + */ + static private boolean isHTMLFamily(IStructuredModel model) { + if (model instanceof XMLModel) { + XMLDocument document = ((XMLModel) model).getDocument(); + DocumentTypeAdapter adapter = (DocumentTypeAdapter) document.getAdapterFor(DocumentTypeAdapter.class); + if (adapter != null) + return adapter.hasFeature(HTMLDocumentTypeConstants.HTML); + } + return false; + } + + /** + * <code>baseModel</code>: the model containing the link + * <code>ref</code>: the link URL string + * <code>resolveCrossProjectLinks</code>: If resolveCrossProjectLinks + * is set to true, then this method will properly resolve the URI if it is + * a valid URI pointing to another (appropriate) project. + */ + public static String resolveURI(IStructuredModel baseModel, String ref, boolean resolveCrossProjectLinks) { + if (baseModel == null) + return null; + // for HTML, 'href' attribute value of BASE element + // should be used, if exists any + String baseHref = null; + // dmw_TODO needs to be changed to handle a content model + // of HTML or XHTML + if (isHTMLFamily(baseModel)) { + final XMLModel xmlmodel = (XMLModel) baseModel; + final XMLDocument doc = xmlmodel.getDocument(); + // look for <BASE> w/ href + final NodeList nl = doc.getElementsByTagName("BASE");//$NON-NLS-1$ + if ((nl != null) && (nl.getLength() > 0)) { + // per each <BASE> + for (int i = 0; i < nl.getLength(); i++) { + final Node baseNode = nl.item(i); + if (baseNode != null) { + // get all attrs + final NamedNodeMap attrNodes = baseNode.getAttributes(); + if (attrNodes != null) { + final Node attrNode = attrNodes.getNamedItem("HREF");//$NON-NLS-1$ + if (attrNode != null) { + // found href="" + final String attrValue = attrNode.getNodeValue(); + if (attrValue != null) { + baseHref = attrValue.trim(); + } + } + } + } + // what if there are multiple <BASE> tags ?? + if (baseHref != null) { + break; + } + } + } + } + + // get resolver in Model + final URIResolver resolver = baseModel.getResolver(); + + // resolve to absolute url + final String absurl = (resolver != null) ? ((baseHref != null) ? resolver.getLocationByURI(ref, baseHref, resolveCrossProjectLinks) : resolver.getLocationByURI(ref, resolveCrossProjectLinks)) : null; + if ((resolver != null) && (absurl == null) && (ref != null) && (ref.trim().length() > 0) && (ref.trim().charAt(0) == '/')) { + // to reach here means : + // ref is a Docroot relative + // resolver can't resolve ref + // so that href is a broken and should not create model + return null; + } + if ((absurl != null) && (absurl.length() > 0)) { + return absurl; + } + + // maybe ref is at outside of the Project + // obtain docroot; + final IContainer container = (resolver != null) ? resolver.getRootLocation() : null; + String docroot = null; + if (container != null) { + docroot = container.getLocation().toString(); + } + if (docroot == null) { + docroot = baseModel.getBaseLocation(); + } + if (docroot == null) { + // should not be + return null; + } + + // obtain document url + String modelBaseLocation = baseModel.getBaseLocation(); + if ((modelBaseLocation == null) || (modelBaseLocation.length() == 0)) { + // fallback... + modelBaseLocation = baseModel.getId(); + } + if ((modelBaseLocation == null) || (modelBaseLocation.length() == 0)) { + // i can't resolve uri ! + return null; + } + + // resolve url + URLHelper helper = new URLHelper(PathHelper.getContainingFolderPath(modelBaseLocation), PathHelper.getContainingFolderPath(PathHelper.appendTrailingURLSlash(docroot))); + return helper.toAbsolute(ref); + } + +} + diff --git a/bundles/org.eclipse.wst.html.core/src/org/eclipse/wst/html/core/internal/Logger.java b/bundles/org.eclipse.wst.html.core/src/org/eclipse/wst/html/core/internal/Logger.java new file mode 100644 index 0000000000..3f109b25ac --- /dev/null +++ b/bundles/org.eclipse.wst.html.core/src/org/eclipse/wst/html/core/internal/Logger.java @@ -0,0 +1,142 @@ +/******************************************************************************* + * Copyright (c) 2004 IBM Corporation and others. + * All rights reserved. This program and the accompanying materials + * are made available under the terms of the Eclipse Public License v1.0 + * which accompanies this distribution, and is available at + * http://www.eclipse.org/legal/epl-v10.html + * + * Contributors: + * IBM Corporation - initial API and implementation + *******************************************************************************/ +package org.eclipse.wst.html.core.internal; + +import java.util.StringTokenizer; + +import org.eclipse.core.runtime.IStatus; +import org.eclipse.core.runtime.Platform; +import org.eclipse.core.runtime.Plugin; +import org.eclipse.core.runtime.Status; +import org.eclipse.wst.html.core.HTMLCorePlugin; + +/** + * Small convenience class to log messages to plugin's log file and also, if desired, + * the console. This class should only be used by classes in this plugin. Other + * plugins should make their own copy, with appropriate ID. + */ +public class Logger { + private static Plugin fPlugin = HTMLCorePlugin.getDefault(); + private static final String fPluginId = fPlugin.getDescriptor().getUniqueIdentifier(); + + private static final String TRACEFILTER_LOCATION = "/debug/tracefilter"; //$NON-NLS-1$ + + public static final int OK = IStatus.OK; // 0 + public static final int INFO = IStatus.INFO; // 1 + public static final int WARNING = IStatus.WARNING; // 2 + public static final int ERROR = IStatus.ERROR; // 4 + + public static final int OK_DEBUG = 200 + OK; + public static final int INFO_DEBUG = 200 + INFO; + public static final int WARNING_DEBUG = 200 + WARNING; + public static final int ERROR_DEBUG = 200 + ERROR; + + /** + * Adds message to log. + * @param level severity level of the message (OK, INFO, WARNING, ERROR, OK_DEBUG, INFO_DEBUG, WARNING_DEBUG, ERROR_DEBUG) + * @param message text to add to the log + * @param exception exception thrown + */ + protected static void _log(int level, String message, Throwable exception) { + if (level == OK_DEBUG || level == INFO_DEBUG || level == WARNING_DEBUG || level == ERROR_DEBUG) { + if (!isDebugging()) + return; + } + + int severity = IStatus.OK; + switch (level) { + case INFO_DEBUG : + case INFO : + severity = IStatus.INFO; + break; + case WARNING_DEBUG : + case WARNING : + severity = IStatus.WARNING; + break; + case ERROR_DEBUG : + case ERROR : + severity = IStatus.ERROR; + } + message = (message != null) ? message : "null"; //$NON-NLS-1$ + Status statusObj = new Status(severity, fPluginId, severity, message, exception); + fPlugin.getLog().log(statusObj); + } + + /** + * Prints message to log if category matches /debug/tracefilter option. + * @param message text to print + * @param category category of the message, to be compared with /debug/tracefilter + */ + protected static void _trace(String category, String message, Throwable exception) { + if (isTracing(category)) { + message = (message != null) ? message : "null"; //$NON-NLS-1$ + Status statusObj = new Status(IStatus.OK, fPluginId, IStatus.OK, message, exception); + fPlugin.getLog().log(statusObj); + } + } + + /** + * @return true if the plugin for this logger is debugging + */ + public static boolean isDebugging() { + return fPlugin.isDebugging(); + } + + /** + * Determines if currently tracing a category + * @param category + * @return true if tracing category, false otherwise + */ + public static boolean isTracing(String category) { + if (!isDebugging()) + return false; + + String traceFilter = Platform.getDebugOption(fPluginId + TRACEFILTER_LOCATION); + if (traceFilter != null) { + StringTokenizer tokenizer = new StringTokenizer(traceFilter, ","); //$NON-NLS-1$ + while (tokenizer.hasMoreTokens()) { + String cat = tokenizer.nextToken().trim(); + if (category.equals(cat)) { + return true; + } + } + } + return false; + } + + public static void log(int level, String message) { + _log(level, message, null); + } + + public static void log(int level, String message, Throwable exception) { + _log(level, message, exception); + } + + public static void logException(String message, Throwable exception) { + _log(ERROR, message, exception); + } + + public static void logException(Throwable exception) { + _log(ERROR, exception.getMessage(), exception); + } + + public static void traceException(String category, String message, Throwable exception) { + _trace(category, message, exception); + } + + public static void traceException(String category, Throwable exception) { + _trace(category, exception.getMessage(), exception); + } + + public static void trace(String category, String message) { + _trace(category, message, null); + } +}
\ No newline at end of file diff --git a/bundles/org.eclipse.wst.html.core/src/org/eclipse/wst/html/core/internal/contenttype/ContentDescriberForHTML.java b/bundles/org.eclipse.wst.html.core/src/org/eclipse/wst/html/core/internal/contenttype/ContentDescriberForHTML.java new file mode 100644 index 0000000000..a125eb7d65 --- /dev/null +++ b/bundles/org.eclipse.wst.html.core/src/org/eclipse/wst/html/core/internal/contenttype/ContentDescriberForHTML.java @@ -0,0 +1,25 @@ +/******************************************************************************* + * Copyright (c) 2004 IBM Corporation and others. + * All rights reserved. This program and the accompanying materials + * are made available under the terms of the Eclipse Public License v1.0 + * which accompanies this distribution, and is available at + * http://www.eclipse.org/legal/epl-v10.html + * + * Contributors: + * IBM Corporation - initial API and implementation + *******************************************************************************/ +package org.eclipse.wst.html.core.internal.contenttype; + +import org.eclipse.core.runtime.content.ITextContentDescriber; +import org.eclipse.wst.common.encoding.AbstractContentDescriber; +import org.eclipse.wst.common.encoding.IResourceCharsetDetector; + + +public class ContentDescriberForHTML extends AbstractContentDescriber implements ITextContentDescriber { + + + protected IResourceCharsetDetector getDetector() { + return new HTMLResourceEncodingDetector(); + } + +}
\ No newline at end of file diff --git a/bundles/org.eclipse.wst.html.core/src/org/eclipse/wst/html/core/internal/contenttype/HTMLHeadTokenizer.java b/bundles/org.eclipse.wst.html.core/src/org/eclipse/wst/html/core/internal/contenttype/HTMLHeadTokenizer.java new file mode 100644 index 0000000000..7dfa6948ca --- /dev/null +++ b/bundles/org.eclipse.wst.html.core/src/org/eclipse/wst/html/core/internal/contenttype/HTMLHeadTokenizer.java @@ -0,0 +1,1692 @@ +/******************************************************************************* + * Copyright (c) 2004 IBM Corporation and others. + * All rights reserved. This program and the accompanying materials + * are made available under the terms of the Eclipse Public License v1.0 + * which accompanies this distribution, and is available at + * http://www.eclipse.org/legal/epl-v10.html + * + * Contributors: + * IBM Corporation - initial API and implementation + *******************************************************************************/ +/* The following code was generated by JFlex 1.2.2 on 1/27/04 6:41 PM */ + +/*nlsXXX*/ +package org.eclipse.wst.html.core.internal.contenttype; + +import java.io.IOException; +import java.io.Reader; + +import org.eclipse.wst.common.encoding.EncodingParserConstants; +import org.eclipse.wst.common.encoding.HeadParserToken; +import org.eclipse.wst.common.encoding.IntStack; +import org.eclipse.wst.xml.core.contenttype.XMLHeadTokenizerConstants; + + + +/** + * This class is a scanner generated by + * <a href="http://www.informatik.tu-muenchen.de/~kleing/jflex/">JFlex</a> 1.2.2 + * on 1/27/04 6:41 PM from the specification file + * <tt>file:/D:/DevTimeSupport/HeadParsers/HTMLHeadTokenizer/HTMLHeadTokenizer.jflex</tt> + */ +public class HTMLHeadTokenizer { + + /** this character denotes the end of file */ + final public static int YYEOF = -1; + + /** lexical states */ + final public static int ST_META_TAG = 4; + final public static int YYINITIAL = 0; + final public static int UnDelimitedString = 12; + final public static int DQ_STRING = 8; + final public static int SQ_STRING = 10; + final public static int ST_XMLDecl = 2; + final public static int QuotedAttributeValue = 6; + + /** + * YY_LEXSTATE[l] is the state in the DFA for the lexical state l + * YY_LEXSTATE[l+1] is the state in the DFA for the lexical state l + * at the beginning of a line + * l is of the form l = 2*k, k a non negative integer + */ + private final static int YY_LEXSTATE[] = {0, 1, 2, 2, 3, 3, 4, 4, 5, 5, 6, 6, 7, 7}; + + /** + * Translates characters to character classes + */ + final private static String yycmap_packed = "\11\0\1\6\1\7\2\0\1\11\22\0\1\22\1\0\1\40\2\0" + "\1\44\1\0\1\43\5\0\1\34\1\0\1\42\13\0\1\45\1\12" + "\1\10\1\31\1\13\1\0\1\21\1\0\1\24\1\26\1\17\1\0" + "\1\30\1\32\1\27\2\0\1\16\1\15\1\23\1\25\1\33\1\35" + "\2\0\1\20\1\36\1\37\1\0\1\14\1\41\7\0\1\21\1\0" + "\1\24\1\26\1\17\1\0\1\30\1\32\1\27\2\0\1\16\1\15" + "\1\23\1\25\1\33\1\35\2\0\1\20\1\36\1\37\1\0\1\14" + "\1\41\101\0\1\4\3\0\1\5\17\0\1\3\16\0\1\1\20\0" + "\1\3\16\0\1\1\1\2\170\0\1\2\ufe87\0"; + + /** + * Translates characters to character classes + */ + final private static char[] yycmap = yy_unpack_cmap(yycmap_packed); + + + /* error codes */ + final private static int YY_UNKNOWN_ERROR = 0; + final private static int YY_ILLEGAL_STATE = 1; + final private static int YY_NO_MATCH = 2; + final private static int YY_PUSHBACK_2BIG = 3; + + /* error messages for the codes above */ + final private static String YY_ERROR_MSG[] = {"Unkown internal scanner error", "Internal error: unknown state", "Error: could not match input", "Error: pushback value was too large"}; + + /** the input device */ + private java.io.Reader yy_reader; + + /** the current state of the DFA */ + private int yy_state; + + /** the current lexical state */ + private int yy_lexical_state = YYINITIAL; + + /** this buffer contains the current text to be matched and is + the source of the yytext() string */ + private char yy_buffer[] = new char[16384]; + + /** the textposition at the last accepting state */ + private int yy_markedPos; + + /** the textposition at the last state to be included in yytext */ + private int yy_pushbackPos; + + /** the current text position in the buffer */ + private int yy_currentPos; + + /** startRead marks the beginning of the yytext() string in the buffer */ + private int yy_startRead; + + /** endRead marks the last character in the buffer, that has been read + from input */ + private int yy_endRead; + + + /** the number of characters up to the start of the matched text */ + private int yychar; + + + /** + * yy_atBOL == true <=> the scanner is currently at the beginning of a line + */ + private boolean yy_atBOL; + + /** yy_atEOF == true <=> the scanner has returned a value for EOF */ + private boolean yy_atEOF; + + /** denotes if the user-EOF-code has already been executed */ + private boolean yy_eof_done; + + /* user code: */ + + + private boolean hasMore = true; + private final static int MAX_TO_SCAN = 1000; + StringBuffer string = new StringBuffer(); + // state stack for easier state handling + private IntStack fStateStack = new IntStack(); + private String valueText = null; + boolean foundContentTypeValue = false; + + + + public HTMLHeadTokenizer() { + super(); + } + + public void reset(Reader in) { + /* the input device */ + yy_reader = in; + + /* the current state of the DFA */ + yy_state = 0; + + /* the current lexical state */ + yy_lexical_state = YYINITIAL; + + /* this buffer contains the current text to be matched and is + the source of the yytext() string */ + java.util.Arrays.fill(yy_buffer, (char) 0); + + /* the textposition at the last accepting state */ + yy_markedPos = 0; + + /* the textposition at the last state to be included in yytext */ + yy_pushbackPos = 0; + + /* the current text position in the buffer */ + yy_currentPos = 0; + + /* startRead marks the beginning of the yytext() string in the buffer */ + yy_startRead = 0; + + /** + * endRead marks the last character in the buffer, that has been read + * from input + */ + yy_endRead = 0; + + + /* the number of characters up to the start of the matched text */ + yychar = 0; + + + /** + * yy_atBOL == true <=> the scanner is currently at the beginning + * of a line + */ + yy_atBOL = false; + + /* yy_atEOF == true <=> the scanner has returned a value for EOF */ + yy_atEOF = false; + + /* denotes if the user-EOF-code has already been executed */ + yy_eof_done = false; + + + fStateStack.clear(); + + hasMore = true; + + // its a little wasteful to "throw away" first char array generated + // by class init (via auto generated code), but we really do want + // a small buffer for our head parsers. + if (yy_buffer.length != MAX_TO_SCAN) { + yy_buffer = new char[MAX_TO_SCAN]; + } + + + } + + + public final HeadParserToken getNextToken() throws IOException { + String context = null; + context = primGetNextToken(); + HeadParserToken result = null; + if (valueText != null) { + result = createToken(context, yychar, valueText); + valueText = null; + } + else { + result = createToken(context, yychar, yytext()); + } + return result; + } + + public final boolean hasMoreTokens() { + return hasMore && yychar < MAX_TO_SCAN; + } + + private void pushCurrentState() { + fStateStack.push(yystate()); + + } + + private void popState() { + yybegin(fStateStack.pop()); + } + + private HeadParserToken createToken(String context, int start, String text) { + return new HeadParserToken(context, start, text); + } + + + + /** + * Creates a new scanner + * There is also a java.io.InputStream version of this constructor. + * + * @param in the java.io.Reader to read input from. + */ + public HTMLHeadTokenizer(java.io.Reader in) { + this.yy_reader = in; + } + + /** + * Creates a new scanner. + * There is also java.io.Reader version of this constructor. + * + * @param in the java.io.Inputstream to read input from. + */ + public HTMLHeadTokenizer(java.io.InputStream in) { + this(new java.io.InputStreamReader(in)); + } + + /** + * Unpacks the compressed character translation table. + * + * @param packed the packed character translation table + * @return the unpacked character translation table + */ + private static char[] yy_unpack_cmap(String packed) { + char[] map = new char[0x10000]; + int i = 0; /* index in packed string */ + int j = 0; /* index in unpacked array */ + while (i < 174) { + int count = packed.charAt(i++); + char value = packed.charAt(i++); + do + map[j++] = value; + while (--count > 0); + } + return map; + } + + + /** + * Gets the next input character. + * + * @return the next character of the input stream, EOF if the + * end of the stream is reached. + * @exception IOException if any I/O-Error occurs + */ + private int yy_advance() throws java.io.IOException { + + /* standard case */ + if (yy_currentPos < yy_endRead) + return yy_buffer[yy_currentPos++]; + + /* if the eof is reached, we don't need to work hard */ + if (yy_atEOF) + return YYEOF; + + /* otherwise: need to refill the buffer */ + + /* first: make room (if you can) */ + if (yy_startRead > 0) { + System.arraycopy(yy_buffer, yy_startRead, yy_buffer, 0, yy_endRead - yy_startRead); + + /* translate stored positions */ + yy_endRead -= yy_startRead; + yy_currentPos -= yy_startRead; + yy_markedPos -= yy_startRead; + yy_pushbackPos -= yy_startRead; + yy_startRead = 0; + } + + /* is the buffer big enough? */ + if (yy_currentPos >= yy_buffer.length) { + /* if not: blow it up */ + char newBuffer[] = new char[yy_currentPos * 2]; + System.arraycopy(yy_buffer, 0, newBuffer, 0, yy_buffer.length); + yy_buffer = newBuffer; + } + + /* finally: fill the buffer with new input */ + int numRead = yy_reader.read(yy_buffer, yy_endRead, yy_buffer.length - yy_endRead); + + if (numRead == -1) + return YYEOF; + + yy_endRead += numRead; + + return yy_buffer[yy_currentPos++]; + } + + + /** + * Closes the input stream. + */ + final public void yyclose() throws java.io.IOException { + yy_atEOF = true; /* indicate end of file */ + yy_endRead = yy_startRead; /* invalidate buffer */ + yy_reader.close(); + } + + + /** + * Returns the current lexical state. + */ + final public int yystate() { + return yy_lexical_state; + } + + /** + * Enters a new lexical state + * + * @param newState the new lexical state + */ + final public void yybegin(int newState) { + yy_lexical_state = newState; + } + + + /** + * Returns the text matched by the current regular expression. + */ + final public String yytext() { + return new String(yy_buffer, yy_startRead, yy_markedPos - yy_startRead); + } + + /** + * Returns the length of the matched text region. + */ + final public int yylength() { + return yy_markedPos - yy_startRead; + } + + + /** + * Reports an error that occured while scanning. + * + * @param errorCode the code of the errormessage to display + */ + private void yy_ScanError(int errorCode) { + try { + System.out.println(YY_ERROR_MSG[errorCode]); + } + catch (ArrayIndexOutOfBoundsException e) { + System.out.println(YY_ERROR_MSG[YY_UNKNOWN_ERROR]); + } + + System.exit(1); + } + + + /** + * Pushes the specified amount of characters back into the input stream. + * + * They will be read again by then next call of the scanning method + * + * @param number the number of characters to be read again. + * This number must not be greater than yylength()! + */ + private void yypushback(int number) { + if (number > yylength()) + yy_ScanError(YY_PUSHBACK_2BIG); + + yy_markedPos -= number; + } + + + /** + * Contains user EOF-code, which will be executed exactly once, + * when the end of file is reached + */ + private void yy_do_eof() { + if (!yy_eof_done) { + yy_eof_done = true; + hasMore = false; + + } + } + + + /** + * Resumes scanning until the next regular expression is matched, + * the end of input is encountered or an I/O-Error occurs. + * + * @return the next token + * @exception IOException if any I/O-Error occurs + */ + public String primGetNextToken() throws java.io.IOException { + int yy_input; + int yy_action; + + + while (true) { + + yychar += yylength(); + + yy_atBOL = yy_markedPos <= 0 || yy_buffer[yy_markedPos - 1] == '\n'; + if (!yy_atBOL && yy_buffer[yy_markedPos - 1] == '\r') { + yy_atBOL = yy_advance() != '\n'; + if (!yy_atEOF) + yy_currentPos--; + } + + yy_action = -1; + + yy_currentPos = yy_startRead = yy_markedPos; + + if (yy_atBOL) + yy_state = YY_LEXSTATE[yy_lexical_state + 1]; + else + yy_state = YY_LEXSTATE[yy_lexical_state]; + + + yy_forAction : { + while (true) { + + yy_input = yy_advance(); + + if (yy_input == YYEOF) + break yy_forAction; + + yy_input = yycmap[yy_input]; + + boolean yy_isFinal = false; + boolean yy_noLookAhead = false; + + yy_forNext : { + switch (yy_state) { + case 0 : + switch (yy_input) { + case 1 : + yy_isFinal = true; + yy_state = 9; + break yy_forNext; + case 2 : + yy_isFinal = true; + yy_state = 10; + break yy_forNext; + case 3 : + yy_isFinal = true; + yy_state = 11; + break yy_forNext; + case 10 : + yy_isFinal = true; + yy_state = 12; + break yy_forNext; + default : + yy_isFinal = true; + yy_noLookAhead = true; + yy_state = 8; + break yy_forNext; + } + + case 1 : + switch (yy_input) { + case 1 : + yy_isFinal = true; + yy_state = 9; + break yy_forNext; + case 2 : + yy_isFinal = true; + yy_state = 10; + break yy_forNext; + case 3 : + yy_isFinal = true; + yy_state = 11; + break yy_forNext; + case 6 : + case 7 : + case 9 : + case 18 : + yy_isFinal = true; + yy_state = 13; + break yy_forNext; + case 10 : + yy_isFinal = true; + yy_state = 14; + break yy_forNext; + default : + yy_isFinal = true; + yy_noLookAhead = true; + yy_state = 8; + break yy_forNext; + } + + case 2 : + switch (yy_input) { + case 11 : + yy_isFinal = true; + yy_state = 15; + break yy_forNext; + case 15 : + yy_isFinal = true; + yy_state = 16; + break yy_forNext; + default : + yy_isFinal = true; + yy_noLookAhead = true; + yy_state = 8; + break yy_forNext; + } + + case 3 : + switch (yy_input) { + case 25 : + yy_isFinal = true; + yy_noLookAhead = true; + yy_state = 17; + break yy_forNext; + case 26 : + yy_isFinal = true; + yy_state = 18; + break yy_forNext; + case 34 : + yy_isFinal = true; + yy_state = 19; + break yy_forNext; + default : + yy_isFinal = true; + yy_noLookAhead = true; + yy_state = 8; + break yy_forNext; + } + + case 4 : + switch (yy_input) { + case 6 : + case 9 : + case 18 : + yy_isFinal = true; + yy_state = 21; + break yy_forNext; + case 7 : + yy_isFinal = true; + yy_state = 22; + break yy_forNext; + case 32 : + yy_isFinal = true; + yy_noLookAhead = true; + yy_state = 23; + break yy_forNext; + case 35 : + yy_isFinal = true; + yy_noLookAhead = true; + yy_state = 24; + break yy_forNext; + default : + yy_isFinal = true; + yy_noLookAhead = true; + yy_state = 20; + break yy_forNext; + } + + case 5 : + switch (yy_input) { + case 7 : + case 9 : + case 10 : + case 25 : + yy_isFinal = true; + yy_noLookAhead = true; + yy_state = 26; + break yy_forNext; + case 11 : + case 34 : + yy_isFinal = true; + yy_state = 27; + break yy_forNext; + case 32 : + yy_isFinal = true; + yy_noLookAhead = true; + yy_state = 28; + break yy_forNext; + default : + yy_isFinal = true; + yy_noLookAhead = true; + yy_state = 25; + break yy_forNext; + } + + case 6 : + switch (yy_input) { + case 7 : + case 9 : + case 10 : + case 25 : + yy_isFinal = true; + yy_noLookAhead = true; + yy_state = 26; + break yy_forNext; + case 34 : + yy_isFinal = true; + yy_state = 27; + break yy_forNext; + case 35 : + yy_isFinal = true; + yy_noLookAhead = true; + yy_state = 28; + break yy_forNext; + case 36 : + yy_isFinal = true; + yy_state = 29; + break yy_forNext; + default : + yy_isFinal = true; + yy_noLookAhead = true; + yy_state = 25; + break yy_forNext; + } + + case 7 : + switch (yy_input) { + case 10 : + case 25 : + yy_isFinal = true; + yy_noLookAhead = true; + yy_state = 26; + break yy_forNext; + case 34 : + yy_isFinal = true; + yy_state = 27; + break yy_forNext; + case 11 : + yy_isFinal = true; + yy_state = 29; + break yy_forNext; + case 6 : + case 7 : + case 9 : + case 18 : + yy_isFinal = true; + yy_noLookAhead = true; + yy_state = 30; + break yy_forNext; + case 32 : + case 35 : + yy_isFinal = true; + yy_noLookAhead = true; + yy_state = 31; + break yy_forNext; + case 37 : + yy_isFinal = true; + yy_state = 32; + break yy_forNext; + default : + yy_isFinal = true; + yy_noLookAhead = true; + yy_state = 25; + break yy_forNext; + } + + case 9 : + switch (yy_input) { + case 2 : + yy_isFinal = true; + yy_noLookAhead = true; + yy_state = 33; + break yy_forNext; + default : + break yy_forAction; + } + + case 10 : + switch (yy_input) { + case 1 : + yy_isFinal = true; + yy_noLookAhead = true; + yy_state = 34; + break yy_forNext; + default : + break yy_forAction; + } + + case 11 : + switch (yy_input) { + case 4 : + yy_state = 35; + break yy_forNext; + default : + break yy_forAction; + } + + case 12 : + switch (yy_input) { + case 13 : + yy_state = 36; + break yy_forNext; + default : + break yy_forAction; + } + + case 13 : + switch (yy_input) { + case 6 : + case 7 : + case 9 : + case 18 : + yy_state = 37; + break yy_forNext; + case 10 : + yy_state = 38; + break yy_forNext; + default : + break yy_forAction; + } + + case 14 : + switch (yy_input) { + case 13 : + yy_state = 36; + break yy_forNext; + case 11 : + yy_state = 39; + break yy_forNext; + default : + break yy_forAction; + } + + case 15 : + switch (yy_input) { + case 25 : + yy_isFinal = true; + yy_noLookAhead = true; + yy_state = 40; + break yy_forNext; + default : + break yy_forAction; + } + + case 16 : + switch (yy_input) { + case 19 : + yy_state = 41; + break yy_forNext; + default : + break yy_forAction; + } + + case 18 : + switch (yy_input) { + case 16 : + yy_state = 42; + break yy_forNext; + default : + break yy_forAction; + } + + case 19 : + switch (yy_input) { + case 25 : + yy_isFinal = true; + yy_noLookAhead = true; + yy_state = 43; + break yy_forNext; + default : + break yy_forAction; + } + + case 21 : + switch (yy_input) { + case 6 : + case 9 : + case 18 : + yy_isFinal = true; + yy_state = 21; + break yy_forNext; + case 7 : + yy_state = 44; + break yy_forNext; + default : + yy_isFinal = true; + yy_noLookAhead = true; + yy_state = 20; + break yy_forNext; + } + + case 22 : + switch (yy_input) { + case 6 : + case 9 : + case 18 : + yy_isFinal = true; + yy_state = 21; + break yy_forNext; + case 7 : + yy_state = 44; + break yy_forNext; + default : + yy_isFinal = true; + yy_noLookAhead = true; + yy_state = 20; + break yy_forNext; + } + + case 27 : + switch (yy_input) { + case 25 : + yy_isFinal = true; + yy_noLookAhead = true; + yy_state = 45; + break yy_forNext; + default : + break yy_forAction; + } + + case 29 : + switch (yy_input) { + case 25 : + yy_isFinal = true; + yy_noLookAhead = true; + yy_state = 46; + break yy_forNext; + default : + break yy_forAction; + } + + case 32 : + switch (yy_input) { + case 6 : + case 7 : + case 9 : + case 18 : + yy_isFinal = true; + yy_state = 32; + break yy_forNext; + default : + break yy_forAction; + } + + case 35 : + switch (yy_input) { + case 5 : + yy_isFinal = true; + yy_noLookAhead = true; + yy_state = 47; + break yy_forNext; + default : + break yy_forAction; + } + + case 36 : + switch (yy_input) { + case 15 : + yy_state = 48; + break yy_forNext; + default : + break yy_forAction; + } + + case 37 : + switch (yy_input) { + case 6 : + case 7 : + case 9 : + case 18 : + yy_state = 37; + break yy_forNext; + case 10 : + yy_state = 38; + break yy_forNext; + default : + break yy_forAction; + } + + case 38 : + switch (yy_input) { + case 11 : + yy_state = 39; + break yy_forNext; + default : + break yy_forAction; + } + + case 39 : + switch (yy_input) { + case 12 : + yy_state = 49; + break yy_forNext; + default : + break yy_forAction; + } + + case 41 : + switch (yy_input) { + case 20 : + yy_state = 50; + break yy_forNext; + default : + break yy_forAction; + } + + case 42 : + switch (yy_input) { + case 16 : + yy_state = 51; + break yy_forNext; + default : + break yy_forAction; + } + + case 44 : + switch (yy_input) { + case 6 : + case 9 : + case 18 : + yy_isFinal = true; + yy_state = 21; + break yy_forNext; + case 7 : + yy_state = 44; + break yy_forNext; + default : + yy_isFinal = true; + yy_noLookAhead = true; + yy_state = 20; + break yy_forNext; + } + + case 48 : + switch (yy_input) { + case 16 : + yy_state = 52; + break yy_forNext; + default : + break yy_forAction; + } + + case 49 : + switch (yy_input) { + case 13 : + yy_state = 53; + break yy_forNext; + default : + break yy_forAction; + } + + case 50 : + switch (yy_input) { + case 21 : + yy_state = 54; + break yy_forNext; + default : + break yy_forAction; + } + + case 51 : + switch (yy_input) { + case 27 : + yy_state = 55; + break yy_forNext; + default : + break yy_forAction; + } + + case 52 : + switch (yy_input) { + case 17 : + yy_state = 56; + break yy_forNext; + default : + break yy_forAction; + } + + case 53 : + switch (yy_input) { + case 14 : + yy_state = 57; + break yy_forNext; + default : + break yy_forAction; + } + + case 54 : + switch (yy_input) { + case 22 : + yy_state = 58; + break yy_forNext; + default : + break yy_forAction; + } + + case 55 : + switch (yy_input) { + case 28 : + yy_state = 59; + break yy_forNext; + default : + break yy_forAction; + } + + case 56 : + switch (yy_input) { + case 18 : + yy_isFinal = true; + yy_noLookAhead = true; + yy_state = 60; + break yy_forNext; + default : + break yy_forAction; + } + + case 57 : + switch (yy_input) { + case 6 : + case 7 : + case 9 : + case 18 : + yy_isFinal = true; + yy_state = 61; + break yy_forNext; + default : + break yy_forAction; + } + + case 58 : + switch (yy_input) { + case 23 : + yy_state = 62; + break yy_forNext; + default : + break yy_forAction; + } + + case 59 : + switch (yy_input) { + case 15 : + yy_state = 63; + break yy_forNext; + default : + break yy_forAction; + } + + case 61 : + switch (yy_input) { + case 6 : + case 7 : + case 9 : + case 18 : + yy_isFinal = true; + yy_state = 61; + break yy_forNext; + default : + break yy_forAction; + } + + case 62 : + switch (yy_input) { + case 19 : + yy_state = 64; + break yy_forNext; + default : + break yy_forAction; + } + + case 63 : + switch (yy_input) { + case 29 : + yy_state = 65; + break yy_forNext; + default : + break yy_forAction; + } + + case 64 : + switch (yy_input) { + case 24 : + yy_state = 66; + break yy_forNext; + default : + break yy_forAction; + } + + case 65 : + switch (yy_input) { + case 30 : + yy_state = 67; + break yy_forNext; + default : + break yy_forAction; + } + + case 66 : + switch (yy_input) { + case 6 : + case 7 : + case 9 : + case 18 : + yy_state = 66; + break yy_forNext; + case 8 : + yy_isFinal = true; + yy_state = 68; + break yy_forNext; + default : + break yy_forAction; + } + + case 67 : + switch (yy_input) { + case 23 : + yy_state = 69; + break yy_forNext; + default : + break yy_forAction; + } + + case 68 : + switch (yy_input) { + case 6 : + case 7 : + case 9 : + case 18 : + yy_isFinal = true; + yy_state = 68; + break yy_forNext; + default : + break yy_forAction; + } + + case 69 : + switch (yy_input) { + case 31 : + yy_state = 70; + break yy_forNext; + default : + break yy_forAction; + } + + case 70 : + switch (yy_input) { + case 6 : + case 7 : + case 9 : + case 18 : + yy_state = 70; + break yy_forNext; + case 8 : + yy_state = 71; + break yy_forNext; + default : + break yy_forAction; + } + + case 71 : + switch (yy_input) { + case 6 : + case 7 : + case 9 : + case 18 : + yy_state = 71; + break yy_forNext; + case 20 : + yy_state = 72; + break yy_forNext; + case 32 : + yy_state = 73; + break yy_forNext; + default : + break yy_forAction; + } + + case 72 : + switch (yy_input) { + case 21 : + yy_state = 74; + break yy_forNext; + default : + break yy_forAction; + } + + case 73 : + switch (yy_input) { + case 20 : + yy_state = 72; + break yy_forNext; + default : + break yy_forAction; + } + + case 74 : + switch (yy_input) { + case 19 : + yy_state = 75; + break yy_forNext; + default : + break yy_forAction; + } + + case 75 : + switch (yy_input) { + case 16 : + yy_state = 76; + break yy_forNext; + default : + break yy_forAction; + } + + case 76 : + switch (yy_input) { + case 15 : + yy_state = 77; + break yy_forNext; + default : + break yy_forAction; + } + + case 77 : + switch (yy_input) { + case 19 : + yy_state = 78; + break yy_forNext; + default : + break yy_forAction; + } + + case 78 : + switch (yy_input) { + case 16 : + yy_state = 79; + break yy_forNext; + default : + break yy_forAction; + } + + case 79 : + switch (yy_input) { + case 28 : + yy_state = 80; + break yy_forNext; + default : + break yy_forAction; + } + + case 80 : + switch (yy_input) { + case 16 : + yy_state = 81; + break yy_forNext; + default : + break yy_forAction; + } + + case 81 : + switch (yy_input) { + case 33 : + yy_state = 82; + break yy_forNext; + default : + break yy_forAction; + } + + case 82 : + switch (yy_input) { + case 27 : + yy_state = 83; + break yy_forNext; + default : + break yy_forAction; + } + + case 83 : + switch (yy_input) { + case 15 : + yy_state = 84; + break yy_forNext; + default : + break yy_forAction; + } + + case 84 : + switch (yy_input) { + case 6 : + case 7 : + case 9 : + case 18 : + yy_state = 85; + break yy_forNext; + case 32 : + yy_state = 86; + break yy_forNext; + default : + break yy_forAction; + } + + case 85 : + switch (yy_input) { + case 6 : + case 7 : + case 9 : + case 18 : + yy_state = 85; + break yy_forNext; + case 20 : + yy_state = 87; + break yy_forNext; + default : + break yy_forAction; + } + + case 86 : + switch (yy_input) { + case 6 : + case 7 : + case 9 : + case 18 : + yy_state = 85; + break yy_forNext; + default : + break yy_forAction; + } + + case 87 : + switch (yy_input) { + case 21 : + yy_state = 88; + break yy_forNext; + default : + break yy_forAction; + } + + case 88 : + switch (yy_input) { + case 19 : + yy_state = 89; + break yy_forNext; + default : + break yy_forAction; + } + + case 89 : + switch (yy_input) { + case 16 : + yy_state = 90; + break yy_forNext; + default : + break yy_forAction; + } + + case 90 : + switch (yy_input) { + case 15 : + yy_state = 91; + break yy_forNext; + default : + break yy_forAction; + } + + case 91 : + switch (yy_input) { + case 19 : + yy_state = 92; + break yy_forNext; + default : + break yy_forAction; + } + + case 92 : + switch (yy_input) { + case 16 : + yy_state = 93; + break yy_forNext; + default : + break yy_forAction; + } + + case 93 : + switch (yy_input) { + case 6 : + case 7 : + case 9 : + case 18 : + yy_state = 93; + break yy_forNext; + case 8 : + yy_isFinal = true; + yy_state = 94; + break yy_forNext; + default : + break yy_forAction; + } + + case 94 : + switch (yy_input) { + case 6 : + case 7 : + case 9 : + case 18 : + yy_isFinal = true; + yy_state = 94; + break yy_forNext; + default : + break yy_forAction; + } + + default : + yy_ScanError(YY_ILLEGAL_STATE); + break; + } + } + + if (yy_isFinal) { + yy_action = yy_state; + yy_markedPos = yy_currentPos; + if (yy_noLookAhead) + break yy_forAction; + } + + } + } + + + switch (yy_action) { + + case 26 : + { + yypushback(1); + popState(); + valueText = string.toString(); + return EncodingParserConstants.InvalidTerminatedStringValue; + } + case 96 : + break; + case 20 : + case 21 : + { + yypushback(1); + yybegin(UnDelimitedString); + string.setLength(0); + } + case 97 : + break; + case 17 : + { + yybegin(YYINITIAL); + if (foundContentTypeValue) + hasMore = false; + return HTMLHeadTokenizerConstants.MetaTagEnd; + } + case 98 : + break; + case 31 : + { + yypushback(1); + popState(); + valueText = string.toString(); + return EncodingParserConstants.InvalidTermintatedUnDelimitedStringValue; + } + case 99 : + break; + case 43 : + { + yybegin(YYINITIAL); + if (foundContentTypeValue) + hasMore = false; + return HTMLHeadTokenizerConstants.MetaTagEnd; + } + case 100 : + break; + case 45 : + { + yypushback(2); + popState(); + valueText = string.toString(); + return EncodingParserConstants.InvalidTerminatedStringValue; + } + case 101 : + break; + case 46 : + { + yypushback(2); + popState(); + valueText = string.toString(); + return EncodingParserConstants.InvalidTerminatedStringValue; + } + case 102 : + break; + case 61 : + { + if (yychar == 0) { + yybegin(ST_XMLDecl); + return XMLHeadTokenizerConstants.XMLDeclStart; + } + } + case 103 : + break; + case 8 : + case 9 : + case 10 : + case 11 : + case 12 : + case 13 : + case 14 : + case 15 : + case 16 : + case 18 : + case 19 : + case 22 : + { + if (yychar > MAX_TO_SCAN) { + hasMore = false; + return EncodingParserConstants.MAX_CHARS_REACHED; + } + } + case 104 : + break; + case 60 : + { + yybegin(ST_META_TAG); + return HTMLHeadTokenizerConstants.MetaTagStart; + } + case 105 : + break; + case 40 : + { + yybegin(YYINITIAL); + return XMLHeadTokenizerConstants.XMLDeclEnd; + } + case 106 : + break; + case 94 : + { + pushCurrentState(); + yybegin(QuotedAttributeValue); + foundContentTypeValue = true; + return HTMLHeadTokenizerConstants.MetaTagContentType; + } + case 107 : + break; + case 68 : + { + pushCurrentState(); + yybegin(QuotedAttributeValue); + return XMLHeadTokenizerConstants.XMLDelEncoding; + } + case 108 : + break; + case 33 : + { + hasMore = false; + return EncodingParserConstants.UTF16BE; + } + case 109 : + break; + case 34 : + { + hasMore = false; + return EncodingParserConstants.UTF16LE; + } + case 110 : + break; + case 47 : + { + hasMore = false; + return EncodingParserConstants.UTF83ByteBOM; + } + case 111 : + break; + case 28 : + { + popState(); + valueText = string.toString(); + return EncodingParserConstants.StringValue; + } + case 112 : + break; + case 25 : + case 27 : + case 29 : + case 32 : + { + string.append(yytext()); + } + case 113 : + break; + case 24 : + { + yybegin(SQ_STRING); + string.setLength(0); + } + case 114 : + break; + case 23 : + { + yybegin(DQ_STRING); + string.setLength(0); + } + case 115 : + break; + case 30 : + { + yypushback(1); + popState(); + valueText = string.toString(); + return EncodingParserConstants.UnDelimitedStringValue; + } + case 116 : + break; + default : + if (yy_input == YYEOF && yy_startRead == yy_currentPos) { + yy_atEOF = true; + yy_do_eof(); + { + hasMore = false; + return EncodingParserConstants.EOF; + } + } + else { + yy_ScanError(YY_NO_MATCH); + } + } + } + } + + /** + * Runs the scanner on input files. + * + * This main method is the debugging routine for the scanner. + * It prints each returned token to System.out until the end of + * file is reached, or an error occured. + * + * @param argv the command line, contains the filenames to run + * the scanner on. + */ + public static void main(String argv[]) { + for (int i = 0; i < argv.length; i++) { + HTMLHeadTokenizer scanner = null; + try { + scanner = new HTMLHeadTokenizer(new java.io.FileReader(argv[i])); + } + catch (java.io.FileNotFoundException e) { + System.out.println("File not found : \"" + argv[i] + "\""); + System.exit(1); + } + catch (ArrayIndexOutOfBoundsException e) { + System.out.println("Usage : java HTMLHeadTokenizer <inputfile>"); + System.exit(1); + } + + try { + do { + System.out.println(scanner.primGetNextToken()); + } + while (!scanner.yy_atEOF); + + } + catch (java.io.IOException e) { + System.out.println("An I/O error occured while scanning :"); + System.out.println(e); + System.exit(1); + } + catch (Exception e) { + e.printStackTrace(); + System.exit(1); + } + } + } + + +}
\ No newline at end of file diff --git a/bundles/org.eclipse.wst.html.core/src/org/eclipse/wst/html/core/internal/contenttype/HTMLHeadTokenizerConstants.java b/bundles/org.eclipse.wst.html.core/src/org/eclipse/wst/html/core/internal/contenttype/HTMLHeadTokenizerConstants.java new file mode 100644 index 0000000000..938bcde421 --- /dev/null +++ b/bundles/org.eclipse.wst.html.core/src/org/eclipse/wst/html/core/internal/contenttype/HTMLHeadTokenizerConstants.java @@ -0,0 +1,20 @@ +/******************************************************************************* + * Copyright (c) 2004 IBM Corporation and others. + * All rights reserved. This program and the accompanying materials + * are made available under the terms of the Eclipse Public License v1.0 + * which accompanies this distribution, and is available at + * http://www.eclipse.org/legal/epl-v10.html + * + * Contributors: + * IBM Corporation - initial API and implementation + *******************************************************************************/ +package org.eclipse.wst.html.core.internal.contenttype; + + +public interface HTMLHeadTokenizerConstants { + + String MetaTagEnd = "MetaTagEnd"; //$NON-NLS-1$ + String MetaTagStart = "MetaTagStart"; //$NON-NLS-1$ + String MetaTagContentType = "MetaTagContentType"; //$NON-NLS-1$ + +}
\ No newline at end of file diff --git a/bundles/org.eclipse.wst.html.core/src/org/eclipse/wst/html/core/internal/contenttype/HTMLResourceEncodingDetector.java b/bundles/org.eclipse.wst.html.core/src/org/eclipse/wst/html/core/internal/contenttype/HTMLResourceEncodingDetector.java new file mode 100644 index 0000000000..504a2758f0 --- /dev/null +++ b/bundles/org.eclipse.wst.html.core/src/org/eclipse/wst/html/core/internal/contenttype/HTMLResourceEncodingDetector.java @@ -0,0 +1,190 @@ +/******************************************************************************* + * Copyright (c) 2004 IBM Corporation and others. + * All rights reserved. This program and the accompanying materials + * are made available under the terms of the Eclipse Public License v1.0 + * which accompanies this distribution, and is available at + * http://www.eclipse.org/legal/epl-v10.html + * + * Contributors: + * IBM Corporation - initial API and implementation + *******************************************************************************/ +package org.eclipse.wst.html.core.internal.contenttype; + +import java.io.IOException; +import java.util.regex.Pattern; + +import org.eclipse.wst.common.encoding.AbstractResourceEncodingDetector; +import org.eclipse.wst.common.encoding.CodedIO; +import org.eclipse.wst.common.encoding.EncodingGuesser; +import org.eclipse.wst.common.encoding.EncodingMemento; +import org.eclipse.wst.common.encoding.EncodingParserConstants; +import org.eclipse.wst.common.encoding.HeadParserToken; +import org.eclipse.wst.common.encoding.IResourceCharsetDetector; + +public class HTMLResourceEncodingDetector extends AbstractResourceEncodingDetector implements IResourceCharsetDetector { + + private HTMLHeadTokenizer fTokenizer; + + /** + * There is no spec defined encoding for HTML (historically), so null is + * returned. + */ + public String getSpecDefaultEncoding() { + return null; + } + + private boolean canHandleAsUnicodeStream(String tokenType) { + boolean canHandleAsUnicodeStream = false; + if (tokenType == EncodingParserConstants.UTF83ByteBOM) { + canHandleAsUnicodeStream = true; + String enc = "UTF-8"; //$NON-NLS-1$ + createEncodingMemento(enc, EncodingMemento.DETECTED_STANDARD_UNICODE_BYTES); + fEncodingMemento.setUTF83ByteBOMUsed(true); + } + else if (tokenType == EncodingParserConstants.UTF16BE) { + canHandleAsUnicodeStream = true; + String enc = "UTF-16BE"; //$NON-NLS-1$ + createEncodingMemento(enc, EncodingMemento.DETECTED_STANDARD_UNICODE_BYTES); + } + else if (tokenType == EncodingParserConstants.UTF16LE) { + canHandleAsUnicodeStream = true; + String enc = "UTF-16"; //$NON-NLS-1$ + createEncodingMemento(enc, EncodingMemento.DETECTED_STANDARD_UNICODE_BYTES); + } + return canHandleAsUnicodeStream; + } + + /** + * @return Returns the tokenizer. + */ + private HTMLHeadTokenizer getTokenizer() { + // TODO: need to work on 'reset' in tokenizer, so new instance isn't + // always needed + //if (fTokenizer == null) { + fTokenizer = new HTMLHeadTokenizer(); + // } + return fTokenizer; + } + + private boolean isLegalString(String valueTokenType) { + if (valueTokenType == null) + return false; + else + return valueTokenType.equals(EncodingParserConstants.StringValue) || valueTokenType.equals(EncodingParserConstants.UnDelimitedStringValue) || valueTokenType.equals(EncodingParserConstants.InvalidTerminatedStringValue) || valueTokenType.equals(EncodingParserConstants.InvalidTermintatedUnDelimitedStringValue); + } + + protected void parseInput() throws IOException { + checkInContent(); + if (fEncodingMemento == null) { + checkHeuristics(); + } + } + + /** + * + */ + private void checkHeuristics() throws IOException { + boolean noHeuristic = false; + String heuristicEncoding = null; + try { + fReader.reset(); + fReader.mark(CodedIO.MAX_MARK_SIZE); + byte[] bytes = new byte[CodedIO.MAX_MARK_SIZE]; + int nRead = 0; + for (int i = 0; i < bytes.length; i++) { + if (fReader.ready()) { + int oneByte = fReader.read(); + nRead++; + if (oneByte <= 0xFF) { + bytes[i] = (byte) oneByte; + } + else { + noHeuristic = true; + break; + } + } + else { + break; + } + } + if (!noHeuristic) { + heuristicEncoding = EncodingGuesser.guessEncoding(bytes, nRead); + } + } + catch (IOException e) { + // if any IO exception, then not a heuristic case + } + finally { + fReader.reset(); + } + if (heuristicEncoding != null) { + createEncodingMemento(heuristicEncoding, EncodingMemento.GUESSED_ENCODING_FROM_STREAM); + } + + } + + private void checkInContent() throws IOException { + HTMLHeadTokenizer tokenizer = getTokenizer(); + tokenizer.reset(fReader); + HeadParserToken token = null; + String tokenType = null; + String contentTypeValue = null; + do { + token = tokenizer.getNextToken(); + tokenType = token.getType(); + if (canHandleAsUnicodeStream(tokenType)) { + // side effect of canHandle is to create appropriate + // memento + } + else if (tokenType == HTMLHeadTokenizerConstants.MetaTagContentType) { + if (tokenizer.hasMoreTokens()) { + HeadParserToken valueToken = tokenizer.getNextToken(); + String valueTokenType = valueToken.getType(); + if (isLegalString(valueTokenType)) { + contentTypeValue = valueToken.getText(); + + } + } + } + + } + while (tokenizer.hasMoreTokens()); + if (contentTypeValue != null) { + parseContentTypeValue(contentTypeValue); + } + } + + private void parseContentTypeValue(String contentType) { + String charset = null; + Pattern pattern = Pattern.compile(";\\s*charset\\s*=\\s*"); //$NON-NLS-1$ + String[] parts = pattern.split(contentType); + if (parts.length > 0) { + // if only one item, it can still be charset instead of + // contentType + if (parts.length == 1) { + if (parts[0].length() > 6) { + String checkForCharset = parts[0].substring(0, 7); + if (checkForCharset.equalsIgnoreCase("charset")) { //$NON-NLS-1$ + int eqpos = parts[0].indexOf('='); + eqpos = eqpos + 1; + if (eqpos < parts[0].length()) { + charset = parts[0].substring(eqpos); + charset = charset.trim(); + } + } + } + } + else { + //fContentType = parts[0]; + } + } + if (parts.length > 1) { + charset = parts[1]; + } + + if (charset != null && charset.length() > 0) { + createEncodingMemento(charset, EncodingMemento.FOUND_ENCODING_IN_CONTENT); + } + } + +}
\ No newline at end of file diff --git a/bundles/org.eclipse.wst.html.core/src/org/eclipse/wst/html/core/internal/nls/ResourceHandler.java b/bundles/org.eclipse.wst.html.core/src/org/eclipse/wst/html/core/internal/nls/ResourceHandler.java new file mode 100644 index 0000000000..c164012219 --- /dev/null +++ b/bundles/org.eclipse.wst.html.core/src/org/eclipse/wst/html/core/internal/nls/ResourceHandler.java @@ -0,0 +1,72 @@ +/******************************************************************************* + * Copyright (c) 2004 IBM Corporation and others. + * All rights reserved. This program and the accompanying materials + * are made available under the terms of the Eclipse Public License v1.0 + * which accompanies this distribution, and is available at + * http://www.eclipse.org/legal/epl-v10.html + * + * Contributors: + * IBM Corporation - initial API and implementation + *******************************************************************************/ +package org.eclipse.wst.html.core.internal.nls; + + + +import java.text.MessageFormat; +import java.util.MissingResourceException; +import java.util.ResourceBundle; + +public class ResourceHandler { + + + private static ResourceBundle fgResourceBundle; + + /** + * Returns the resource bundle used by all classes in this Project + */ + public static ResourceBundle getResourceBundle() { + try { + return ResourceBundle.getBundle("ModelsHTML");//$NON-NLS-1$ + } + catch (MissingResourceException e) { + // does nothing - this method will return null and + // getString(String) will return the key + // it was called with + } + return null; + } + + public static String getString(String key) { + if (fgResourceBundle == null) { + fgResourceBundle = getResourceBundle(); + } + + if (fgResourceBundle != null) { + try { + return fgResourceBundle.getString(key); + } + catch (MissingResourceException e) { + return "!" + key + "!";//$NON-NLS-2$//$NON-NLS-1$ + } + } + else { + return "!" + key + "!";//$NON-NLS-2$//$NON-NLS-1$ + } + } + + public static String getString(String key, Object[] args) { + + try { + return MessageFormat.format(getString(key), args); + } + catch (IllegalArgumentException e) { + return getString(key); + } + + } + + public static String getString(String key, Object[] args, int x) { + + return getString(key); + } +}
\ No newline at end of file diff --git a/bundles/org.eclipse.wst.html.core/src/org/eclipse/wst/html/core/internal/text/rules/StructuredTextPartitionerForHTML.java b/bundles/org.eclipse.wst.html.core/src/org/eclipse/wst/html/core/internal/text/rules/StructuredTextPartitionerForHTML.java new file mode 100644 index 0000000000..0d501b9dfc --- /dev/null +++ b/bundles/org.eclipse.wst.html.core/src/org/eclipse/wst/html/core/internal/text/rules/StructuredTextPartitionerForHTML.java @@ -0,0 +1,204 @@ +/******************************************************************************* + * Copyright (c) 2004 IBM Corporation and others. + * All rights reserved. This program and the accompanying materials + * are made available under the terms of the Eclipse Public License v1.0 + * which accompanies this distribution, and is available at + * http://www.eclipse.org/legal/epl-v10.html + * + * Contributors: + * IBM Corporation - initial API and implementation + *******************************************************************************/ +package org.eclipse.wst.html.core.internal.text.rules; + +import java.util.Locale; + +import org.eclipse.jface.text.IDocumentPartitioner; +import org.eclipse.wst.css.core.internal.text.rules.StructuredTextPartitionerForCSS; +import org.eclipse.wst.html.core.HTML40Namespace; +import org.eclipse.wst.sse.core.internal.parser.ForeignRegion; +import org.eclipse.wst.sse.core.text.IStructuredDocumentRegion; +import org.eclipse.wst.sse.core.text.IStructuredTextPartitioner; +import org.eclipse.wst.sse.core.text.ITextRegion; +import org.eclipse.wst.sse.core.text.ITextRegionList; +import org.eclipse.wst.sse.core.text.StructuredTypedRegion; +import org.eclipse.wst.sse.core.util.ScriptLanguageKeys; +import org.eclipse.wst.sse.core.util.StringUtils; +import org.eclipse.wst.xml.core.parser.XMLRegionContext; +import org.eclipse.wst.xml.core.text.rules.StructuredTextPartitionerForXML; + +/** + * Document partitioner for HTML. Client-side scripts of type JavaScript are + * reported as ST_SCRIPT, all others for <script language="foo" type="foo2"> + * as SCRIPT.language:FOO and SCRIPT.type:FOO2. + */ +public class StructuredTextPartitionerForHTML extends StructuredTextPartitionerForXML implements IStructuredTextPartitioner { + + public final static String ST_DEFAULT_HTML = "org.eclipse.wst.html.DEFAULT_HTML"; //$NON-NLS-1$ + public final static String ST_HTML_DECLARATION = "org.eclipse.wst.html.HTML_DECLARATION"; //$NON-NLS-1$ + public final static String ST_HTML_COMMENT = "org.eclipse.wst.htmlHTML_COMMENT"; //$NON-NLS-1$ + public final static String ST_SCRIPT = "org.eclipse.wst.html.SCRIPT"; //$NON-NLS-1$ + private final static String[] configuredContentTypes = new String[]{ST_DEFAULT_HTML, ST_HTML_DECLARATION, ST_HTML_COMMENT, ST_SCRIPT, StructuredTextPartitionerForCSS.ST_STYLE}; + + public static final String JAVASCRIPT = "javascript"; //$NON-NLS-1$ + public static final String JAVASCRIPT_APPLICATION = "application/x-javascript"; //$NON-NLS-1$ + + + /** + * Constructor for JSPDocumentPartioner. + */ + public StructuredTextPartitionerForHTML() { + super(); + } + + public StructuredTypedRegion createPartition(int offset, int length, String type) { + if (type == ST_SCRIPT) { + IStructuredDocumentRegion node = structuredDocument.getRegionAtCharacterOffset(offset); + if (node != null) { + String stype = getScriptingPartitionType(node); + return super.createPartition(offset, length, stype); + } + } + return super.createPartition(offset, length, type); + } + + /** + * @see com.ibm.sed.structuredDocument.partition.StructuredTextPartitioner#createPartition(int, + * int, java.lang.String) + */ + protected void setInternalPartition(int offset, int length, String type) { + String localType = type; + if (type == ST_SCRIPT) { + IStructuredDocumentRegion node = structuredDocument.getRegionAtCharacterOffset(offset); + if (node != null) { + localType = getScriptingPartitionType(node); + } + } + super.setInternalPartition(offset, length, localType); + } + + private String getScriptingPartitionType(IStructuredDocumentRegion coreNode) { + String language = null; + String type = null; + String result = ST_SCRIPT; + IStructuredDocumentRegion node = coreNode; + ITextRegion attrNameRegion = null; + while (node != null && isValidScriptingRegionType(node.getType())) { + node = node.getPrevious(); + } + + ITextRegionList regions = node.getRegions(); + if (regions.size() > 4 && regions.get(1).getType() == XMLRegionContext.XML_TAG_NAME) { + ITextRegion potentialLanguageRegion = regions.get(1); + String potentialLanguageString = node.getText(potentialLanguageRegion); + if (potentialLanguageString.equalsIgnoreCase(HTML40Namespace.ElementName.SCRIPT)) { + for (int i = 0; i < regions.size(); i++) { + ITextRegion region = regions.get(i); + String regionType = region.getType(); + if (regionType == XMLRegionContext.XML_TAG_ATTRIBUTE_NAME) + attrNameRegion = region; + else if (regionType == XMLRegionContext.XML_TAG_ATTRIBUTE_VALUE) { + String attrName = node.getText(attrNameRegion); + if (attrName.equalsIgnoreCase(HTML40Namespace.ATTR_NAME_LANGUAGE)) + language = StringUtils.strip(node.getText(region)); + else if (attrName.equalsIgnoreCase(HTML40Namespace.ATTR_NAME_TYPE)) { + type = StringUtils.strip(node.getText(region)); + break; + } + attrNameRegion = null; + } + } + } + } + if (type != null) + result = lookupScriptType(type); + else if (language != null) + result = lookupScriptLanguage(language); + return result; + } + + private boolean isValidScriptingRegionType(String type) { + return type == XMLRegionContext.BLOCK_TEXT || type == XMLRegionContext.XML_CDATA_OPEN || type == XMLRegionContext.XML_CDATA_TEXT || type == XMLRegionContext.XML_CDATA_CLOSE; + } + + protected void initLegalContentTypes() { + fSupportedTypes = getConfiguredContentTypes(); + } + + private String lookupScriptType(String type) { + for (int i = 0; i < ScriptLanguageKeys.JAVASCRIPT_MIME_TYPE_KEYS.length; i++) + if (ScriptLanguageKeys.JAVASCRIPT_MIME_TYPE_KEYS[i].equalsIgnoreCase(type)) + return ST_SCRIPT; + return "SCRIPT.type:" + type.toUpperCase(Locale.ENGLISH); //$NON-NLS-1$ + } + + private String lookupScriptLanguage(String language) { + for (int i = 0; i < ScriptLanguageKeys.JAVASCRIPT_LANGUAGE_KEYS.length; i++) + if (ScriptLanguageKeys.JAVASCRIPT_LANGUAGE_KEYS[i].equalsIgnoreCase(language)) + return ST_SCRIPT; + return "SCRIPT.language:" + language.toUpperCase(Locale.ENGLISH); //$NON-NLS-1$ + } + + /** + * @see com.ibm.sed.model.StructuredTextPartitioner#getPartitionType(com.ibm.sed.structuredDocument.ITextRegion) + */ + public String getPartitionType(ITextRegion region, int offset) { + String result = null; + if (region.getType() == XMLRegionContext.XML_COMMENT_TEXT || region.getType() == XMLRegionContext.XML_COMMENT_OPEN) + result = ST_HTML_COMMENT; + else if (region.getType() == XMLRegionContext.XML_DOCTYPE_DECLARATION || region.getType() == XMLRegionContext.XML_DECLARATION_OPEN) + result = ST_HTML_DECLARATION; + else + result = super.getPartitionType(region, offset); + return result; + } + + /** + * @see com.ibm.sed.structuredDocument.partition.StructuredTextPartitioner#getPartitionTypeBetween(com.ibm.sed.structuredDocument.ITextRegion, + * com.ibm.sed.structuredDocument.ITextRegion) + */ + public String getPartitionTypeBetween(IStructuredDocumentRegion previousNode, ITextRegion previousStartTagNameRegion, IStructuredDocumentRegion nextNode, ITextRegion nextEndTagNameRegion) { + String name1 = previousNode.getText(previousStartTagNameRegion); + String name2 = nextNode.getText(nextEndTagNameRegion); + if (name1.equalsIgnoreCase(HTML40Namespace.ElementName.SCRIPT) && name2.equalsIgnoreCase(HTML40Namespace.ElementName.SCRIPT)) + // return ST_SCRIPT; + return getScriptingPartitionType(structuredDocument.getRegionAtCharacterOffset(previousNode.getStartOffset(previousStartTagNameRegion))); + else if (name1.equalsIgnoreCase(HTML40Namespace.ElementName.STYLE) && name2.equalsIgnoreCase(HTML40Namespace.ElementName.STYLE)) + return StructuredTextPartitionerForCSS.ST_STYLE; + return super.getPartitionTypeBetween(previousNode, previousStartTagNameRegion, nextNode, nextEndTagNameRegion); + } + + + protected String getPartitionType(ForeignRegion region, int offset) { + String tagname = region.getSurroundingTag(); + String result = null; + // tagname should not be null, + // but see https://w3.opensource.ibm.com/bugzilla/show_bug.cgi?id=4911 + if (tagname == null) { + result = getUnknown(); + } + else if (tagname.equalsIgnoreCase(HTML40Namespace.ElementName.SCRIPT)) + result = ST_SCRIPT; + else if (tagname.equalsIgnoreCase(HTML40Namespace.ElementName.STYLE)) + result = StructuredTextPartitionerForCSS.ST_STYLE; + else + result = super.getPartitionType(region, offset); + + return result; + } + + public String getDefault() { + return ST_DEFAULT_HTML; + } + + public IDocumentPartitioner newInstance() { + return new StructuredTextPartitionerForHTML(); + } + + /** + * @return + */ + public static String[] getConfiguredContentTypes() { + return configuredContentTypes; + } + +}
\ No newline at end of file diff --git a/bundles/org.eclipse.wst.html.core/src/org/eclipse/wst/html/core/modelhandler/EmbeddedHTML.java b/bundles/org.eclipse.wst.html.core/src/org/eclipse/wst/html/core/modelhandler/EmbeddedHTML.java new file mode 100644 index 0000000000..daeb2164e3 --- /dev/null +++ b/bundles/org.eclipse.wst.html.core/src/org/eclipse/wst/html/core/modelhandler/EmbeddedHTML.java @@ -0,0 +1,139 @@ +/******************************************************************************* + * Copyright (c) 2004 IBM Corporation and others. + * All rights reserved. This program and the accompanying materials + * are made available under the terms of the Eclipse Public License v1.0 + * which accompanies this distribution, and is available at + * http://www.eclipse.org/legal/epl-v10.html + * + * Contributors: + * IBM Corporation - initial API and implementation + *******************************************************************************/ +package org.eclipse.wst.html.core.modelhandler; + +import java.util.ArrayList; +import java.util.List; + +import org.eclipse.wst.html.core.document.HTMLDocumentTypeAdapterFactory; +import org.eclipse.wst.html.core.document.HTMLModelParserAdapterFactory; +import org.eclipse.wst.html.core.htmlcss.HTMLStyleSelectorAdapterFactory; +import org.eclipse.wst.html.core.htmlcss.StyleAdapterFactory; +import org.eclipse.wst.html.core.modelquery.ModelQueryAdapterFactoryForEmbeddedHTML; +import org.eclipse.wst.sse.core.AdapterFactory; +import org.eclipse.wst.sse.core.IFactoryRegistry; +import org.eclipse.wst.sse.core.modelhandler.EmbeddedTypeHandler; +import org.eclipse.wst.sse.core.parser.BlockMarker; +import org.eclipse.wst.sse.core.parser.BlockTagParser; +import org.eclipse.wst.sse.core.parser.JSPCapableParser; +import org.eclipse.wst.sse.core.util.Assert; +import org.eclipse.wst.xml.core.parser.XMLRegionContext; + +public class EmbeddedHTML implements EmbeddedTypeHandler { + public String ContentTypeID_EmbeddedHTML = "org.eclipse.wst.html.core.internal.contenttype.EmbeddedHTML"; //$NON-NLS-1$ + + private List supportedMimeTypes; + + /** + * Constructor for EmbeddedHTML. + */ + public EmbeddedHTML() { + super(); + } + + /** + * Convenience method to add tag names using BlockMarker object + */ + protected void addHTMLishTag(BlockTagParser parser, String tagname) { + BlockMarker bm = new BlockMarker(tagname, null, XMLRegionContext.BLOCK_TEXT, false); + parser.addBlockMarker(bm); + } + + /** + * @see EmbeddedContentType#getFamilyId() + */ + public String getFamilyId() { + return ModelHandlerForHTML.AssociatedContentTypeID; + } + + /* + * Only "model side" embedded factories can be added here. + */ + public List getAdapterFactories() { + List factories = new ArrayList(); + factories.add(new ModelQueryAdapterFactoryForEmbeddedHTML()); + // factories.addAll(PluginContributedFactoryReader.getInstance().getFactories(this)); + return factories; + } + + /* + * @see EmbeddedContentType#initializeParser(RegionParser) + */ + public void initializeParser(JSPCapableParser parser) { + addHTMLishTag(parser, "script"); //$NON-NLS-1$ + addHTMLishTag(parser, "style"); //$NON-NLS-1$ + } + + public List getSupportedMimeTypes() { + if (supportedMimeTypes == null) { + supportedMimeTypes = new ArrayList(); + supportedMimeTypes.add("text/html"); //$NON-NLS-1$ + supportedMimeTypes.add("text/xhtml"); //$NON-NLS-1$ + supportedMimeTypes.add("application/xhtml+xml"); //$NON-NLS-1$ + supportedMimeTypes.add("application/xml"); //$NON-NLS-1$ + supportedMimeTypes.add("text/vnd.wap.wml"); //$NON-NLS-1$ + } + return supportedMimeTypes; + } + + public void initializeFactoryRegistry(IFactoryRegistry registry) { + Assert.isNotNull(registry); + AdapterFactory factory = HTMLDocumentTypeAdapterFactory.getInstance(); + registry.addFactory(factory); + factory = HTMLModelParserAdapterFactory.getInstance(); + registry.addFactory(factory); + factory = StyleAdapterFactory.getInstance(); + registry.addFactory(factory); + factory = HTMLStyleSelectorAdapterFactory.getInstance(); + registry.addFactory(factory); + } + + public void uninitializeFactoryRegistry(IFactoryRegistry registry) { + Assert.isNotNull(registry); + // note this BIG assumption about factory singletons! + // for this particular list, they are, but may not + // be in future. + + AdapterFactory factory = HTMLDocumentTypeAdapterFactory.getInstance(); + factory.release(); + registry.removeFactory(factory); + + factory = HTMLModelParserAdapterFactory.getInstance(); + factory.release(); + registry.removeFactory(factory); + + factory = StyleAdapterFactory.getInstance(); + factory.release(); + registry.removeFactory(factory); + + factory = HTMLStyleSelectorAdapterFactory.getInstance(); + factory.release(); + registry.removeFactory(factory); + } + + public void uninitializeParser(JSPCapableParser parser) { + // I'm assuming block markers are unique based on name only + // we add these as full BlockMarkers, but remove based on name alone. + parser.removeBlockMarker("script"); //$NON-NLS-1$ + parser.removeBlockMarker("script"); //$NON-NLS-1$ + } + + public EmbeddedTypeHandler newInstance() { + return new EmbeddedHTML(); + } + + /** + * will someday be controlled via extension point + */ + public boolean isDefault() { + return true; + } +}
\ No newline at end of file diff --git a/bundles/org.eclipse.wst.html.core/src/org/eclipse/wst/html/core/modelhandler/ModelHandlerForHTML.java b/bundles/org.eclipse.wst.html.core/src/org/eclipse/wst/html/core/modelhandler/ModelHandlerForHTML.java new file mode 100644 index 0000000000..dd27aecfe7 --- /dev/null +++ b/bundles/org.eclipse.wst.html.core/src/org/eclipse/wst/html/core/modelhandler/ModelHandlerForHTML.java @@ -0,0 +1,55 @@ +/******************************************************************************* + * Copyright (c) 2004 IBM Corporation and others. + * All rights reserved. This program and the accompanying materials + * are made available under the terms of the Eclipse Public License v1.0 + * which accompanies this distribution, and is available at + * http://www.eclipse.org/legal/epl-v10.html + * + * Contributors: + * IBM Corporation - initial API and implementation + *******************************************************************************/ +package org.eclipse.wst.html.core.modelhandler; + +import org.eclipse.wst.html.core.encoding.HTMLDocumentCharsetDetector; +import org.eclipse.wst.html.core.encoding.HTMLDocumentLoader; +import org.eclipse.wst.html.core.encoding.HTMLModelLoader; +import org.eclipse.wst.sse.core.ModelLoader; +import org.eclipse.wst.sse.core.document.IDocumentCharsetDetector; +import org.eclipse.wst.sse.core.document.IDocumentLoader; +import org.eclipse.wst.sse.core.modelhandler.AbstractModelHandler; +import org.eclipse.wst.sse.core.modelhandler.IModelHandler; + +public class ModelHandlerForHTML extends AbstractModelHandler implements IModelHandler { + /** + * Needs to match what's in plugin registry. + * In fact, can be overwritten at run time with + * what's in registry! (so should never be 'final') + */ + static String AssociatedContentTypeID = "org.eclipse.wst.html.core.htmlsource"; //$NON-NLS-1$ + /** + * Needs to match what's in plugin registry. + * In fact, can be overwritten at run time with + * what's in registry! (so should never be 'final') + */ + private static String ModelHandlerID_HTML = "org.eclipse.wst.html.core.modelhandler"; //$NON-NLS-1$ + + + public ModelHandlerForHTML() { + super(); + setId(ModelHandlerID_HTML); + setAssociatedContentTypeId(AssociatedContentTypeID); + } + + public ModelLoader getModelLoader() { + return new HTMLModelLoader(); + } + + public IDocumentCharsetDetector getEncodingDetector() { + return new HTMLDocumentCharsetDetector(); + } + + public IDocumentLoader getDocumentLoader() { + return new HTMLDocumentLoader(); + } + +}
\ No newline at end of file diff --git a/bundles/org.eclipse.wst.html.core/src/org/eclipse/wst/html/core/modelquery/CMAttributeDeclarationBuddySystem.java b/bundles/org.eclipse.wst.html.core/src/org/eclipse/wst/html/core/modelquery/CMAttributeDeclarationBuddySystem.java new file mode 100644 index 0000000000..9d38dad87c --- /dev/null +++ b/bundles/org.eclipse.wst.html.core/src/org/eclipse/wst/html/core/modelquery/CMAttributeDeclarationBuddySystem.java @@ -0,0 +1,67 @@ +/******************************************************************************* + * Copyright (c) 2004 IBM Corporation and others. + * All rights reserved. This program and the accompanying materials + * are made available under the terms of the Eclipse Public License v1.0 + * which accompanies this distribution, and is available at + * http://www.eclipse.org/legal/epl-v10.html + * + * Contributors: + * IBM Corporation - initial API and implementation + *******************************************************************************/ +package org.eclipse.wst.html.core.modelquery; + +import java.util.Enumeration; + +import org.eclipse.wst.common.contentmodel.CMAttributeDeclaration; +import org.eclipse.wst.common.contentmodel.CMDataType; + +/** + */ +class CMAttributeDeclarationBuddySystem extends CMNodeBuddySystem implements CMAttributeDeclaration { + + + public CMAttributeDeclarationBuddySystem(CMAttributeDeclaration self, CMAttributeDeclaration buddy, boolean isXHTML) { + super(self, buddy, isXHTML); + } + + /* + * @see CMAttributeDeclaration#getAttrName() + */ + public String getAttrName() { + return getSelf().getAttrName(); + } + + /* + * @see CMAttributeDeclaration#getAttrType() + */ + public CMDataType getAttrType() { + return getSelf().getAttrType(); + } + + /* + * @see CMAttributeDeclaration#getDefaultValue() + * @deprecated in superclass + */ + public String getDefaultValue() { + return getSelf().getDefaultValue(); + } + + /* + * @see CMAttributeDeclaration#getEnumAttr() + * @deprecated in superclass + */ + public Enumeration getEnumAttr() { + return getSelf().getEnumAttr(); + } + + /* + * @see CMAttributeDeclaration#getUsage() + */ + public int getUsage() { + return getSelf().getUsage(); + } + + private CMAttributeDeclaration getSelf() { + return (CMAttributeDeclaration) self; + } +}
\ No newline at end of file diff --git a/bundles/org.eclipse.wst.html.core/src/org/eclipse/wst/html/core/modelquery/CMDocumentForBuddySystem.java b/bundles/org.eclipse.wst.html.core/src/org/eclipse/wst/html/core/modelquery/CMDocumentForBuddySystem.java new file mode 100644 index 0000000000..b63c6a6116 --- /dev/null +++ b/bundles/org.eclipse.wst.html.core/src/org/eclipse/wst/html/core/modelquery/CMDocumentForBuddySystem.java @@ -0,0 +1,119 @@ +/******************************************************************************* + * Copyright (c) 2004 IBM Corporation and others. + * All rights reserved. This program and the accompanying materials + * are made available under the terms of the Eclipse Public License v1.0 + * which accompanies this distribution, and is available at + * http://www.eclipse.org/legal/epl-v10.html + * + * Contributors: + * IBM Corporation - initial API and implementation + *******************************************************************************/ +package org.eclipse.wst.html.core.modelquery; + +import java.util.Iterator; + +import org.eclipse.wst.common.contentmodel.CMDocument; +import org.eclipse.wst.common.contentmodel.CMElementDeclaration; +import org.eclipse.wst.common.contentmodel.CMNamedNodeMap; +import org.eclipse.wst.common.contentmodel.CMNamespace; +import org.eclipse.wst.common.contentmodel.CMNode; +import org.eclipse.wst.html.core.contentmodel.HTMLCMDocumentFactory; +import org.eclipse.wst.html.core.contentmodel.ssi.SSICMDocumentFactory; +import org.eclipse.wst.sse.core.contentmodel.CMDocType; + +/** + */ +class CMDocumentForBuddySystem extends CMNodeBuddySystem implements CMDocument { + + + private static CMDocument getHTMLCMDocument() { + return HTMLCMDocumentFactory.getCMDocument(CMDocType.HTML_DOC_TYPE); + } + + class Elements extends CMNamedNodeMapForBuddySystem { + public Elements(CMNamedNodeMap elements, boolean isXHTML) { + super(isXHTML); + makeBuddySystem(elements); + addSSIDecls(); + } + + protected String getKeyName(CMNode original) { + CMElementDeclaration edecl = getDecl(original); + if (edecl == null) + return null; + return edecl.getElementName(); + } + + protected CMNode createBuddySystem(CMNode original) { + CMElementDeclaration edecl = getDecl(original); + return new CMElementDeclarationBuddySystem(edecl, isXHTML()); + } + + private CMElementDeclaration getDecl(CMNode cmnode) { + if (cmnode == null) + return null; + if (cmnode.getNodeType() != CMNode.ELEMENT_DECLARATION) + return null; + return (CMElementDeclaration) cmnode; + } + + private void addSSIDecls() { + CMDocument ssi = SSICMDocumentFactory.getCMDocument(); + if (ssi == null) + return; + CMNamedNodeMap elements = ssi.getElements(); + Iterator i = elements.iterator(); + while (i.hasNext()) { + CMElementDeclaration decl = (CMElementDeclaration) i.next(); + if (decl == null) + continue; + put(decl.getElementName(), decl); + } + } + } + + private Elements elements = null; + + public CMDocumentForBuddySystem(CMDocument self, boolean isXHTML) { + super(self, getHTMLCMDocument(), isXHTML); + } + + /* + * @see CMDocument#getElements() + */ + public CMNamedNodeMap getElements() { + if (elements != null) + return elements; + CMDocument cmdoc = getSelf(); + if (cmdoc == null) + return null; + elements = new Elements(cmdoc.getElements(), isXHTML); + return elements; + } + + /* + * @see CMDocument#getEntities() + */ + public CMNamedNodeMap getEntities() { + CMDocument cmdoc = getSelf(); + if (cmdoc == null) + return null; + return cmdoc.getEntities(); + } + + /* + * @see CMDocument#getNamespace() + */ + public CMNamespace getNamespace() { + CMDocument cmdoc = getSelf(); + if (cmdoc == null) + return null; + return cmdoc.getNamespace(); + } + + private CMDocument getSelf() { + if (self.getNodeType() != CMNode.DOCUMENT) + return null; + return (CMDocument) self; + } +}
\ No newline at end of file diff --git a/bundles/org.eclipse.wst.html.core/src/org/eclipse/wst/html/core/modelquery/CMElementDeclarationBuddySystem.java b/bundles/org.eclipse.wst.html.core/src/org/eclipse/wst/html/core/modelquery/CMElementDeclarationBuddySystem.java new file mode 100644 index 0000000000..030b4f41ce --- /dev/null +++ b/bundles/org.eclipse.wst.html.core/src/org/eclipse/wst/html/core/modelquery/CMElementDeclarationBuddySystem.java @@ -0,0 +1,201 @@ +/******************************************************************************* + * Copyright (c) 2004 IBM Corporation and others. + * All rights reserved. This program and the accompanying materials + * are made available under the terms of the Eclipse Public License v1.0 + * which accompanies this distribution, and is available at + * http://www.eclipse.org/legal/epl-v10.html + * + * Contributors: + * IBM Corporation - initial API and implementation + *******************************************************************************/ +package org.eclipse.wst.html.core.modelquery; + + +import org.eclipse.wst.common.contentmodel.CMAttributeDeclaration; +import org.eclipse.wst.common.contentmodel.CMContent; +import org.eclipse.wst.common.contentmodel.CMDataType; +import org.eclipse.wst.common.contentmodel.CMDocument; +import org.eclipse.wst.common.contentmodel.CMElementDeclaration; +import org.eclipse.wst.common.contentmodel.CMNamedNodeMap; +import org.eclipse.wst.common.contentmodel.CMNode; +import org.eclipse.wst.html.core.HTMLCMProperties; +import org.eclipse.wst.html.core.contentmodel.HTMLCMDocumentFactory; +import org.eclipse.wst.sse.core.contentmodel.CMDocType; + +/** + */ +class CMElementDeclarationBuddySystem extends CMNodeBuddySystem implements CMElementDeclaration { + + + private static CMDocument htmlcm = HTMLCMDocumentFactory.getCMDocument(CMDocType.HTML_DOC_TYPE); + + private static CMElementDeclaration getHTMLCMElemDecl(CMElementDeclaration original) { + CMElementDeclaration buddy = null; + if (htmlcm != null) { + CMNamedNodeMap elems = htmlcm.getElements(); + if (elems != null) { + buddy = (CMElementDeclaration) elems.getNamedItem(original.getElementName()); + } + } + return buddy; + } + + private class Attrs extends CMNamedNodeMapForBuddySystem { + private CMNamedNodeMap buddyAttrs = null; + + public Attrs(CMNamedNodeMap attrs, CMNamedNodeMap buddyAttrs, boolean isXHTML) { + super(isXHTML); + this.buddyAttrs = buddyAttrs; + makeBuddySystem(attrs); + } + + protected String getKeyName(CMNode original) { + CMAttributeDeclaration adecl = getDecl(original); + if (adecl == null) + return null; + return adecl.getAttrName(); + } + + protected CMNode createBuddySystem(CMNode original) { + CMAttributeDeclaration adecl = getDecl(original); + if (adecl == null) + return null; + CMAttributeDeclaration buddy = null; + if (buddyAttrs != null) { + buddy = (CMAttributeDeclaration) buddyAttrs.getNamedItem(adecl.getAttrName()); + } + return new CMAttributeDeclarationBuddySystem(adecl, buddy, isXHTML()); + } + + private CMAttributeDeclaration getDecl(CMNode cmnode) { + if (cmnode == null) + return null; + if (cmnode.getNodeType() != CMNode.ATTRIBUTE_DECLARATION) + return null; + return (CMAttributeDeclaration) cmnode; + } + } + + private Attrs attributes = null; + + public CMElementDeclarationBuddySystem(CMElementDeclaration self, boolean isXHTML) { + super(self, getHTMLCMElemDecl(self), isXHTML); + } + + /* + * @see CMElementDeclaration#getAttributes() + */ + public CMNamedNodeMap getAttributes() { + if (attributes != null) + return attributes; + CMElementDeclaration edecl = getSelf(); + if (edecl == null) + return null; + CMElementDeclaration htmlDecl = getBuddy(); + CMNamedNodeMap htmlAttrs = (htmlDecl == null) ? null : htmlDecl.getAttributes(); + attributes = new Attrs(edecl.getAttributes(), htmlAttrs, isXHTML); + return attributes; + } + + /* + * @see CMElementDeclaration#getContent() + */ + public CMContent getContent() { + CMElementDeclaration edecl = getSelf(); + if (edecl == null) + return null; + return edecl.getContent(); + } + + /* + * @see CMElementDeclaration#getContentType() + */ + public int getContentType() { + CMElementDeclaration edecl = getSelf(); + if (edecl == null) + return CMElementDeclaration.ANY; + return edecl.getContentType(); + } + + /* + * @see CMElementDeclaration#getElementName() + */ + public String getElementName() { + CMElementDeclaration edecl = getSelf(); + if (edecl == null) + return null; + return edecl.getElementName(); + } + + /* + * @see CMElementDeclaration#getDataType() + */ + public CMDataType getDataType() { + CMElementDeclaration edecl = getSelf(); + if (edecl == null) + return null; + return edecl.getDataType(); + } + + /* + * @see CMElementDeclaration#getLocalElements() + */ + public CMNamedNodeMap getLocalElements() { + CMElementDeclaration edecl = getSelf(); + if (edecl == null) + return null; + return edecl.getLocalElements(); + } + + /* + * @see CMContent#getMaxOccur() + */ + public int getMaxOccur() { + CMElementDeclaration edecl = getSelf(); + if (edecl == null) + return -1; + return edecl.getMaxOccur(); + } + + /* + * @see CMContent#getMinOccur() + */ + public int getMinOccur() { + CMElementDeclaration edecl = getSelf(); + if (edecl == null) + return -1; + return edecl.getMinOccur(); + } + + /* + * @see CMNode#supports(String) + */ + public boolean supports(String propertyName) { + if (isXHTML && propertyName.equals(HTMLCMProperties.OMIT_TYPE)) + return true; + return super.supports(propertyName); + } + + /* + * @see CMNode#getProperty(String) + */ + public Object getProperty(String propertyName) { + if (isXHTML && propertyName.equals(HTMLCMProperties.OMIT_TYPE)) + return HTMLCMProperties.Values.OMIT_NONE; + return super.getProperty(propertyName); + } + + private CMElementDeclaration getSelf() { + if (self.getNodeType() != CMNode.ELEMENT_DECLARATION) + return null; + return (CMElementDeclaration) self; + } + + private CMElementDeclaration getBuddy() { + if (buddy == null) + return null; + if (buddy.getNodeType() != CMNode.ELEMENT_DECLARATION) + return null; + return (CMElementDeclaration) buddy; + } +}
\ No newline at end of file diff --git a/bundles/org.eclipse.wst.html.core/src/org/eclipse/wst/html/core/modelquery/CMNamedNodeMapForBuddySystem.java b/bundles/org.eclipse.wst.html.core/src/org/eclipse/wst/html/core/modelquery/CMNamedNodeMapForBuddySystem.java new file mode 100644 index 0000000000..0969a93fdd --- /dev/null +++ b/bundles/org.eclipse.wst.html.core/src/org/eclipse/wst/html/core/modelquery/CMNamedNodeMapForBuddySystem.java @@ -0,0 +1,109 @@ +/******************************************************************************* + * Copyright (c) 2004 IBM Corporation and others. + * All rights reserved. This program and the accompanying materials + * are made available under the terms of the Eclipse Public License v1.0 + * which accompanies this distribution, and is available at + * http://www.eclipse.org/legal/epl-v10.html + * + * Contributors: + * IBM Corporation - initial API and implementation + *******************************************************************************/ +package org.eclipse.wst.html.core.modelquery; + + +import java.util.Hashtable; +import java.util.Iterator; + +import org.eclipse.wst.common.contentmodel.CMNamedNodeMap; +import org.eclipse.wst.common.contentmodel.CMNode; + +/** + */ +abstract class CMNamedNodeMapForBuddySystem implements CMNamedNodeMap { + + + private boolean isXHTML = false; + private Hashtable map = new Hashtable(); + + /** + * Constructor of CMNamedNodeMapForBuddySystem. + * CAUTION: Each derived class must call 'makeBuddySystem' method in its + * constructor to build up its contents. + */ + public CMNamedNodeMapForBuddySystem(boolean isXHTML) { + super(); + this.isXHTML = isXHTML; + } + + /* + * @see CMNamedNodeMap#getLength() + */ + public int getLength() { + return map.size(); + } + + /* + * @see CMNamedNodeMap#getNamedItem(String) + */ + public CMNode getNamedItem(String name) { + String key = canonicalName(name); + if (!map.containsKey(key)) + return null; + return (CMNode) map.get(key); + } + + /* + * @see CMNamedNodeMap#item(int) + */ + public CMNode item(int index) { + Iterator iter = iterator(); + while (iter.hasNext()) { + Object node = iter.next(); + if (--index < 0) + return (CMNode) node; + } + return null; + } + + /* + * @see CMNamedNodeMap#iterator() + */ + public Iterator iterator() { + return map.values().iterator(); + } + + /* package scope. */ + void put(String name, CMNode cmnode) { + if (name == null || cmnode == null) + return; + map.put(canonicalName(name), cmnode); + } + + abstract protected String getKeyName(CMNode original); + + abstract protected CMNode createBuddySystem(CMNode original); + + protected boolean isXHTML() { + return isXHTML; + } + + /** + * Each derived class must call this method in its constructor + * to build up its contents. + */ + protected void makeBuddySystem(CMNamedNodeMap original) { + Iterator i = original.iterator(); + if (i == null) + return; + while (i.hasNext()) { + CMNode org = (CMNode) i.next(); + String key = getKeyName(org); + CMNode newNode = createBuddySystem(org); + put(key, newNode); + } + } + + private String canonicalName(String name) { + return name.toUpperCase(); + } +}
\ No newline at end of file diff --git a/bundles/org.eclipse.wst.html.core/src/org/eclipse/wst/html/core/modelquery/CMNodeBuddySystem.java b/bundles/org.eclipse.wst.html.core/src/org/eclipse/wst/html/core/modelquery/CMNodeBuddySystem.java new file mode 100644 index 0000000000..908b7e18c3 --- /dev/null +++ b/bundles/org.eclipse.wst.html.core/src/org/eclipse/wst/html/core/modelquery/CMNodeBuddySystem.java @@ -0,0 +1,74 @@ +/******************************************************************************* + * Copyright (c) 2004 IBM Corporation and others. + * All rights reserved. This program and the accompanying materials + * are made available under the terms of the Eclipse Public License v1.0 + * which accompanies this distribution, and is available at + * http://www.eclipse.org/legal/epl-v10.html + * + * Contributors: + * IBM Corporation - initial API and implementation + *******************************************************************************/ +package org.eclipse.wst.html.core.modelquery; + +import org.eclipse.wst.common.contentmodel.CMNode; +import org.eclipse.wst.html.core.HTMLCMProperties; + +/** + */ +class CMNodeBuddySystem implements CMNode { + + + protected boolean isXHTML = false; + protected CMNode self = null; + protected CMNode buddy = null; + + public CMNodeBuddySystem(CMNode self, CMNode buddy, boolean isXHTML) { + super(); + this.self = self; + this.buddy = buddy; + this.isXHTML = isXHTML; + } + + /* + * @see CMNode#getNodeName() + */ + public String getNodeName() { + return self.getNodeName(); + } + + /* + * @see CMNode#getNodeType() + */ + public int getNodeType() { + return self.getNodeType(); + } + + /* + * @see CMNode#supports(String) + */ + public boolean supports(String propertyName) { + if (propertyName.equals(HTMLCMProperties.SHOULD_IGNORE_CASE)) + return true; + if (propertyName.equals(HTMLCMProperties.IS_XHTML)) + return true; + if (buddy == null) + return false; + return buddy.supports(propertyName); + } + + /* + * @see CMNode#getProperty(String) + */ + public Object getProperty(String propertyName) { + if (propertyName.equals(HTMLCMProperties.SHOULD_IGNORE_CASE)) { + return new Boolean(!isXHTML); + } + if (propertyName.equals(HTMLCMProperties.IS_XHTML)) { + return new Boolean(isXHTML); + } + + if (buddy == null || (!buddy.supports(propertyName))) + return null; + return buddy.getProperty(propertyName); + } +}
\ No newline at end of file diff --git a/bundles/org.eclipse.wst.html.core/src/org/eclipse/wst/html/core/modelquery/DocumentQuery.java b/bundles/org.eclipse.wst.html.core/src/org/eclipse/wst/html/core/modelquery/DocumentQuery.java new file mode 100644 index 0000000000..4613395cff --- /dev/null +++ b/bundles/org.eclipse.wst.html.core/src/org/eclipse/wst/html/core/modelquery/DocumentQuery.java @@ -0,0 +1,200 @@ +/******************************************************************************* + * Copyright (c) 2004 IBM Corporation and others. + * All rights reserved. This program and the accompanying materials + * are made available under the terms of the Eclipse Public License v1.0 + * which accompanies this distribution, and is available at + * http://www.eclipse.org/legal/epl-v10.html + * + * Contributors: + * IBM Corporation - initial API and implementation + *******************************************************************************/ +package org.eclipse.wst.html.core.modelquery; + +import org.w3c.dom.Document; +import org.w3c.dom.Node; +import org.w3c.dom.ranges.Range; + +/** + */ +public interface DocumentQuery { + + /** + * isRenderRoot() returns true if - node is BODY element (both explicit + * and implicit) - node is portalhtml:body element - node is Document node + * and the document is treated as fragment (with BODY context) Note that + * in editing a fragment file, Document node should be treated as a + * substitute of BODY element. + */ + boolean isRenderRoot(Node node); + + /** + * isHeadCorrespondent() returns true if - node is HEAD element (both + * explicit and implicit) - node is portalhtml:head element - node is + * Document node and the document is treated as fragment (with HEAD + * context) Note that in editing a fragment file (with HEAD context), + * Document node should be treated as a substitute of HEAD element. + */ + boolean isHeadCorrespondent(Node node); + + /** + * Implicit BODY element will be gone in V6 SED model. So page designer + * provides an API to get a range whose content nodes are rendered in + * design view. getRenderRootRange() returns - a range from BODY's first + * to its last (if the document has BODY element) - a range form + * Document's first to its last (if the document is fragment with BODY + * context) - null (if the document is fragment with HEAD context) [The + * following cases will be supported since V6] - a range from a custom + * tag's first to its last (if the document has a custom tag which + * generates BODY element at runtime) - a range from Document's + * appropirate offset to its last (if the document does not have explicit + * BODY/HTML) - a range from HTML element's appropriate offset to its last + * (if the document does not have explicit BODY but have explicit HTML) + * + * @param doc + * @return + */ + Range getRenderRootRange(Document doc); + + /** + * Implicit HEAD element will be gone in V6 SED model. So page designer + * provides an API to get a range whose content nodes are treated as HEAD + * element's child. getHeadCorrespondentRange() returns - a range from + * HEAD's first to its last (if the document has HEAD element) - a range + * form Document's first to its last (if the document is fragment with + * HEAD context) - null (if the document is fragment with BODY context) + * [The following cases will be supported since V6] - a range from a + * custom tag's first to its last (if the document has a custom tag which + * generates HEAD element at runtime) - a range from Document's first to + * appropirate offset (if the document does not have explicit HEAD/HTML) - + * a range from HTML element's first to appropriate offset (if the + * document does not have explicit HEAD but have explicit HTML) + * + * @param doc + * @return + */ + Range getHeadCorrespondentRange(Document doc); + + /** + * getRenderRootNode() with [create=false] returns - BODY element if this + * document is not fragment and has BODY element - null if this document + * is not fragment and does not have BODY element - Document node if this + * document is fragment with BODY context - null if this document is + * fragment with HEAD context [The following cases will be supported since + * V6] - a custom tag which generates BODY tag at runtime - Document node + * or HTML element if this document is not fragment but does not have + * explicit BODY element getRenderRootNode() with [create=true] returns - + * BODY element if this document is not fragment and has BODY element (no + * modifictation) - newly created BODY element if this document is not + * fragment but does not have BODY element - Document node if this + * document is fragment with BODY context (no modifictation) [The + * following cases will be supported since V6] - a custom tag which + * generates BODY tag at runtime (no modifictation) - newly created BODY + * element if this document is not fragment but does not have explicit + * BODY element getRenderRootNode() throws HTMLCommandException (since V6) + * if - this document is fragment with HEAD context and - "create" + * parameter is true Note that in editing a fragment file, Document node + * should be treated as a substitute of BODY element. + * + * @param childOrDocument + * @param create + * @return + */ + Node getRenderRootNode(Node childOrDocument, boolean create); + + /** + * getHeadCorrespondentNode() with [create=false] returns - HEAD element + * if this document is not fragment and has HEAD element - null if this + * document is not fragment and does not have HEAD element - Document node + * if this document is fragment with HEAD context - null if this document + * is fragment with BODY context [The following cases will be supported + * since V6] - a custom tag which generates HEAD tag at runtime - Document + * node or HTML element if this document is not fragment but does not have + * explicit HEAD element getHeadCorrespondentNode() with [create=true] + * returns - HEAD element if this document is not fragment and has HEAD + * element (no modifictation) - newly created HEAD element if this + * document is not fragment but does not have HEAD element - Document node + * if this document is fragment with HEAD context (no modifictation) [The + * following cases will be supported since V6] - a custom tag which + * generates HEAD tag at runtime (no modifictation) - newly created HEAD + * element if this document is not fragment but does not have explicit + * HEAD element getHeadCorrespondentNode() throws HTMLCommandException + * (since V6) if - this document is fragment with BODY context and - + * "create" parameter is true Note that in editing a fragment file, + * Document node should be treated as a substitute of HEAD element. + * + * @param childOrDocument + * @param create + * @return + */ + Node getHeadCorrespondentNode(Node childOrDocument, boolean create); + + /** + * getHtmlCorrespondentNode() throws HTMLCommandException (since V6) if - + * this document is fragment and "create" parameter is true + * + * @param childOrDocument + * @param create + * @return + */ + Node getHtmlCorrespondentNode(Node childOrDocument, boolean create); + + /** + * This inner class is intended for insertion target. please use this like + * the following : DocumentQuery.InsertionTarget ins; + * ins.getParent().insertBefore(youInsertionNode, ins.getRef()); + */ + public class InsertionTarget { + private final Node parent; + private final Node ref; + + public InsertionTarget(Node parent, Node ref) { + this.parent = parent; + this.ref = ref; + } + + public Node getParent() { + return parent; + } + + public Node getRef() { + return ref; + } + } + + /** + * getHeadInsertionTarget() returns appropriate insetion target location + * for HEAD child tags such as <script>, <style>, <meta>etc. Basically + * this function returns <HEAD>tag's the last position. Note that this + * would not create actual <HEAD>tag when the document does not have it. + * <HEAD>is omittable tag so this function returns appropriate position + * to which implicit <HEAD>can be inserted, if the document has no + * <HEAD>. + * + * @param doc + * @return + */ + InsertionTarget getHeadInsertionTarget(Document doc); + + /** + * getPageInsertionTarget() returns appropriate insetion target location + * for page-level markups, such as JSP directives, usebean tags or <html> + * tag. Basically this function returns just before <HTML>tag. Note that + * this would not create actual <HTML>tag when the document does not have + * it. In such case, this function returns a position just before the + * meaningful tags such as HTML/JSP elements. + * + * @param doc + * @return + */ + InsertionTarget getPageInsertionTarget(Document doc); + + /** + * isFragment() returns whether the document is fragment or complete + * document + * + * @param doc + * @return + */ + boolean isFragment(Document doc); + +}
\ No newline at end of file diff --git a/bundles/org.eclipse.wst.html.core/src/org/eclipse/wst/html/core/modelquery/ElementDeclarationAdapter.java b/bundles/org.eclipse.wst.html.core/src/org/eclipse/wst/html/core/modelquery/ElementDeclarationAdapter.java new file mode 100644 index 0000000000..60545feedc --- /dev/null +++ b/bundles/org.eclipse.wst.html.core/src/org/eclipse/wst/html/core/modelquery/ElementDeclarationAdapter.java @@ -0,0 +1,29 @@ +/******************************************************************************* + * Copyright (c) 2004 IBM Corporation and others. + * All rights reserved. This program and the accompanying materials + * are made available under the terms of the Eclipse Public License v1.0 + * which accompanies this distribution, and is available at + * http://www.eclipse.org/legal/epl-v10.html + * + * Contributors: + * IBM Corporation - initial API and implementation + *******************************************************************************/ +package org.eclipse.wst.html.core.modelquery; + + + +import org.eclipse.wst.common.contentmodel.CMElementDeclaration; +import org.eclipse.wst.sse.core.INodeAdapter; + +/** + */ +public interface ElementDeclarationAdapter extends INodeAdapter { + + /** + */ + CMElementDeclaration getDeclaration(); + + /** + */ + void setDeclaration(CMElementDeclaration declaration); +}
\ No newline at end of file diff --git a/bundles/org.eclipse.wst.html.core/src/org/eclipse/wst/html/core/modelquery/ElementDeclarationAdapterFactory.java b/bundles/org.eclipse.wst.html.core/src/org/eclipse/wst/html/core/modelquery/ElementDeclarationAdapterFactory.java new file mode 100644 index 0000000000..992ad77161 --- /dev/null +++ b/bundles/org.eclipse.wst.html.core/src/org/eclipse/wst/html/core/modelquery/ElementDeclarationAdapterFactory.java @@ -0,0 +1,68 @@ +/******************************************************************************* + * Copyright (c) 2004 IBM Corporation and others. + * All rights reserved. This program and the accompanying materials + * are made available under the terms of the Eclipse Public License v1.0 + * which accompanies this distribution, and is available at + * http://www.eclipse.org/legal/epl-v10.html + * + * Contributors: + * IBM Corporation - initial API and implementation + *******************************************************************************/ +package org.eclipse.wst.html.core.modelquery; + + + +import org.eclipse.wst.sse.core.AdapterFactory; +import org.eclipse.wst.sse.core.INodeAdapter; +import org.eclipse.wst.sse.core.INodeNotifier; + +/** + */ +public class ElementDeclarationAdapterFactory implements AdapterFactory { + + private static ElementDeclarationAdapterFactory instance = null; + + /** + */ + private ElementDeclarationAdapterFactory() { + super(); + } + + /** + */ + public INodeAdapter adapt(INodeNotifier notifier) { + if (notifier == null) + return null; + INodeAdapter adapter = notifier.getExistingAdapter(ElementDeclarationAdapter.class); + if (adapter != null) + return adapter; + adapter = new HTMLElementDeclarationAdapter(); + notifier.addAdapter(adapter); + return adapter; + } + + /** + */ + public synchronized static ElementDeclarationAdapterFactory getInstance() { + if (instance == null) + instance = new ElementDeclarationAdapterFactory(); + return instance; + } + + /** + */ + public boolean isFactoryForType(Object type) { + return (type == ElementDeclarationAdapter.class); + } + + public void release() { + // default is to do nothing + } + + /** + * Overriding copy method + */ + public AdapterFactory copy() { + return getInstance(); + } +}
\ No newline at end of file diff --git a/bundles/org.eclipse.wst.html.core/src/org/eclipse/wst/html/core/modelquery/HMQUtil.java b/bundles/org.eclipse.wst.html.core/src/org/eclipse/wst/html/core/modelquery/HMQUtil.java new file mode 100644 index 0000000000..38574c3a98 --- /dev/null +++ b/bundles/org.eclipse.wst.html.core/src/org/eclipse/wst/html/core/modelquery/HMQUtil.java @@ -0,0 +1,121 @@ +/******************************************************************************* + * Copyright (c) 2004 IBM Corporation and others. + * All rights reserved. This program and the accompanying materials + * are made available under the terms of the Eclipse Public License v1.0 + * which accompanies this distribution, and is available at + * http://www.eclipse.org/legal/epl-v10.html + * + * Contributors: + * IBM Corporation - initial API and implementation + *******************************************************************************/ +package org.eclipse.wst.html.core.modelquery; + +import java.util.Collection; +import java.util.Hashtable; +import java.util.Iterator; +import java.util.Vector; + +import org.eclipse.wst.common.contentmodel.CMContent; +import org.eclipse.wst.common.contentmodel.CMElementDeclaration; +import org.eclipse.wst.common.contentmodel.CMGroup; +import org.eclipse.wst.common.contentmodel.CMNode; +import org.eclipse.wst.common.contentmodel.CMNodeList; +import org.eclipse.wst.common.contentmodel.modelquery.ModelQuery; +import org.eclipse.wst.html.core.HTMLCMProperties; +import org.eclipse.wst.xml.core.modelquery.ModelQueryUtil; +import org.w3c.dom.Document; +import org.w3c.dom.Element; +import org.w3c.dom.Node; + +public final class HMQUtil { + + private final static Vector nullVector = new Vector(); + + /* HMQUtil class must not instantiate. */ + private HMQUtil() { + super(); + } + + /* gather all element declarations in inclusion of each parent of the target. + * the inclusion of the target is also gathered. */ + public static Collection getInclusions(Element target) { + if (target == null) + return nullVector; + Collection inclusions = gatherInclusions(getAncestorDeclarations(target)); + + Hashtable availables = new Hashtable(); + Iterator iter = inclusions.iterator(); + while (iter.hasNext()) { + CMContent inclusion = (CMContent) iter.next(); + switch (inclusion.getNodeType()) { + case CMNode.GROUP : + extractDeclarations(availables, (CMGroup) inclusion); + break; + case CMNode.ELEMENT_DECLARATION : + addInclusion(availables, (CMElementDeclaration) inclusion); + break; + } + } + + return availables.values(); + } + + private static Collection getAncestorDeclarations(Element target) { + Vector ancestors = new Vector(); + + Document doc = target.getOwnerDocument(); + ModelQuery query = ModelQueryUtil.getModelQuery(doc); + CMElementDeclaration decl = query.getCMElementDeclaration(target); + ancestors.add(decl); + + Element parent = getParent(target); + while (parent != null) { + decl = query.getCMElementDeclaration(parent); + if (decl != null) + ancestors.add(decl); + parent = getParent(parent); + } + return ancestors; + } + + private static void addInclusion(Hashtable availables, CMElementDeclaration decl) { + String name = decl.getElementName(); + if (availables.containsKey(name)) + return; + availables.put(name, decl); + } + + private static Collection gatherInclusions(Collection ancestors) { + Vector inclusions = new Vector(); + Iterator iter = ancestors.iterator(); + while (iter.hasNext()) { + CMElementDeclaration decl = (CMElementDeclaration) iter.next(); + if (decl.supports(HTMLCMProperties.INCLUSION)) { + CMContent inclusion = (CMContent) decl.getProperty(HTMLCMProperties.INCLUSION); + if (inclusion != null) + inclusions.add(inclusion); + } + } + return inclusions; + } + + private static Element getParent(Node target) { + Node parent = target.getParentNode(); + while (parent != null) { + if (parent.getNodeType() == Node.ELEMENT_NODE) + return (Element) parent; + parent = parent.getParentNode(); + } + return null; + } + + private static void extractDeclarations(Hashtable availables, CMGroup group) { + CMNodeList content = group.getChildNodes(); + for (int i = 0; i < content.getLength(); i++) { + CMNode cmn = content.item(i); + if (cmn == null || cmn.getNodeType() != CMNode.ELEMENT_DECLARATION) + continue; + addInclusion(availables, (CMElementDeclaration) cmn); + } + } +}
\ No newline at end of file diff --git a/bundles/org.eclipse.wst.html.core/src/org/eclipse/wst/html/core/modelquery/HTMLElementDeclarationAdapter.java b/bundles/org.eclipse.wst.html.core/src/org/eclipse/wst/html/core/modelquery/HTMLElementDeclarationAdapter.java new file mode 100644 index 0000000000..0774d880df --- /dev/null +++ b/bundles/org.eclipse.wst.html.core/src/org/eclipse/wst/html/core/modelquery/HTMLElementDeclarationAdapter.java @@ -0,0 +1,54 @@ +/******************************************************************************* + * Copyright (c) 2004 IBM Corporation and others. + * All rights reserved. This program and the accompanying materials + * are made available under the terms of the Eclipse Public License v1.0 + * which accompanies this distribution, and is available at + * http://www.eclipse.org/legal/epl-v10.html + * + * Contributors: + * IBM Corporation - initial API and implementation + *******************************************************************************/ +package org.eclipse.wst.html.core.modelquery; + + + +import org.eclipse.wst.common.contentmodel.CMElementDeclaration; +import org.eclipse.wst.sse.core.INodeNotifier; + +/** + */ +public class HTMLElementDeclarationAdapter implements ElementDeclarationAdapter { + + private CMElementDeclaration declaration = null; + + /** + */ + public HTMLElementDeclarationAdapter() { + super(); + } + + /** + */ + public CMElementDeclaration getDeclaration() { + return this.declaration; + } + + /** + * Allowing the INodeAdapter to compare itself against the type + * allows it to return true in more than one case. + */ + public boolean isAdapterForType(Object type) { + return (type == ElementDeclarationAdapter.class); + } + + /** + */ + public void notifyChanged(INodeNotifier notifier, int eventType, Object changedFeature, Object oldValue, Object newValue, int pos) { + } + + /** + */ + public void setDeclaration(CMElementDeclaration declaration) { + this.declaration = declaration; + } +}
\ No newline at end of file diff --git a/bundles/org.eclipse.wst.html.core/src/org/eclipse/wst/html/core/modelquery/HTMLModelQueryAssociationProvider.java b/bundles/org.eclipse.wst.html.core/src/org/eclipse/wst/html/core/modelquery/HTMLModelQueryAssociationProvider.java new file mode 100644 index 0000000000..6161a17728 --- /dev/null +++ b/bundles/org.eclipse.wst.html.core/src/org/eclipse/wst/html/core/modelquery/HTMLModelQueryAssociationProvider.java @@ -0,0 +1,54 @@ +/******************************************************************************* + * Copyright (c) 2004 IBM Corporation and others. + * All rights reserved. This program and the accompanying materials + * are made available under the terms of the Eclipse Public License v1.0 + * which accompanies this distribution, and is available at + * http://www.eclipse.org/legal/epl-v10.html + * + * Contributors: + * IBM Corporation - initial API and implementation + *******************************************************************************/ +package org.eclipse.wst.html.core.modelquery; + + + +import org.eclipse.wst.common.contentmodel.modelqueryimpl.SimpleAssociationProvider; +import org.eclipse.wst.common.contentmodel.util.CMDocumentCache; +import org.eclipse.wst.xml.uriresolver.util.IdResolver; + +/** + */ +public class HTMLModelQueryAssociationProvider extends SimpleAssociationProvider { + + /** + * @param modelQueryCMProvider org.eclipse.wst.common.contentmodel.modelquery.ModelQueryCMProvider + */ + public HTMLModelQueryAssociationProvider(CMDocumentCache cache, IdResolver idResolver) { + super(new HTMLModelQueryCMProvider(cache, idResolver)); + } + + // MIWA: We cannot cache a CMElementDeclaration any more. Because, when the DOCTYPE + // was changed, CMDocument would be changed. Then, a cached CMElementDeclaration + // would be invalid. If some performance problems occurs, we consider a smarter + // cache mechanism. + // + // public CMElementDeclaration getCMElementDeclaration(Element element) { + // // check if element declaration is cached + // INodeNotifier notifier = (INodeNotifier) element; + // ElementDeclarationAdapter adapter = (ElementDeclarationAdapter) notifier.getExistingAdapter(ElementDeclarationAdapter.class); + // if (adapter != null) + // return adapter.getDeclaration(); + // + // CMElementDeclaration decl = super.getCMElementDeclaration(element); + // + // // cache HTML element declaration only + // if (decl != null && decl instanceof HTMLElementDeclaration) { + // AdapterFactory factory = ElementDeclarationAdapterFactory.getInstance(); + // adapter = (ElementDeclarationAdapter) factory.adapt(notifier); + // if (adapter != null) + // adapter.setDeclaration(decl); + // } + // + // return decl; + // } +}
\ No newline at end of file diff --git a/bundles/org.eclipse.wst.html.core/src/org/eclipse/wst/html/core/modelquery/HTMLModelQueryCMProvider.java b/bundles/org.eclipse.wst.html.core/src/org/eclipse/wst/html/core/modelquery/HTMLModelQueryCMProvider.java new file mode 100644 index 0000000000..c5c11ce428 --- /dev/null +++ b/bundles/org.eclipse.wst.html.core/src/org/eclipse/wst/html/core/modelquery/HTMLModelQueryCMProvider.java @@ -0,0 +1,100 @@ +/******************************************************************************* + * Copyright (c) 2004 IBM Corporation and others. + * All rights reserved. This program and the accompanying materials + * are made available under the terms of the Eclipse Public License v1.0 + * which accompanies this distribution, and is available at + * http://www.eclipse.org/legal/epl-v10.html + * + * Contributors: + * IBM Corporation - initial API and implementation + *******************************************************************************/ +package org.eclipse.wst.html.core.modelquery; + + +import java.util.Hashtable; + +import org.eclipse.wst.common.contentmodel.CMDocument; +import org.eclipse.wst.common.contentmodel.modelquery.ModelQueryCMProvider; +import org.eclipse.wst.common.contentmodel.util.CMDocumentCache; +import org.eclipse.wst.html.core.contentmodel.HTMLCMDocumentFactory; +import org.eclipse.wst.html.core.document.HTMLDocumentTypeEntry; +import org.eclipse.wst.html.core.document.HTMLDocumentTypeRegistry; +import org.eclipse.wst.sse.core.contentmodel.CMDocType; +import org.eclipse.wst.xml.core.document.XMLDocument; +import org.eclipse.wst.xml.uriresolver.util.IdResolver; +import org.w3c.dom.Document; +import org.w3c.dom.DocumentType; +import org.w3c.dom.Node; + +/** + * CMDocument provider for HTML and XHTML documents. + */ +public class HTMLModelQueryCMProvider implements ModelQueryCMProvider { + + + private static CMDocument staticHTML = HTMLCMDocumentFactory.getCMDocument(CMDocType.HTML_DOC_TYPE); + private static CMDocument staticCHTML = HTMLCMDocumentFactory.getCMDocument(CMDocType.CHTML_DOC_TYPE); + private static HTMLDocumentTypeRegistry doctypeRegistry = HTMLDocumentTypeRegistry.getInstance(); + private static Hashtable buddyCache = new Hashtable(); + + private XHTMLAssociationProvider xhtmlassoc = null; + + public HTMLModelQueryCMProvider(CMDocumentCache cache, IdResolver idResolver) { + super(); + xhtmlassoc = new XHTMLAssociationProvider(cache, idResolver); + } + + /** + * Returns the CMDocument that corresponds to the DOM Node. + * or null if no CMDocument is appropriate for the DOM Node. + */ + public CMDocument getCorrespondingCMDocument(Node node) { + XMLDocument owner = getOwnerXMLDocument(node); + if (owner == null) + return null; + + String pid = getPublicId(owner); + if (pid == null) + return staticHTML; + + HTMLDocumentTypeEntry entry = doctypeRegistry.getEntry(pid); + if (entry == null) + return staticHTML; + + pid = entry.getPublicId(); + CMDocument dtdcm = xhtmlassoc.getXHTMLCMDocument(pid, entry.getSystemId()); + if (dtdcm == null) { + if (pid != null && pid.equals(HTMLDocumentTypeRegistry.CHTML_PUBLIC_ID)) { + return staticCHTML; + } + return staticHTML; + } + + CMDocument buddycm = (CMDocument) buddyCache.get(pid); + if (buddycm != null) + return buddycm; + + buddycm = new CMDocumentForBuddySystem(dtdcm, entry.isXMLType()); + buddyCache.put(pid, buddycm); + return buddycm; + } + + // private methods + private XMLDocument getOwnerXMLDocument(Node node) { + if (node == null) + return null; + Document owner = (node.getNodeType() == Node.DOCUMENT_NODE) ? (Document) node : node.getOwnerDocument(); + if (owner == null) + return null; + if (!(owner instanceof XMLDocument)) + return null; + return (XMLDocument) owner; + } + + private String getPublicId(XMLDocument doc) { + if (doc == null) + return null; + DocumentType doctype = doc.getDoctype(); + return (doctype != null) ? doctype.getPublicId() : doc.getDocumentTypeId(); + } +}
\ No newline at end of file diff --git a/bundles/org.eclipse.wst.html.core/src/org/eclipse/wst/html/core/modelquery/HTMLModelQueryImpl.java b/bundles/org.eclipse.wst.html.core/src/org/eclipse/wst/html/core/modelquery/HTMLModelQueryImpl.java new file mode 100644 index 0000000000..103bad13ae --- /dev/null +++ b/bundles/org.eclipse.wst.html.core/src/org/eclipse/wst/html/core/modelquery/HTMLModelQueryImpl.java @@ -0,0 +1,148 @@ +/******************************************************************************* + * Copyright (c) 2004 IBM Corporation and others. + * All rights reserved. This program and the accompanying materials + * are made available under the terms of the Eclipse Public License v1.0 + * which accompanies this distribution, and is available at + * http://www.eclipse.org/legal/epl-v10.html + * + * Contributors: + * IBM Corporation - initial API and implementation + *******************************************************************************/ +package org.eclipse.wst.html.core.modelquery; + + +import java.util.List; +import java.util.Vector; + +import org.eclipse.wst.common.contentmodel.CMElementDeclaration; +import org.eclipse.wst.common.contentmodel.CMNamedNodeMap; +import org.eclipse.wst.common.contentmodel.CMNode; +import org.eclipse.wst.common.contentmodel.modelqueryimpl.ModelQueryImpl; +import org.eclipse.wst.common.contentmodel.util.CMDocumentCache; +import org.eclipse.wst.html.core.HTMLCMProperties; +import org.eclipse.wst.sse.core.modelquery.MovableModelQuery; +import org.eclipse.wst.xml.core.document.XMLElement; +import org.eclipse.wst.xml.uriresolver.util.IdResolver; +import org.w3c.dom.Element; +import org.w3c.dom.Node; + + +public class HTMLModelQueryImpl extends ModelQueryImpl implements MovableModelQuery { + + protected CMDocumentCache fCache = null; + + public HTMLModelQueryImpl(CMDocumentCache cache, IdResolver idResolver) { + super(new HTMLModelQueryAssociationProvider(cache, idResolver)); + fCache = cache; + } + + public List getAvailableContent(Element element, CMElementDeclaration ed, int includeOptions) { + List originalCandidates = super.getAvailableContent(element, ed, includeOptions); + if ((includeOptions & INCLUDE_CHILD_NODES) == 0) + return originalCandidates; + // When the target document is XHTML, it is waste to find inclusions, + // since inclusion is available in HTML only. + if (!ed.supports(HTMLCMProperties.IS_XHTML)) + return originalCandidates; + + Boolean isXhtml = Boolean.FALSE; + isXhtml = (Boolean) ed.getProperty(HTMLCMProperties.IS_XHTML); + if (isXhtml != null && isXhtml.booleanValue()) + return originalCandidates; + + // OK, the target is surely a HTML element, so it may have inclusion. + // Try to find it. + Vector candidates = new Vector(originalCandidates); + + switch (ed.getContentType()) { + case CMElementDeclaration.ANY : + case CMElementDeclaration.ELEMENT : + case CMElementDeclaration.MIXED : + // do enumerate inclusions. + candidates.addAll(HMQUtil.getInclusions(element)); + break; + case CMElementDeclaration.EMPTY : + case CMElementDeclaration.PCDATA : + case CMElementDeclaration.CDATA : + default : + // should not add any inclusions. + // so, nothing to do here. + break; + } + // If the current element does not available, it is impossible + // to filter out exclusion. + if (element == null) + return candidates; + + // Now, the time to check exclusion. + Vector content = new Vector(candidates.size()); + for (int i = 0; i < candidates.size(); i++) { + CMElementDeclaration candidate = (CMElementDeclaration) candidates.elementAt(i); + if (candidate == null) + continue; + if (isExcluded(candidate, element)) + continue; + content.add(candidate); + } + + return content; + } + + /** + * @see MovableModelQuery#setIdResolver(IdResolver) + */ + public void setIdResolver(IdResolver newIdResolver) { + modelQueryAssociationProvider = new HTMLModelQueryAssociationProvider(fCache, newIdResolver); + } + + // utilities + private static boolean isExcluded(CMElementDeclaration candidate, Element target) { + CMNamedNodeMap prohibited = getProhibitedAncestors(candidate); + if (prohibited == null) + return false; + Element parent = target; + while (parent != null) { + CMNode pdec = prohibited.getNamedItem(parent.getNodeName()); + if (pdec != null) + return true; + parent = getExplicitParentElement(parent); + } + return false; + } + + private static CMNamedNodeMap getProhibitedAncestors(CMElementDeclaration dec) { + if (!dec.supports(HTMLCMProperties.PROHIBITED_ANCESTORS)) + return null; + return (CMNamedNodeMap) dec.getProperty(HTMLCMProperties.PROHIBITED_ANCESTORS); + } + + /* get an ancestor element ignoring implicit ones. */ + private static Element getExplicitParentElement(Node child) { + if (child == null) + return null; + + Node p = child.getParentNode(); + while (p != null) { + if (p.getNodeType() == Node.ELEMENT_NODE) { + if (p instanceof XMLElement) { + if (((XMLElement) p).isImplicitTag()) { + p = p.getParentNode(); + continue; + } + } + return (Element) p; + } + p = p.getParentNode(); + } + return null; + } + + /* check the target is implicit elemnt or not */ + private static boolean isImplicitElement(Node node) { + if (node.getNodeType() != Node.ELEMENT_NODE) + return false; + if (!(node instanceof XMLElement)) + return false; + return ((XMLElement) node).isImplicitTag(); + } +}
\ No newline at end of file diff --git a/bundles/org.eclipse.wst.html.core/src/org/eclipse/wst/html/core/modelquery/ModelQueryAdapterFactoryForEmbeddedHTML.java b/bundles/org.eclipse.wst.html.core/src/org/eclipse/wst/html/core/modelquery/ModelQueryAdapterFactoryForEmbeddedHTML.java new file mode 100644 index 0000000000..07ca873cc1 --- /dev/null +++ b/bundles/org.eclipse.wst.html.core/src/org/eclipse/wst/html/core/modelquery/ModelQueryAdapterFactoryForEmbeddedHTML.java @@ -0,0 +1,52 @@ +/******************************************************************************* + * Copyright (c) 2004 IBM Corporation and others. + * All rights reserved. This program and the accompanying materials + * are made available under the terms of the Eclipse Public License v1.0 + * which accompanies this distribution, and is available at + * http://www.eclipse.org/legal/epl-v10.html + * + * Contributors: + * IBM Corporation - initial API and implementation + *******************************************************************************/ +package org.eclipse.wst.html.core.modelquery; + + + +import org.eclipse.wst.sse.core.AdapterFactory; +import org.eclipse.wst.sse.core.INodeAdapter; +import org.eclipse.wst.sse.core.INodeNotifier; +import org.eclipse.wst.sse.core.modelquery.ModelQueryAdapter; + +public class ModelQueryAdapterFactoryForEmbeddedHTML extends ModelQueryAdapterFactoryForHTML { + + + /** + * Constructor for ModelQueryAdapterFactoryForEmbeddedHTML. + */ + public ModelQueryAdapterFactoryForEmbeddedHTML() { + this(ModelQueryAdapter.class, false); + } + + /** + * Constructor for ModelQueryAdapterFactoryForEmbeddedHTML. + * @param adapterKey + * @param registerAdapters + */ + protected ModelQueryAdapterFactoryForEmbeddedHTML(Object adapterKey, boolean registerAdapters) { + super(adapterKey, registerAdapters); + } + + /** + * @see AdapterFactory#adapt(INodeNotifier) + */ + public INodeAdapter adapt(INodeNotifier object) { + if (object == null) + return null; + return adaptNew(object); + } + + public Object clone() throws CloneNotSupportedException { + + return new ModelQueryAdapterFactoryForEmbeddedHTML(this.adapterKey, this.shouldRegisterAdapter); + } +}
\ No newline at end of file diff --git a/bundles/org.eclipse.wst.html.core/src/org/eclipse/wst/html/core/modelquery/ModelQueryAdapterFactoryForHTML.java b/bundles/org.eclipse.wst.html.core/src/org/eclipse/wst/html/core/modelquery/ModelQueryAdapterFactoryForHTML.java new file mode 100644 index 0000000000..0aed9ca03f --- /dev/null +++ b/bundles/org.eclipse.wst.html.core/src/org/eclipse/wst/html/core/modelquery/ModelQueryAdapterFactoryForHTML.java @@ -0,0 +1,131 @@ +/******************************************************************************* + * Copyright (c) 2004 IBM Corporation and others. + * All rights reserved. This program and the accompanying materials + * are made available under the terms of the Eclipse Public License v1.0 + * which accompanies this distribution, and is available at + * http://www.eclipse.org/legal/epl-v10.html + * + * Contributors: + * IBM Corporation - initial API and implementation + *******************************************************************************/ +package org.eclipse.wst.html.core.modelquery; + + + +import org.eclipse.wst.common.contentmodel.modelquery.ModelQuery; +import org.eclipse.wst.common.contentmodel.util.CMDocumentCache; +import org.eclipse.wst.sse.core.AbstractAdapterFactory; +import org.eclipse.wst.sse.core.AdapterFactory; +import org.eclipse.wst.sse.core.IModelStateListener; +import org.eclipse.wst.sse.core.INodeAdapter; +import org.eclipse.wst.sse.core.INodeNotifier; +import org.eclipse.wst.sse.core.IStructuredModel; +import org.eclipse.wst.sse.core.modelquery.ModelQueryAdapter; +import org.eclipse.wst.sse.core.modelquery.ModelQueryAdapterImpl; +import org.eclipse.wst.sse.core.util.Debug; +import org.eclipse.wst.xml.core.document.XMLNode; +import org.eclipse.wst.xml.core.modelquery.XMLCatalogIdResolver; +import org.eclipse.wst.xml.uriresolver.util.IdResolver; + +/** + * Creates a ModelQueryAdapter for HTML models + */ +public class ModelQueryAdapterFactoryForHTML extends AbstractAdapterFactory implements IModelStateListener { + + protected ModelQueryAdapterImpl modelQueryAdapterImpl; + protected IStructuredModel stateNotifier = null; + + /** + * ModelQueryAdapterFactoryForHTML constructor comment. + */ + public ModelQueryAdapterFactoryForHTML() { + this(ModelQueryAdapter.class, true); + } + + /** + * ModelQueryAdapterFactoryForHTML constructor comment. + * @param adapterKey java.lang.Object + * @param registerAdapters boolean + */ + public ModelQueryAdapterFactoryForHTML(Object adapterKey, boolean registerAdapters) { + super(adapterKey, registerAdapters); + } + + /** + * createAdapter method comment. + */ + protected INodeAdapter createAdapter(INodeNotifier target) { + + if (Debug.displayInfo) + System.out.println("-----------------------ModelQueryAdapterFactoryForHTML.createAdapter" + target); //$NON-NLS-1$ + if (modelQueryAdapterImpl == null) { + if (target instanceof XMLNode) { + XMLNode xmlNode = (XMLNode) target; + IStructuredModel model = stateNotifier = xmlNode.getModel(); + stateNotifier.addModelStateListener(this); + String baseLocation = model.getBaseLocation(); + if (Debug.displayInfo) + System.out.println("----------------ModelQueryAdapterFactoryForHTML... baseLocation : " + baseLocation); //$NON-NLS-1$ + + CMDocumentCache cmDocumentCache = new CMDocumentCache(); + IdResolver idResolver = new XMLCatalogIdResolver(baseLocation, model.getResolver()); + ModelQuery modelQuery = new HTMLModelQueryImpl(cmDocumentCache, idResolver); + modelQuery.setEditMode(ModelQuery.EDIT_MODE_UNCONSTRAINED); + modelQueryAdapterImpl = new ModelQueryAdapterImpl(cmDocumentCache, modelQuery, idResolver); + } + } + return modelQueryAdapterImpl; + } + + protected void updateResolver(IStructuredModel model) { + modelQueryAdapterImpl.setIdResolver(new XMLCatalogIdResolver(model.getBaseLocation(), model.getResolver())); + } + + /** + * @see IModelStateListener#modelAboutToBeChanged(IStructuredModel) + */ + public void modelAboutToBeChanged(IStructuredModel model) { + } + + /** + * @see IModelStateListener#modelChanged(IStructuredModel) + */ + public void modelChanged(IStructuredModel model) { + } + + /** + * @see IModelStateListener#modelDirtyStateChanged(IStructuredModel, boolean) + */ + public void modelDirtyStateChanged(IStructuredModel model, boolean isDirty) { + } + + /** + * @see IModelStateListener#modelResourceDeleted(IStructuredModel) + */ + public void modelResourceDeleted(IStructuredModel model) { + } + + /** + * @see IModelStateListener#modelResourceMoved(IStructuredModel, IStructuredModel) + */ + public void modelResourceMoved(IStructuredModel oldModel, IStructuredModel newModel) { + stateNotifier.removeModelStateListener(this); + stateNotifier = newModel; + updateResolver(stateNotifier); + stateNotifier.addModelStateListener(this); + } + + public void release() { + super.release(); + if (stateNotifier != null) + stateNotifier.removeModelStateListener(this); + stateNotifier = null; + if (modelQueryAdapterImpl != null) + modelQueryAdapterImpl.release(); + } + + public AdapterFactory copy() { + + return new ModelQueryAdapterFactoryForHTML(this.adapterKey, this.shouldRegisterAdapter); + } +}
\ No newline at end of file diff --git a/bundles/org.eclipse.wst.html.core/src/org/eclipse/wst/html/core/modelquery/XHTMLAssociationProvider.java b/bundles/org.eclipse.wst.html.core/src/org/eclipse/wst/html/core/modelquery/XHTMLAssociationProvider.java new file mode 100644 index 0000000000..fe331c4059 --- /dev/null +++ b/bundles/org.eclipse.wst.html.core/src/org/eclipse/wst/html/core/modelquery/XHTMLAssociationProvider.java @@ -0,0 +1,80 @@ +/******************************************************************************* + * Copyright (c) 2004 IBM Corporation and others. + * All rights reserved. This program and the accompanying materials + * are made available under the terms of the Eclipse Public License v1.0 + * which accompanies this distribution, and is available at + * http://www.eclipse.org/legal/epl-v10.html + * + * Contributors: + * IBM Corporation - initial API and implementation + *******************************************************************************/ +package org.eclipse.wst.html.core.modelquery; + + +import org.eclipse.wst.common.contentmodel.CMDocument; +import org.eclipse.wst.common.contentmodel.modelqueryimpl.XMLAssociationProvider; +import org.eclipse.wst.common.contentmodel.util.CMDocumentCache; +import org.eclipse.wst.xml.uriresolver.util.IdResolver; +import org.w3c.dom.Document; + +/** + * A Class to provide an association between XHTML documents and DTDs for + * XHTML. This class is intended to be used only in HTMLModelQueryCMProvider. + */ +/* + * This class closely resemble XMLModelQueryAssociationProvider. + */ +class XHTMLAssociationProvider extends XMLAssociationProvider { + + protected IdResolver idResolver = null; + private String fCachedGrammerURI; + private String fCachedPublicID; + private String fCachedSystemID; + private static final boolean USE_QUICK_CACHE = true; + + public XHTMLAssociationProvider(CMDocumentCache cache, IdResolver idResolver) { + super(cache); + this.idResolver = idResolver; + } + + /** + * + * @param publicId + * @param systemId + * @return + */ + public CMDocument getXHTMLCMDocument(String publicId, String systemId) { + String grammerURI = null; + if (USE_QUICK_CACHE) { + // In parsing a document, we get many identiical requests to this + // method, so instead of looking up (resolving) grammerURI each + // time, + // we'll just return previously cached one. Probably not worth + // have a + // more complex cache than that. + if (fCachedGrammerURI != null && fCachedPublicID.equals(publicId) && fCachedSystemID.equals(systemId)) { + grammerURI = fCachedGrammerURI; + } + else { + grammerURI = idResolver.resolveId(publicId, systemId); + fCachedGrammerURI = grammerURI; + fCachedPublicID = publicId; + fCachedSystemID = systemId; + } + } + else { + grammerURI = idResolver.resolveId(publicId, systemId); + } + + if (grammerURI == null) + return null; + CMDocument cmDocument = documentManager.getCMDocument(publicId, grammerURI); + return cmDocument; + } + + /** + */ + protected String resolveGrammarURI(Document document, String publicId, String systemId) { + return idResolver.resolveId(publicId, systemId); + } +}
\ No newline at end of file diff --git a/bundles/org.eclipse.wst.html.core/src/org/eclipse/wst/html/core/preferences/HTMLContentBuilder.java b/bundles/org.eclipse.wst.html.core/src/org/eclipse/wst/html/core/preferences/HTMLContentBuilder.java new file mode 100644 index 0000000000..9ff0cf743a --- /dev/null +++ b/bundles/org.eclipse.wst.html.core/src/org/eclipse/wst/html/core/preferences/HTMLContentBuilder.java @@ -0,0 +1,75 @@ +/******************************************************************************* + * Copyright (c) 2004 IBM Corporation and others. + * All rights reserved. This program and the accompanying materials + * are made available under the terms of the Eclipse Public License v1.0 + * which accompanies this distribution, and is available at + * http://www.eclipse.org/legal/epl-v10.html + * + * Contributors: + * IBM Corporation - initial API and implementation + *******************************************************************************/ +package org.eclipse.wst.html.core.preferences; + + + +import org.eclipse.core.runtime.Platform; +import org.eclipse.core.runtime.Preferences; +import org.eclipse.wst.common.contentmodel.CMNode; +import org.eclipse.wst.html.core.HTMLCMProperties; +import org.eclipse.wst.html.core.PreferenceNames; +import org.eclipse.wst.sse.core.preferences.CommonModelPreferenceNames; +import org.w3c.dom.Node; + +public class HTMLContentBuilder extends org.eclipse.wst.common.contentmodel.util.DOMContentBuilderImpl { + + private String fTagCase; + private String fAttrCase; + + /** + * DOMContentBuilder constructor comment. + * @param document org.w3c.dom.Document + */ + public HTMLContentBuilder(org.w3c.dom.Document document) { + super(document); + Preferences prefs = Platform.getPlugin("org.eclipse.wst.html.core").getPluginPreferences();//$NON-NLS-1$ + fTagCase = prefs.getString(CommonModelPreferenceNames.TAG_NAME_CASE); + fAttrCase = prefs.getString(CommonModelPreferenceNames.ATTR_NAME_CASE); + // Element caseSettings = HTMLPreferenceManager.getHTMLInstance().getElement(PreferenceNames.PREFERRED_CASE); + // fTagCase = caseSettings.getAttribute(PreferenceNames.TAGNAME); + // fAttrCase = caseSettings.getAttribute(PreferenceNames.ATTRIBUTENAME); + } + + public String computeName(CMNode cmnode, Node parent) { + String name = super.computeName(cmnode, parent); + // don't change the case unless we're certain it is meaningless + // if (cmnode instanceof HTMLCMNode && ((HTMLCMNode) cmnode).shouldIgnoreCase()) { + if (shouldIgnoreCase(cmnode)) { + if (cmnode.getNodeType() == CMNode.ELEMENT_DECLARATION) { + if (fTagCase.length() > 0) { + if (fTagCase.equals(PreferenceNames.LOWER)) + name = name.toLowerCase(); + else if (fTagCase.equals(PreferenceNames.UPPER)) + name = name.toUpperCase(); + // else do nothing + } + } + else if (cmnode.getNodeType() == CMNode.ATTRIBUTE_DECLARATION) { + if (fAttrCase.length() > 0) { + if (fAttrCase.equals(PreferenceNames.LOWER)) + name = name.toLowerCase(); + else if (fAttrCase.equals(PreferenceNames.UPPER)) + name = name.toUpperCase(); + // else do nothing + } + } + } + return name; + + } + + private boolean shouldIgnoreCase(CMNode cmnode) { + if (!cmnode.supports(HTMLCMProperties.SHOULD_IGNORE_CASE)) + return false; + return ((Boolean) cmnode.getProperty(HTMLCMProperties.SHOULD_IGNORE_CASE)).booleanValue(); + } +}
\ No newline at end of file diff --git a/bundles/org.eclipse.wst.html.core/src/org/eclipse/wst/html/core/validate/AbstractErrorInfo.java b/bundles/org.eclipse.wst.html.core/src/org/eclipse/wst/html/core/validate/AbstractErrorInfo.java new file mode 100644 index 0000000000..5e6ee85f30 --- /dev/null +++ b/bundles/org.eclipse.wst.html.core/src/org/eclipse/wst/html/core/validate/AbstractErrorInfo.java @@ -0,0 +1,40 @@ +/******************************************************************************* + * Copyright (c) 2004 IBM Corporation and others. + * All rights reserved. This program and the accompanying materials + * are made available under the terms of the Eclipse Public License v1.0 + * which accompanies this distribution, and is available at + * http://www.eclipse.org/legal/epl-v10.html + * + * Contributors: + * IBM Corporation - initial API and implementation + *******************************************************************************/ +package org.eclipse.wst.html.core.validate; + +abstract class AbstractErrorInfo implements ErrorInfo, ErrorState { + + + private int state = NONE_ERROR; + private Segment seg = null; + + public AbstractErrorInfo(int state, Segment seg) { + super(); + this.state = state; + this.seg = seg; + } + + abstract public String getHint(); + + abstract public short getTargetType(); + + public int getLength() { + return (seg == null) ? 0 : seg.getLength(); + } + + public int getOffset() { + return (seg == null) ? 0 : seg.getOffset(); + } + + public int getState() { + return this.state; + } +}
\ No newline at end of file diff --git a/bundles/org.eclipse.wst.html.core/src/org/eclipse/wst/html/core/validate/CMUtil.java b/bundles/org.eclipse.wst.html.core/src/org/eclipse/wst/html/core/validate/CMUtil.java new file mode 100644 index 0000000000..38f351d2e1 --- /dev/null +++ b/bundles/org.eclipse.wst.html.core/src/org/eclipse/wst/html/core/validate/CMUtil.java @@ -0,0 +1,200 @@ +/******************************************************************************* + * Copyright (c) 2004 IBM Corporation and others. + * All rights reserved. This program and the accompanying materials + * are made available under the terms of the Eclipse Public License v1.0 + * which accompanies this distribution, and is available at + * http://www.eclipse.org/legal/epl-v10.html + * + * Contributors: + * IBM Corporation - initial API and implementation + *******************************************************************************/ +package org.eclipse.wst.html.core.validate; + + +import java.util.Iterator; + +import org.eclipse.wst.common.contentmodel.CMAttributeDeclaration; +import org.eclipse.wst.common.contentmodel.CMContent; +import org.eclipse.wst.common.contentmodel.CMDataType; +import org.eclipse.wst.common.contentmodel.CMElementDeclaration; +import org.eclipse.wst.common.contentmodel.CMGroup; +import org.eclipse.wst.common.contentmodel.CMNode; +import org.eclipse.wst.common.contentmodel.CMNodeList; +import org.eclipse.wst.common.contentmodel.modelquery.ModelQuery; +import org.eclipse.wst.html.core.HTMLCMProperties; +import org.eclipse.wst.html.core.modelquery.HMQUtil; +import org.eclipse.wst.xml.core.document.XMLElement; +import org.eclipse.wst.xml.core.modelquery.ModelQueryUtil; +import org.w3c.dom.Document; +import org.w3c.dom.Element; + +final class CMUtil { + + /** + * Never instantiate! + */ + private CMUtil() { + super(); + } + + /** + * You cannot always retrieve HTMLElementDeclaration via an Element instance. + * Because, it occasionally a JSP custom tag. -- 9/7/2001 + */ + public static CMElementDeclaration getDeclaration(Element target) { + Document doc = target.getOwnerDocument(); + ModelQuery query = ModelQueryUtil.getModelQuery(doc); + return query.getCMElementDeclaration(target); + } + + /** + */ + public static boolean isCaseSensitive(CMElementDeclaration decl) { + if (decl == null || (!decl.supports(HTMLCMProperties.SHOULD_IGNORE_CASE))) + return false; + return !((Boolean) decl.getProperty(HTMLCMProperties.SHOULD_IGNORE_CASE)).booleanValue(); + } + + /** + */ + private static boolean isChild(CMContent content, CMElementDeclaration target) { + switch (content.getNodeType()) { + case CMNode.ELEMENT_DECLARATION : + if (isWholeTagOmissible((CMElementDeclaration) content)) + if (isChild(((CMElementDeclaration) content).getContent(), target)) + return true; + return isSameDeclaration((CMElementDeclaration) content, target); + case CMNode.GROUP : + CMNodeList children = ((CMGroup) content).getChildNodes(); + for (int i = 0; i < children.getLength(); i++) { + CMNode child = children.item(i); + switch (child.getNodeType()) { + case CMNode.ELEMENT_DECLARATION : + if (isWholeTagOmissible((CMElementDeclaration) child)) + if (isChild(((CMElementDeclaration) child).getContent(), target)) + return true; + if (isSameDeclaration((CMElementDeclaration) child, target)) + return true; + continue; // Go next child. + case CMNode.GROUP : + if (isChild((CMContent) child, target)) + return true; + continue; // Go next child. + default : + continue; // Go next child. + } + } + } + return false; + } + + /** + */ + public static boolean isEndTagOmissible(CMElementDeclaration decl) { + if (!(decl.supports(HTMLCMProperties.OMIT_TYPE))) + return false; + String omitType = (String) decl.getProperty(HTMLCMProperties.OMIT_TYPE); + return !omitType.equals(HTMLCMProperties.Values.OMIT_NONE); + } + + /** + */ + public static boolean isWholeTagOmissible(CMElementDeclaration decl) { + if (!(decl.supports(HTMLCMProperties.OMIT_TYPE))) + return false; + String omitType = (String) decl.getProperty(HTMLCMProperties.OMIT_TYPE); + return omitType.equals(HTMLCMProperties.Values.OMIT_BOTH); + } + + /** + */ + public static boolean isJSP(CMElementDeclaration decl) { + if (!decl.supports(HTMLCMProperties.IS_JSP)) + return false; + return ((Boolean) decl.getProperty(HTMLCMProperties.IS_JSP)).booleanValue(); + } + + /** + */ + public static boolean isXHTML(CMElementDeclaration decl) { + if (!decl.supports(HTMLCMProperties.IS_XHTML)) + return false; + return ((Boolean) decl.getProperty(HTMLCMProperties.IS_XHTML)).booleanValue(); + } + + /** + * The method to distinguish HTML and XHTML from other mark up. + * This method returns true if the target is, + * (1) not JSP, + * (2) not SSI. + */ + public static boolean isHTML(CMElementDeclaration decl) { + return (!isJSP(decl)) && (!isSSI(decl)); + } + + /** + */ + private static boolean isSameDeclaration(CMElementDeclaration aDec, CMElementDeclaration otherDec) { + return aDec.getElementName() == otherDec.getElementName(); + } + + /** + */ + public static boolean isSSI(CMElementDeclaration edec) { + if (edec == null) + return false; + if (!edec.supports(HTMLCMProperties.IS_SSI)) + return false; + return ((Boolean) edec.getProperty(HTMLCMProperties.IS_SSI)).booleanValue(); + } + + /** + * Call this method only when the parent content type is one of + * the following: ANY, ELEMENT, or MIXED. + */ + public static boolean isValidChild(CMElementDeclaration parent, CMElementDeclaration child) { + if (parent == null || child == null) + return false; + if (isHTML(parent) && (!isHTML(child))) + return true; + CMContent content = parent.getContent(); + if (content == null) + return false; + return isChild(content, child); + } + + public static boolean isForeign(Element target) { + if (!(target instanceof XMLElement)) + return true; + XMLElement element = (XMLElement) target; + return !element.isGlobalTag(); + } + + /** + * This method returns true if all of the following conditions are met: + * (1) value type is ENUM, + * (2) only one value is defined in the enumeration, + * (3) the value has same name to the attribute name. + */ + public static boolean isBooleanAttr(CMAttributeDeclaration adec) { + CMDataType attrtype = adec.getAttrType(); + if (attrtype == null) + return false; + if (attrtype.getDataTypeName() != CMDataType.ENUM) + return false; + String[] values = attrtype.getEnumeratedValues(); + if (values.length != 1) + return false; + return values[0].equals(adec.getAttrName()); + } + + public static boolean isValidInclusion(CMElementDeclaration decl, Element parent) { + Iterator iter = HMQUtil.getInclusions(parent).iterator(); + while (iter.hasNext()) { + CMElementDeclaration inclusion = (CMElementDeclaration) iter.next(); + if (isSameDeclaration(decl, inclusion)) + return true; + } + return false; + } +}
\ No newline at end of file diff --git a/bundles/org.eclipse.wst.html.core/src/org/eclipse/wst/html/core/validate/CompositeValidator.java b/bundles/org.eclipse.wst.html.core/src/org/eclipse/wst/html/core/validate/CompositeValidator.java new file mode 100644 index 0000000000..1c5a6017e5 --- /dev/null +++ b/bundles/org.eclipse.wst.html.core/src/org/eclipse/wst/html/core/validate/CompositeValidator.java @@ -0,0 +1,74 @@ +/******************************************************************************* + * Copyright (c) 2004 IBM Corporation and others. + * All rights reserved. This program and the accompanying materials + * are made available under the terms of the Eclipse Public License v1.0 + * which accompanies this distribution, and is available at + * http://www.eclipse.org/legal/epl-v10.html + * + * Contributors: + * IBM Corporation - initial API and implementation + *******************************************************************************/ +package org.eclipse.wst.html.core.validate; + +import java.util.Iterator; +import java.util.Vector; + +import org.eclipse.wst.sse.core.IndexedRegion; +import org.eclipse.wst.sse.core.validate.ValidationAdapter; +import org.eclipse.wst.sse.core.validate.ValidationReporter; +import org.eclipse.wst.xml.core.internal.validate.ValidationComponent; + +abstract class CompositeValidator extends ValidationComponent { + + protected Vector components = new Vector(); + + /** + * CompositeValidator constructor comment. + */ + public CompositeValidator() { + super(); + } + + /** + */ + public void setReporter(ValidationReporter reporter) { + super.setReporter(reporter); + + Iterator i = components.iterator(); + while (i.hasNext()) { + ValidationAdapter component = (ValidationAdapter) i.next(); + if (component == null) + continue; + component.setReporter(reporter); + } + } + + /** + */ + public void validate(IndexedRegion node) { + Iterator i = components.iterator(); + while (i.hasNext()) { + ValidationComponent component = (ValidationComponent) i.next(); + if (component == null) + continue; + component.validate(node); + } + } + + /** + */ + void add(ValidationComponent validator) { + components.add(validator); + } + + /** + * This method registers all components in 'validators'. + * Each derivative must call this methid in its constructor. + */ + protected void register(ValidationComponent[] validators) { + for (int i = 0; i < validators.length; i++) { + if (validators[i] != null) + add(validators[i]); + } + } +}
\ No newline at end of file diff --git a/bundles/org.eclipse.wst.html.core/src/org/eclipse/wst/html/core/validate/DocumentPropagatingValidator.java b/bundles/org.eclipse.wst.html.core/src/org/eclipse/wst/html/core/validate/DocumentPropagatingValidator.java new file mode 100644 index 0000000000..51edfcda31 --- /dev/null +++ b/bundles/org.eclipse.wst.html.core/src/org/eclipse/wst/html/core/validate/DocumentPropagatingValidator.java @@ -0,0 +1,58 @@ +/******************************************************************************* + * Copyright (c) 2004 IBM Corporation and others. + * All rights reserved. This program and the accompanying materials + * are made available under the terms of the Eclipse Public License v1.0 + * which accompanies this distribution, and is available at + * http://www.eclipse.org/legal/epl-v10.html + * + * Contributors: + * IBM Corporation - initial API and implementation + *******************************************************************************/ +package org.eclipse.wst.html.core.validate; + + +import org.eclipse.wst.sse.core.IndexedRegion; +import org.eclipse.wst.sse.core.validate.ValidationAdapter; +import org.eclipse.wst.sse.core.validate.ValidationReporter; +import org.eclipse.wst.xml.core.internal.validate.AbstractPropagatingValidator; +import org.eclipse.wst.xml.core.internal.validate.ValidationComponent; + +class DocumentPropagatingValidator extends AbstractPropagatingValidator { + + + private ValidationComponent validator = new HTMLSimpleDocumentValidator(); + private ElementPropagatingValidator propagatee = new ElementPropagatingValidator(); + + public DocumentPropagatingValidator() { + super(); + } + + public void validate(IndexedRegion node) { + getPropagatee().setReporter(this.reporter); + super.validate(node); + } + + public boolean isAdapterForType(Object type) { + return (type == DocumentPropagatingValidator.class || super.isAdapterForType(type)); + } + + public void setReporter(ValidationReporter reporter) { + super.setReporter(reporter); + validator.setReporter(reporter); + propagatee.setReporter(reporter); + } + + /** + * @see com.ibm.sed.validate.html.AbstractPropagatingValidator#getPropagatee() + */ + protected final ValidationComponent getPropagatee() { + return propagatee; + } + + /** + * @see com.ibm.sed.validate.html.AbstractPropagatingValidator#getValidator() + */ + protected final ValidationAdapter getValidator() { + return validator; + } +}
\ No newline at end of file diff --git a/bundles/org.eclipse.wst.html.core/src/org/eclipse/wst/html/core/validate/ElementPropagatingValidator.java b/bundles/org.eclipse.wst.html.core/src/org/eclipse/wst/html/core/validate/ElementPropagatingValidator.java new file mode 100644 index 0000000000..bd10b279a2 --- /dev/null +++ b/bundles/org.eclipse.wst.html.core/src/org/eclipse/wst/html/core/validate/ElementPropagatingValidator.java @@ -0,0 +1,50 @@ +/******************************************************************************* + * Copyright (c) 2004 IBM Corporation and others. + * All rights reserved. This program and the accompanying materials + * are made available under the terms of the Eclipse Public License v1.0 + * which accompanies this distribution, and is available at + * http://www.eclipse.org/legal/epl-v10.html + * + * Contributors: + * IBM Corporation - initial API and implementation + *******************************************************************************/ +package org.eclipse.wst.html.core.validate; + + +import org.eclipse.wst.sse.core.validate.ValidationAdapter; +import org.eclipse.wst.sse.core.validate.ValidationReporter; +import org.eclipse.wst.xml.core.internal.validate.AbstractPropagatingValidator; +import org.eclipse.wst.xml.core.internal.validate.ValidationComponent; + +class ElementPropagatingValidator extends AbstractPropagatingValidator { + + + private ValidationComponent validator = new HTMLSimpleValidator(); + + public ElementPropagatingValidator() { + super(); + } + + public boolean isAdapterForType(Object type) { + return (type == ElementPropagatingValidator.class || super.isAdapterForType(type)); + } + + public void setReporter(ValidationReporter reporter) { + super.setReporter(reporter); + validator.setReporter(reporter); + } + + /** + * @see com.ibm.sed.validate.html.AbstractPropagatingValidator#getPropagatee() + */ + protected ValidationComponent getPropagatee() { + return this; + } + + /** + * @see com.ibm.sed.validate.html.AbstractPropagatingValidator#getValidator() + */ + protected ValidationAdapter getValidator() { + return validator; + } +}
\ No newline at end of file diff --git a/bundles/org.eclipse.wst.html.core/src/org/eclipse/wst/html/core/validate/ErrorInfo.java b/bundles/org.eclipse.wst.html.core/src/org/eclipse/wst/html/core/validate/ErrorInfo.java new file mode 100644 index 0000000000..01ce2c0799 --- /dev/null +++ b/bundles/org.eclipse.wst.html.core/src/org/eclipse/wst/html/core/validate/ErrorInfo.java @@ -0,0 +1,26 @@ +/******************************************************************************* + * Copyright (c) 2004 IBM Corporation and others. + * All rights reserved. This program and the accompanying materials + * are made available under the terms of the Eclipse Public License v1.0 + * which accompanies this distribution, and is available at + * http://www.eclipse.org/legal/epl-v10.html + * + * Contributors: + * IBM Corporation - initial API and implementation + *******************************************************************************/ +package org.eclipse.wst.html.core.validate; + + + +interface ErrorInfo { + + public String getHint(); + + public int getLength(); + + public int getOffset(); + + public int getState(); + + public short getTargetType(); +}
\ No newline at end of file diff --git a/bundles/org.eclipse.wst.html.core/src/org/eclipse/wst/html/core/validate/ErrorInfoImpl.java b/bundles/org.eclipse.wst.html.core/src/org/eclipse/wst/html/core/validate/ErrorInfoImpl.java new file mode 100644 index 0000000000..f10294e99f --- /dev/null +++ b/bundles/org.eclipse.wst.html.core/src/org/eclipse/wst/html/core/validate/ErrorInfoImpl.java @@ -0,0 +1,56 @@ +/******************************************************************************* + * Copyright (c) 2004 IBM Corporation and others. + * All rights reserved. This program and the accompanying materials + * are made available under the terms of the Eclipse Public License v1.0 + * which accompanies this distribution, and is available at + * http://www.eclipse.org/legal/epl-v10.html + * + * Contributors: + * IBM Corporation - initial API and implementation + *******************************************************************************/ +package org.eclipse.wst.html.core.validate; + + + +import org.w3c.dom.Attr; +import org.w3c.dom.Node; +import org.w3c.dom.Text; + +final class ErrorInfoImpl extends AbstractErrorInfo { + + private Node target = null; + + // private Segment seg = null; + /** + */ + public ErrorInfoImpl(int state, Segment errorSeg, Node target) { + super(state, errorSeg); + this.target = target; + } + + /** + */ + public String getHint() { + switch (target.getNodeType()) { + case Node.ATTRIBUTE_NODE : + switch (getState()) { + case UNDEFINED_VALUE_ERROR : + case MISMATCHED_VALUE_ERROR : + case UNCLOSED_ATTR_VALUE : + //D210422 + return ((Attr) target).getValue(); + default : + return target.getNodeName(); + } + case Node.TEXT_NODE : + return ((Text) target).getData(); + case Node.ELEMENT_NODE : + default : + return target.getNodeName(); + } + } + + public short getTargetType() { + return target.getNodeType(); + } +}
\ No newline at end of file diff --git a/bundles/org.eclipse.wst.html.core/src/org/eclipse/wst/html/core/validate/ErrorState.java b/bundles/org.eclipse.wst.html.core/src/org/eclipse/wst/html/core/validate/ErrorState.java new file mode 100644 index 0000000000..2c0eb26eba --- /dev/null +++ b/bundles/org.eclipse.wst.html.core/src/org/eclipse/wst/html/core/validate/ErrorState.java @@ -0,0 +1,41 @@ +/******************************************************************************* + * Copyright (c) 2004 IBM Corporation and others. + * All rights reserved. This program and the accompanying materials + * are made available under the terms of the Eclipse Public License v1.0 + * which accompanies this distribution, and is available at + * http://www.eclipse.org/legal/epl-v10.html + * + * Contributors: + * IBM Corporation - initial API and implementation + *******************************************************************************/ +package org.eclipse.wst.html.core.validate; + + + +interface ErrorState { + static final int NONE_ERROR = 0; + // generic error + static final int UNDEFINED_NAME_ERROR = 11; + static final int UNDEFINED_VALUE_ERROR = 12; + static final int MISMATCHED_VALUE_ERROR = 13; + // format error + static final int FORMAT_ERROR_LEVEL = 100; + static final int INVALID_NAME_ERROR = 101; + static final int INVALID_CHAR_ERROR = 102; + static final int MISMATCHED_ERROR = 103; + static final int MISMATCHED_END_TAG_ERROR = 104; + static final int MISSING_START_TAG_ERROR = 105; + static final int MISSING_END_TAG_ERROR = 106; + static final int UNNECESSARY_END_TAG_ERROR = 107; + static final int INVALID_ATTR_ERROR = 108; + static final int INVALID_DIRECTIVE_ERROR = 109; + static final int UNCLOSED_TAG_ERROR = 110; + static final int UNCLOSED_END_TAG_ERROR = 111; + static final int INVALID_EMPTY_ELEMENT_TAG = 112; + static final int UNCLOSED_ATTR_VALUE = 113; //D210422 + // layout error + static final int LAYOUT_ERROR_LEVEL = 1000; + static final int INVALID_CONTENT_ERROR = 1001; + static final int DUPLICATE_ERROR = 1002; + static final int COEXISTENCE_ERROR = 1003; +}
\ No newline at end of file diff --git a/bundles/org.eclipse.wst.html.core/src/org/eclipse/wst/html/core/validate/FMUtil.java b/bundles/org.eclipse.wst.html.core/src/org/eclipse/wst/html/core/validate/FMUtil.java new file mode 100644 index 0000000000..da4f240415 --- /dev/null +++ b/bundles/org.eclipse.wst.html.core/src/org/eclipse/wst/html/core/validate/FMUtil.java @@ -0,0 +1,103 @@ +/******************************************************************************* + * Copyright (c) 2004 IBM Corporation and others. + * All rights reserved. This program and the accompanying materials + * are made available under the terms of the Eclipse Public License v1.0 + * which accompanies this distribution, and is available at + * http://www.eclipse.org/legal/epl-v10.html + * + * Contributors: + * IBM Corporation - initial API and implementation + *******************************************************************************/ +package org.eclipse.wst.html.core.validate; + + + +import java.util.Iterator; + +import org.eclipse.wst.sse.core.text.IStructuredDocumentRegion; +import org.eclipse.wst.sse.core.text.ITextRegion; +import org.eclipse.wst.sse.core.text.ITextRegionContainer; +import org.eclipse.wst.sse.core.text.ITextRegionList; +import org.eclipse.wst.xml.core.document.XMLNode; +import org.eclipse.wst.xml.core.jsp.model.parser.temp.XMLJSPRegionContexts; +import org.eclipse.wst.xml.core.parser.XMLRegionContext; + +final class FMUtil { + + public final static int SEG_NONE = 0; + public final static int SEG_WHOLE_TAG = 1; + public final static int SEG_START_TAG = 2; + public final static int SEG_END_TAG = 3; + + /** + */ + private FMUtil() { + super(); + } + + /** + */ + public final static Segment getSegment(XMLNode target, int segType) { + if (target == null) + return new Segment(0, 0); + Segment seg = null; + IStructuredDocumentRegion startTag = null; + IStructuredDocumentRegion endTag = null; + switch (segType) { + case SEG_WHOLE_TAG : + startTag = target.getFirstStructuredDocumentRegion(); + if (startTag != null) { + endTag = target.getLastStructuredDocumentRegion(); + seg = new Segment(startTag, endTag); + } + else { + int startOffset = target.getStartOffset(); + int endOffset = target.getEndOffset(); + seg = new Segment(startOffset, endOffset - startOffset); + } + break; + case SEG_START_TAG : + startTag = target.getStartStructuredDocumentRegion(); + if (startTag != null) { + seg = new Segment(startTag); + } + else { + seg = new Segment(target.getStartOffset(), 0); + } + break; + case SEG_END_TAG : + endTag = target.getEndStructuredDocumentRegion(); + if (endTag != null) { + seg = new Segment(endTag); + } + else { + seg = new Segment(target.getEndOffset(), 0); + } + break; + case SEG_NONE : + default : + return new Segment(0, 0); + } + return seg; + } + + /** + */ + public final static boolean hasJSPRegion(ITextRegion container) { + if (!(container instanceof ITextRegionContainer)) + return false; + ITextRegionList regions = ((ITextRegionContainer) container).getRegions(); + if (regions == null) + return false; + Iterator e = regions.iterator(); + while (e.hasNext()) { + ITextRegion region = (ITextRegion) e.next(); + if (region == null) + continue; + String regionType = region.getType(); + if (regionType == XMLRegionContext.XML_TAG_OPEN || regionType == XMLJSPRegionContexts.JSP_SCRIPTLET_OPEN || regionType == XMLJSPRegionContexts.JSP_EXPRESSION_OPEN || regionType == XMLJSPRegionContexts.JSP_DECLARATION_OPEN || regionType == XMLJSPRegionContexts.JSP_DIRECTIVE_OPEN) + return true; + } + return false; + } +}
\ No newline at end of file diff --git a/bundles/org.eclipse.wst.html.core/src/org/eclipse/wst/html/core/validate/HTMLAttributeValidator.java b/bundles/org.eclipse.wst.html.core/src/org/eclipse/wst/html/core/validate/HTMLAttributeValidator.java new file mode 100644 index 0000000000..a57a30720d --- /dev/null +++ b/bundles/org.eclipse.wst.html.core/src/org/eclipse/wst/html/core/validate/HTMLAttributeValidator.java @@ -0,0 +1,207 @@ +/******************************************************************************* + * Copyright (c) 2004 IBM Corporation and others. + * All rights reserved. This program and the accompanying materials + * are made available under the terms of the Eclipse Public License v1.0 + * which accompanies this distribution, and is available at + * http://www.eclipse.org/legal/epl-v10.html + * + * Contributors: + * IBM Corporation - initial API and implementation + *******************************************************************************/ +package org.eclipse.wst.html.core.validate; + + + +import org.eclipse.wst.common.contentmodel.CMAttributeDeclaration; +import org.eclipse.wst.common.contentmodel.CMDataType; +import org.eclipse.wst.common.contentmodel.CMElementDeclaration; +import org.eclipse.wst.common.contentmodel.CMNamedNodeMap; +import org.eclipse.wst.sse.core.IndexedRegion; +import org.eclipse.wst.sse.core.text.ITextRegion; +import org.eclipse.wst.xml.core.document.XMLAttr; +import org.eclipse.wst.xml.core.document.XMLElement; +import org.eclipse.wst.xml.core.document.XMLNode; +import org.w3c.dom.Attr; +import org.w3c.dom.Element; +import org.w3c.dom.NamedNodeMap; + +public class HTMLAttributeValidator extends PrimeValidator { + + private static final int REGION_NAME = 1; + private static final int REGION_VALUE = 2; + //<<D210422 + private static final char SINGLE_QUOTE = '\''; + private static final char DOUBLE_QUOTE = '\"'; + + //D210422 + /** + * HTMLAttributeValidator constructor comment. + */ + public HTMLAttributeValidator() { + super(); + } + + /** + */ + private Segment getErrorSegment(XMLNode errorNode, int regionType) { + ITextRegion rgn = null; + switch (regionType) { + case REGION_NAME : + rgn = errorNode.getNameRegion(); + break; + case REGION_VALUE : + rgn = errorNode.getValueRegion(); + break; + default : + // nothing to do. + break; + } + if (rgn != null) { + if (errorNode instanceof XMLAttr) { + XMLElement ownerElement = (XMLElement) ((XMLAttr) errorNode).getOwnerElement(); + if (ownerElement != null) { + int regionStartOffset = ownerElement.getFirstStructuredDocumentRegion().getStartOffset(rgn); + int regionLength = rgn.getLength(); + return new Segment(regionStartOffset, regionLength); + } + } + } + return new Segment(errorNode.getStartOffset(), 0); + } + + /** + * Allowing the INodeAdapter to compare itself against the type + * allows it to return true in more than one case. + */ + public boolean isAdapterForType(Object type) { + return ((type == HTMLAttributeValidator.class) || super.isAdapterForType(type)); + } + + /** + */ + public void validate(IndexedRegion node) { + Element target = (Element) node; + if (CMUtil.isForeign(target)) + return; + CMElementDeclaration edec = CMUtil.getDeclaration(target); + if (edec == null) + return; + CMNamedNodeMap declarations = edec.getAttributes(); + + NamedNodeMap attrs = target.getAttributes(); + for (int i = 0; i < attrs.getLength(); i++) { + int rgnType = REGION_NAME; + int state = ErrorState.NONE_ERROR; + Attr a = (Attr) attrs.item(i); + // D203637; If the target attr has prefix, the validator should not + // warn about it. That is, just ignore. It is able to check whether + // an attr has prefix or not by calling XMLAttr#isGlobalAttr(). + // When a attr has prefix (not global), it returns false. + boolean isXMLAttr = a instanceof XMLAttr; + if (isXMLAttr) { + XMLAttr xmlattr = (XMLAttr) a; + if (!xmlattr.isGlobalAttr()) + continue; // skip futher validation and begin next loop. + } + + CMAttributeDeclaration adec = (CMAttributeDeclaration) declarations.getNamedItem(a.getName()); + if (adec == null) { + // No attr declaration was found. That is, the attr name is undefined. + // but not regard it as undefined name if it includes JSP + if (!FMUtil.hasJSPRegion(((XMLNode) a).getNameRegion())) { + rgnType = REGION_NAME; + state = ErrorState.UNDEFINED_NAME_ERROR; + } + } + else { + // The attr declaration was found. + // At 1st, the name should be checked. + if (CMUtil.isHTML(edec) && (!CMUtil.isXHTML(edec))) { + // If the target element is pure HTML (not XHTML), some attributes + // might be written in boolean format. It should be check specifically. + if (CMUtil.isBooleanAttr(adec) && ((XMLAttr) a).hasNameOnly()) + continue; // OK, keep going. No more check is needed against this attr. + } + else { + // If the target is other than pure HTML (JSP or XHTML), the name + // must be checked exactly (ie in case sensitive way). + String actual = a.getName(); + String desired = adec.getAttrName(); + if (!actual.equals(desired)) { // case mismatch + rgnType = REGION_NAME; + state = ErrorState.MISMATCHED_ERROR; + } + } + // Then, the value must be checked. + if (state == ErrorState.NONE_ERROR) { // Need more check. + // Now, the value should be checked, if the type is ENUM. + CMDataType attrType = adec.getAttrType(); + String actualValue = a.getValue(); + if (attrType.getImpliedValueKind() == CMDataType.IMPLIED_VALUE_FIXED) { + // Check FIXED value. + String validValue = attrType.getImpliedValue(); + if (!actualValue.equals(validValue)) { + rgnType = REGION_VALUE; + state = ErrorState.UNDEFINED_VALUE_ERROR; + } + } + else { + String[] candidates = attrType.getEnumeratedValues(); + if (candidates != null && candidates.length > 0) { + // several candidates are found. + boolean found = false; + for (int index = 0; index < candidates.length; index++) { + String candidate = candidates[index]; + // At 1st, compare ignoring case. + if (actualValue.equalsIgnoreCase(candidate)) { + found = true; + if (CMUtil.isCaseSensitive(edec) && (!actualValue.equals(candidate))) { + rgnType = REGION_VALUE; + state = ErrorState.MISMATCHED_VALUE_ERROR; + } + break; // exit the loop. + } + } + if (!found) { + // No candidate was found. That is, actualValue is invalid. + // but not regard it as undefined value if it includes JSP. + if (!FMUtil.hasJSPRegion(((XMLNode) a).getValueRegion())) { + rgnType = REGION_VALUE; + state = ErrorState.UNDEFINED_VALUE_ERROR; + } + } + } + } + } + //<<D210422 + if (state == ErrorState.NONE_ERROR) { // Need more check. + if (isXMLAttr) { + String source = ((XMLAttr) a).getValueRegionText(); + if (source != null) { + char firstChar = source.charAt(0); + char lastChar = source.charAt(source.length() - 1); + if (isQuote(firstChar) || isQuote(lastChar)) { + if (lastChar != firstChar) { + rgnType = REGION_VALUE; + state = ErrorState.UNCLOSED_ATTR_VALUE; + } + } + } + } + } + //D210422 + } + if (state != ErrorState.NONE_ERROR) { + Segment seg = getErrorSegment((XMLNode) a, rgnType); + if (seg != null) + reporter.report(MessageFactory.createMessage(new ErrorInfoImpl(state, seg, a))); + } + } + } + + //<<D214022 + private boolean isQuote(char c) { + return (c == SINGLE_QUOTE) || (c == DOUBLE_QUOTE); + } + //D210422 +}
\ No newline at end of file diff --git a/bundles/org.eclipse.wst.html.core/src/org/eclipse/wst/html/core/validate/HTMLDocumentContentValidator.java b/bundles/org.eclipse.wst.html.core/src/org/eclipse/wst/html/core/validate/HTMLDocumentContentValidator.java new file mode 100644 index 0000000000..14e298aed7 --- /dev/null +++ b/bundles/org.eclipse.wst.html.core/src/org/eclipse/wst/html/core/validate/HTMLDocumentContentValidator.java @@ -0,0 +1,194 @@ +/******************************************************************************* + * Copyright (c) 2004 IBM Corporation and others. + * All rights reserved. This program and the accompanying materials + * are made available under the terms of the Eclipse Public License v1.0 + * which accompanies this distribution, and is available at + * http://www.eclipse.org/legal/epl-v10.html + * + * Contributors: + * IBM Corporation - initial API and implementation + *******************************************************************************/ +package org.eclipse.wst.html.core.validate; + + +import java.util.Iterator; +import java.util.List; +import java.util.Vector; + +import org.eclipse.wst.common.contentmodel.CMElementDeclaration; +import org.eclipse.wst.html.core.HTML40Namespace; +import org.eclipse.wst.sse.core.IndexedRegion; +import org.eclipse.wst.xml.core.document.DocumentTypeAdapter; +import org.eclipse.wst.xml.core.document.XMLDocument; +import org.eclipse.wst.xml.core.document.XMLNode; +import org.eclipse.wst.xml.core.document.XMLText; +import org.w3c.dom.Document; +import org.w3c.dom.DocumentType; +import org.w3c.dom.Element; +import org.w3c.dom.Node; +import org.w3c.dom.NodeList; + +public class HTMLDocumentContentValidator extends PrimeValidator { + + + private final static class Division { + private Vector explicitHtmls = new Vector(); + private Vector rest = new Vector(); + + public Division(Document document, NodeList children) { + String rootTagName = getRootTagName(document); + for (int i = 0; i < children.getLength(); i++) { + Node child = children.item(i); + if (isHtmlTag(child, rootTagName)) { + explicitHtmls.add(child); + } + else { + rest.add(child); + } + } + } + + public boolean hasExplicitHtmls() { + return explicitHtmls.size() > 0; + } + + public List getExplicitHtmls() { + return explicitHtmls; + } + + public Iterator getRestNodes() { + return rest.iterator(); + } + + /* utilities */ + private static boolean isHtmlTag(Node node, String tagName) { + if (node.getNodeType() != Node.ELEMENT_NODE) + return false; + return ((Element) node).getTagName().equalsIgnoreCase(tagName); + } + + private static String getRootTagName(Document document) { + DocumentTypeAdapter adapter = (DocumentTypeAdapter) ((XMLDocument) document).getAdapterFor(DocumentTypeAdapter.class); + if (adapter != null) { + DocumentType docType = adapter.getDocumentType(); + if (docType != null) { + return docType.getName(); + } + } + + return HTML40Namespace.ElementName.HTML; + } + } + + /** + * HTMLDocumentContentValidator constructor comment. + */ + public HTMLDocumentContentValidator() { + super(); + } + + /** + * Allowing the INodeAdapter to compare itself against the type + * allows it to return true in more than one case. + */ + public boolean isAdapterForType(Object type) { + return ((type == HTMLDocumentContentValidator.class) || super.isAdapterForType(type)); + } + + /** + */ + public void validate(IndexedRegion node) { + // isFragment check should be more intelligent. + boolean isFragment = true; + + Document target = (Document) node; + NodeList children = target.getChildNodes(); + if (children == null) + return; + + Division division = new Division(target, children); + if (division.hasExplicitHtmls()) { + isFragment = false; + + List explicits = division.getExplicitHtmls(); + if (explicits.size() > 1) { + for (int i = 1; i < explicits.size(); i++) { + Element html = (Element) explicits.get(i); + // report error (duplicate) + Segment errorSeg = FMUtil.getSegment((XMLNode) html, FMUtil.SEG_START_TAG); + if (errorSeg != null) + reporter.report(MessageFactory.createMessage(new ErrorInfoImpl(ErrorState.DUPLICATE_ERROR, errorSeg, html))); + } + } + } + validateContent(division.getRestNodes(), isFragment); + } + + /* + * This methods validate nodes other than HTML elements. + */ + private void validateContent(Iterator children, boolean isFragment) { + boolean foundDoctype = false; + while (children.hasNext()) { + XMLNode child = (XMLNode) children.next(); + + int error = ErrorState.NONE_ERROR; + int segType = FMUtil.SEG_WHOLE_TAG; + + switch (child.getNodeType()) { + case Node.ELEMENT_NODE : + if (! isFragment) { + Element childElem = (Element) child; + CMElementDeclaration ced = CMUtil.getDeclaration(childElem); + // Undefined element is valid. + if (ced == null) + continue; + // JSP (includes custom tags) and SSI are valid. + if (CMUtil.isForeign(childElem) || CMUtil.isSSI(ced)) + continue; // Defect 186774 + + // report error (invalid content) + error = ErrorState.INVALID_CONTENT_ERROR; + // mark the whole start tag as error. + segType = FMUtil.SEG_START_TAG; + } + break; + case Node.TEXT_NODE : + if (! isFragment) { + // TEXT node is valid when it contains white space characters only. + // Otherwise, it is invalid content. + if (((XMLText) child).isWhitespace()) + continue; + error = ErrorState.INVALID_CONTENT_ERROR; + segType = FMUtil.SEG_WHOLE_TAG; + } + break; + case Node.DOCUMENT_TYPE_NODE : + // DOCTYPE is also valid when it appears once and only once. + if (!foundDoctype) { + foundDoctype = true; + continue; + } + error = ErrorState.DUPLICATE_ERROR; + segType = FMUtil.SEG_WHOLE_TAG; + break; + case Node.COMMENT_NODE : + // always valid. + case Node.PROCESSING_INSTRUCTION_NODE : + continue; + default : + if (! isFragment) { + error = ErrorState.INVALID_CONTENT_ERROR; + segType = FMUtil.SEG_WHOLE_TAG; + } + break; + } + if (error != ErrorState.NONE_ERROR) { + Segment errorSeg = FMUtil.getSegment(child, segType); + if (errorSeg != null) + reporter.report(MessageFactory.createMessage(new ErrorInfoImpl(error, errorSeg, child))); + } + } + } + +}
\ No newline at end of file diff --git a/bundles/org.eclipse.wst.html.core/src/org/eclipse/wst/html/core/validate/HTMLElementAncestorValidator.java b/bundles/org.eclipse.wst.html.core/src/org/eclipse/wst/html/core/validate/HTMLElementAncestorValidator.java new file mode 100644 index 0000000000..b4c26b4561 --- /dev/null +++ b/bundles/org.eclipse.wst.html.core/src/org/eclipse/wst/html/core/validate/HTMLElementAncestorValidator.java @@ -0,0 +1,70 @@ +/******************************************************************************* + * Copyright (c) 2004 IBM Corporation and others. + * All rights reserved. This program and the accompanying materials + * are made available under the terms of the Eclipse Public License v1.0 + * which accompanies this distribution, and is available at + * http://www.eclipse.org/legal/epl-v10.html + * + * Contributors: + * IBM Corporation - initial API and implementation + *******************************************************************************/ +package org.eclipse.wst.html.core.validate; + + + +import org.eclipse.wst.common.contentmodel.CMElementDeclaration; +import org.eclipse.wst.common.contentmodel.CMNamedNodeMap; +import org.eclipse.wst.common.contentmodel.CMNode; +import org.eclipse.wst.html.core.HTMLCMProperties; +import org.eclipse.wst.sse.core.IndexedRegion; +import org.eclipse.wst.xml.core.document.XMLNode; +import org.w3c.dom.Element; + +public class HTMLElementAncestorValidator extends PrimeValidator { + + /** + * HTMLElementAncestorValidator constructor comment. + */ + public HTMLElementAncestorValidator() { + super(); + } + + /** + * Allowing the INodeAdapter to compare itself against the type + * allows it to return true in more than one case. + */ + public boolean isAdapterForType(Object type) { + return ((type == HTMLElementAncestorValidator.class) || super.isAdapterForType(type)); + } + + /** + * Check exclusion which is defined in only HTML DTD (SGML). + */ + public void validate(IndexedRegion node) { + Element target = (Element) node; + if (CMUtil.isForeign(target)) + return; + CMElementDeclaration dec = CMUtil.getDeclaration(target); + if (dec == null) + return; // cannot validate. + if (!CMUtil.isHTML(dec)) + return; // no need to validate + if (!dec.supports(HTMLCMProperties.PROHIBITED_ANCESTORS)) + return; // cannot validate. + CMNamedNodeMap prohibited = (CMNamedNodeMap) dec.getProperty(HTMLCMProperties.PROHIBITED_ANCESTORS); + if (prohibited.getLength() <= 0) + return; // no prohibited ancestors. + + Element parent = SMUtil.getParentElement(target); + while (parent != null) { + CMNode pdec = prohibited.getNamedItem(parent.getNodeName()); + if (pdec != null) { // prohibited element is found in ancestors. + Segment errorSeg = FMUtil.getSegment((XMLNode) node, FMUtil.SEG_START_TAG); + if (errorSeg != null) + reporter.report(MessageFactory.createMessage(new ErrorInfoImpl(ErrorState.INVALID_CONTENT_ERROR, errorSeg, target))); + break; // If one prohibited ancestor is found, it's enough. + } + parent = SMUtil.getParentElement(parent); + } + } +}
\ No newline at end of file diff --git a/bundles/org.eclipse.wst.html.core/src/org/eclipse/wst/html/core/validate/HTMLElementContentValidator.java b/bundles/org.eclipse.wst.html.core/src/org/eclipse/wst/html/core/validate/HTMLElementContentValidator.java new file mode 100644 index 0000000000..007c225719 --- /dev/null +++ b/bundles/org.eclipse.wst.html.core/src/org/eclipse/wst/html/core/validate/HTMLElementContentValidator.java @@ -0,0 +1,178 @@ +/******************************************************************************* + * Copyright (c) 2004 IBM Corporation and others. + * All rights reserved. This program and the accompanying materials + * are made available under the terms of the Eclipse Public License v1.0 + * which accompanies this distribution, and is available at + * http://www.eclipse.org/legal/epl-v10.html + * + * Contributors: + * IBM Corporation - initial API and implementation + *******************************************************************************/ +package org.eclipse.wst.html.core.validate; + +import org.eclipse.wst.common.contentmodel.CMElementDeclaration; +import org.eclipse.wst.sse.core.IndexedRegion; +import org.eclipse.wst.xml.core.document.XMLNode; +import org.eclipse.wst.xml.core.document.XMLText; +import org.w3c.dom.Element; +import org.w3c.dom.Node; +import org.w3c.dom.NodeList; + +public class HTMLElementContentValidator extends PrimeValidator { + + /** + * HTMLElementContentValidator constructor comment. + */ + public HTMLElementContentValidator() { + super(); + } + + /** + * Allowing the INodeAdapter to compare itself against the type + * allows it to return true in more than one case. + */ + public boolean isAdapterForType(Object type) { + return ((type == HTMLElementContentValidator.class) || super.isAdapterForType(type)); + } + + /** + */ + public void validate(IndexedRegion node) { + Element target = (Element) node; + if (CMUtil.isForeign(target)) + return; + + validateContent(target, target.getChildNodes()); + } + + private void validateContent(Element parent, NodeList children) { + for (int i = 0; i < children.getLength(); i++) { + Node child = children.item(i); + if (child == null) + continue; + + // perform actual validation + validateNode(parent, child); + } + } + +// private int countExplicitSiblings(Element parent, String tagName) { +// NodeList children = parent.getChildNodes(); +// int count = 0; +// for (int i = 0; i < children.getLength(); i++) { +// Node child = children.item(i); +// if (child.getNodeType() != Node.ELEMENT_NODE) +// continue; +// if (tagName.equalsIgnoreCase(((Element) child).getTagName())) { +// count++; +// } +// } +// return count; +// } + + /* The implementation of the following method is practical but accurate. + * The accurate maximum occurence should be retreive from the content model. + * However, it is useful enough, since almost implicit elements are HTML, + * HEAD, or BODY. + */ +// private int getMaxOccur(Element parent, String childTag) { +// return 1; +// } + + private void validateNode(Element target, Node child) { + // NOTE: If the target element is 'UNKNOWN', that is, it has no + // element declaration, the content type of the element should be + // regarded as 'ANY'. -- 9/10/2001 + int contentType = CMElementDeclaration.ANY; + CMElementDeclaration edec = CMUtil.getDeclaration(target); + if (edec != null) + contentType = edec.getContentType(); + + int error = ErrorState.NONE_ERROR; + int segType = FMUtil.SEG_WHOLE_TAG; + + switch (child.getNodeType()) { + case Node.ELEMENT_NODE : + Element childElem = (Element) child; + // Defect 200321: + // This validator cares only HTML/XHTML elements. If a child is + // an element of foreign markup languages, just ignore it. + if (CMUtil.isForeign(childElem)) + return; + + CMElementDeclaration ced = CMUtil.getDeclaration((Element) child); + // Defect 186774: If a child is not one of HTML elements, + // it should be regarded as a valid child regardless the + // type of the parent content model. -- 10/12/2001 + if (ced == null || CMUtil.isSSI(ced) || (!CMUtil.isHTML(ced))) + return; + + switch (contentType) { + case CMElementDeclaration.ANY : + // Keep going. + return; + case CMElementDeclaration.ELEMENT : + case CMElementDeclaration.MIXED : + if (ced == null) + return; + if (CMUtil.isValidChild(edec, ced)) + return; + // Now, it is the time to check inclusion, unless the target + // document is not a XHTML. + if (!CMUtil.isXHTML(edec)) { + // pure HTML + if (CMUtil.isValidInclusion(ced, target)) + return; + } + error = ErrorState.INVALID_CONTENT_ERROR; + break; + default : + error = ErrorState.INVALID_CONTENT_ERROR; + break; + } + // Mark the whole START tag as an error segment. + segType = FMUtil.SEG_START_TAG; + break; + case Node.TEXT_NODE : + switch (contentType) { + case CMElementDeclaration.ANY : + case CMElementDeclaration.MIXED : + case CMElementDeclaration.PCDATA : + case CMElementDeclaration.CDATA : + // D184339 + // Keep going. + return; + case CMElementDeclaration.ELEMENT : + case CMElementDeclaration.EMPTY : + if (((XMLText) child).isWhitespace()) + return; + error = ErrorState.INVALID_CONTENT_ERROR; + break; + default : + error = ErrorState.INVALID_CONTENT_ERROR; + break; + } + // Mark the whole node as an error segment. + segType = FMUtil.SEG_WHOLE_TAG; + break; + case Node.COMMENT_NODE : + case Node.PROCESSING_INSTRUCTION_NODE : + if (contentType != CMElementDeclaration.EMPTY) + return; + error = ErrorState.INVALID_CONTENT_ERROR; + // Mark the whole node as an error segment. + segType = FMUtil.SEG_WHOLE_TAG; + break; + default : + error = ErrorState.INVALID_CONTENT_ERROR; + // Mark the whole node as an error segment. + segType = FMUtil.SEG_WHOLE_TAG; + break; + } + if (error != ErrorState.NONE_ERROR) { + Segment errorSeg = FMUtil.getSegment((XMLNode) child, segType); + if (errorSeg != null) + reporter.report(MessageFactory.createMessage(new ErrorInfoImpl(error, errorSeg, child))); + } + } +}
\ No newline at end of file diff --git a/bundles/org.eclipse.wst.html.core/src/org/eclipse/wst/html/core/validate/HTMLSimpleDocumentValidator.java b/bundles/org.eclipse.wst.html.core/src/org/eclipse/wst/html/core/validate/HTMLSimpleDocumentValidator.java new file mode 100644 index 0000000000..d3630a3626 --- /dev/null +++ b/bundles/org.eclipse.wst.html.core/src/org/eclipse/wst/html/core/validate/HTMLSimpleDocumentValidator.java @@ -0,0 +1,39 @@ +/******************************************************************************* + * Copyright (c) 2004 IBM Corporation and others. + * All rights reserved. This program and the accompanying materials + * are made available under the terms of the Eclipse Public License v1.0 + * which accompanies this distribution, and is available at + * http://www.eclipse.org/legal/epl-v10.html + * + * Contributors: + * IBM Corporation - initial API and implementation + *******************************************************************************/ +package org.eclipse.wst.html.core.validate; + + +import org.eclipse.wst.xml.core.internal.validate.ValidationComponent; + +class HTMLSimpleDocumentValidator extends CompositeValidator { + + /** + * HTMLSimpleDocumentValidator constructor comment. + */ + public HTMLSimpleDocumentValidator() { + super(); + + ValidationComponent[] validators = new ValidationComponent[2]; + + validators[0] = new HTMLDocumentContentValidator(); + validators[1] = new SyntaxValidator(); + + register(validators); + } + + /** + * Allowing the INodeAdapter to compare itself against the type + * allows it to return true in more than one case. + */ + public boolean isAdapterForType(Object type) { + return ((type == HTMLSimpleDocumentValidator.class) || super.isAdapterForType(type)); + } +}
\ No newline at end of file diff --git a/bundles/org.eclipse.wst.html.core/src/org/eclipse/wst/html/core/validate/HTMLSimpleValidator.java b/bundles/org.eclipse.wst.html.core/src/org/eclipse/wst/html/core/validate/HTMLSimpleValidator.java new file mode 100644 index 0000000000..47b6ff8f3e --- /dev/null +++ b/bundles/org.eclipse.wst.html.core/src/org/eclipse/wst/html/core/validate/HTMLSimpleValidator.java @@ -0,0 +1,42 @@ +/******************************************************************************* + * Copyright (c) 2004 IBM Corporation and others. + * All rights reserved. This program and the accompanying materials + * are made available under the terms of the Eclipse Public License v1.0 + * which accompanies this distribution, and is available at + * http://www.eclipse.org/legal/epl-v10.html + * + * Contributors: + * IBM Corporation - initial API and implementation + *******************************************************************************/ +package org.eclipse.wst.html.core.validate; + + +import org.eclipse.wst.xml.core.internal.validate.ValidationComponent; + +class HTMLSimpleValidator extends CompositeValidator { + + /** + * HTMLSimpleValidator constructor comment. + */ + public HTMLSimpleValidator() { + super(); + + ValidationComponent[] validators = new ValidationComponent[5]; + + validators[0] = new HTMLAttributeValidator(); + validators[1] = new HTMLElementContentValidator(); + validators[2] = new SyntaxValidator(); + validators[3] = new HTMLElementAncestorValidator(); + validators[4] = new NamespaceValidator(); + + register(validators); + } + + /** + * Allowing the INodeAdapter to compare itself against the type + * allows it to return true in more than one case. + */ + public boolean isAdapterForType(Object type) { + return ((type == HTMLSimpleValidator.class) || super.isAdapterForType(type)); + } +}
\ No newline at end of file diff --git a/bundles/org.eclipse.wst.html.core/src/org/eclipse/wst/html/core/validate/HTMLValidationAdapterFactory.java b/bundles/org.eclipse.wst.html.core/src/org/eclipse/wst/html/core/validate/HTMLValidationAdapterFactory.java new file mode 100644 index 0000000000..68185c317f --- /dev/null +++ b/bundles/org.eclipse.wst.html.core/src/org/eclipse/wst/html/core/validate/HTMLValidationAdapterFactory.java @@ -0,0 +1,72 @@ +/******************************************************************************* + * Copyright (c) 2004 IBM Corporation and others. + * All rights reserved. This program and the accompanying materials + * are made available under the terms of the Eclipse Public License v1.0 + * which accompanies this distribution, and is available at + * http://www.eclipse.org/legal/epl-v10.html + * + * Contributors: + * IBM Corporation - initial API and implementation + *******************************************************************************/ +package org.eclipse.wst.html.core.validate; + + + +import org.eclipse.wst.sse.core.AbstractAdapterFactory; +import org.eclipse.wst.sse.core.AdapterFactory; +import org.eclipse.wst.sse.core.INodeAdapter; +import org.eclipse.wst.sse.core.INodeNotifier; +import org.eclipse.wst.sse.core.validate.ValidationAdapter; +import org.w3c.dom.Node; + +public class HTMLValidationAdapterFactory extends AbstractAdapterFactory { + + private static HTMLValidationAdapterFactory instance = null; + + /** + * HTMLValidationAdapterFactory constructor comment. + */ + public HTMLValidationAdapterFactory() { + super(ValidationAdapter.class, true); + } + + /** + * HTMLValidationAdapterFactory constructor comment. + * @param adapterKey java.lang.Object + * @param registerAdapters boolean + */ + public HTMLValidationAdapterFactory(Object adapterKey, boolean registerAdapters) { + super(adapterKey, registerAdapters); + } + + /** + */ + protected INodeAdapter createAdapter(INodeNotifier target) { + Node node = (Node) target; + switch (node.getNodeType()) { + case Node.DOCUMENT_NODE : + return new DocumentPropagatingValidator(); + case Node.ELEMENT_NODE : + return new ElementPropagatingValidator(); + default : + return new NullValidator(); + } + } + + /** + */ + public synchronized static HTMLValidationAdapterFactory getInstance() { + if (instance != null) + return instance; + instance = new HTMLValidationAdapterFactory(); + return instance; + } + + /** + * Overriding Object's clone() method + * This is used in IModelManager's IStructuredModel copying. + */ + public AdapterFactory copy() { + return getInstance(); + } +}
\ No newline at end of file diff --git a/bundles/org.eclipse.wst.html.core/src/org/eclipse/wst/html/core/validate/MessageFactory.java b/bundles/org.eclipse.wst.html.core/src/org/eclipse/wst/html/core/validate/MessageFactory.java new file mode 100644 index 0000000000..0419e925d5 --- /dev/null +++ b/bundles/org.eclipse.wst.html.core/src/org/eclipse/wst/html/core/validate/MessageFactory.java @@ -0,0 +1,256 @@ +/******************************************************************************* + * Copyright (c) 2004 IBM Corporation and others. + * All rights reserved. This program and the accompanying materials + * are made available under the terms of the Eclipse Public License v1.0 + * which accompanies this distribution, and is available at + * http://www.eclipse.org/legal/epl-v10.html + * + * Contributors: + * IBM Corporation - initial API and implementation + *******************************************************************************/ +package org.eclipse.wst.html.core.validate; + + + +import java.text.MessageFormat; +import java.util.Hashtable; + +import org.eclipse.wst.html.core.internal.Logger; +import org.eclipse.wst.html.core.internal.nls.ResourceHandler; +import org.eclipse.wst.sse.core.validate.ValidationMessage; +import org.w3c.dom.Node; + +class MessageFactory implements ErrorState { + + + private static class ErrorTable { + private class Packet { + public Packet(String msg, int severity) { + this.msg = msg; + this.severity = severity; + } + + public String getMessage() { + return msg; + } + + public int getSeverity() { + return severity; + } + + private String msg = null; + private int severity = -1; + } + + public ErrorTable() { + } + + public void put(int state, String msg, int severity) { + Packet packet = new Packet(msg, severity); + map.put(new Integer(state), packet); + } + + public String getMessage(int state) { + return getPacket(state).getMessage(); + } + + public int getSeverity(int state) { + return getPacket(state).getSeverity(); + } + + private Packet getPacket(int state) { + return (Packet) map.get(new Integer(state)); + } + + private Hashtable map = new Hashtable(); + } + + private static interface NodeType { + static final int ATTRIBUTE = 0; + static final int ELEMENT = 1; + static final int DOCUMENT_TYPE = 2; + static final int TEXT = 3; + static final int COMMENT = 4; + static final int CDATA_SECTION = 5; + static final int PROCESSING_INSTRUCTION = 6; + static final int ENTITY_REFERENCE = 7; + + static final int MAX_TYPE = 8; + } + + // error messages + private static final String MSG_NO_ERROR = ResourceHandler.getString("No_error._UI_"); //$NON-NLS-1$ = "No error." + private static final String MSG_UNDEFINED_ATTR_ERROR = ResourceHandler.getString("Undefined_attribute_name_(_ERROR_"); //$NON-NLS-1$ = "Undefined attribute name ({0})." + private static final String MSG_UNDEFINED_VALUE_ERROR = ResourceHandler.getString("Undefined_attribute_value__ERROR_"); //$NON-NLS-1$ = "Undefined attribute value ({0})." + private static final String MSG_DUPLICATE_ATTR_ERROR = ResourceHandler.getString("Multiple_values_specified__ERROR_"); //$NON-NLS-1$ = "Multiple values specified for an attribute ({0})." + private static final String MSG_MISMATCHED_ATTR_ERROR = ResourceHandler.getString("Attribute_name_({0})_uses__ERROR_"); //$NON-NLS-1$ = "Attribute name ({0}) uses wrong case character." + private static final String MSG_INVALID_ATTR_ERROR = ResourceHandler.getString("Invalid_attribute_name_({0_ERROR_"); //$NON-NLS-1$ = "Invalid attribute name ({0})." + private static final String MSG_ATTR_NO_VALUE_ERROR = ResourceHandler.getString("Invalid_attribute_({0})._ERROR_"); //$NON-NLS-1$ = "Invalid attribute ({0})." + private static final String MSG_INVALID_CONTENT_ERROR = ResourceHandler.getString("Invalid_location_of_tag_({_ERROR_"); //$NON-NLS-1$ = "Invalid location of tag ({0})." + private static final String MSG_DUPLICATE_TAG_ERROR = ResourceHandler.getString("Duplicate_tag_({0})._ERROR_"); //$NON-NLS-1$ = "Duplicate tag ({0})." + private static final String MSG_MISSING_START_TAG_ERROR = ResourceHandler.getString("No_start_tag_(<{0}>)._ERROR_"); //$NON-NLS-1$ = "No start tag (<{0}>)." + private static final String MSG_MISSING_END_TAG_ERROR = ResourceHandler.getString("No_end_tag_(</{0}>)._ERROR_"); //$NON-NLS-1$ = "No end tag (</{0}>)." + private static final String MSG_UNNECESSARY_END_TAG_ERROR = ResourceHandler.getString("End_tag_(</{0}>)_not_neede_ERROR_"); //$NON-NLS-1$ = "End tag (</{0}>) not needed." + private static final String MSG_UNDEFINED_TAG_ERROR = ResourceHandler.getString("Unknown_tag_({0})._ERROR_"); //$NON-NLS-1$ = "Unknown tag ({0})." + private static final String MSG_MISMATCHED_TAG_ERROR = ResourceHandler.getString("Tag_name_({0})_uses_wrong__ERROR_"); //$NON-NLS-1$ = "Tag name ({0}) uses wrong case character." + private static final String MSG_INVALID_TAG_ERROR = ResourceHandler.getString("Invalid_tag_name_({0})._ERROR_"); //$NON-NLS-1$ = "Invalid tag name ({0})." + private static final String MSG_INVALID_DIRECTIVE_ERROR = ResourceHandler.getString("Invalid_JSP_directive_({0}_ERROR_"); //$NON-NLS-1$ = "Invalid JSP directive ({0})." + private static final String MSG_INVALID_TEXT_ERROR = ResourceHandler.getString("Invalid_text_string_({0})._ERROR_"); //$NON-NLS-1$ = "Invalid text string ({0})." + private static final String MSG_INVALID_CHAR_ERROR = ResourceHandler.getString("Invalid_character_used_in__ERROR_"); //$NON-NLS-1$ = "Invalid character used in text string ({0})." + private static final String MSG_UNKNOWN_ERROR = ResourceHandler.getString("Unknown_error._ERROR_"); //$NON-NLS-1$ = "Unknown error." + private static final String MSG_UNCLOSED_START_TAG_ERROR = ResourceHandler.getString("Start_tag_(<{0}>)_not_clos_ERROR_"); //$NON-NLS-1$ = "Start tag (<{0}>) not closed." + private static final String MSG_UNCLOSED_END_TAG_ERROR = ResourceHandler.getString("End_tag_(</{0}>)_not_close_ERROR_"); //$NON-NLS-1$ = "End tag (</{0}>) not closed." + private static final String MSG_UNCLOSED_TAG_ERROR = ResourceHandler.getString("Tag_({0})_not_closed._ERROR_"); //$NON-NLS-1$ = "Tag ({0}) not closed." + private static final String MSG_MISMATCHED_ATTR_VALUE_ERROR = ResourceHandler.getString("Attribute_value_({0})_uses_ERROR_"); //$NON-NLS-1$ = "Attribute value ({0}) uses wrong case character." + private static final String MSG_UNCLOSED_COMMENT_ERROR = ResourceHandler.getString("Comment_not_closed._ERROR_"); //$NON-NLS-1$ = "Comment not closed." + private static final String MSG_UNCLOSED_DOCTYPE_ERROR = ResourceHandler.getString("DOCTYPE_declaration_not_cl_ERROR_"); //$NON-NLS-1$ = "DOCTYPE declaration not closed." + private static final String MSG_UNCLOSED_PI_ERROR = ResourceHandler.getString("Processing_instruction_not_ERROR_"); //$NON-NLS-1$ = "Processing instruction not closed." + private static final String MSG_UNCLOSED_CDATA_SECTION_ERROR = ResourceHandler.getString("CDATA_section_not_closed._ERROR_"); //$NON-NLS-1$ = "CDATA section not closed." + private static final String MSG_INVALID_EMPTY_ELEMENT_TAG = ResourceHandler.getString("_ERROR_Tag_({0})_should_be_an_empty-element_tag_1"); //$NON-NLS-1$ = "Tag ({0}) should be an empty-element tag." + private static final String MSG_UNCLOSED_ATTR_VALUE_ERROR = ResourceHandler.getString("_ERROR_Attribute_value_({0})_not_closed._1"); //$NON-NLS-1$ ="Attribute value ({0}) not closed." + private static ErrorTable[] errTables = new ErrorTable[NodeType.MAX_TYPE]; + + static { + for (int i = 0; i < NodeType.MAX_TYPE; i++) { + errTables[i] = new ErrorTable(); + } + // NOTE: The severities are just stub. They must be reviewed. + // -- 8/30/2001 + + // attribute error map + ErrorTable attrTable = errTables[NodeType.ATTRIBUTE];// short hand + attrTable.put(NONE_ERROR, MSG_NO_ERROR, 0); + attrTable.put(UNDEFINED_NAME_ERROR, MSG_UNDEFINED_ATTR_ERROR, ValidationMessage.WARNING); + attrTable.put(UNDEFINED_VALUE_ERROR, MSG_UNDEFINED_VALUE_ERROR, ValidationMessage.WARNING); + attrTable.put(MISMATCHED_ERROR, MSG_MISMATCHED_ATTR_ERROR, ValidationMessage.WARNING); + attrTable.put(INVALID_NAME_ERROR, MSG_INVALID_ATTR_ERROR, ValidationMessage.WARNING); + attrTable.put(INVALID_ATTR_ERROR, MSG_ATTR_NO_VALUE_ERROR, ValidationMessage.WARNING); + attrTable.put(DUPLICATE_ERROR, MSG_DUPLICATE_ATTR_ERROR, ValidationMessage.WARNING); + attrTable.put(MISMATCHED_VALUE_ERROR, MSG_MISMATCHED_ATTR_VALUE_ERROR, ValidationMessage.ERROR); + //<<D210422 + attrTable.put(UNCLOSED_ATTR_VALUE, MSG_UNCLOSED_ATTR_VALUE_ERROR, ValidationMessage.WARNING); + //D210422 + // element error map + ErrorTable elemTable = errTables[NodeType.ELEMENT];// short hand + elemTable.put(NONE_ERROR, MSG_NO_ERROR, 0); + elemTable.put(UNDEFINED_NAME_ERROR, MSG_UNDEFINED_TAG_ERROR, ValidationMessage.WARNING); + elemTable.put(INVALID_NAME_ERROR, MSG_INVALID_TAG_ERROR, ValidationMessage.ERROR); + elemTable.put(MISMATCHED_ERROR, MSG_MISMATCHED_TAG_ERROR, ValidationMessage.WARNING); + elemTable.put(MISMATCHED_END_TAG_ERROR, MSG_MISMATCHED_TAG_ERROR, ValidationMessage.ERROR); + elemTable.put(MISSING_START_TAG_ERROR, MSG_MISSING_START_TAG_ERROR, ValidationMessage.ERROR); + elemTable.put(MISSING_END_TAG_ERROR, MSG_MISSING_END_TAG_ERROR, ValidationMessage.WARNING); + elemTable.put(UNNECESSARY_END_TAG_ERROR, MSG_UNNECESSARY_END_TAG_ERROR, ValidationMessage.WARNING); + elemTable.put(INVALID_DIRECTIVE_ERROR, MSG_INVALID_DIRECTIVE_ERROR, ValidationMessage.ERROR); + elemTable.put(INVALID_CONTENT_ERROR, MSG_INVALID_CONTENT_ERROR, ValidationMessage.WARNING); + elemTable.put(DUPLICATE_ERROR, MSG_DUPLICATE_TAG_ERROR, ValidationMessage.WARNING); + elemTable.put(COEXISTENCE_ERROR, MSG_INVALID_CONTENT_ERROR, ValidationMessage.WARNING); + elemTable.put(UNCLOSED_TAG_ERROR, MSG_UNCLOSED_START_TAG_ERROR, ValidationMessage.ERROR); + elemTable.put(UNCLOSED_END_TAG_ERROR, MSG_UNCLOSED_END_TAG_ERROR, ValidationMessage.ERROR); + elemTable.put(INVALID_EMPTY_ELEMENT_TAG, MSG_INVALID_EMPTY_ELEMENT_TAG, ValidationMessage.WARNING); + + // document type error map + ErrorTable docTable = errTables[NodeType.DOCUMENT_TYPE];// short hand + docTable.put(NONE_ERROR, MSG_NO_ERROR, 0); + docTable.put(DUPLICATE_ERROR, MSG_DUPLICATE_TAG_ERROR, ValidationMessage.ERROR); + docTable.put(INVALID_CONTENT_ERROR, MSG_INVALID_CONTENT_ERROR, ValidationMessage.WARNING); + docTable.put(UNCLOSED_TAG_ERROR, MSG_UNCLOSED_DOCTYPE_ERROR, ValidationMessage.ERROR); + + // text error map + ErrorTable textTable = errTables[NodeType.TEXT]; + textTable.put(NONE_ERROR, MSG_NO_ERROR, 0); + textTable.put(INVALID_CONTENT_ERROR, MSG_INVALID_TEXT_ERROR, ValidationMessage.WARNING); + textTable.put(INVALID_CHAR_ERROR, MSG_INVALID_CHAR_ERROR, ValidationMessage.WARNING); + + // comment error map + ErrorTable commTable = errTables[NodeType.COMMENT]; + commTable.put(NONE_ERROR, MSG_NO_ERROR, 0); + commTable.put(INVALID_CONTENT_ERROR, MSG_INVALID_CONTENT_ERROR, ValidationMessage.WARNING); + commTable.put(UNCLOSED_TAG_ERROR, MSG_UNCLOSED_COMMENT_ERROR, ValidationMessage.ERROR); + + // cdata section error map + ErrorTable cdatTable = errTables[NodeType.CDATA_SECTION]; + cdatTable.put(NONE_ERROR, MSG_NO_ERROR, 0); + cdatTable.put(INVALID_CONTENT_ERROR, MSG_INVALID_CONTENT_ERROR, ValidationMessage.WARNING); + cdatTable.put(UNCLOSED_TAG_ERROR, MSG_UNCLOSED_CDATA_SECTION_ERROR, ValidationMessage.ERROR); + + // processing instruction error map + ErrorTable piTable = errTables[NodeType.PROCESSING_INSTRUCTION]; + piTable.put(NONE_ERROR, MSG_NO_ERROR, 0); + piTable.put(INVALID_CONTENT_ERROR, MSG_INVALID_CONTENT_ERROR, ValidationMessage.WARNING); + piTable.put(UNCLOSED_TAG_ERROR, MSG_UNCLOSED_PI_ERROR, ValidationMessage.ERROR); + + // entity reference error map + ErrorTable erTable = errTables[NodeType.ENTITY_REFERENCE]; + erTable.put(NONE_ERROR, MSG_NO_ERROR, 0); + erTable.put(UNDEFINED_NAME_ERROR, MSG_UNDEFINED_TAG_ERROR, ValidationMessage.WARNING); + erTable.put(INVALID_CONTENT_ERROR, MSG_INVALID_CONTENT_ERROR, ValidationMessage.WARNING); + } + + /** + */ + public static ValidationMessage createMessage(ErrorInfo info) { + String errorMsg = getErrorMessage(info); + int errorSeverity = getErrorSeverity(info); + return new ValidationMessage(errorMsg, info.getOffset(), info.getLength(), errorSeverity); + } + + private static String getErrorMessage(ErrorInfo info) { + ErrorTable tab = getErrorTable(info.getTargetType()); + if (tab == null) + return MSG_UNKNOWN_ERROR; + + String template = tab.getMessage(info.getState()); + Object[] arguments = {info.getHint()}; + String s = null; + try { + s = MessageFormat.format(template, arguments); + } + catch (IllegalArgumentException e) { + Logger.logException(e); + s = template + ":" + arguments.toString(); //$NON-NLS-1$ + } + return s; + } + + /** + */ + private static int getErrorSeverity(ErrorInfo info) { + ErrorTable tab = getErrorTable(info.getTargetType()); + if (tab == null) + return 0; + return tab.getSeverity(info.getState()); + } + + private static ErrorTable getErrorTable(short nodetype) { + ErrorTable tab = null; + switch (nodetype) { + case Node.ATTRIBUTE_NODE : + tab = errTables[NodeType.ATTRIBUTE]; + break; + case Node.ELEMENT_NODE : + tab = errTables[NodeType.ELEMENT]; + break; + case Node.DOCUMENT_TYPE_NODE : + tab = errTables[NodeType.DOCUMENT_TYPE]; + break; + case Node.TEXT_NODE : + tab = errTables[NodeType.TEXT]; + break; + case Node.COMMENT_NODE : + tab = errTables[NodeType.COMMENT]; + break; + case Node.CDATA_SECTION_NODE : + tab = errTables[NodeType.CDATA_SECTION]; + break; + case Node.PROCESSING_INSTRUCTION_NODE : + tab = errTables[NodeType.PROCESSING_INSTRUCTION]; + break; + case Node.ENTITY_REFERENCE_NODE : + tab = errTables[NodeType.ENTITY_REFERENCE]; + break; + default : + return null; + } + return tab; + } +}
\ No newline at end of file diff --git a/bundles/org.eclipse.wst.html.core/src/org/eclipse/wst/html/core/validate/NamespaceValidator.java b/bundles/org.eclipse.wst.html.core/src/org/eclipse/wst/html/core/validate/NamespaceValidator.java new file mode 100644 index 0000000000..f2e605da44 --- /dev/null +++ b/bundles/org.eclipse.wst.html.core/src/org/eclipse/wst/html/core/validate/NamespaceValidator.java @@ -0,0 +1,127 @@ +/******************************************************************************* + * Copyright (c) 2004 IBM Corporation and others. + * All rights reserved. This program and the accompanying materials + * are made available under the terms of the Eclipse Public License v1.0 + * which accompanies this distribution, and is available at + * http://www.eclipse.org/legal/epl-v10.html + * + * Contributors: + * IBM Corporation - initial API and implementation + *******************************************************************************/ +package org.eclipse.wst.html.core.validate; + +import org.eclipse.wst.common.contentmodel.CMAttributeDeclaration; +import org.eclipse.wst.common.contentmodel.CMElementDeclaration; +import org.eclipse.wst.common.contentmodel.CMNamedNodeMap; +import org.eclipse.wst.sse.core.IndexedRegion; +import org.eclipse.wst.sse.core.text.ITextRegion; +import org.eclipse.wst.xml.core.document.XMLAttr; +import org.eclipse.wst.xml.core.document.XMLElement; +import org.w3c.dom.Attr; +import org.w3c.dom.Element; +import org.w3c.dom.NamedNodeMap; +import org.w3c.dom.Node; + +public class NamespaceValidator extends PrimeValidator implements ErrorState { + + private final static String XMLNS_PREFIX = "xmlns";//$NON-NLS-1$ + private final static String NS_SEPARATOR = ":";//$NON-NLS-1$ + + public NamespaceValidator() { + super(); + } + + public boolean isAdapterForType(Object type) { + return ((type == NamespaceValidator.class) || super.isAdapterForType(type)); + } + + public void validate(IndexedRegion node) { + Element target = (Element) node; + if (isXMLElement(target) && hasUnknownPrefix(target)) { + XMLElement e = (XMLElement) target; + if (!isValidPrefix(e.getPrefix(), target) && !e.isCommentTag()) { + // report unknown tag error. + Segment errorSeg = FMUtil.getSegment(e, FMUtil.SEG_START_TAG); + if (errorSeg != null) + reporter.report(MessageFactory.createMessage(new ErrorInfoImpl(UNDEFINED_NAME_ERROR, errorSeg, e))); + } + } + // (2) check prefix of each attr + NamedNodeMap attrs = target.getAttributes(); + for (int i = 0; i < attrs.getLength(); i++) { + Node n = attrs.item(i); + if (!(n instanceof XMLAttr)) + continue; + XMLAttr a = (XMLAttr) n; + String prefix = a.getPrefix(); + if ((prefix != null) && isUnknownAttr(a, target)) { + // The attr has unknown prefix. So, check it. + if (!isValidPrefix(prefix, target)) { + // report unknown attr error. + ITextRegion r = a.getNameRegion(); + if (r == null) + continue; + int a_offset = a.getNameRegionStartOffset(); + int a_length = a.getNameRegion().getLength(); + reporter.report(MessageFactory.createMessage(new ErrorInfoImpl(UNDEFINED_NAME_ERROR, new Segment(a_offset, a_length), a))); + } + } + } + } + + // private methods + private boolean isXMLElement(Element target) { + return target instanceof XMLElement; + } + + private boolean hasUnknownPrefix(Element target) { + return isUnknownElement(target) && CMUtil.isForeign(target); + } + + private boolean isUnknownElement(Element target) { + CMElementDeclaration dec = CMUtil.getDeclaration(target); + return dec == null; + } + + private boolean isUnknownAttr(XMLAttr attr, Element target) { + CMElementDeclaration dec = CMUtil.getDeclaration(target); + if (dec == null) + return true; // unknown. + CMNamedNodeMap adecls = dec.getAttributes(); + CMAttributeDeclaration adec = (CMAttributeDeclaration) adecls.getNamedItem(attr.getName()); + return adec == null; + } + + private boolean isValidPrefix(String prefix, Element e) { + if (prefix.equals(XMLNS_PREFIX)) + return true; // "xmlns:foo" attr is always valid. + + // (1) check the element has the namespace definition or not. + if (isValidPrefixWithinElement(prefix, e)) + return true; + + // (2) check ancestors of the element have the namespace definition or not. + Element parent = SMUtil.getParentElement(e); + while (parent != null) { + if (isValidPrefixWithinElement(prefix, parent)) + return true; + parent = SMUtil.getParentElement(parent); + } + return false; + } + + private boolean isValidPrefixWithinElement(String prefix, Element e) { + String ns = XMLNS_PREFIX + NS_SEPARATOR + prefix; + NamedNodeMap attrs = e.getAttributes(); + for (int i = 0; i < attrs.getLength(); i++) { + Node n = attrs.item(i); + if (n == null) + continue; + if (n.getNodeType() != Node.ATTRIBUTE_NODE) + continue; + if (ns.equals(((Attr) n).getName())) + return true; + } + return false; + } +}
\ No newline at end of file diff --git a/bundles/org.eclipse.wst.html.core/src/org/eclipse/wst/html/core/validate/NullValidator.java b/bundles/org.eclipse.wst.html.core/src/org/eclipse/wst/html/core/validate/NullValidator.java new file mode 100644 index 0000000000..1a9cbc0e7a --- /dev/null +++ b/bundles/org.eclipse.wst.html.core/src/org/eclipse/wst/html/core/validate/NullValidator.java @@ -0,0 +1,34 @@ +/******************************************************************************* + * Copyright (c) 2004 IBM Corporation and others. + * All rights reserved. This program and the accompanying materials + * are made available under the terms of the Eclipse Public License v1.0 + * which accompanies this distribution, and is available at + * http://www.eclipse.org/legal/epl-v10.html + * + * Contributors: + * IBM Corporation - initial API and implementation + *******************************************************************************/ +package org.eclipse.wst.html.core.validate; + +import org.eclipse.wst.sse.core.IndexedRegion; +import org.eclipse.wst.sse.core.validate.ValidationReporter; +import org.eclipse.wst.xml.core.internal.validate.ValidationComponent; + +/** + * NullValidator class is intended to be a replacement of null + * for ValidationComponent type. + */ +final class NullValidator extends ValidationComponent { + + public NullValidator() { + super(); + } + + public void validate(IndexedRegion node) { + return; + } + + public void setReporter(ValidationReporter reporter) { + return; + } +}
\ No newline at end of file diff --git a/bundles/org.eclipse.wst.html.core/src/org/eclipse/wst/html/core/validate/PrimeValidator.java b/bundles/org.eclipse.wst.html.core/src/org/eclipse/wst/html/core/validate/PrimeValidator.java new file mode 100644 index 0000000000..6278a3ab23 --- /dev/null +++ b/bundles/org.eclipse.wst.html.core/src/org/eclipse/wst/html/core/validate/PrimeValidator.java @@ -0,0 +1,25 @@ +/******************************************************************************* + * Copyright (c) 2004 IBM Corporation and others. + * All rights reserved. This program and the accompanying materials + * are made available under the terms of the Eclipse Public License v1.0 + * which accompanies this distribution, and is available at + * http://www.eclipse.org/legal/epl-v10.html + * + * Contributors: + * IBM Corporation - initial API and implementation + *******************************************************************************/ +package org.eclipse.wst.html.core.validate; + + + +import org.eclipse.wst.xml.core.internal.validate.ValidationComponent; + +abstract class PrimeValidator extends ValidationComponent { + + /** + * PrimeValidator constructor comment. + */ + public PrimeValidator() { + super(); + } +}
\ No newline at end of file diff --git a/bundles/org.eclipse.wst.html.core/src/org/eclipse/wst/html/core/validate/SMUtil.java b/bundles/org.eclipse.wst.html.core/src/org/eclipse/wst/html/core/validate/SMUtil.java new file mode 100644 index 0000000000..97adcf80fc --- /dev/null +++ b/bundles/org.eclipse.wst.html.core/src/org/eclipse/wst/html/core/validate/SMUtil.java @@ -0,0 +1,36 @@ +/******************************************************************************* + * Copyright (c) 2004 IBM Corporation and others. + * All rights reserved. This program and the accompanying materials + * are made available under the terms of the Eclipse Public License v1.0 + * which accompanies this distribution, and is available at + * http://www.eclipse.org/legal/epl-v10.html + * + * Contributors: + * IBM Corporation - initial API and implementation + *******************************************************************************/ +package org.eclipse.wst.html.core.validate; + +import org.w3c.dom.Element; +import org.w3c.dom.Node; + +final class SMUtil { + + private SMUtil() { + super(); + } + + /* get an ancestor element ignoring implicit ones. */ + public static Element getParentElement(Node child) { + if (child == null) + return null; + + Node p = child.getParentNode(); + while (p != null) { + if (p.getNodeType() == Node.ELEMENT_NODE) { + return (Element) p; + } + p = p.getParentNode(); + } + return null; + } +}
\ No newline at end of file diff --git a/bundles/org.eclipse.wst.html.core/src/org/eclipse/wst/html/core/validate/Segment.java b/bundles/org.eclipse.wst.html.core/src/org/eclipse/wst/html/core/validate/Segment.java new file mode 100644 index 0000000000..2e5db726e5 --- /dev/null +++ b/bundles/org.eclipse.wst.html.core/src/org/eclipse/wst/html/core/validate/Segment.java @@ -0,0 +1,64 @@ +/******************************************************************************* + * Copyright (c) 2004 IBM Corporation and others. + * All rights reserved. This program and the accompanying materials + * are made available under the terms of the Eclipse Public License v1.0 + * which accompanies this distribution, and is available at + * http://www.eclipse.org/legal/epl-v10.html + * + * Contributors: + * IBM Corporation - initial API and implementation + *******************************************************************************/ +package org.eclipse.wst.html.core.validate; + + + +import org.eclipse.wst.sse.core.text.IStructuredDocumentRegion; + +public class Segment { + + private int offset = 0; + private int length = 0; + + /** + */ + public Segment(int offset, int length) { + super(); + this.offset = offset; + this.length = length; + } + + public Segment(IStructuredDocumentRegion region) { + super(); + this.offset = region.getStartOffset(); + this.length = region.getLength(); + } + + /** + * NOTE: 'start' and 'end' must be the start and end of the contiguous regions. + * Otherwise, this class cannot work correctly. + */ + public Segment(IStructuredDocumentRegion start, IStructuredDocumentRegion end) { + super(); + this.offset = start.getStartOffset(); + int endOffset = (end == null) ? start.getEndOffset() : end.getEndOffset(); + this.length = endOffset - this.offset; + } + + //public Segment(ITextRegion start, ITextRegion end) { + // super(); + // this.offset = start.getStartOffset(); + // int endOffset = (end == null) ? start.getEndOffset() : end.getEndOffset(); + // this.length = endOffset - this.offset; + //} + /** + */ + public int getLength() { + return this.length; + } + + /** + */ + public int getOffset() { + return this.offset; + } +}
\ No newline at end of file diff --git a/bundles/org.eclipse.wst.html.core/src/org/eclipse/wst/html/core/validate/SyntaxValidator.java b/bundles/org.eclipse.wst.html.core/src/org/eclipse/wst/html/core/validate/SyntaxValidator.java new file mode 100644 index 0000000000..01b217727e --- /dev/null +++ b/bundles/org.eclipse.wst.html.core/src/org/eclipse/wst/html/core/validate/SyntaxValidator.java @@ -0,0 +1,345 @@ +/******************************************************************************* + * Copyright (c) 2004 IBM Corporation and others. + * All rights reserved. This program and the accompanying materials + * are made available under the terms of the Eclipse Public License v1.0 + * which accompanies this distribution, and is available at + * http://www.eclipse.org/legal/epl-v10.html + * + * Contributors: + * IBM Corporation - initial API and implementation + *******************************************************************************/ +package org.eclipse.wst.html.core.validate; + +import java.util.Iterator; + +import org.eclipse.wst.common.contentmodel.CMElementDeclaration; +import org.eclipse.wst.html.core.document.HTMLDocumentTypeEntry; +import org.eclipse.wst.html.core.document.HTMLDocumentTypeRegistry; +import org.eclipse.wst.sse.core.IndexedRegion; +import org.eclipse.wst.sse.core.text.IStructuredDocumentRegion; +import org.eclipse.wst.sse.core.text.ITextRegion; +import org.eclipse.wst.sse.core.text.ITextRegionList; +import org.eclipse.wst.xml.core.document.InvalidCharacterException; +import org.eclipse.wst.xml.core.document.XMLDocument; +import org.eclipse.wst.xml.core.document.XMLElement; +import org.eclipse.wst.xml.core.document.XMLNode; +import org.eclipse.wst.xml.core.internal.document.SourceValidator; +import org.eclipse.wst.xml.core.parser.XMLRegionContext; +import org.w3c.dom.Document; +import org.w3c.dom.Element; +import org.w3c.dom.Node; + +class SyntaxValidator extends PrimeValidator implements ErrorState { + + + static private boolean isValidRegion(ITextRegion rgn) { + String type = rgn.getType(); + if (type == null) + return false; // no type is invalid. + if (type == XMLRegionContext.XML_END_TAG_OPEN || type == XMLRegionContext.XML_TAG_NAME || type == XMLRegionContext.XML_TAG_CLOSE) { + return true; + } + return false; + } + + static private String getTagName(IStructuredDocumentRegion tag) { + ITextRegionList regions = tag.getRegions(); + Iterator iter = regions.iterator(); + while (iter.hasNext()) { + ITextRegion rgn = (ITextRegion) iter.next(); + if (rgn.getType() == XMLRegionContext.XML_TAG_NAME) + return tag.getText(rgn); + } + return "";//$NON-NLS-1$ + } + + static private boolean isEmptyContent(CMElementDeclaration decl) { + return (decl != null) && (decl.getContentType() == CMElementDeclaration.EMPTY); + } + + public SyntaxValidator() { + super(); + } + + public boolean isAdapterForType(Object type) { + return ((type == SyntaxValidator.class) || super.isAdapterForType(type)); + } + + class ElementInfo { + public ElementInfo() { + super(); + } + + public XMLElement target = null; + public CMElementDeclaration decl = null; + public IStructuredDocumentRegion startTag = null; + public IStructuredDocumentRegion endTag = null; + public boolean hasStartTag = false; + public boolean hasEndTag = false; + public boolean isXHTML = false; + } + + public void validate(IndexedRegion indexedNode) { + Node node = (Node) indexedNode; + validateChildren(node); + + if (node.getNodeType() != Node.ELEMENT_NODE) + return; + if (!(node instanceof XMLElement)) + return; + + ElementInfo info = new ElementInfo(); + info.target = (XMLElement) node; + + // gather information to validate from target at once. + getInfo(info); + + if (info.target.isGlobalTag()) { + validateTags(info); + validateNames(info); + if (info.decl != null && info.isXHTML) { + validateTagCase(info); + } + } + } + + private void getInfo(ElementInfo info) { + info.decl = CMUtil.getDeclaration(info.target); + info.startTag = info.target.getStartStructuredDocumentRegion(); + info.endTag = info.target.getEndStructuredDocumentRegion(); + + info.hasStartTag = (info.startTag != null); + info.hasEndTag = (info.endTag != null); + + Document doc = info.target.getOwnerDocument(); + if (!(doc instanceof XMLDocument)) + return; + String typeid = ((XMLDocument) doc).getDocumentTypeId(); + if (typeid != null) { + HTMLDocumentTypeEntry entry = HTMLDocumentTypeRegistry.getInstance().getEntry(typeid); + info.isXHTML = (entry != null && entry.isXMLType()); + } + } + + class TagErrorInfoImpl extends AbstractErrorInfo { + private String hint = null; + + public TagErrorInfoImpl(int state, IStructuredDocumentRegion tag, String hint) { + super(state, new Segment(tag)); + this.hint = hint; + } + + public String getHint() { + return hint; + } + + public short getTargetType() { + return Node.ELEMENT_NODE; + } + } + + private boolean isEndTagCorrupted(ElementInfo info) { + ITextRegionList regions = info.endTag.getRegions(); + if (regions == null || regions.isEmpty()) + return false; + Iterator iter = regions.iterator(); + while (iter.hasNext()) { + ITextRegion rgn = (ITextRegion) iter.next(); + if (!isValidRegion(rgn)) + return true; // found invalid region type. + } + return false; // all regions are valid. + } + + private String getEndTagFullText(ElementInfo info) { + String hint = "";//$NON-NLS-1$ + ITextRegionList regions = info.endTag.getRegions(); + Iterator iter = regions.iterator(); + while (iter.hasNext()) { + ITextRegion rgn = (ITextRegion) iter.next(); + String type = rgn.getType(); + if (type == null) + continue; + if (type == XMLRegionContext.XML_END_TAG_OPEN || type == XMLRegionContext.XML_TAG_CLOSE) + continue; + hint += info.endTag.getFullText(rgn); + } + return hint; + } + + private void reportCorruptedEndTagError(ElementInfo info) { + String hint = getEndTagFullText(info); + TagErrorInfoImpl error = new TagErrorInfoImpl(UNDEFINED_NAME_ERROR, info.endTag, hint); + this.reporter.report(MessageFactory.createMessage(error)); + } + + private void validateTags(ElementInfo info) { + if (info.hasStartTag) { + if (!info.target.isStartTagClosed()) { + // Mark the whole START tag as an error segment. + Segment errorSeg = new Segment(info.startTag); + report(UNCLOSED_TAG_ERROR, errorSeg, info.target); + } + } + else { + if (info.hasEndTag) { + if (info.decl != null) { + if (CMUtil.isHTML(info.decl) && !info.target.hasChildNodes()) { + if (info.target.isContainer()) { + // Set the error mark to the start of the element. + Segment errorSeg = new Segment(info.target.getStartOffset(), 0); + report(MISSING_START_TAG_ERROR, errorSeg, info.target); + } + else { + // Mark the whole END tag as an error segment. + Segment errorSeg = new Segment(info.endTag); + report(UNNECESSARY_END_TAG_ERROR, errorSeg, info.target); + } + } + else if (info.isXHTML) { + Segment errorSeg = new Segment(info.target.getStartOffset(), 0); + report(MISSING_START_TAG_ERROR, errorSeg, info.target); + } + } + } + } + + if (info.hasEndTag) { + if (!info.target.isClosed()) { + // Set the whole END tag as error segment. + Segment errorSeg = new Segment(info.endTag); + report(UNCLOSED_END_TAG_ERROR, errorSeg, info.target); + } + } + else { + if (info.isXHTML) { // XHTML + if (!info.target.isEmptyTag()) { + if (isEmptyContent(info.decl)) { + // EMPTY element should be written in <.../> form. + Segment errorSeg = FMUtil.getSegment(info.target, FMUtil.SEG_START_TAG); + report(INVALID_EMPTY_ELEMENT_TAG, errorSeg, info.target); + } + else { + // end tag is required. + Segment errorSeg = new Segment(info.target.getEndOffset(), 0); + report(MISSING_END_TAG_ERROR, errorSeg, info.target); + } + } + } + else { // HTML + if (info.hasStartTag) { + if (info.decl != null && CMUtil.isHTML(info.decl) && !info.target.isEmptyTag() && !CMUtil.isEndTagOmissible(info.decl)) { + // Set the error mark to the end of the element. + Segment errorSeg = new Segment(info.target.getEndOffset(), 0); + report(MISSING_END_TAG_ERROR, errorSeg, info.target); + } + } + } + } + } + + /* perform validation about tag name definition. */ + private void validateNames(ElementInfo info) { + boolean corrupted = info.hasEndTag && isEndTagCorrupted(info); + if (info.decl == null) { + // If no declaration is retrieved, the target is really + // unknown element. + if (!info.hasStartTag && corrupted) { + reportCorruptedEndTagError(info); + } + else { + Segment errorSeg = FMUtil.getSegment(info.target, FMUtil.SEG_START_TAG); + report(UNDEFINED_NAME_ERROR, errorSeg, info.target); + } + } + else { + // Even if a declaration could be retrieved, if the end + // tag is corrupted, it should be reported as undefined + // name. (D202493) + if (corrupted) { + reportCorruptedEndTagError(info); + } + } + } + + /* perform validation tag case only for XHTML document */ + private void validateTagCase(ElementInfo info) { + String declared = info.decl.getElementName(); + String startTagName = "";//$NON-NLS-1$ + String endTagName = "";//$NON-NLS-1$ + if (declared == null) + return; + + // start tag + if (info.hasStartTag) { + startTagName = getTagName(info.startTag); + if (!declared.equals(startTagName)) { + TagErrorInfoImpl error = new TagErrorInfoImpl(MISMATCHED_ERROR, info.startTag, startTagName); + this.reporter.report(MessageFactory.createMessage(error)); + } + } + // end tag + if (info.hasEndTag) { + endTagName = getTagName(info.endTag); + if (!info.hasStartTag || (!endTagName.equals(startTagName))) { + if (!declared.equals(endTagName)) { + TagErrorInfoImpl error = new TagErrorInfoImpl(MISMATCHED_ERROR, info.endTag, endTagName); + this.reporter.report(MessageFactory.createMessage(error)); + } + } + } + } + + private void validateChildren(Node target) { + if ((target.getNodeType() == Node.ELEMENT_NODE) && CMUtil.isForeign((Element) target)) + return; + + for (Node child = target.getFirstChild(); child != null; child = child.getNextSibling()) { + switch (child.getNodeType()) { + case Node.TEXT_NODE : + { + XMLNode text = (XMLNode) child; + int charOffset = validateTextSource(text); + if (charOffset >= 0) { + charOffset += text.getStartOffset(); + Segment errorSeg = new Segment(charOffset, 1); + if (errorSeg != null) + report(INVALID_CHAR_ERROR, errorSeg, text); + } + break; + } + case Node.COMMENT_NODE : + case Node.DOCUMENT_TYPE_NODE : + case Node.PROCESSING_INSTRUCTION_NODE : + case Node.CDATA_SECTION_NODE : + { + XMLNode tag = (XMLNode) child; + if (!tag.isClosed()) { + Segment errorSeg = FMUtil.getSegment(tag, FMUtil.SEG_WHOLE_TAG); + if (errorSeg != null) + report(UNCLOSED_TAG_ERROR, errorSeg, tag); + } + break; + } + default : + break; + } + } + } + + private int validateTextSource(XMLNode text) { + try { + SourceValidator validator = new SourceValidator(text); + validator.validateSource(text.getSource()); + } + catch (InvalidCharacterException ex) { + return ex.getOffset(); + } + return -1; + } + + private void report(int state, Segment errorSeg, Node node) { + ErrorInfo info = new ErrorInfoImpl(state, errorSeg, node); + reporter.report(MessageFactory.createMessage(info)); + } +}
\ No newline at end of file |