1 16 17 package org.apache.xerces.impl.xs.traversers; 18 19 import java.util.Enumeration ; 20 import java.util.Hashtable ; 21 import java.util.StringTokenizer ; 22 import java.util.Vector ; 23 24 import org.apache.xerces.impl.dv.InvalidDatatypeValueException; 25 import org.apache.xerces.impl.dv.XSSimpleType; 26 import org.apache.xerces.impl.xs.SchemaGrammar; 27 import org.apache.xerces.impl.xs.SchemaNamespaceSupport; 28 import org.apache.xerces.impl.xs.SchemaSymbols; 29 import org.apache.xerces.impl.xs.XSAttributeDecl; 30 import org.apache.xerces.impl.xs.XSGrammarBucket; 31 import org.apache.xerces.impl.xs.XSWildcardDecl; 32 import org.apache.xerces.impl.xs.util.XInt; 33 import org.apache.xerces.impl.xs.util.XIntPool; 34 import org.apache.xerces.util.DOMUtil; 35 import org.apache.xerces.util.SymbolTable; 36 import org.apache.xerces.util.XMLSymbols; 37 import org.apache.xerces.xni.QName; 38 import org.apache.xerces.xs.XSConstants; 39 import org.w3c.dom.Attr ; 40 import org.w3c.dom.Element ; 41 42 66 67 public class XSAttributeChecker { 68 69 private static final String ELEMENT_N = "element_n"; 74 private static final String ELEMENT_R = "element_r"; 75 private static final String ATTRIBUTE_N = "attribute_n"; 76 private static final String ATTRIBUTE_R = "attribute_r"; 77 78 private static int ATTIDX_COUNT = 0; 79 public static final int ATTIDX_ABSTRACT = ATTIDX_COUNT++; 80 public static final int ATTIDX_AFORMDEFAULT = ATTIDX_COUNT++; 81 public static final int ATTIDX_BASE = ATTIDX_COUNT++; 82 public static final int ATTIDX_BLOCK = ATTIDX_COUNT++; 83 public static final int ATTIDX_BLOCKDEFAULT = ATTIDX_COUNT++; 84 public static final int ATTIDX_DEFAULT = ATTIDX_COUNT++; 85 public static final int ATTIDX_EFORMDEFAULT = ATTIDX_COUNT++; 86 public static final int ATTIDX_FINAL = ATTIDX_COUNT++; 87 public static final int ATTIDX_FINALDEFAULT = ATTIDX_COUNT++; 88 public static final int ATTIDX_FIXED = ATTIDX_COUNT++; 89 public static final int ATTIDX_FORM = ATTIDX_COUNT++; 90 public static final int ATTIDX_ID = ATTIDX_COUNT++; 91 public static final int ATTIDX_ITEMTYPE = ATTIDX_COUNT++; 92 public static final int ATTIDX_MAXOCCURS = ATTIDX_COUNT++; 93 public static final int ATTIDX_MEMBERTYPES = ATTIDX_COUNT++; 94 public static final int ATTIDX_MINOCCURS = ATTIDX_COUNT++; 95 public static final int ATTIDX_MIXED = ATTIDX_COUNT++; 96 public static final int ATTIDX_NAME = ATTIDX_COUNT++; 97 public static final int ATTIDX_NAMESPACE = ATTIDX_COUNT++; 98 public static final int ATTIDX_NAMESPACE_LIST = ATTIDX_COUNT++; 99 public static final int ATTIDX_NILLABLE = ATTIDX_COUNT++; 100 public static final int ATTIDX_NONSCHEMA = ATTIDX_COUNT++; 101 public static final int ATTIDX_PROCESSCONTENTS = ATTIDX_COUNT++; 102 public static final int ATTIDX_PUBLIC = ATTIDX_COUNT++; 103 public static final int ATTIDX_REF = ATTIDX_COUNT++; 104 public static final int ATTIDX_REFER = ATTIDX_COUNT++; 105 public static final int ATTIDX_SCHEMALOCATION = ATTIDX_COUNT++; 106 public static final int ATTIDX_SOURCE = ATTIDX_COUNT++; 107 public static final int ATTIDX_SUBSGROUP = ATTIDX_COUNT++; 108 public static final int ATTIDX_SYSTEM = ATTIDX_COUNT++; 109 public static final int ATTIDX_TARGETNAMESPACE = ATTIDX_COUNT++; 110 public static final int ATTIDX_TYPE = ATTIDX_COUNT++; 111 public static final int ATTIDX_USE = ATTIDX_COUNT++; 112 public static final int ATTIDX_VALUE = ATTIDX_COUNT++; 113 public static final int ATTIDX_ENUMNSDECLS = ATTIDX_COUNT++; 114 public static final int ATTIDX_VERSION = ATTIDX_COUNT++; 115 public static final int ATTIDX_XML_LANG = ATTIDX_COUNT++; 116 public static final int ATTIDX_XPATH = ATTIDX_COUNT++; 117 public static final int ATTIDX_FROMDEFAULT = ATTIDX_COUNT++; 118 public static final int ATTIDX_ISRETURNED = ATTIDX_COUNT++; 120 121 private static final XIntPool fXIntPool = new XIntPool(); 122 private static final XInt INT_QUALIFIED = fXIntPool.getXInt(SchemaSymbols.FORM_QUALIFIED); 124 private static final XInt INT_UNQUALIFIED = fXIntPool.getXInt(SchemaSymbols.FORM_UNQUALIFIED); 125 private static final XInt INT_EMPTY_SET = fXIntPool.getXInt(XSConstants.DERIVATION_NONE); 126 private static final XInt INT_ANY_STRICT = fXIntPool.getXInt(XSWildcardDecl.PC_STRICT); 127 private static final XInt INT_ANY_LAX = fXIntPool.getXInt(XSWildcardDecl.PC_LAX); 128 private static final XInt INT_ANY_SKIP = fXIntPool.getXInt(XSWildcardDecl.PC_SKIP); 129 private static final XInt INT_ANY_ANY = fXIntPool.getXInt(XSWildcardDecl.NSCONSTRAINT_ANY); 130 private static final XInt INT_ANY_LIST = fXIntPool.getXInt(XSWildcardDecl.NSCONSTRAINT_LIST); 131 private static final XInt INT_ANY_NOT = fXIntPool.getXInt(XSWildcardDecl.NSCONSTRAINT_NOT); 132 private static final XInt INT_USE_OPTIONAL = fXIntPool.getXInt(SchemaSymbols.USE_OPTIONAL); 133 private static final XInt INT_USE_REQUIRED = fXIntPool.getXInt(SchemaSymbols.USE_REQUIRED); 134 private static final XInt INT_USE_PROHIBITED = fXIntPool.getXInt(SchemaSymbols.USE_PROHIBITED); 135 private static final XInt INT_WS_PRESERVE = fXIntPool.getXInt(XSSimpleType.WS_PRESERVE); 136 private static final XInt INT_WS_REPLACE = fXIntPool.getXInt(XSSimpleType.WS_REPLACE); 137 private static final XInt INT_WS_COLLAPSE = fXIntPool.getXInt(XSSimpleType.WS_COLLAPSE); 138 private static final XInt INT_UNBOUNDED = fXIntPool.getXInt(SchemaSymbols.OCCURRENCE_UNBOUNDED); 139 140 private static final Hashtable fEleAttrsMapG = new Hashtable (29); 143 private static final Hashtable fEleAttrsMapL = new Hashtable (79); 145 146 151 protected static final int DT_ANYURI = 0; 152 protected static final int DT_ID = 1; 153 protected static final int DT_QNAME = 2; 154 protected static final int DT_STRING = 3; 155 protected static final int DT_TOKEN = 4; 156 protected static final int DT_NCNAME = 5; 157 protected static final int DT_XPATH = 6; 158 protected static final int DT_XPATH1 = 7; 159 protected static final int DT_LANGUAGE = 8; 160 161 protected static final int DT_COUNT = DT_LANGUAGE + 1; 163 private static final XSSimpleType[] fExtraDVs = new XSSimpleType[DT_COUNT]; 164 static { 165 SchemaGrammar grammar = SchemaGrammar.SG_SchemaNS; 167 fExtraDVs[DT_ANYURI] = (XSSimpleType)grammar.getGlobalTypeDecl(SchemaSymbols.ATTVAL_ANYURI); 169 fExtraDVs[DT_ID] = (XSSimpleType)grammar.getGlobalTypeDecl(SchemaSymbols.ATTVAL_ID); 171 fExtraDVs[DT_QNAME] = (XSSimpleType)grammar.getGlobalTypeDecl(SchemaSymbols.ATTVAL_QNAME); 173 fExtraDVs[DT_STRING] = (XSSimpleType)grammar.getGlobalTypeDecl(SchemaSymbols.ATTVAL_STRING); 175 fExtraDVs[DT_TOKEN] = (XSSimpleType)grammar.getGlobalTypeDecl(SchemaSymbols.ATTVAL_TOKEN); 177 fExtraDVs[DT_NCNAME] = (XSSimpleType)grammar.getGlobalTypeDecl(SchemaSymbols.ATTVAL_NCNAME); 179 fExtraDVs[DT_XPATH] = fExtraDVs[DT_STRING]; 181 fExtraDVs[DT_XPATH] = fExtraDVs[DT_STRING]; 183 fExtraDVs[DT_LANGUAGE] = (XSSimpleType)grammar.getGlobalTypeDecl(SchemaSymbols.ATTVAL_LANGUAGE); 185 } 186 187 protected static final int DT_BLOCK = -1; 188 protected static final int DT_BLOCK1 = -2; 189 protected static final int DT_FINAL = -3; 190 protected static final int DT_FINAL1 = -4; 191 protected static final int DT_FINAL2 = -5; 192 protected static final int DT_FORM = -6; 193 protected static final int DT_MAXOCCURS = -7; 194 protected static final int DT_MAXOCCURS1 = -8; 195 protected static final int DT_MEMBERTYPES = -9; 196 protected static final int DT_MINOCCURS1 = -10; 197 protected static final int DT_NAMESPACE = -11; 198 protected static final int DT_PROCESSCONTENTS = -12; 199 protected static final int DT_USE = -13; 200 protected static final int DT_WHITESPACE = -14; 201 protected static final int DT_BOOLEAN = -15; 202 protected static final int DT_NONNEGINT = -16; 203 protected static final int DT_POSINT = -17; 204 205 static { 206 int attCount = 0; 208 int ATT_ABSTRACT_D = attCount++; 209 int ATT_ATTRIBUTE_FD_D = attCount++; 210 int ATT_BASE_R = attCount++; 211 int ATT_BASE_N = attCount++; 212 int ATT_BLOCK_N = attCount++; 213 int ATT_BLOCK1_N = attCount++; 214 int ATT_BLOCK_D_D = attCount++; 215 int ATT_DEFAULT_N = attCount++; 216 int ATT_ELEMENT_FD_D = attCount++; 217 int ATT_FINAL_N = attCount++; 218 int ATT_FINAL1_N = attCount++; 219 int ATT_FINAL_D_D = attCount++; 220 int ATT_FIXED_N = attCount++; 221 int ATT_FIXED_D = attCount++; 222 int ATT_FORM_N = attCount++; 223 int ATT_ID_N = attCount++; 224 int ATT_ITEMTYPE_N = attCount++; 225 int ATT_MAXOCCURS_D = attCount++; 226 int ATT_MAXOCCURS1_D = attCount++; 227 int ATT_MEMBER_T_N = attCount++; 228 int ATT_MINOCCURS_D = attCount++; 229 int ATT_MINOCCURS1_D = attCount++; 230 int ATT_MIXED_D = attCount++; 231 int ATT_MIXED_N = attCount++; 232 int ATT_NAME_R = attCount++; 233 int ATT_NAMESPACE_D = attCount++; 234 int ATT_NAMESPACE_N = attCount++; 235 int ATT_NILLABLE_D = attCount++; 236 int ATT_PROCESS_C_D = attCount++; 237 int ATT_PUBLIC_R = attCount++; 238 int ATT_REF_R = attCount++; 239 int ATT_REFER_R = attCount++; 240 int ATT_SCHEMA_L_R = attCount++; 241 int ATT_SCHEMA_L_N = attCount++; 242 int ATT_SOURCE_N = attCount++; 243 int ATT_SUBSTITUTION_G_N = attCount++; 244 int ATT_SYSTEM_N = attCount++; 245 int ATT_TARGET_N_N = attCount++; 246 int ATT_TYPE_N = attCount++; 247 int ATT_USE_D = attCount++; 248 int ATT_VALUE_NNI_N = attCount++; 249 int ATT_VALUE_PI_N = attCount++; 250 int ATT_VALUE_STR_N = attCount++; 251 int ATT_VALUE_WS_N = attCount++; 252 int ATT_VERSION_N = attCount++; 253 int ATT_XML_LANG = attCount++; 254 int ATT_XPATH_R = attCount++; 255 int ATT_XPATH1_R = attCount++; 256 257 OneAttr[] allAttrs = new OneAttr[attCount]; 259 allAttrs[ATT_ABSTRACT_D] = new OneAttr(SchemaSymbols.ATT_ABSTRACT, 260 DT_BOOLEAN, 261 ATTIDX_ABSTRACT, 262 Boolean.FALSE); 263 allAttrs[ATT_ATTRIBUTE_FD_D] = new OneAttr(SchemaSymbols.ATT_ATTRIBUTEFORMDEFAULT, 264 DT_FORM, 265 ATTIDX_AFORMDEFAULT, 266 INT_UNQUALIFIED); 267 allAttrs[ATT_BASE_R] = new OneAttr(SchemaSymbols.ATT_BASE, 268 DT_QNAME, 269 ATTIDX_BASE, 270 null); 271 allAttrs[ATT_BASE_N] = new OneAttr(SchemaSymbols.ATT_BASE, 272 DT_QNAME, 273 ATTIDX_BASE, 274 null); 275 allAttrs[ATT_BLOCK_N] = new OneAttr(SchemaSymbols.ATT_BLOCK, 276 DT_BLOCK, 277 ATTIDX_BLOCK, 278 null); 279 allAttrs[ATT_BLOCK1_N] = new OneAttr(SchemaSymbols.ATT_BLOCK, 280 DT_BLOCK1, 281 ATTIDX_BLOCK, 282 null); 283 allAttrs[ATT_BLOCK_D_D] = new OneAttr(SchemaSymbols.ATT_BLOCKDEFAULT, 284 DT_BLOCK, 285 ATTIDX_BLOCKDEFAULT, 286 INT_EMPTY_SET); 287 allAttrs[ATT_DEFAULT_N] = new OneAttr(SchemaSymbols.ATT_DEFAULT, 288 DT_STRING, 289 ATTIDX_DEFAULT, 290 null); 291 allAttrs[ATT_ELEMENT_FD_D] = new OneAttr(SchemaSymbols.ATT_ELEMENTFORMDEFAULT, 292 DT_FORM, 293 ATTIDX_EFORMDEFAULT, 294 INT_UNQUALIFIED); 295 allAttrs[ATT_FINAL_N] = new OneAttr(SchemaSymbols.ATT_FINAL, 296 DT_FINAL, 297 ATTIDX_FINAL, 298 null); 299 allAttrs[ATT_FINAL1_N] = new OneAttr(SchemaSymbols.ATT_FINAL, 300 DT_FINAL1, 301 ATTIDX_FINAL, 302 null); 303 allAttrs[ATT_FINAL_D_D] = new OneAttr(SchemaSymbols.ATT_FINALDEFAULT, 304 DT_FINAL2, 305 ATTIDX_FINALDEFAULT, 306 INT_EMPTY_SET); 307 allAttrs[ATT_FIXED_N] = new OneAttr(SchemaSymbols.ATT_FIXED, 308 DT_STRING, 309 ATTIDX_FIXED, 310 null); 311 allAttrs[ATT_FIXED_D] = new OneAttr(SchemaSymbols.ATT_FIXED, 312 DT_BOOLEAN, 313 ATTIDX_FIXED, 314 Boolean.FALSE); 315 allAttrs[ATT_FORM_N] = new OneAttr(SchemaSymbols.ATT_FORM, 316 DT_FORM, 317 ATTIDX_FORM, 318 null); 319 allAttrs[ATT_ID_N] = new OneAttr(SchemaSymbols.ATT_ID, 320 DT_ID, 321 ATTIDX_ID, 322 null); 323 allAttrs[ATT_ITEMTYPE_N] = new OneAttr(SchemaSymbols.ATT_ITEMTYPE, 324 DT_QNAME, 325 ATTIDX_ITEMTYPE, 326 null); 327 allAttrs[ATT_MAXOCCURS_D] = new OneAttr(SchemaSymbols.ATT_MAXOCCURS, 328 DT_MAXOCCURS, 329 ATTIDX_MAXOCCURS, 330 fXIntPool.getXInt(1)); 331 allAttrs[ATT_MAXOCCURS1_D] = new OneAttr(SchemaSymbols.ATT_MAXOCCURS, 332 DT_MAXOCCURS1, 333 ATTIDX_MAXOCCURS, 334 fXIntPool.getXInt(1)); 335 allAttrs[ATT_MEMBER_T_N] = new OneAttr(SchemaSymbols.ATT_MEMBERTYPES, 336 DT_MEMBERTYPES, 337 ATTIDX_MEMBERTYPES, 338 null); 339 allAttrs[ATT_MINOCCURS_D] = new OneAttr(SchemaSymbols.ATT_MINOCCURS, 340 DT_NONNEGINT, 341 ATTIDX_MINOCCURS, 342 fXIntPool.getXInt(1)); 343 allAttrs[ATT_MINOCCURS1_D] = new OneAttr(SchemaSymbols.ATT_MINOCCURS, 344 DT_MINOCCURS1, 345 ATTIDX_MINOCCURS, 346 fXIntPool.getXInt(1)); 347 allAttrs[ATT_MIXED_D] = new OneAttr(SchemaSymbols.ATT_MIXED, 348 DT_BOOLEAN, 349 ATTIDX_MIXED, 350 Boolean.FALSE); 351 allAttrs[ATT_MIXED_N] = new OneAttr(SchemaSymbols.ATT_MIXED, 352 DT_BOOLEAN, 353 ATTIDX_MIXED, 354 null); 355 allAttrs[ATT_NAME_R] = new OneAttr(SchemaSymbols.ATT_NAME, 356 DT_NCNAME, 357 ATTIDX_NAME, 358 null); 359 allAttrs[ATT_NAMESPACE_D] = new OneAttr(SchemaSymbols.ATT_NAMESPACE, 360 DT_NAMESPACE, 361 ATTIDX_NAMESPACE, 362 INT_ANY_ANY); 363 allAttrs[ATT_NAMESPACE_N] = new OneAttr(SchemaSymbols.ATT_NAMESPACE, 364 DT_ANYURI, 365 ATTIDX_NAMESPACE, 366 null); 367 allAttrs[ATT_NILLABLE_D] = new OneAttr(SchemaSymbols.ATT_NILLABLE, 368 DT_BOOLEAN, 369 ATTIDX_NILLABLE, 370 Boolean.FALSE); 371 allAttrs[ATT_PROCESS_C_D] = new OneAttr(SchemaSymbols.ATT_PROCESSCONTENTS, 372 DT_PROCESSCONTENTS, 373 ATTIDX_PROCESSCONTENTS, 374 INT_ANY_STRICT); 375 allAttrs[ATT_PUBLIC_R] = new OneAttr(SchemaSymbols.ATT_PUBLIC, 376 DT_TOKEN, 377 ATTIDX_PUBLIC, 378 null); 379 allAttrs[ATT_REF_R] = new OneAttr(SchemaSymbols.ATT_REF, 380 DT_QNAME, 381 ATTIDX_REF, 382 null); 383 allAttrs[ATT_REFER_R] = new OneAttr(SchemaSymbols.ATT_REFER, 384 DT_QNAME, 385 ATTIDX_REFER, 386 null); 387 allAttrs[ATT_SCHEMA_L_R] = new OneAttr(SchemaSymbols.ATT_SCHEMALOCATION, 388 DT_ANYURI, 389 ATTIDX_SCHEMALOCATION, 390 null); 391 allAttrs[ATT_SCHEMA_L_N] = new OneAttr(SchemaSymbols.ATT_SCHEMALOCATION, 392 DT_ANYURI, 393 ATTIDX_SCHEMALOCATION, 394 null); 395 allAttrs[ATT_SOURCE_N] = new OneAttr(SchemaSymbols.ATT_SOURCE, 396 DT_ANYURI, 397 ATTIDX_SOURCE, 398 null); 399 allAttrs[ATT_SUBSTITUTION_G_N] = new OneAttr(SchemaSymbols.ATT_SUBSTITUTIONGROUP, 400 DT_QNAME, 401 ATTIDX_SUBSGROUP, 402 null); 403 allAttrs[ATT_SYSTEM_N] = new OneAttr(SchemaSymbols.ATT_SYSTEM, 404 DT_ANYURI, 405 ATTIDX_SYSTEM, 406 null); 407 allAttrs[ATT_TARGET_N_N] = new OneAttr(SchemaSymbols.ATT_TARGETNAMESPACE, 408 DT_ANYURI, 409 ATTIDX_TARGETNAMESPACE, 410 null); 411 allAttrs[ATT_TYPE_N] = new OneAttr(SchemaSymbols.ATT_TYPE, 412 DT_QNAME, 413 ATTIDX_TYPE, 414 null); 415 allAttrs[ATT_USE_D] = new OneAttr(SchemaSymbols.ATT_USE, 416 DT_USE, 417 ATTIDX_USE, 418 INT_USE_OPTIONAL); 419 allAttrs[ATT_VALUE_NNI_N] = new OneAttr(SchemaSymbols.ATT_VALUE, 420 DT_NONNEGINT, 421 ATTIDX_VALUE, 422 null); 423 allAttrs[ATT_VALUE_PI_N] = new OneAttr(SchemaSymbols.ATT_VALUE, 424 DT_POSINT, 425 ATTIDX_VALUE, 426 null); 427 allAttrs[ATT_VALUE_STR_N] = new OneAttr(SchemaSymbols.ATT_VALUE, 428 DT_STRING, 429 ATTIDX_VALUE, 430 null); 431 allAttrs[ATT_VALUE_WS_N] = new OneAttr(SchemaSymbols.ATT_VALUE, 432 DT_WHITESPACE, 433 ATTIDX_VALUE, 434 null); 435 allAttrs[ATT_VERSION_N] = new OneAttr(SchemaSymbols.ATT_VERSION, 436 DT_TOKEN, 437 ATTIDX_VERSION, 438 null); 439 allAttrs[ATT_XML_LANG] = new OneAttr(SchemaSymbols.ATT_XML_LANG, 440 DT_LANGUAGE, 441 ATTIDX_XML_LANG, 442 null); 443 allAttrs[ATT_XPATH_R] = new OneAttr(SchemaSymbols.ATT_XPATH, 444 DT_XPATH, 445 ATTIDX_XPATH, 446 null); 447 allAttrs[ATT_XPATH1_R] = new OneAttr(SchemaSymbols.ATT_XPATH, 448 DT_XPATH1, 449 ATTIDX_XPATH, 450 null); 451 452 Container attrList; 454 OneElement oneEle; 455 456 attrList = Container.getContainer(5); 458 attrList.put(SchemaSymbols.ATT_DEFAULT, allAttrs[ATT_DEFAULT_N]); 460 attrList.put(SchemaSymbols.ATT_FIXED, allAttrs[ATT_FIXED_N]); 462 attrList.put(SchemaSymbols.ATT_ID, allAttrs[ATT_ID_N]); 464 attrList.put(SchemaSymbols.ATT_NAME, allAttrs[ATT_NAME_R]); 466 attrList.put(SchemaSymbols.ATT_TYPE, allAttrs[ATT_TYPE_N]); 468 oneEle = new OneElement (attrList); 469 fEleAttrsMapG.put(SchemaSymbols.ELT_ATTRIBUTE, oneEle); 470 471 attrList = Container.getContainer(7); 473 attrList.put(SchemaSymbols.ATT_DEFAULT, allAttrs[ATT_DEFAULT_N]); 475 attrList.put(SchemaSymbols.ATT_FIXED, allAttrs[ATT_FIXED_N]); 477 attrList.put(SchemaSymbols.ATT_FORM, allAttrs[ATT_FORM_N]); 479 attrList.put(SchemaSymbols.ATT_ID, allAttrs[ATT_ID_N]); 481 attrList.put(SchemaSymbols.ATT_NAME, allAttrs[ATT_NAME_R]); 483 attrList.put(SchemaSymbols.ATT_TYPE, allAttrs[ATT_TYPE_N]); 485 attrList.put(SchemaSymbols.ATT_USE, allAttrs[ATT_USE_D]); 487 oneEle = new OneElement (attrList); 488 fEleAttrsMapL.put(ATTRIBUTE_N, oneEle); 489 490 attrList = Container.getContainer(5); 492 attrList.put(SchemaSymbols.ATT_DEFAULT, allAttrs[ATT_DEFAULT_N]); 494 attrList.put(SchemaSymbols.ATT_FIXED, allAttrs[ATT_FIXED_N]); 496 attrList.put(SchemaSymbols.ATT_ID, allAttrs[ATT_ID_N]); 498 attrList.put(SchemaSymbols.ATT_REF, allAttrs[ATT_REF_R]); 500 attrList.put(SchemaSymbols.ATT_USE, allAttrs[ATT_USE_D]); 502 oneEle = new OneElement (attrList); 503 fEleAttrsMapL.put(ATTRIBUTE_R, oneEle); 504 505 attrList = Container.getContainer(10); 507 attrList.put(SchemaSymbols.ATT_ABSTRACT, allAttrs[ATT_ABSTRACT_D]); 509 attrList.put(SchemaSymbols.ATT_BLOCK, allAttrs[ATT_BLOCK_N]); 511 attrList.put(SchemaSymbols.ATT_DEFAULT, allAttrs[ATT_DEFAULT_N]); 513 attrList.put(SchemaSymbols.ATT_FINAL, allAttrs[ATT_FINAL_N]); 515 attrList.put(SchemaSymbols.ATT_FIXED, allAttrs[ATT_FIXED_N]); 517 attrList.put(SchemaSymbols.ATT_ID, allAttrs[ATT_ID_N]); 519 attrList.put(SchemaSymbols.ATT_NAME, allAttrs[ATT_NAME_R]); 521 attrList.put(SchemaSymbols.ATT_NILLABLE, allAttrs[ATT_NILLABLE_D]); 523 attrList.put(SchemaSymbols.ATT_SUBSTITUTIONGROUP, allAttrs[ATT_SUBSTITUTION_G_N]); 525 attrList.put(SchemaSymbols.ATT_TYPE, allAttrs[ATT_TYPE_N]); 527 oneEle = new OneElement (attrList); 528 fEleAttrsMapG.put(SchemaSymbols.ELT_ELEMENT, oneEle); 529 530 attrList = Container.getContainer(10); 532 attrList.put(SchemaSymbols.ATT_BLOCK, allAttrs[ATT_BLOCK_N]); 534 attrList.put(SchemaSymbols.ATT_DEFAULT, allAttrs[ATT_DEFAULT_N]); 536 attrList.put(SchemaSymbols.ATT_FIXED, allAttrs[ATT_FIXED_N]); 538 attrList.put(SchemaSymbols.ATT_FORM, allAttrs[ATT_FORM_N]); 540 attrList.put(SchemaSymbols.ATT_ID, allAttrs[ATT_ID_N]); 542 attrList.put(SchemaSymbols.ATT_MAXOCCURS, allAttrs[ATT_MAXOCCURS_D]); 544 attrList.put(SchemaSymbols.ATT_MINOCCURS, allAttrs[ATT_MINOCCURS_D]); 546 attrList.put(SchemaSymbols.ATT_NAME, allAttrs[ATT_NAME_R]); 548 attrList.put(SchemaSymbols.ATT_NILLABLE, allAttrs[ATT_NILLABLE_D]); 550 attrList.put(SchemaSymbols.ATT_TYPE, allAttrs[ATT_TYPE_N]); 552 oneEle = new OneElement (attrList); 553 fEleAttrsMapL.put(ELEMENT_N, oneEle); 554 555 attrList = Container.getContainer(4); 557 attrList.put(SchemaSymbols.ATT_ID, allAttrs[ATT_ID_N]); 559 attrList.put(SchemaSymbols.ATT_MAXOCCURS, allAttrs[ATT_MAXOCCURS_D]); 561 attrList.put(SchemaSymbols.ATT_MINOCCURS, allAttrs[ATT_MINOCCURS_D]); 563 attrList.put(SchemaSymbols.ATT_REF, allAttrs[ATT_REF_R]); 565 oneEle = new OneElement (attrList); 566 fEleAttrsMapL.put(ELEMENT_R, oneEle); 567 568 attrList = Container.getContainer(6); 570 attrList.put(SchemaSymbols.ATT_ABSTRACT, allAttrs[ATT_ABSTRACT_D]); 572 attrList.put(SchemaSymbols.ATT_BLOCK, allAttrs[ATT_BLOCK1_N]); 574 attrList.put(SchemaSymbols.ATT_FINAL, allAttrs[ATT_FINAL_N]); 576 attrList.put(SchemaSymbols.ATT_ID, allAttrs[ATT_ID_N]); 578 attrList.put(SchemaSymbols.ATT_MIXED, allAttrs[ATT_MIXED_D]); 580 attrList.put(SchemaSymbols.ATT_NAME, allAttrs[ATT_NAME_R]); 582 oneEle = new OneElement (attrList); 583 fEleAttrsMapG.put(SchemaSymbols.ELT_COMPLEXTYPE, oneEle); 584 585 attrList = Container.getContainer(4); 587 attrList.put(SchemaSymbols.ATT_ID, allAttrs[ATT_ID_N]); 589 attrList.put(SchemaSymbols.ATT_NAME, allAttrs[ATT_NAME_R]); 591 attrList.put(SchemaSymbols.ATT_PUBLIC, allAttrs[ATT_PUBLIC_R]); 593 attrList.put(SchemaSymbols.ATT_SYSTEM, allAttrs[ATT_SYSTEM_N]); 595 oneEle = new OneElement (attrList); 596 fEleAttrsMapG.put(SchemaSymbols.ELT_NOTATION, oneEle); 597 598 599 attrList = Container.getContainer(2); 601 attrList.put(SchemaSymbols.ATT_ID, allAttrs[ATT_ID_N]); 603 attrList.put(SchemaSymbols.ATT_MIXED, allAttrs[ATT_MIXED_D]); 605 oneEle = new OneElement (attrList); 606 fEleAttrsMapL.put(SchemaSymbols.ELT_COMPLEXTYPE, oneEle); 607 608 attrList = Container.getContainer(1); 610 attrList.put(SchemaSymbols.ATT_ID, allAttrs[ATT_ID_N]); 612 oneEle = new OneElement (attrList); 613 fEleAttrsMapL.put(SchemaSymbols.ELT_SIMPLECONTENT, oneEle); 614 615 attrList = Container.getContainer(2); 617 attrList.put(SchemaSymbols.ATT_BASE, allAttrs[ATT_BASE_N]); 619 attrList.put(SchemaSymbols.ATT_ID, allAttrs[ATT_ID_N]); 621 oneEle = new OneElement (attrList); 622 fEleAttrsMapL.put(SchemaSymbols.ELT_RESTRICTION, oneEle); 623 624 attrList = Container.getContainer(2); 626 attrList.put(SchemaSymbols.ATT_BASE, allAttrs[ATT_BASE_R]); 628 attrList.put(SchemaSymbols.ATT_ID, allAttrs[ATT_ID_N]); 630 oneEle = new OneElement (attrList); 631 fEleAttrsMapL.put(SchemaSymbols.ELT_EXTENSION, oneEle); 632 633 attrList = Container.getContainer(2); 635 attrList.put(SchemaSymbols.ATT_ID, allAttrs[ATT_ID_N]); 637 attrList.put(SchemaSymbols.ATT_REF, allAttrs[ATT_REF_R]); 639 oneEle = new OneElement (attrList); 640 fEleAttrsMapL.put(SchemaSymbols.ELT_ATTRIBUTEGROUP, oneEle); 641 642 attrList = Container.getContainer(3); 644 attrList.put(SchemaSymbols.ATT_ID, allAttrs[ATT_ID_N]); 646 attrList.put(SchemaSymbols.ATT_NAMESPACE, allAttrs[ATT_NAMESPACE_D]); 648 attrList.put(SchemaSymbols.ATT_PROCESSCONTENTS, allAttrs[ATT_PROCESS_C_D]); 650 oneEle = new OneElement (attrList); 651 fEleAttrsMapL.put(SchemaSymbols.ELT_ANYATTRIBUTE, oneEle); 652 653 attrList = Container.getContainer(2); 655 attrList.put(SchemaSymbols.ATT_ID, allAttrs[ATT_ID_N]); 657 attrList.put(SchemaSymbols.ATT_MIXED, allAttrs[ATT_MIXED_N]); 659 oneEle = new OneElement (attrList); 660 fEleAttrsMapL.put(SchemaSymbols.ELT_COMPLEXCONTENT, oneEle); 661 662 attrList = Container.getContainer(2); 664 attrList.put(SchemaSymbols.ATT_ID, allAttrs[ATT_ID_N]); 666 attrList.put(SchemaSymbols.ATT_NAME, allAttrs[ATT_NAME_R]); 668 oneEle = new OneElement (attrList); 669 fEleAttrsMapG.put(SchemaSymbols.ELT_ATTRIBUTEGROUP, oneEle); 670 671 attrList = Container.getContainer(2); 673 attrList.put(SchemaSymbols.ATT_ID, allAttrs[ATT_ID_N]); 675 attrList.put(SchemaSymbols.ATT_NAME, allAttrs[ATT_NAME_R]); 677 oneEle = new OneElement (attrList); 678 fEleAttrsMapG.put(SchemaSymbols.ELT_GROUP, oneEle); 679 680 attrList = Container.getContainer(4); 682 attrList.put(SchemaSymbols.ATT_ID, allAttrs[ATT_ID_N]); 684 attrList.put(SchemaSymbols.ATT_MAXOCCURS, allAttrs[ATT_MAXOCCURS_D]); 686 attrList.put(SchemaSymbols.ATT_MINOCCURS, allAttrs[ATT_MINOCCURS_D]); 688 attrList.put(SchemaSymbols.ATT_REF, allAttrs[ATT_REF_R]); 690 oneEle = new OneElement (attrList); 691 fEleAttrsMapL.put(SchemaSymbols.ELT_GROUP, oneEle); 692 693 attrList = Container.getContainer(3); 695 attrList.put(SchemaSymbols.ATT_ID, allAttrs[ATT_ID_N]); 697 attrList.put(SchemaSymbols.ATT_MAXOCCURS, allAttrs[ATT_MAXOCCURS1_D]); 699 attrList.put(SchemaSymbols.ATT_MINOCCURS, allAttrs[ATT_MINOCCURS1_D]); 701 oneEle = new OneElement (attrList); 702 fEleAttrsMapL.put(SchemaSymbols.ELT_ALL, oneEle); 703 704 attrList = Container.getContainer(3); 706 attrList.put(SchemaSymbols.ATT_ID, allAttrs[ATT_ID_N]); 708 attrList.put(SchemaSymbols.ATT_MAXOCCURS, allAttrs[ATT_MAXOCCURS_D]); 710 attrList.put(SchemaSymbols.ATT_MINOCCURS, allAttrs[ATT_MINOCCURS_D]); 712 oneEle = new OneElement (attrList); 713 fEleAttrsMapL.put(SchemaSymbols.ELT_CHOICE, oneEle); 714 fEleAttrsMapL.put(SchemaSymbols.ELT_SEQUENCE, oneEle); 716 717 attrList = Container.getContainer(5); 719 attrList.put(SchemaSymbols.ATT_ID, allAttrs[ATT_ID_N]); 721 attrList.put(SchemaSymbols.ATT_MAXOCCURS, allAttrs[ATT_MAXOCCURS_D]); 723 attrList.put(SchemaSymbols.ATT_MINOCCURS, allAttrs[ATT_MINOCCURS_D]); 725 attrList.put(SchemaSymbols.ATT_NAMESPACE, allAttrs[ATT_NAMESPACE_D]); 727 attrList.put(SchemaSymbols.ATT_PROCESSCONTENTS, allAttrs[ATT_PROCESS_C_D]); 729 oneEle = new OneElement (attrList); 730 fEleAttrsMapL.put(SchemaSymbols.ELT_ANY, oneEle); 731 732 attrList = Container.getContainer(2); 734 attrList.put(SchemaSymbols.ATT_ID, allAttrs[ATT_ID_N]); 736 attrList.put(SchemaSymbols.ATT_NAME, allAttrs[ATT_NAME_R]); 738 oneEle = new OneElement (attrList); 739 fEleAttrsMapL.put(SchemaSymbols.ELT_UNIQUE, oneEle); 740 fEleAttrsMapL.put(SchemaSymbols.ELT_KEY, oneEle); 742 743 attrList = Container.getContainer(3); 745 attrList.put(SchemaSymbols.ATT_ID, allAttrs[ATT_ID_N]); 747 attrList.put(SchemaSymbols.ATT_NAME, allAttrs[ATT_NAME_R]); 749 attrList.put(SchemaSymbols.ATT_REFER, allAttrs[ATT_REFER_R]); 751 oneEle = new OneElement (attrList); 752 fEleAttrsMapL.put(SchemaSymbols.ELT_KEYREF, oneEle); 753 754 attrList = Container.getContainer(2); 756 attrList.put(SchemaSymbols.ATT_ID, allAttrs[ATT_ID_N]); 758 attrList.put(SchemaSymbols.ATT_XPATH, allAttrs[ATT_XPATH_R]); 760 oneEle = new OneElement (attrList); 761 fEleAttrsMapL.put(SchemaSymbols.ELT_SELECTOR, oneEle); 762 763 attrList = Container.getContainer(2); 765 attrList.put(SchemaSymbols.ATT_ID, allAttrs[ATT_ID_N]); 767 attrList.put(SchemaSymbols.ATT_XPATH, allAttrs[ATT_XPATH1_R]); 769 oneEle = new OneElement (attrList); 770 fEleAttrsMapL.put(SchemaSymbols.ELT_FIELD, oneEle); 771 772 attrList = Container.getContainer(1); 774 attrList.put(SchemaSymbols.ATT_ID, allAttrs[ATT_ID_N]); 776 oneEle = new OneElement (attrList); 777 fEleAttrsMapG.put(SchemaSymbols.ELT_ANNOTATION, oneEle); 778 fEleAttrsMapL.put(SchemaSymbols.ELT_ANNOTATION, oneEle); 780 781 attrList = Container.getContainer(1); 783 attrList.put(SchemaSymbols.ATT_SOURCE, allAttrs[ATT_SOURCE_N]); 785 oneEle = new OneElement (attrList); 786 fEleAttrsMapG.put(SchemaSymbols.ELT_APPINFO, oneEle); 787 fEleAttrsMapL.put(SchemaSymbols.ELT_APPINFO, oneEle); 788 789 attrList = Container.getContainer(2); 791 attrList.put(SchemaSymbols.ATT_SOURCE, allAttrs[ATT_SOURCE_N]); 793 attrList.put(SchemaSymbols.ATT_XML_LANG, allAttrs[ATT_XML_LANG]); 795 oneEle = new OneElement (attrList); 796 fEleAttrsMapG.put(SchemaSymbols.ELT_DOCUMENTATION, oneEle); 797 fEleAttrsMapL.put(SchemaSymbols.ELT_DOCUMENTATION, oneEle); 798 799 attrList = Container.getContainer(3); 801 attrList.put(SchemaSymbols.ATT_FINAL, allAttrs[ATT_FINAL1_N]); 803 attrList.put(SchemaSymbols.ATT_ID, allAttrs[ATT_ID_N]); 805 attrList.put(SchemaSymbols.ATT_NAME, allAttrs[ATT_NAME_R]); 807 oneEle = new OneElement (attrList); 808 fEleAttrsMapG.put(SchemaSymbols.ELT_SIMPLETYPE, oneEle); 809 810 attrList = Container.getContainer(2); 812 attrList.put(SchemaSymbols.ATT_FINAL, allAttrs[ATT_FINAL1_N]); 814 attrList.put(SchemaSymbols.ATT_ID, allAttrs[ATT_ID_N]); 816 oneEle = new OneElement (attrList); 817 fEleAttrsMapL.put(SchemaSymbols.ELT_SIMPLETYPE, oneEle); 818 819 822 attrList = Container.getContainer(2); 824 attrList.put(SchemaSymbols.ATT_ID, allAttrs[ATT_ID_N]); 826 attrList.put(SchemaSymbols.ATT_ITEMTYPE, allAttrs[ATT_ITEMTYPE_N]); 828 oneEle = new OneElement (attrList); 829 fEleAttrsMapL.put(SchemaSymbols.ELT_LIST, oneEle); 830 831 attrList = Container.getContainer(2); 833 attrList.put(SchemaSymbols.ATT_ID, allAttrs[ATT_ID_N]); 835 attrList.put(SchemaSymbols.ATT_MEMBERTYPES, allAttrs[ATT_MEMBER_T_N]); 837 oneEle = new OneElement (attrList); 838 fEleAttrsMapL.put(SchemaSymbols.ELT_UNION, oneEle); 839 840 attrList = Container.getContainer(8); 842 attrList.put(SchemaSymbols.ATT_ATTRIBUTEFORMDEFAULT, allAttrs[ATT_ATTRIBUTE_FD_D]); 844 attrList.put(SchemaSymbols.ATT_BLOCKDEFAULT, allAttrs[ATT_BLOCK_D_D]); 846 attrList.put(SchemaSymbols.ATT_ELEMENTFORMDEFAULT, allAttrs[ATT_ELEMENT_FD_D]); 848 attrList.put(SchemaSymbols.ATT_FINALDEFAULT, allAttrs[ATT_FINAL_D_D]); 850 attrList.put(SchemaSymbols.ATT_ID, allAttrs[ATT_ID_N]); 852 attrList.put(SchemaSymbols.ATT_TARGETNAMESPACE, allAttrs[ATT_TARGET_N_N]); 854 attrList.put(SchemaSymbols.ATT_VERSION, allAttrs[ATT_VERSION_N]); 856 attrList.put(SchemaSymbols.ATT_XML_LANG, allAttrs[ATT_XML_LANG]); 858 oneEle = new OneElement (attrList); 859 fEleAttrsMapG.put(SchemaSymbols.ELT_SCHEMA, oneEle); 860 861 attrList = Container.getContainer(2); 863 attrList.put(SchemaSymbols.ATT_ID, allAttrs[ATT_ID_N]); 865 attrList.put(SchemaSymbols.ATT_SCHEMALOCATION, allAttrs[ATT_SCHEMA_L_R]); 867 oneEle = new OneElement (attrList); 868 fEleAttrsMapG.put(SchemaSymbols.ELT_INCLUDE, oneEle); 869 fEleAttrsMapG.put(SchemaSymbols.ELT_REDEFINE, oneEle); 871 872 attrList = Container.getContainer(3); 874 attrList.put(SchemaSymbols.ATT_ID, allAttrs[ATT_ID_N]); 876 attrList.put(SchemaSymbols.ATT_NAMESPACE, allAttrs[ATT_NAMESPACE_N]); 878 attrList.put(SchemaSymbols.ATT_SCHEMALOCATION, allAttrs[ATT_SCHEMA_L_N]); 880 oneEle = new OneElement (attrList); 881 fEleAttrsMapG.put(SchemaSymbols.ELT_IMPORT, oneEle); 882 883 attrList = Container.getContainer(3); 885 attrList.put(SchemaSymbols.ATT_ID, allAttrs[ATT_ID_N]); 887 attrList.put(SchemaSymbols.ATT_VALUE, allAttrs[ATT_VALUE_NNI_N]); 889 attrList.put(SchemaSymbols.ATT_FIXED, allAttrs[ATT_FIXED_D]); 891 oneEle = new OneElement (attrList); 892 fEleAttrsMapL.put(SchemaSymbols.ELT_LENGTH, oneEle); 893 fEleAttrsMapL.put(SchemaSymbols.ELT_MINLENGTH, oneEle); 895 fEleAttrsMapL.put(SchemaSymbols.ELT_MAXLENGTH, oneEle); 897 fEleAttrsMapL.put(SchemaSymbols.ELT_FRACTIONDIGITS, oneEle); 899 900 attrList = Container.getContainer(3); 902 attrList.put(SchemaSymbols.ATT_ID, allAttrs[ATT_ID_N]); 904 attrList.put(SchemaSymbols.ATT_VALUE, allAttrs[ATT_VALUE_PI_N]); 906 attrList.put(SchemaSymbols.ATT_FIXED, allAttrs[ATT_FIXED_D]); 908 oneEle = new OneElement (attrList); 909 fEleAttrsMapL.put(SchemaSymbols.ELT_TOTALDIGITS, oneEle); 910 911 attrList = Container.getContainer(2); 913 attrList.put(SchemaSymbols.ATT_ID, allAttrs[ATT_ID_N]); 915 attrList.put(SchemaSymbols.ATT_VALUE, allAttrs[ATT_VALUE_STR_N]); 917 oneEle = new OneElement (attrList); 918 fEleAttrsMapL.put(SchemaSymbols.ELT_PATTERN, oneEle); 919 920 attrList = Container.getContainer(2); 922 attrList.put(SchemaSymbols.ATT_ID, allAttrs[ATT_ID_N]); 924 attrList.put(SchemaSymbols.ATT_VALUE, allAttrs[ATT_VALUE_STR_N]); 926 oneEle = new OneElement (attrList); 927 fEleAttrsMapL.put(SchemaSymbols.ELT_ENUMERATION, oneEle); 928 929 attrList = Container.getContainer(3); 931 attrList.put(SchemaSymbols.ATT_ID, allAttrs[ATT_ID_N]); 933 attrList.put(SchemaSymbols.ATT_VALUE, allAttrs[ATT_VALUE_WS_N]); 935 attrList.put(SchemaSymbols.ATT_FIXED, allAttrs[ATT_FIXED_D]); 937 oneEle = new OneElement (attrList); 938 fEleAttrsMapL.put(SchemaSymbols.ELT_WHITESPACE, oneEle); 939 940 attrList = Container.getContainer(3); 942 attrList.put(SchemaSymbols.ATT_ID, allAttrs[ATT_ID_N]); 944 attrList.put(SchemaSymbols.ATT_VALUE, allAttrs[ATT_VALUE_STR_N]); 946 attrList.put(SchemaSymbols.ATT_FIXED, allAttrs[ATT_FIXED_D]); 948 oneEle = new OneElement (attrList); 949 fEleAttrsMapL.put(SchemaSymbols.ELT_MAXINCLUSIVE, oneEle); 950 fEleAttrsMapL.put(SchemaSymbols.ELT_MAXEXCLUSIVE, oneEle); 952 fEleAttrsMapL.put(SchemaSymbols.ELT_MININCLUSIVE, oneEle); 954 fEleAttrsMapL.put(SchemaSymbols.ELT_MINEXCLUSIVE, oneEle); 956 } 957 958 protected XSDHandler fSchemaHandler = null; 960 961 protected SymbolTable fSymbolTable = null; 963 964 protected Hashtable fNonSchemaAttrs = new Hashtable (); 966 967 protected Vector fNamespaceList = new Vector (); 969 970 protected boolean[] fSeen = new boolean[ATTIDX_COUNT]; 972 private static boolean[] fSeenTemp = new boolean[ATTIDX_COUNT]; 973 974 public XSAttributeChecker(XSDHandler schemaHandler) { 976 fSchemaHandler = schemaHandler; 977 } 978 979 public void reset(SymbolTable symbolTable) { 980 fSymbolTable = symbolTable; 981 fNonSchemaAttrs.clear(); 982 } 983 984 994 public Object [] checkAttributes(Element element, boolean isGlobal, 995 XSDocumentInfo schemaDoc) { 996 return checkAttributes(element, isGlobal, schemaDoc, false); 997 } 998 999 1013 public Object [] checkAttributes(Element element, boolean isGlobal, 1014 XSDocumentInfo schemaDoc, boolean enumAsQName) { 1015 if (element == null) 1016 return null; 1017 1018 Attr [] attrs = DOMUtil.getAttrs(element); 1020 1021 resolveNamespace(element, attrs, schemaDoc.fNamespaceSupport); 1023 1024 String uri = DOMUtil.getNamespaceURI(element); 1025 String elName = DOMUtil.getLocalName(element); 1026 1027 if (!SchemaSymbols.URI_SCHEMAFORSCHEMA.equals(uri)) { 1028 reportSchemaError("s4s-elt-schema-ns", new Object [] {elName}, element); 1029 } 1030 1031 Hashtable eleAttrsMap = fEleAttrsMapG; 1032 String lookupName = elName; 1033 1034 if (!isGlobal) { 1039 eleAttrsMap = fEleAttrsMapL; 1040 if (elName.equals(SchemaSymbols.ELT_ELEMENT)) { 1041 if (DOMUtil.getAttr(element, SchemaSymbols.ATT_REF) != null) 1042 lookupName = ELEMENT_R; 1043 else 1044 lookupName = ELEMENT_N; 1045 } else if (elName.equals(SchemaSymbols.ELT_ATTRIBUTE)) { 1046 if (DOMUtil.getAttr(element, SchemaSymbols.ATT_REF) != null) 1047 lookupName = ATTRIBUTE_R; 1048 else 1049 lookupName = ATTRIBUTE_N; 1050 } 1051 } 1052 1053 OneElement oneEle = (OneElement)eleAttrsMap.get(lookupName); 1055 if (oneEle == null) { 1056 reportSchemaError ("s4s-elt-invalid", new Object [] {elName}, element); 1060 return null; 1061 } 1062 1063 Object [] attrValues = getAvailableArray(); 1065 long fromDefault = 0; 1067 Container attrList = oneEle.attrList; 1068 1069 System.arraycopy(fSeenTemp, 0, fSeen, 0, ATTIDX_COUNT); 1071 1072 int length = attrs.length; 1074 Attr sattr = null; 1075 for (int i = 0; i < length; i++) { 1076 sattr = attrs[i]; 1077 String attrName = sattr.getName(); 1080 String attrURI = DOMUtil.getNamespaceURI(sattr); 1081 String attrVal = DOMUtil.getValue(sattr); 1082 1083 if (attrName.startsWith("xml")) { 1084 String attrPrefix = DOMUtil.getPrefix(sattr); 1085 if ("xmlns".equals(attrPrefix) || "xmlns".equals(attrName)) { 1087 continue; 1088 } 1089 else if (SchemaSymbols.ATT_XML_LANG.equals(attrName) && 1093 (SchemaSymbols.ELT_SCHEMA.equals(elName) || 1094 SchemaSymbols.ELT_DOCUMENTATION.equals(elName))) { 1095 attrURI = null; 1096 } 1097 } 1098 1099 if (attrURI != null && attrURI.length() != 0) { 1102 if (attrURI.equals(SchemaSymbols.URI_SCHEMAFORSCHEMA) || 1105 !oneEle.allowNonSchemaAttr) { 1106 reportSchemaError ("s4s-att-not-allowed", new Object [] {elName, attrName}, element); 1107 } 1108 else { 1109 if(attrValues[ATTIDX_NONSCHEMA] == null) { 1110 attrValues[ATTIDX_NONSCHEMA] = new Vector (4,2); 1112 } 1113 ((Vector )attrValues[ATTIDX_NONSCHEMA]).addElement(attrName); 1114 ((Vector )attrValues[ATTIDX_NONSCHEMA]).addElement(attrVal); 1115 } 1134 continue; 1135 } 1136 1137 OneAttr oneAttr = (OneAttr)attrList.get(attrName); 1139 if (oneAttr == null) { 1140 reportSchemaError ("s4s-att-not-allowed", 1141 new Object [] {elName, attrName}, 1142 element); 1143 continue; 1144 } 1145 1146 fSeen[oneAttr.valueIndex] = true; 1148 1149 try { 1151 if (oneAttr.dvIndex >= 0) { 1155 if (oneAttr.dvIndex != DT_STRING && 1156 oneAttr.dvIndex != DT_XPATH && 1157 oneAttr.dvIndex != DT_XPATH1) { 1158 XSSimpleType dv = fExtraDVs[oneAttr.dvIndex]; 1159 Object avalue = dv.validate(attrVal, schemaDoc.fValidationContext, null); 1160 if (oneAttr.dvIndex == DT_QNAME) { 1162 QName qname = (QName)avalue; 1163 if(qname.prefix == XMLSymbols.EMPTY_STRING && qname.uri == null && schemaDoc.fIsChameleonSchema) 1164 qname.uri = schemaDoc.fTargetNamespace; 1165 } 1166 attrValues[oneAttr.valueIndex] = avalue; 1167 } else { 1168 attrValues[oneAttr.valueIndex] = attrVal; 1169 } 1170 } 1171 else { 1172 attrValues[oneAttr.valueIndex] = validate(attrValues, attrName, attrVal, oneAttr.dvIndex, schemaDoc); 1173 } 1174 } catch (InvalidDatatypeValueException ide) { 1175 reportSchemaError ("s4s-att-invalid-value", 1176 new Object [] {elName, attrName, ide.getMessage()}, 1177 element); 1178 if (oneAttr.dfltValue != null) 1179 attrValues[oneAttr.valueIndex] = oneAttr.dfltValue; 1181 } 1182 1183 if (elName.equals(SchemaSymbols.ELT_ENUMERATION) && enumAsQName) { 1186 attrValues[ATTIDX_ENUMNSDECLS] = new SchemaNamespaceSupport(schemaDoc.fNamespaceSupport); 1187 } 1188 } 1189 1190 OneAttr[] reqAttrs = oneEle.attrList.values; 1192 for (int i = 0; i < reqAttrs.length; i++) { 1193 OneAttr oneAttr = reqAttrs[i]; 1194 1195 if (oneAttr.dfltValue != null && !fSeen[oneAttr.valueIndex]) { 1198 attrValues[oneAttr.valueIndex] = oneAttr.dfltValue; 1200 fromDefault |= (1<<oneAttr.valueIndex); 1201 } 1202 } 1203 1204 attrValues[ATTIDX_FROMDEFAULT] = new Long (fromDefault); 1205 1207 if (attrValues[ATTIDX_MAXOCCURS] != null) { 1210 int min = ((XInt)attrValues[ATTIDX_MINOCCURS]).intValue(); 1211 int max = ((XInt)attrValues[ATTIDX_MAXOCCURS]).intValue(); 1212 if (max != SchemaSymbols.OCCURRENCE_UNBOUNDED) { 1213 if (min > max) { 1214 reportSchemaError ("p-props-correct.2.1", 1215 new Object [] {elName, attrValues[ATTIDX_MINOCCURS], attrValues[ATTIDX_MAXOCCURS]}, 1216 element); 1217 attrValues[ATTIDX_MINOCCURS] = attrValues[ATTIDX_MAXOCCURS]; 1218 } 1219 } 1220 } 1221 1222 return attrValues; 1223 } 1224 1225 private Object validate(Object [] attrValues, String attr, String ivalue, int dvIndex, 1226 XSDocumentInfo schemaDoc) throws InvalidDatatypeValueException { 1227 if (ivalue == null) 1228 return null; 1229 1230 1241 String value = ivalue.trim(); 1242 Object retValue = null; 1243 Vector memberType; 1244 int choice; 1245 1246 switch (dvIndex) { 1247 case DT_BOOLEAN: 1248 if (value.equals(SchemaSymbols.ATTVAL_FALSE) || 1249 value.equals(SchemaSymbols.ATTVAL_FALSE_0)) { 1250 retValue = Boolean.FALSE; 1251 } else if (value.equals(SchemaSymbols.ATTVAL_TRUE) || 1252 value.equals(SchemaSymbols.ATTVAL_TRUE_1)) { 1253 retValue = Boolean.TRUE; 1254 } else { 1255 throw new InvalidDatatypeValueException("cvc-datatype-valid.1.2.1", new Object []{value, "boolean"}); 1256 } 1257 break; 1258 case DT_NONNEGINT: 1259 try { 1260 if (value.length() > 0 && value.charAt(0) == '+') 1261 value = value.substring(1); 1262 retValue = fXIntPool.getXInt(Integer.parseInt(value)); 1263 } catch (NumberFormatException e) { 1264 throw new InvalidDatatypeValueException("cvc-datatype-valid.1.2.1", new Object []{value, "nonNegativeInteger"}); 1265 } 1266 if (((XInt)retValue).intValue() < 0) 1267 throw new InvalidDatatypeValueException("cvc-datatype-valid.1.2.1", new Object []{value, "nonNegativeInteger"}); 1268 break; 1269 case DT_POSINT: 1270 try { 1271 if (value.length() > 0 && value.charAt(0) == '+') 1272 value = value.substring(1); 1273 retValue = fXIntPool.getXInt(Integer.parseInt(value)); 1274 } catch (NumberFormatException e) { 1275 throw new InvalidDatatypeValueException("cvc-datatype-valid.1.2.1", new Object []{value, "positiveInteger"}); 1276 } 1277 if (((XInt)retValue).intValue() <= 0) 1278 throw new InvalidDatatypeValueException("cvc-datatype-valid.1.2.1", new Object []{value, "positiveInteger"}); 1279 break; 1280 case DT_BLOCK: 1281 choice = 0; 1283 if (value.equals (SchemaSymbols.ATTVAL_POUNDALL)) { 1284 choice = XSConstants.DERIVATION_SUBSTITUTION|XSConstants.DERIVATION_EXTENSION| 1285 XSConstants.DERIVATION_RESTRICTION|XSConstants.DERIVATION_LIST| 1286 XSConstants.DERIVATION_UNION; 1287 } 1288 else { 1289 StringTokenizer t = new StringTokenizer (value); 1291 while (t.hasMoreTokens()) { 1292 String token = t.nextToken (); 1293 1294 if (token.equals (SchemaSymbols.ATTVAL_SUBSTITUTION)) { 1295 choice |= XSConstants.DERIVATION_SUBSTITUTION; 1296 } 1297 else if (token.equals (SchemaSymbols.ATTVAL_EXTENSION)) { 1298 choice |= XSConstants.DERIVATION_EXTENSION; 1299 } 1300 else if (token.equals (SchemaSymbols.ATTVAL_RESTRICTION)) { 1301 choice |= XSConstants.DERIVATION_RESTRICTION; 1302 } 1303 else if (token.equals (SchemaSymbols.ATTVAL_LIST)) { 1304 choice |= XSConstants.DERIVATION_LIST; 1305 } 1306 else if (token.equals (SchemaSymbols.ATTVAL_UNION)) { 1307 choice |= XSConstants.DERIVATION_RESTRICTION; 1308 } 1309 else { 1310 throw new InvalidDatatypeValueException("cvc-datatype-valid.1.2.3", new Object []{value, "(#all | List of (substitution | extension | restriction | list | union))"}); 1311 } 1312 } 1313 } 1314 retValue = fXIntPool.getXInt(choice); 1315 break; 1316 case DT_BLOCK1: 1317 case DT_FINAL: 1318 choice = 0; 1321 if (value.equals (SchemaSymbols.ATTVAL_POUNDALL)) { 1322 choice = XSConstants.DERIVATION_SUBSTITUTION|XSConstants.DERIVATION_EXTENSION| 1334 XSConstants.DERIVATION_RESTRICTION|XSConstants.DERIVATION_LIST| 1335 XSConstants.DERIVATION_UNION; 1336 } 1337 else { 1338 StringTokenizer t = new StringTokenizer (value); 1340 while (t.hasMoreTokens()) { 1341 String token = t.nextToken (); 1342 1343 if (token.equals (SchemaSymbols.ATTVAL_EXTENSION)) { 1344 choice |= XSConstants.DERIVATION_EXTENSION; 1345 } 1346 else if (token.equals (SchemaSymbols.ATTVAL_RESTRICTION)) { 1347 choice |= XSConstants.DERIVATION_RESTRICTION; 1348 } 1349 else { 1350 throw new InvalidDatatypeValueException("cvc-datatype-valid.1.2.3", new Object []{value, "(#all | List of (extension | restriction))"}); 1351 } 1352 } 1353 } 1354 retValue = fXIntPool.getXInt(choice); 1355 break; 1356 case DT_FINAL1: 1357 choice = 0; 1359 if (value.equals (SchemaSymbols.ATTVAL_POUNDALL)) { 1360 choice = XSConstants.DERIVATION_SUBSTITUTION|XSConstants.DERIVATION_EXTENSION| 1367 XSConstants.DERIVATION_RESTRICTION|XSConstants.DERIVATION_LIST| 1368 XSConstants.DERIVATION_UNION; 1369 } 1370 else { 1371 StringTokenizer t = new StringTokenizer (value); 1373 while (t.hasMoreTokens()) { 1374 String token = t.nextToken (); 1375 1376 if (token.equals (SchemaSymbols.ATTVAL_LIST)) { 1377 choice |= XSConstants.DERIVATION_LIST; 1378 } 1379 else if (token.equals (SchemaSymbols.ATTVAL_UNION)) { 1380 choice |= XSConstants.DERIVATION_UNION; 1381 } 1382 else if (token.equals (SchemaSymbols.ATTVAL_RESTRICTION)) { 1383 choice |= XSConstants.DERIVATION_RESTRICTION; 1384 } 1385 else { 1386 throw new InvalidDatatypeValueException("cvc-datatype-valid.1.2.3", new Object []{value, "(#all | List of (list | union | restriction))"}); 1387 } 1388 } 1389 } 1390 retValue = fXIntPool.getXInt(choice); 1391 break; 1392 case DT_FINAL2: 1393 choice = 0; 1395 if (value.equals (SchemaSymbols.ATTVAL_POUNDALL)) { 1396 choice = XSConstants.DERIVATION_SUBSTITUTION|XSConstants.DERIVATION_EXTENSION| 1403 XSConstants.DERIVATION_RESTRICTION|XSConstants.DERIVATION_LIST| 1404 XSConstants.DERIVATION_UNION; 1405 } 1406 else { 1407 StringTokenizer t = new StringTokenizer (value); 1409 while (t.hasMoreTokens()) { 1410 String token = t.nextToken (); 1411 1412 if (token.equals (SchemaSymbols.ATTVAL_EXTENSION)) { 1413 choice |= XSConstants.DERIVATION_EXTENSION; 1414 } 1415 else if (token.equals (SchemaSymbols.ATTVAL_RESTRICTION)) { 1416 choice |= XSConstants.DERIVATION_RESTRICTION; 1417 } 1418 else if (token.equals (SchemaSymbols.ATTVAL_LIST)) { 1419 choice |= XSConstants.DERIVATION_LIST; 1420 } 1421 else if (token.equals (SchemaSymbols.ATTVAL_UNION)) { 1422 choice |= XSConstants.DERIVATION_UNION; 1423 } 1424 else { 1425 throw new InvalidDatatypeValueException("cvc-datatype-valid.1.2.3", new Object []{value, "(#all | List of (extension | restriction | list | union))"}); 1426 } 1427 } 1428 } 1429 retValue = fXIntPool.getXInt(choice); 1430 break; 1431 case DT_FORM: 1432 if (value.equals (SchemaSymbols.ATTVAL_QUALIFIED)) 1434 retValue = INT_QUALIFIED; 1435 else if (value.equals (SchemaSymbols.ATTVAL_UNQUALIFIED)) 1436 retValue = INT_UNQUALIFIED; 1437 else 1438 throw new InvalidDatatypeValueException("cvc-enumeration-valid", 1439 new Object []{value, "(qualified | unqualified)"}); 1440 break; 1441 case DT_MAXOCCURS: 1442 if (value.equals(SchemaSymbols.ATTVAL_UNBOUNDED)) { 1444 retValue = INT_UNBOUNDED; 1445 } else { 1446 try { 1447 retValue = validate(attrValues, attr, value, DT_NONNEGINT, schemaDoc); 1448 } catch (NumberFormatException e) { 1449 throw new InvalidDatatypeValueException("cvc-datatype-valid.1.2.3", new Object []{value, "(nonNegativeInteger | unbounded)"}); 1450 } 1451 } 1452 break; 1453 case DT_MAXOCCURS1: 1454 if (value.equals("1")) 1456 retValue = fXIntPool.getXInt(1); 1457 else 1458 throw new InvalidDatatypeValueException("cvc-enumeration-valid", 1459 new Object []{value, "(1)"}); 1460 break; 1461 case DT_MEMBERTYPES: 1462 memberType = new Vector (); 1464 try { 1465 StringTokenizer t = new StringTokenizer (value); 1467 while (t.hasMoreTokens()) { 1468 String token = t.nextToken (); 1469 QName qname = (QName)fExtraDVs[DT_QNAME].validate(token, schemaDoc.fValidationContext, null); 1470 if(qname.prefix == XMLSymbols.EMPTY_STRING && qname.uri == null && schemaDoc.fIsChameleonSchema) 1472 qname.uri = schemaDoc.fTargetNamespace; 1473 memberType.addElement(qname); 1474 } 1475 retValue = memberType; 1476 } 1477 catch (InvalidDatatypeValueException ide) { 1478 throw new InvalidDatatypeValueException("cvc-datatype-valid.1.2.2", new Object []{value, "(List of QName)"}); 1479 } 1480 break; 1481 case DT_MINOCCURS1: 1482 if (value.equals("0")) 1484 retValue = fXIntPool.getXInt(0); 1485 else if (value.equals("1")) 1486 retValue = fXIntPool.getXInt(1); 1487 else 1488 throw new InvalidDatatypeValueException("cvc-enumeration-valid", 1489 new Object []{value, "(0 | 1)"}); 1490 break; 1491 case DT_NAMESPACE: 1492 if (value.equals(SchemaSymbols.ATTVAL_TWOPOUNDANY)) { 1494 retValue = INT_ANY_ANY; 1496 } else if (value.equals(SchemaSymbols.ATTVAL_TWOPOUNDOTHER)) { 1497 retValue = INT_ANY_NOT; 1499 String [] list = new String [2]; 1500 list[0] = schemaDoc.fTargetNamespace; 1501 list[1] = null; 1502 attrValues[ATTIDX_NAMESPACE_LIST] = list; 1503 } else { 1504 retValue = INT_ANY_LIST; 1506 1507 fNamespaceList.removeAllElements(); 1508 1509 StringTokenizer tokens = new StringTokenizer (value); 1512 String token; 1513 String tempNamespace; 1514 try { 1515 while (tokens.hasMoreTokens()) { 1516 token = tokens.nextToken(); 1517 if (token.equals(SchemaSymbols.ATTVAL_TWOPOUNDLOCAL)) { 1518 tempNamespace = null; 1519 } else if (token.equals(SchemaSymbols.ATTVAL_TWOPOUNDTARGETNS)) { 1520 tempNamespace = schemaDoc.fTargetNamespace; 1521 } else { 1522 fExtraDVs[DT_ANYURI].validate(token, schemaDoc.fValidationContext, null); 1525 tempNamespace = fSymbolTable.addSymbol(token); 1526 } 1527 1528 if (!fNamespaceList.contains(tempNamespace)) { 1530 fNamespaceList.addElement(tempNamespace); 1531 } 1532 } 1533 } catch (InvalidDatatypeValueException ide) { 1534 throw new InvalidDatatypeValueException("cvc-datatype-valid.1.2.3", new Object []{value, "((##any | ##other) | List of (anyURI | (##targetNamespace | ##local)) )"}); 1535 } 1536 1537 int num = fNamespaceList.size(); 1539 String [] list = new String [num]; 1540 fNamespaceList.copyInto(list); 1541 attrValues[ATTIDX_NAMESPACE_LIST] = list; 1542 } 1543 break; 1544 case DT_PROCESSCONTENTS: 1545 if (value.equals (SchemaSymbols.ATTVAL_STRICT)) 1547 retValue = INT_ANY_STRICT; 1548 else if (value.equals (SchemaSymbols.ATTVAL_LAX)) 1549 retValue = INT_ANY_LAX; 1550 else if (value.equals (SchemaSymbols.ATTVAL_SKIP)) 1551 retValue = INT_ANY_SKIP; 1552 else 1553 throw new InvalidDatatypeValueException("cvc-enumeration-valid", 1554 new Object []{value, "(lax | skip | strict)"}); 1555 break; 1556 case DT_USE: 1557 if (value.equals (SchemaSymbols.ATTVAL_OPTIONAL)) 1559 retValue = INT_USE_OPTIONAL; 1560 else if (value.equals (SchemaSymbols.ATTVAL_REQUIRED)) 1561 retValue = INT_USE_REQUIRED; 1562 else if (value.equals (SchemaSymbols.ATTVAL_PROHIBITED)) 1563 retValue = INT_USE_PROHIBITED; 1564 else 1565 throw new InvalidDatatypeValueException("cvc-enumeration-valid", 1566 new Object []{value, "(optional | prohibited | required)"}); 1567 break; 1568 case DT_WHITESPACE: 1569 if (value.equals (SchemaSymbols.ATTVAL_PRESERVE)) 1571 retValue = INT_WS_PRESERVE; 1572 else if (value.equals (SchemaSymbols.ATTVAL_REPLACE)) 1573 retValue = INT_WS_REPLACE; 1574 else if (value.equals (SchemaSymbols.ATTVAL_COLLAPSE)) 1575 retValue = INT_WS_COLLAPSE; 1576 else 1577 throw new InvalidDatatypeValueException("cvc-enumeration-valid", 1578 new Object []{value, "(preserve | replace | collapse)"}); 1579 break; 1580 } 1581 1582 return retValue; 1583 } 1584 1585 void reportSchemaError (String key, Object [] args, Element ele) { 1586 fSchemaHandler.reportSchemaError(key, args, ele); 1587 } 1588 1589 public void checkNonSchemaAttributes(XSGrammarBucket grammarBucket) { 1594 Enumeration keys = fNonSchemaAttrs.keys(); 1596 XSAttributeDecl attrDecl; 1597 while (keys.hasMoreElements()) { 1598 String attrRName = (String )keys.nextElement(); 1600 String attrURI = attrRName.substring(0,attrRName.indexOf(',')); 1601 String attrLocal = attrRName.substring(attrRName.indexOf(',')+1); 1602 SchemaGrammar sGrammar = grammarBucket.getGrammar(attrURI); 1604 if (sGrammar == null) 1605 continue; 1606 attrDecl = sGrammar.getGlobalAttributeDecl(attrLocal); 1608 if (attrDecl == null) 1609 continue; 1610 XSSimpleType dv = (XSSimpleType)attrDecl.getTypeDefinition(); 1611 if (dv == null) 1612 continue; 1613 1614 Vector values = (Vector )fNonSchemaAttrs.get(attrRName); 1616 String elName, attrVal; 1617 String attrName = (String )values.elementAt(0); 1618 int count = values.size(); 1620 for (int i = 1; i < count; i += 2) { 1621 elName = (String )values.elementAt(i); 1622 try { 1623 dv.validate((String )values.elementAt(i+1), null, null); 1627 } catch(InvalidDatatypeValueException ide) { 1628 reportSchemaError ("s4s-att-invalid-value", 1629 new Object [] {elName, attrName, ide.getMessage()}, 1630 null); 1631 } 1632 } 1633 } 1634 } 1635 1636 public static String normalize(String content, short ws) { 1638 int len = content == null ? 0 : content.length(); 1639 if (len == 0 || ws == XSSimpleType.WS_PRESERVE) 1640 return content; 1641 1642 StringBuffer sb = new StringBuffer (); 1643 if (ws == XSSimpleType.WS_REPLACE) { 1644 char ch; 1645 for (int i = 0; i < len; i++) { 1647 ch = content.charAt(i); 1648 if (ch != 0x9 && ch != 0xa && ch != 0xd) 1649 sb.append(ch); 1650 else 1651 sb.append((char)0x20); 1652 } 1653 } else { 1654 char ch; 1655 int i; 1656 boolean isLeading = true; 1657 for (i = 0; i < len; i++) { 1659 ch = content.charAt(i); 1660 if (ch != 0x9 && ch != 0xa && ch != 0xd && ch != 0x20) { 1662 sb.append(ch); 1663 isLeading = false; 1664 } 1665 else { 1666 for (; i < len-1; i++) { 1668 ch = content.charAt(i+1); 1669 if (ch != 0x9 && ch != 0xa && ch != 0xd && ch != 0x20) 1670 break; 1671 } 1672 if (i < len - 1 && !isLeading) 1674 sb.append((char)0x20); 1675 } 1676 } 1677 } 1678 1679 return sb.toString(); 1680 } 1681 1682 1687 static final int INIT_POOL_SIZE = 10; 1689 static final int INC_POOL_SIZE = 10; 1691 Object [][] fArrayPool = new Object [INIT_POOL_SIZE][ATTIDX_COUNT]; 1693 private static Object [] fTempArray = new Object [ATTIDX_COUNT]; 1696 int fPoolPos = 0; 1698 1699 protected Object [] getAvailableArray() { 1701 if (fArrayPool.length == fPoolPos) { 1703 fArrayPool = new Object [fPoolPos+INC_POOL_SIZE][]; 1705 for (int i = fPoolPos; i < fArrayPool.length; i++) 1707 fArrayPool[i] = new Object [ATTIDX_COUNT]; 1708 } 1709 Object [] retArray = fArrayPool[fPoolPos]; 1711 fArrayPool[fPoolPos++] = null; 1714 System.arraycopy(fTempArray, 0, retArray, 0, ATTIDX_COUNT-1); 1718 retArray[ATTIDX_ISRETURNED] = Boolean.FALSE; 1719 1720 return retArray; 1721 } 1722 1723 public void returnAttrArray(Object [] attrArray, XSDocumentInfo schemaDoc) { 1725 if (schemaDoc != null) 1727 schemaDoc.fNamespaceSupport.popContext(); 1728 1729 if (fPoolPos == 0 || 1733 attrArray == null || 1734 attrArray.length != ATTIDX_COUNT || 1735 ((Boolean )attrArray[ATTIDX_ISRETURNED]).booleanValue()) { 1736 return; 1737 } 1738 1739 attrArray[ATTIDX_ISRETURNED] = Boolean.TRUE; 1741 if(attrArray[ATTIDX_NONSCHEMA] != null) 1743 ((Vector )attrArray[ATTIDX_NONSCHEMA]).clear(); 1744 fArrayPool[--fPoolPos] = attrArray; 1746 } 1747 1748 public void resolveNamespace(Element element, Attr [] attrs, 1749 SchemaNamespaceSupport nsSupport) { 1750 nsSupport.pushContext(); 1752 1753 int length = attrs.length; 1755 Attr sattr = null; 1756 String rawname, prefix, uri; 1757 for (int i = 0; i < length; i++) { 1758 sattr = attrs[i]; 1759 rawname = DOMUtil.getName(sattr); 1760 prefix = null; 1761 if (rawname.equals(XMLSymbols.PREFIX_XMLNS)) 1762 prefix = XMLSymbols.EMPTY_STRING; 1763 else if (rawname.startsWith("xmlns:")) 1764 prefix = fSymbolTable.addSymbol(DOMUtil.getLocalName(sattr)); 1765 if (prefix != null) { 1766 uri = fSymbolTable.addSymbol(DOMUtil.getValue(sattr)); 1767 nsSupport.declarePrefix(prefix, uri.length()!=0 ? uri : null); 1768 } 1769 } 1770 } 1771} 1772 1773class OneAttr { 1774 public String name; 1776 public int dvIndex; 1778 public int valueIndex; 1780 public Object dfltValue; 1782 1783 public OneAttr(String name, int dvIndex, int valueIndex, Object dfltValue) { 1784 this.name = name; 1785 this.dvIndex = dvIndex; 1786 this.valueIndex = valueIndex; 1787 this.dfltValue = dfltValue; 1788 } 1789} 1790 1791class OneElement { 1792 public Container attrList; 1794 public boolean allowNonSchemaAttr; 1796 1797 public OneElement (Container attrList) { 1798 this(attrList, true); 1799 } 1800 1801 public OneElement (Container attrList, boolean allowNonSchemaAttr) { 1802 this.attrList = attrList; 1803 this.allowNonSchemaAttr = allowNonSchemaAttr; 1804 } 1805} 1806 1807abstract class Container { 1808 static final int THRESHOLD = 5; 1809 static Container getContainer(int size) { 1810 if (size > THRESHOLD) 1811 return new LargeContainer(size); 1812 else 1813 return new SmallContainer(size); 1814 } 1815 abstract void put(String key, OneAttr value); 1816 abstract OneAttr get(String key); 1817 1818 OneAttr[] values; 1819 int pos = 0; 1820} 1821 1822class SmallContainer extends Container { 1823 String [] keys; 1824 SmallContainer(int size) { 1825 keys = new String [size]; 1826 values = new OneAttr[size]; 1827 } 1828 void put(String key, OneAttr value) { 1829 keys[pos] = key; 1830 values[pos++] = value; 1831 } 1832 OneAttr get(String key) { 1833 for (int i = 0; i < pos; i++) { 1834 if (keys[i].equals(key)) { 1835 return values[i]; 1836 } 1837 } 1838 return null; 1839 } 1840} 1841 1842class LargeContainer extends Container { 1843 Hashtable items; 1844 LargeContainer(int size) { 1845 items = new Hashtable (size*2+1); 1846 values = new OneAttr[size]; 1847 } 1848 void put(String key, OneAttr value) { 1849 items.put(key, value); 1850 values[pos++] = value; 1851 } 1852 OneAttr get(String key) { 1853 OneAttr ret = (OneAttr)items.get(key); 1854 return ret; 1855 } 1856} 1857 | Popular Tags |