Source Code Cross Referenced for GeneralAttrCheck.java in  » Web-Server » Rimfaxe-Web-Server » org » apache » xerces » validators » schema » Java Source Code / Java DocumentationJava Source Code and Java Documentation

Java Source Code / Java Documentation
1. 6.0 JDK Core
2. 6.0 JDK Modules
3. 6.0 JDK Modules com.sun
4. 6.0 JDK Modules com.sun.java
5. 6.0 JDK Modules sun
6. 6.0 JDK Platform
7. Ajax
8. Apache Harmony Java SE
9. Aspect oriented
10. Authentication Authorization
11. Blogger System
12. Build
13. Byte Code
14. Cache
15. Chart
16. Chat
17. Code Analyzer
18. Collaboration
19. Content Management System
20. Database Client
21. Database DBMS
22. Database JDBC Connection Pool
23. Database ORM
24. Development
25. EJB Server geronimo
26. EJB Server GlassFish
27. EJB Server JBoss 4.2.1
28. EJB Server resin 3.1.5
29. ERP CRM Financial
30. ESB
31. Forum
32. GIS
33. Graphic Library
34. Groupware
35. HTML Parser
36. IDE
37. IDE Eclipse
38. IDE Netbeans
39. Installer
40. Internationalization Localization
41. Inversion of Control
42. Issue Tracking
43. J2EE
44. JBoss
45. JMS
46. JMX
47. Library
48. Mail Clients
49. Net
50. Parser
51. PDF
52. Portal
53. Profiler
54. Project Management
55. Report
56. RSS RDF
57. Rule Engine
58. Science
59. Scripting
60. Search Engine
61. Security
62. Sevlet Container
63. Source Control
64. Swing Library
65. Template Engine
66. Test Coverage
67. Testing
68. UML
69. Web Crawler
70. Web Framework
71. Web Mail
72. Web Server
73. Web Services
74. Web Services apache cxf 2.0.1
75. Web Services AXIS2
76. Wiki Engine
77. Workflow Engines
78. XML
79. XML UI
Java
Java Tutorial
Java Open Source
Jar File Download
Java Articles
Java Products
Java by API
Photoshop Tutorials
Maya Tutorials
Flash Tutorials
3ds-Max Tutorials
Illustrator Tutorials
GIMP Tutorials
C# / C Sharp
C# / CSharp Tutorial
C# / CSharp Open Source
ASP.Net
ASP.NET Tutorial
JavaScript DHTML
JavaScript Tutorial
JavaScript Reference
HTML / CSS
HTML CSS Reference
C / ANSI-C
C Tutorial
C++
C++ Tutorial
Ruby
PHP
Python
Python Tutorial
Python Open Source
SQL Server / T-SQL
SQL Server / T-SQL Tutorial
Oracle PL / SQL
Oracle PL/SQL Tutorial
PostgreSQL
SQL / MySQL
MySQL Tutorial
VB.Net
VB.Net Tutorial
Flash / Flex / ActionScript
VBA / Excel / Access / Word
XML
XML Tutorial
Microsoft Office PowerPoint 2007 Tutorial
Microsoft Office Excel 2007 Tutorial
Microsoft Office Word 2007 Tutorial
Java Source Code / Java Documentation » Web Server » Rimfaxe Web Server » org.apache.xerces.validators.schema 
Source Cross Referenced  Class Diagram Java Document (Java Doc) 


0001:        /*
0002:         * The Apache Software License, Version 1.1
0003:         *
0004:         *
0005:         * Copyright (c) 2000,2001 The Apache Software Foundation.
0006:         * All rights reserved.
0007:         *
0008:         * Redistribution and use in source and binary forms, with or without
0009:         * modification, are permitted provided that the following conditions
0010:         * are met:
0011:         *
0012:         * 1. Redistributions of source code must retain the above copyright
0013:         *    notice, this list of conditions and the following disclaimer.
0014:         *
0015:         * 2. Redistributions in binary form must reproduce the above copyright
0016:         *    notice, this list of conditions and the following disclaimer in
0017:         *    the documentation and/or other materials provided with the
0018:         *    distribution.
0019:         *
0020:         * 3. The end-user documentation included with the redistribution,
0021:         *    if any, must include the following acknowledgment:
0022:         *       "This product includes software developed by the
0023:         *        Apache Software Foundation (http://www.apache.org/)."
0024:         *    Alternately, this acknowledgment may appear in the software itself,
0025:         *    if and wherever such third-party acknowledgments normally appear.
0026:         *
0027:         * 4. The names "Xerces" and "Apache Software Foundation" must
0028:         *    not be used to endorse or promote products derived from this
0029:         *    software without prior written permission. For written
0030:         *    permission, please contact apache@apache.org.
0031:         *
0032:         * 5. Products derived from this software may not be called "Apache",
0033:         *    nor may "Apache" appear in their name, without prior written
0034:         *    permission of the Apache Software Foundation.
0035:         *
0036:         * THIS SOFTWARE IS PROVIDED ``AS IS'' AND ANY EXPRESSED OR IMPLIED
0037:         * WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES
0038:         * OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
0039:         * DISCLAIMED.  IN NO EVENT SHALL THE APACHE SOFTWARE FOUNDATION OR
0040:         * ITS CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
0041:         * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
0042:         * LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF
0043:         * USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND
0044:         * ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY,
0045:         * OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT
0046:         * OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
0047:         * SUCH DAMAGE.
0048:         * ====================================================================
0049:         *
0050:         * This software consists of voluntary contributions made by many
0051:         * individuals on behalf of the Apache Software Foundation and was
0052:         * originally based on software copyright (c) 1999, International
0053:         * Business Machines, Inc., http://www.apache.org.  For more
0054:         * information on the Apache Software Foundation, please see
0055:         * <http://www.apache.org/>.
0056:         */
0057:
0058:        package org.apache.xerces.validators.schema;
0059:
0060:        import java.util.*;
0061:        import org.w3c.dom.*;
0062:        import org.apache.xerces.validators.schema.SchemaSymbols;
0063:        import org.apache.xerces.validators.datatype.*;
0064:        import org.apache.xerces.framework.XMLErrorReporter;
0065:        import org.apache.xerces.validators.common.XMLAttributeDecl;
0066:        import org.apache.xerces.validators.common.GrammarResolver;
0067:        import org.apache.xerces.validators.common.Grammar;
0068:
0069:        /**
0070:         * Title:
0071:         * Description:
0072:         * Copyright:    Copyright (c) 2001
0073:         * @author:  Sandy Gao, IBM
0074:         * @version 1.0
0075:         */
0076:
0077:        public class GeneralAttrCheck {
0078:
0079:            // used to specify in which context the element appears: global or local
0080:            public static int ELE_CONTEXT_GLOBAL = 0;
0081:            public static int ELE_CONTEXT_LOCAL = 1;
0082:
0083:            // used to specify whether the attribute is optional,
0084:            // and whether it has a default value
0085:            public static int ATT_REQUIRED = 0;
0086:            public static int ATT_OPT_DFLT = 1;
0087:            public static int ATT_OPT_NODFLT = 2;
0088:
0089:            // the prefix to distinguish gloval vs. local; name vs. ref
0090:            protected static String PRE_GLOBAL = "G_";
0091:            protected static String PRE_LOC_NAME = "LN_";
0092:            protected static String PRE_LOC_REF = "LR_";
0093:
0094:            // used to store the map from element name to attribute list
0095:            protected static Hashtable fEleAttrsMap = new Hashtable();
0096:
0097:            // used to store extra datatype validators
0098:            protected static DatatypeValidator[] fExtraDVs = null;
0099:
0100:            // used to initialize fEleAttrsMap
0101:            // step 1: all possible data types
0102:            // DT_??? >= 0 : validate using a validator, which is initialized staticly
0103:            // DT_??? <  0 : validate directly, which is done in "validate()"
0104:            protected static int dtCount = 0;
0105:
0106:            protected static final int DT_ANYURI = dtCount++;
0107:            protected static final int DT_BOOLEAN = dtCount++;
0108:            protected static final int DT_ID = dtCount++;
0109:            protected static final int DT_NONNEGINT = dtCount++;
0110:            protected static final int DT_QNAME = dtCount++;
0111:            protected static final int DT_STRING = dtCount++;
0112:            protected static final int DT_TOKEN = dtCount++;
0113:            protected static final int DT_NCNAME = dtCount++;
0114:            protected static final int DT_XPATH = dtCount++;
0115:            protected static final int DT_XPATH1 = dtCount++;
0116:
0117:            protected static final int DT_BLOCK = -1;
0118:            protected static final int DT_BLOCK1 = DT_BLOCK - 1;
0119:            protected static final int DT_FINAL = DT_BLOCK1 - 1;
0120:            protected static final int DT_FINAL1 = DT_FINAL - 1;
0121:            protected static final int DT_FORM = DT_FINAL1 - 1;
0122:            protected static final int DT_MAXOCCURS = DT_FORM - 1;
0123:            protected static final int DT_MAXOCCURS1 = DT_MAXOCCURS - 1;
0124:            protected static final int DT_MEMBERTYPES = DT_MAXOCCURS1 - 1;
0125:            protected static final int DT_MINOCCURS1 = DT_MEMBERTYPES - 1;
0126:            protected static final int DT_NAMESPACE = DT_MINOCCURS1 - 1;
0127:            protected static final int DT_PROCESSCONTENTS = DT_NAMESPACE - 1;
0128:            protected static final int DT_PUBLIC = DT_PROCESSCONTENTS - 1;
0129:            protected static final int DT_USE = DT_PUBLIC - 1;
0130:            protected static final int DT_WHITESPACE = DT_USE - 1;
0131:
0132:            static {
0133:                fExtraDVs = new DatatypeValidator[dtCount];
0134:
0135:                // step 2: all possible attributes for all elements
0136:                int attCount = 0;
0137:                int ATT_ABSTRACT_D = attCount++;
0138:                int ATT_ATTRIBUTE_FD_D = attCount++;
0139:                int ATT_BASE_R = attCount++;
0140:                int ATT_BASE_N = attCount++;
0141:                int ATT_BLOCK_N = attCount++;
0142:                int ATT_BLOCK1_N = attCount++;
0143:                int ATT_BLOCK_D_D = attCount++;
0144:                int ATT_DEFAULT_N = attCount++;
0145:                int ATT_ELEMENT_FD_D = attCount++;
0146:                int ATT_FINAL_N = attCount++;
0147:                int ATT_FINAL1_N = attCount++;
0148:                int ATT_FINAL_D_D = attCount++;
0149:                int ATT_FIXED_N = attCount++;
0150:                int ATT_FIXED_D = attCount++;
0151:                int ATT_FORM_N = attCount++;
0152:                int ATT_ID_N = attCount++;
0153:                int ATT_ITEMTYPE_N = attCount++;
0154:                int ATT_MAXOCCURS_D = attCount++;
0155:                int ATT_MAXOCCURS1_D = attCount++;
0156:                int ATT_MEMBER_T_N = attCount++;
0157:                int ATT_MINOCCURS_D = attCount++;
0158:                int ATT_MINOCCURS1_D = attCount++;
0159:                int ATT_MIXED_D = attCount++;
0160:                int ATT_MIXED_N = attCount++;
0161:                int ATT_NAME_R = attCount++;
0162:                int ATT_NAMESPACE_D = attCount++;
0163:                int ATT_NAMESPACE_N = attCount++;
0164:                int ATT_NILLABLE_D = attCount++;
0165:                int ATT_PROCESS_C_D = attCount++;
0166:                int ATT_PUBLIC_R = attCount++;
0167:                int ATT_REF_R = attCount++;
0168:                int ATT_REFER_R = attCount++;
0169:                int ATT_SCHEMA_L_R = attCount++;
0170:                int ATT_SCHEMA_L_N = attCount++;
0171:                int ATT_SOURCE_N = attCount++;
0172:                int ATT_SUBSTITUTION_G_N = attCount++;
0173:                int ATT_SYSTEM_N = attCount++;
0174:                int ATT_TARGET_N_N = attCount++;
0175:                int ATT_TYPE_N = attCount++;
0176:                int ATT_USE_D = attCount++;
0177:                int ATT_VALUE_NNI_N = attCount++;
0178:                int ATT_VALUE_STR_N = attCount++;
0179:                int ATT_VALUE_WS_N = attCount++;
0180:                int ATT_VERSION_N = attCount++;
0181:                int ATT_XPATH_R = attCount++;
0182:                int ATT_XPATH1_R = attCount++;
0183:
0184:                // step 3: store all these attributes in an array
0185:                OneAttr[] allAttrs = new OneAttr[attCount];
0186:                allAttrs[ATT_ABSTRACT_D] = new OneAttr(
0187:                        SchemaSymbols.ATT_ABSTRACT, DT_BOOLEAN, ATT_OPT_DFLT,
0188:                        SchemaSymbols.ATTVAL_FALSE);
0189:                allAttrs[ATT_ATTRIBUTE_FD_D] = new OneAttr(
0190:                        SchemaSymbols.ATT_ATTRIBUTEFORMDEFAULT, DT_FORM,
0191:                        ATT_OPT_DFLT, SchemaSymbols.ATTVAL_UNQUALIFIED);
0192:                allAttrs[ATT_BASE_R] = new OneAttr(SchemaSymbols.ATT_BASE,
0193:                        DT_QNAME, ATT_REQUIRED, null);
0194:                allAttrs[ATT_BASE_N] = new OneAttr(SchemaSymbols.ATT_BASE,
0195:                        DT_QNAME, ATT_OPT_NODFLT, null);
0196:                allAttrs[ATT_BLOCK_N] = new OneAttr(SchemaSymbols.ATT_BLOCK,
0197:                        DT_BLOCK, ATT_OPT_NODFLT, null);
0198:                allAttrs[ATT_BLOCK1_N] = new OneAttr(SchemaSymbols.ATT_BLOCK,
0199:                        DT_BLOCK1, ATT_OPT_NODFLT, null);
0200:                allAttrs[ATT_BLOCK_D_D] = new OneAttr(
0201:                        SchemaSymbols.ATT_BLOCKDEFAULT, DT_BLOCK, ATT_OPT_DFLT,
0202:                        "");
0203:                allAttrs[ATT_DEFAULT_N] = new OneAttr(
0204:                        SchemaSymbols.ATT_DEFAULT, DT_STRING, ATT_OPT_NODFLT,
0205:                        null);
0206:                allAttrs[ATT_ELEMENT_FD_D] = new OneAttr(
0207:                        SchemaSymbols.ATT_ELEMENTFORMDEFAULT, DT_FORM,
0208:                        ATT_OPT_DFLT, SchemaSymbols.ATTVAL_UNQUALIFIED);
0209:                allAttrs[ATT_FINAL_N] = new OneAttr(SchemaSymbols.ATT_FINAL,
0210:                        DT_FINAL, ATT_OPT_NODFLT, null);
0211:                allAttrs[ATT_FINAL1_N] = new OneAttr(SchemaSymbols.ATT_FINAL,
0212:                        DT_FINAL1, ATT_OPT_NODFLT, null);
0213:                allAttrs[ATT_FINAL_D_D] = new OneAttr(
0214:                        SchemaSymbols.ATT_FINALDEFAULT, DT_FINAL, ATT_OPT_DFLT,
0215:                        "");
0216:                allAttrs[ATT_FIXED_N] = new OneAttr(SchemaSymbols.ATT_FIXED,
0217:                        DT_STRING, ATT_OPT_NODFLT, null);
0218:                allAttrs[ATT_FIXED_D] = new OneAttr(SchemaSymbols.ATT_FIXED,
0219:                        DT_BOOLEAN, ATT_OPT_DFLT, SchemaSymbols.ATTVAL_FALSE);
0220:                allAttrs[ATT_FORM_N] = new OneAttr(SchemaSymbols.ATT_FORM,
0221:                        DT_FORM, ATT_OPT_NODFLT, null);
0222:                allAttrs[ATT_ID_N] = new OneAttr(SchemaSymbols.ATT_ID, DT_ID,
0223:                        ATT_OPT_NODFLT, null);
0224:                allAttrs[ATT_ITEMTYPE_N] = new OneAttr(
0225:                        SchemaSymbols.ATT_ITEMTYPE, DT_QNAME, ATT_OPT_NODFLT,
0226:                        null);
0227:                allAttrs[ATT_MAXOCCURS_D] = new OneAttr(
0228:                        SchemaSymbols.ATT_MAXOCCURS, DT_MAXOCCURS,
0229:                        ATT_OPT_DFLT, "1");
0230:                allAttrs[ATT_MAXOCCURS1_D] = new OneAttr(
0231:                        SchemaSymbols.ATT_MAXOCCURS, DT_MAXOCCURS1,
0232:                        ATT_OPT_DFLT, "1");
0233:                allAttrs[ATT_MEMBER_T_N] = new OneAttr(
0234:                        SchemaSymbols.ATT_MEMBERTYPES, DT_MEMBERTYPES,
0235:                        ATT_OPT_NODFLT, null);
0236:                allAttrs[ATT_MINOCCURS_D] = new OneAttr(
0237:                        SchemaSymbols.ATT_MINOCCURS, DT_NONNEGINT,
0238:                        ATT_OPT_DFLT, "1");
0239:                allAttrs[ATT_MINOCCURS1_D] = new OneAttr(
0240:                        SchemaSymbols.ATT_MINOCCURS, DT_MINOCCURS1,
0241:                        ATT_OPT_DFLT, "1");
0242:                allAttrs[ATT_MIXED_D] = new OneAttr(SchemaSymbols.ATT_MIXED,
0243:                        DT_BOOLEAN, ATT_OPT_DFLT, SchemaSymbols.ATTVAL_FALSE);
0244:                allAttrs[ATT_MIXED_N] = new OneAttr(SchemaSymbols.ATT_MIXED,
0245:                        DT_BOOLEAN, ATT_OPT_NODFLT, null);
0246:                allAttrs[ATT_NAME_R] = new OneAttr(SchemaSymbols.ATT_NAME,
0247:                        DT_NCNAME, ATT_REQUIRED, null);
0248:                allAttrs[ATT_NAMESPACE_D] = new OneAttr(
0249:                        SchemaSymbols.ATT_NAMESPACE, DT_NAMESPACE,
0250:                        ATT_OPT_DFLT, SchemaSymbols.ATTVAL_TWOPOUNDANY);
0251:                allAttrs[ATT_NAMESPACE_N] = new OneAttr(
0252:                        SchemaSymbols.ATT_NAMESPACE, DT_ANYURI, ATT_OPT_NODFLT,
0253:                        null);
0254:                allAttrs[ATT_NILLABLE_D] = new OneAttr(
0255:                        SchemaSymbols.ATT_NILLABLE, DT_BOOLEAN, ATT_OPT_DFLT,
0256:                        SchemaSymbols.ATTVAL_FALSE);
0257:                allAttrs[ATT_PROCESS_C_D] = new OneAttr(
0258:                        SchemaSymbols.ATT_PROCESSCONTENTS, DT_PROCESSCONTENTS,
0259:                        ATT_OPT_DFLT, SchemaSymbols.ATTVAL_STRICT);
0260:                allAttrs[ATT_PUBLIC_R] = new OneAttr(SchemaSymbols.ATT_PUBLIC,
0261:                        DT_PUBLIC, ATT_REQUIRED, null);
0262:                allAttrs[ATT_REF_R] = new OneAttr(SchemaSymbols.ATT_REF,
0263:                        DT_QNAME, ATT_REQUIRED, null);
0264:                allAttrs[ATT_REFER_R] = new OneAttr(SchemaSymbols.ATT_REFER,
0265:                        DT_QNAME, ATT_REQUIRED, null);
0266:                allAttrs[ATT_SCHEMA_L_R] = new OneAttr(
0267:                        SchemaSymbols.ATT_SCHEMALOCATION, DT_ANYURI,
0268:                        ATT_REQUIRED, null);
0269:                allAttrs[ATT_SCHEMA_L_N] = new OneAttr(
0270:                        SchemaSymbols.ATT_SCHEMALOCATION, DT_ANYURI,
0271:                        ATT_OPT_NODFLT, null);
0272:                allAttrs[ATT_SOURCE_N] = new OneAttr(SchemaSymbols.ATT_SOURCE,
0273:                        DT_ANYURI, ATT_OPT_NODFLT, null);
0274:                allAttrs[ATT_SUBSTITUTION_G_N] = new OneAttr(
0275:                        SchemaSymbols.ATT_SUBSTITUTIONGROUP, DT_QNAME,
0276:                        ATT_OPT_NODFLT, null);
0277:                allAttrs[ATT_SYSTEM_N] = new OneAttr(SchemaSymbols.ATT_SYSTEM,
0278:                        DT_ANYURI, ATT_OPT_NODFLT, null);
0279:                allAttrs[ATT_TARGET_N_N] = new OneAttr(
0280:                        SchemaSymbols.ATT_TARGETNAMESPACE, DT_ANYURI,
0281:                        ATT_OPT_NODFLT, null);
0282:                allAttrs[ATT_TYPE_N] = new OneAttr(SchemaSymbols.ATT_TYPE,
0283:                        DT_QNAME, ATT_OPT_NODFLT, null);
0284:                allAttrs[ATT_USE_D] = new OneAttr(SchemaSymbols.ATT_USE,
0285:                        DT_USE, ATT_OPT_DFLT, SchemaSymbols.ATTVAL_OPTIONAL);
0286:                allAttrs[ATT_VALUE_NNI_N] = new OneAttr(
0287:                        SchemaSymbols.ATT_VALUE, DT_NONNEGINT, ATT_OPT_NODFLT,
0288:                        null);
0289:                allAttrs[ATT_VALUE_STR_N] = new OneAttr(
0290:                        SchemaSymbols.ATT_VALUE, DT_STRING, ATT_OPT_NODFLT,
0291:                        null);
0292:                allAttrs[ATT_VALUE_WS_N] = new OneAttr(SchemaSymbols.ATT_VALUE,
0293:                        DT_WHITESPACE, ATT_OPT_NODFLT, null);
0294:                allAttrs[ATT_VERSION_N] = new OneAttr(
0295:                        SchemaSymbols.ATT_VERSION, DT_TOKEN, ATT_OPT_NODFLT,
0296:                        null);
0297:                allAttrs[ATT_XPATH_R] = new OneAttr(SchemaSymbols.ATT_XPATH,
0298:                        DT_XPATH, ATT_REQUIRED, null);
0299:                allAttrs[ATT_XPATH1_R] = new OneAttr(SchemaSymbols.ATT_XPATH,
0300:                        DT_XPATH1, ATT_REQUIRED, null);
0301:
0302:                // step 4: for each element, make a list of possible attributes
0303:                Hashtable attrList;
0304:                Object[] attrArray;
0305:                OneElement oneEle;
0306:
0307:                // for element "attribute" - global
0308:                attrList = new Hashtable();
0309:                // default = string
0310:                attrList
0311:                        .put(SchemaSymbols.ATT_DEFAULT, allAttrs[ATT_DEFAULT_N]);
0312:                // fixed = string
0313:                attrList.put(SchemaSymbols.ATT_FIXED, allAttrs[ATT_FIXED_N]);
0314:                // id = ID
0315:                attrList.put(SchemaSymbols.ATT_ID, allAttrs[ATT_ID_N]);
0316:                // name = NCName
0317:                attrList.put(SchemaSymbols.ATT_NAME, allAttrs[ATT_NAME_R]);
0318:                // type = QName
0319:                attrList.put(SchemaSymbols.ATT_TYPE, allAttrs[ATT_TYPE_N]);
0320:                oneEle = new OneElement(attrList);
0321:                fEleAttrsMap.put(PRE_GLOBAL + SchemaSymbols.ELT_ATTRIBUTE,
0322:                        oneEle);
0323:
0324:                // for element "attribute" - local name
0325:                attrList = new Hashtable();
0326:                // default = string
0327:                attrList
0328:                        .put(SchemaSymbols.ATT_DEFAULT, allAttrs[ATT_DEFAULT_N]);
0329:                // fixed = string
0330:                attrList.put(SchemaSymbols.ATT_FIXED, allAttrs[ATT_FIXED_N]);
0331:                // form = (qualified | unqualified)
0332:                attrList.put(SchemaSymbols.ATT_FORM, allAttrs[ATT_FORM_N]);
0333:                // id = ID
0334:                attrList.put(SchemaSymbols.ATT_ID, allAttrs[ATT_ID_N]);
0335:                // name = NCName
0336:                attrList.put(SchemaSymbols.ATT_NAME, allAttrs[ATT_NAME_R]);
0337:                // type = QName
0338:                attrList.put(SchemaSymbols.ATT_TYPE, allAttrs[ATT_TYPE_N]);
0339:                // use = (optional | prohibited | required) : optional
0340:                attrList.put(SchemaSymbols.ATT_USE, allAttrs[ATT_USE_D]);
0341:                oneEle = new OneElement(attrList);
0342:                fEleAttrsMap.put(PRE_LOC_NAME + SchemaSymbols.ELT_ATTRIBUTE,
0343:                        oneEle);
0344:
0345:                // for element "attribute" - local ref
0346:                attrList = new Hashtable();
0347:                // default = string
0348:                attrList
0349:                        .put(SchemaSymbols.ATT_DEFAULT, allAttrs[ATT_DEFAULT_N]);
0350:                // fixed = string
0351:                attrList.put(SchemaSymbols.ATT_FIXED, allAttrs[ATT_FIXED_N]);
0352:                // id = ID
0353:                attrList.put(SchemaSymbols.ATT_ID, allAttrs[ATT_ID_N]);
0354:                // ref = QName
0355:                attrList.put(SchemaSymbols.ATT_REF, allAttrs[ATT_REF_R]);
0356:                // use = (optional | prohibited | required) : optional
0357:                attrList.put(SchemaSymbols.ATT_USE, allAttrs[ATT_USE_D]);
0358:                oneEle = new OneElement(attrList);
0359:                fEleAttrsMap.put(PRE_LOC_REF + SchemaSymbols.ELT_ATTRIBUTE,
0360:                        oneEle);
0361:
0362:                // for element "element" - global
0363:                attrList = new Hashtable();
0364:                // abstract = boolean : false
0365:                attrList.put(SchemaSymbols.ATT_ABSTRACT,
0366:                        allAttrs[ATT_ABSTRACT_D]);
0367:                // block = (#all | List of (substitution | extension | restriction | list | union))
0368:                attrList.put(SchemaSymbols.ATT_BLOCK, allAttrs[ATT_BLOCK_N]);
0369:                // default = string
0370:                attrList
0371:                        .put(SchemaSymbols.ATT_DEFAULT, allAttrs[ATT_DEFAULT_N]);
0372:                // final = (#all | List of (extension | restriction))
0373:                attrList.put(SchemaSymbols.ATT_FINAL, allAttrs[ATT_FINAL_N]);
0374:                // fixed = string
0375:                attrList.put(SchemaSymbols.ATT_FIXED, allAttrs[ATT_FIXED_N]);
0376:                // id = ID
0377:                attrList.put(SchemaSymbols.ATT_ID, allAttrs[ATT_ID_N]);
0378:                // name = NCName
0379:                attrList.put(SchemaSymbols.ATT_NAME, allAttrs[ATT_NAME_R]);
0380:                // nillable = boolean : false
0381:                attrList.put(SchemaSymbols.ATT_NILLABLE,
0382:                        allAttrs[ATT_NILLABLE_D]);
0383:                // substitutionGroup = QName
0384:                attrList.put(SchemaSymbols.ATT_SUBSTITUTIONGROUP,
0385:                        allAttrs[ATT_SUBSTITUTION_G_N]);
0386:                // type = QName
0387:                attrList.put(SchemaSymbols.ATT_TYPE, allAttrs[ATT_TYPE_N]);
0388:                oneEle = new OneElement(attrList);
0389:                fEleAttrsMap
0390:                        .put(PRE_GLOBAL + SchemaSymbols.ELT_ELEMENT, oneEle);
0391:
0392:                // for element "element" - local name
0393:                attrList = new Hashtable();
0394:                // block = (#all | List of (substitution | extension | restriction | list | union))
0395:                attrList.put(SchemaSymbols.ATT_BLOCK, allAttrs[ATT_BLOCK_N]);
0396:                // default = string
0397:                attrList
0398:                        .put(SchemaSymbols.ATT_DEFAULT, allAttrs[ATT_DEFAULT_N]);
0399:                // fixed = string
0400:                attrList.put(SchemaSymbols.ATT_FIXED, allAttrs[ATT_FIXED_N]);
0401:                // form = (qualified | unqualified)
0402:                attrList.put(SchemaSymbols.ATT_FORM, allAttrs[ATT_FORM_N]);
0403:                // id = ID
0404:                attrList.put(SchemaSymbols.ATT_ID, allAttrs[ATT_ID_N]);
0405:                // maxOccurs = (nonNegativeInteger | unbounded)  : 1
0406:                attrList.put(SchemaSymbols.ATT_MAXOCCURS,
0407:                        allAttrs[ATT_MAXOCCURS_D]);
0408:                // minOccurs = nonNegativeInteger : 1
0409:                attrList.put(SchemaSymbols.ATT_MINOCCURS,
0410:                        allAttrs[ATT_MINOCCURS_D]);
0411:                // name = NCName
0412:                attrList.put(SchemaSymbols.ATT_NAME, allAttrs[ATT_NAME_R]);
0413:                // nillable = boolean : false
0414:                attrList.put(SchemaSymbols.ATT_NILLABLE,
0415:                        allAttrs[ATT_NILLABLE_D]);
0416:                // type = QName
0417:                attrList.put(SchemaSymbols.ATT_TYPE, allAttrs[ATT_TYPE_N]);
0418:                oneEle = new OneElement(attrList);
0419:                fEleAttrsMap.put(PRE_LOC_NAME + SchemaSymbols.ELT_ELEMENT,
0420:                        oneEle);
0421:
0422:                // for element "element" - local ref
0423:                attrList = new Hashtable();
0424:                // id = ID
0425:                attrList.put(SchemaSymbols.ATT_ID, allAttrs[ATT_ID_N]);
0426:                // maxOccurs = (nonNegativeInteger | unbounded)  : 1
0427:                attrList.put(SchemaSymbols.ATT_MAXOCCURS,
0428:                        allAttrs[ATT_MAXOCCURS_D]);
0429:                // minOccurs = nonNegativeInteger : 1
0430:                attrList.put(SchemaSymbols.ATT_MINOCCURS,
0431:                        allAttrs[ATT_MINOCCURS_D]);
0432:                // ref = QName
0433:                attrList.put(SchemaSymbols.ATT_REF, allAttrs[ATT_REF_R]);
0434:                oneEle = new OneElement(attrList);
0435:                fEleAttrsMap.put(PRE_LOC_REF + SchemaSymbols.ELT_ELEMENT,
0436:                        oneEle);
0437:
0438:                // for element "complexType" - global
0439:                attrList = new Hashtable();
0440:                // abstract = boolean : false
0441:                attrList.put(SchemaSymbols.ATT_ABSTRACT,
0442:                        allAttrs[ATT_ABSTRACT_D]);
0443:                // block = (#all | List of (extension | restriction))
0444:                attrList.put(SchemaSymbols.ATT_BLOCK, allAttrs[ATT_BLOCK1_N]);
0445:                // final = (#all | List of (extension | restriction))
0446:                attrList.put(SchemaSymbols.ATT_FINAL, allAttrs[ATT_FINAL_N]);
0447:                // id = ID
0448:                attrList.put(SchemaSymbols.ATT_ID, allAttrs[ATT_ID_N]);
0449:                // mixed = boolean : false
0450:                attrList.put(SchemaSymbols.ATT_MIXED, allAttrs[ATT_MIXED_D]);
0451:                // name = NCName
0452:                attrList.put(SchemaSymbols.ATT_NAME, allAttrs[ATT_NAME_R]);
0453:                oneEle = new OneElement(attrList);
0454:                fEleAttrsMap.put(PRE_GLOBAL + SchemaSymbols.ELT_COMPLEXTYPE,
0455:                        oneEle);
0456:
0457:                // for element "complexType" - local name
0458:                attrList = new Hashtable();
0459:                // id = ID
0460:                attrList.put(SchemaSymbols.ATT_ID, allAttrs[ATT_ID_N]);
0461:                // mixed = boolean : false
0462:                attrList.put(SchemaSymbols.ATT_MIXED, allAttrs[ATT_MIXED_D]);
0463:                oneEle = new OneElement(attrList);
0464:                fEleAttrsMap.put(PRE_LOC_NAME + SchemaSymbols.ELT_COMPLEXTYPE,
0465:                        oneEle);
0466:
0467:                // for element "simpleContent" - local name
0468:                attrList = new Hashtable();
0469:                // id = ID
0470:                attrList.put(SchemaSymbols.ATT_ID, allAttrs[ATT_ID_N]);
0471:                oneEle = new OneElement(attrList);
0472:                fEleAttrsMap.put(
0473:                        PRE_LOC_NAME + SchemaSymbols.ELT_SIMPLECONTENT, oneEle);
0474:
0475:                // for element "restriction" - local name
0476:                attrList = new Hashtable();
0477:                // base = QName
0478:                attrList.put(SchemaSymbols.ATT_BASE, allAttrs[ATT_BASE_N]);
0479:                // id = ID
0480:                attrList.put(SchemaSymbols.ATT_ID, allAttrs[ATT_ID_N]);
0481:                oneEle = new OneElement(attrList);
0482:                fEleAttrsMap.put(PRE_LOC_NAME + SchemaSymbols.ELT_RESTRICTION,
0483:                        oneEle);
0484:
0485:                // for element "extension" - local name
0486:                attrList = new Hashtable();
0487:                // base = QName
0488:                attrList.put(SchemaSymbols.ATT_BASE, allAttrs[ATT_BASE_R]);
0489:                // id = ID
0490:                attrList.put(SchemaSymbols.ATT_ID, allAttrs[ATT_ID_N]);
0491:                oneEle = new OneElement(attrList);
0492:                fEleAttrsMap.put(PRE_LOC_NAME + SchemaSymbols.ELT_EXTENSION,
0493:                        oneEle);
0494:
0495:                // for element "attributeGroup" - local ref
0496:                attrList = new Hashtable();
0497:                // id = ID
0498:                attrList.put(SchemaSymbols.ATT_ID, allAttrs[ATT_ID_N]);
0499:                // ref = QName
0500:                attrList.put(SchemaSymbols.ATT_REF, allAttrs[ATT_REF_R]);
0501:                oneEle = new OneElement(attrList);
0502:                fEleAttrsMap.put(
0503:                        PRE_LOC_REF + SchemaSymbols.ELT_ATTRIBUTEGROUP, oneEle);
0504:
0505:                // for element "anyAttribute" - local name
0506:                attrList = new Hashtable();
0507:                // id = ID
0508:                attrList.put(SchemaSymbols.ATT_ID, allAttrs[ATT_ID_N]);
0509:                // namespace = ((##any | ##other) | List of (anyURI | (##targetNamespace | ##local)) )  : ##any
0510:                attrList.put(SchemaSymbols.ATT_NAMESPACE,
0511:                        allAttrs[ATT_NAMESPACE_D]);
0512:                // processContents = (lax | skip | strict) : strict
0513:                attrList.put(SchemaSymbols.ATT_PROCESSCONTENTS,
0514:                        allAttrs[ATT_PROCESS_C_D]);
0515:                oneEle = new OneElement(attrList);
0516:                fEleAttrsMap.put(PRE_LOC_NAME + SchemaSymbols.ELT_ANYATTRIBUTE,
0517:                        oneEle);
0518:
0519:                // for element "complexContent" - local name
0520:                attrList = new Hashtable();
0521:                // id = ID
0522:                attrList.put(SchemaSymbols.ATT_ID, allAttrs[ATT_ID_N]);
0523:                // mixed = boolean
0524:                attrList.put(SchemaSymbols.ATT_MIXED, allAttrs[ATT_MIXED_N]);
0525:                oneEle = new OneElement(attrList);
0526:                fEleAttrsMap.put(PRE_LOC_NAME
0527:                        + SchemaSymbols.ELT_COMPLEXCONTENT, oneEle);
0528:
0529:                // for element "attributeGroup" - global
0530:                attrList = new Hashtable();
0531:                // id = ID
0532:                attrList.put(SchemaSymbols.ATT_ID, allAttrs[ATT_ID_N]);
0533:                // name = NCName
0534:                attrList.put(SchemaSymbols.ATT_NAME, allAttrs[ATT_NAME_R]);
0535:                oneEle = new OneElement(attrList);
0536:                fEleAttrsMap.put(PRE_GLOBAL + SchemaSymbols.ELT_ATTRIBUTEGROUP,
0537:                        oneEle);
0538:
0539:                // for element "group" - global
0540:                attrList = new Hashtable();
0541:                // id = ID
0542:                attrList.put(SchemaSymbols.ATT_ID, allAttrs[ATT_ID_N]);
0543:                // name = NCName
0544:                attrList.put(SchemaSymbols.ATT_NAME, allAttrs[ATT_NAME_R]);
0545:                oneEle = new OneElement(attrList);
0546:                fEleAttrsMap.put(PRE_GLOBAL + SchemaSymbols.ELT_GROUP, oneEle);
0547:
0548:                // for element "group" - local ref
0549:                attrList = new Hashtable();
0550:                // id = ID
0551:                attrList.put(SchemaSymbols.ATT_ID, allAttrs[ATT_ID_N]);
0552:                // maxOccurs = (nonNegativeInteger | unbounded)  : 1
0553:                attrList.put(SchemaSymbols.ATT_MAXOCCURS,
0554:                        allAttrs[ATT_MAXOCCURS_D]);
0555:                // minOccurs = nonNegativeInteger : 1
0556:                attrList.put(SchemaSymbols.ATT_MINOCCURS,
0557:                        allAttrs[ATT_MINOCCURS_D]);
0558:                // ref = QName
0559:                attrList.put(SchemaSymbols.ATT_REF, allAttrs[ATT_REF_R]);
0560:                oneEle = new OneElement(attrList);
0561:                fEleAttrsMap.put(PRE_LOC_REF + SchemaSymbols.ELT_GROUP, oneEle);
0562:
0563:                // for element "all" - local name
0564:                attrList = new Hashtable();
0565:                // id = ID
0566:                attrList.put(SchemaSymbols.ATT_ID, allAttrs[ATT_ID_N]);
0567:                // maxOccurs = 1 : 1
0568:                attrList.put(SchemaSymbols.ATT_MAXOCCURS,
0569:                        allAttrs[ATT_MAXOCCURS1_D]);
0570:                // minOccurs = (0 | 1) : 1
0571:                attrList.put(SchemaSymbols.ATT_MINOCCURS,
0572:                        allAttrs[ATT_MINOCCURS1_D]);
0573:                oneEle = new OneElement(attrList);
0574:                fEleAttrsMap.put(PRE_LOC_NAME + SchemaSymbols.ELT_ALL, oneEle);
0575:
0576:                // for element "choice" - local name
0577:                attrList = new Hashtable();
0578:                // id = ID
0579:                attrList.put(SchemaSymbols.ATT_ID, allAttrs[ATT_ID_N]);
0580:                // maxOccurs = (nonNegativeInteger | unbounded)  : 1
0581:                attrList.put(SchemaSymbols.ATT_MAXOCCURS,
0582:                        allAttrs[ATT_MAXOCCURS_D]);
0583:                // minOccurs = nonNegativeInteger : 1
0584:                attrList.put(SchemaSymbols.ATT_MINOCCURS,
0585:                        allAttrs[ATT_MINOCCURS_D]);
0586:                oneEle = new OneElement(attrList);
0587:                fEleAttrsMap.put(PRE_LOC_NAME + SchemaSymbols.ELT_CHOICE,
0588:                        oneEle);
0589:                // for element "sequence" - local name
0590:                fEleAttrsMap.put(PRE_LOC_NAME + SchemaSymbols.ELT_SEQUENCE,
0591:                        oneEle);
0592:
0593:                // for element "any" - local name
0594:                attrList = new Hashtable();
0595:                // id = ID
0596:                attrList.put(SchemaSymbols.ATT_ID, allAttrs[ATT_ID_N]);
0597:                // maxOccurs = (nonNegativeInteger | unbounded)  : 1
0598:                attrList.put(SchemaSymbols.ATT_MAXOCCURS,
0599:                        allAttrs[ATT_MAXOCCURS_D]);
0600:                // minOccurs = nonNegativeInteger : 1
0601:                attrList.put(SchemaSymbols.ATT_MINOCCURS,
0602:                        allAttrs[ATT_MINOCCURS_D]);
0603:                // namespace = ((##any | ##other) | List of (anyURI | (##targetNamespace | ##local)) )  : ##any
0604:                attrList.put(SchemaSymbols.ATT_NAMESPACE,
0605:                        allAttrs[ATT_NAMESPACE_D]);
0606:                // processContents = (lax | skip | strict) : strict
0607:                attrList.put(SchemaSymbols.ATT_PROCESSCONTENTS,
0608:                        allAttrs[ATT_PROCESS_C_D]);
0609:                oneEle = new OneElement(attrList);
0610:                fEleAttrsMap.put(PRE_LOC_NAME + SchemaSymbols.ELT_ANY, oneEle);
0611:
0612:                // for element "unique" - local name
0613:                attrList = new Hashtable();
0614:                // id = ID
0615:                attrList.put(SchemaSymbols.ATT_ID, allAttrs[ATT_ID_N]);
0616:                // name = NCName
0617:                attrList.put(SchemaSymbols.ATT_NAME, allAttrs[ATT_NAME_R]);
0618:                oneEle = new OneElement(attrList);
0619:                fEleAttrsMap.put(PRE_LOC_NAME + SchemaSymbols.ELT_UNIQUE,
0620:                        oneEle);
0621:                // for element "key" - local name
0622:                fEleAttrsMap.put(PRE_LOC_NAME + SchemaSymbols.ELT_KEY, oneEle);
0623:
0624:                // for element "keyref" - local name
0625:                attrList = new Hashtable();
0626:                // id = ID
0627:                attrList.put(SchemaSymbols.ATT_ID, allAttrs[ATT_ID_N]);
0628:                // name = NCName
0629:                attrList.put(SchemaSymbols.ATT_NAME, allAttrs[ATT_NAME_R]);
0630:                // refer = QName
0631:                attrList.put(SchemaSymbols.ATT_REFER, allAttrs[ATT_REFER_R]);
0632:                oneEle = new OneElement(attrList);
0633:                fEleAttrsMap.put(PRE_LOC_NAME + SchemaSymbols.ELT_KEYREF,
0634:                        oneEle);
0635:
0636:                // for element "selector" - local name
0637:                attrList = new Hashtable();
0638:                // id = ID
0639:                attrList.put(SchemaSymbols.ATT_ID, allAttrs[ATT_ID_N]);
0640:                // xpath = a subset of XPath expression
0641:                attrList.put(SchemaSymbols.ATT_XPATH, allAttrs[ATT_XPATH_R]);
0642:                oneEle = new OneElement(attrList);
0643:                fEleAttrsMap.put(PRE_LOC_NAME + SchemaSymbols.ELT_SELECTOR,
0644:                        oneEle);
0645:
0646:                // for element "field" - local name
0647:                attrList = new Hashtable();
0648:                // id = ID
0649:                attrList.put(SchemaSymbols.ATT_ID, allAttrs[ATT_ID_N]);
0650:                // xpath = a subset of XPath expression
0651:                attrList.put(SchemaSymbols.ATT_XPATH, allAttrs[ATT_XPATH1_R]);
0652:                oneEle = new OneElement(attrList);
0653:                fEleAttrsMap
0654:                        .put(PRE_LOC_NAME + SchemaSymbols.ELT_FIELD, oneEle);
0655:
0656:                // for element "notation" - local name
0657:                attrList = new Hashtable();
0658:                // id = ID
0659:                attrList.put(SchemaSymbols.ATT_ID, allAttrs[ATT_ID_N]);
0660:                // name = NCName
0661:                attrList.put(SchemaSymbols.ATT_NAME, allAttrs[ATT_NAME_R]);
0662:                // public = A public identifier, per ISO 8879
0663:                attrList.put(SchemaSymbols.ATT_PUBLIC, allAttrs[ATT_PUBLIC_R]);
0664:                // system = anyURI
0665:                attrList.put(SchemaSymbols.ATT_SYSTEM, allAttrs[ATT_SYSTEM_N]);
0666:                oneEle = new OneElement(attrList);
0667:                fEleAttrsMap.put(PRE_LOC_NAME + SchemaSymbols.ELT_NOTATION,
0668:                        oneEle);
0669:
0670:                // for element "annotation" - global
0671:                attrList = new Hashtable();
0672:                // id = ID
0673:                attrList.put(SchemaSymbols.ATT_ID, allAttrs[ATT_ID_N]);
0674:                oneEle = new OneElement(attrList);
0675:                fEleAttrsMap.put(PRE_GLOBAL + SchemaSymbols.ELT_ANNOTATION,
0676:                        oneEle);
0677:                // for element "annotation" - local name
0678:                fEleAttrsMap.put(PRE_LOC_NAME + SchemaSymbols.ELT_ANNOTATION,
0679:                        oneEle);
0680:
0681:                // for element "appinfo" - local name
0682:                attrList = new Hashtable();
0683:                // source = anyURI
0684:                attrList.put(SchemaSymbols.ATT_SOURCE, allAttrs[ATT_SOURCE_N]);
0685:                oneEle = new OneElement(attrList, false);
0686:                fEleAttrsMap.put(PRE_LOC_NAME + SchemaSymbols.ELT_APPINFO,
0687:                        oneEle);
0688:
0689:                // for element "documentation" - local name
0690:                attrList = new Hashtable();
0691:                // source = anyURI
0692:                attrList.put(SchemaSymbols.ATT_SOURCE, allAttrs[ATT_SOURCE_N]);
0693:                // xml:lang = language ???
0694:                oneEle = new OneElement(attrList, false);
0695:                fEleAttrsMap.put(
0696:                        PRE_LOC_NAME + SchemaSymbols.ELT_DOCUMENTATION, oneEle);
0697:
0698:                // for element "simpleType" - global
0699:                attrList = new Hashtable();
0700:                // final = (#all | (list | union | restriction))
0701:                attrList.put(SchemaSymbols.ATT_FINAL, allAttrs[ATT_FINAL1_N]);
0702:                // id = ID
0703:                attrList.put(SchemaSymbols.ATT_ID, allAttrs[ATT_ID_N]);
0704:                // name = NCName
0705:                attrList.put(SchemaSymbols.ATT_NAME, allAttrs[ATT_NAME_R]);
0706:                oneEle = new OneElement(attrList);
0707:                fEleAttrsMap.put(PRE_GLOBAL + SchemaSymbols.ELT_SIMPLETYPE,
0708:                        oneEle);
0709:
0710:                // for element "simpleType" - local name
0711:                attrList = new Hashtable();
0712:                // final = (#all | (list | union | restriction))
0713:                attrList.put(SchemaSymbols.ATT_FINAL, allAttrs[ATT_FINAL1_N]);
0714:                // id = ID
0715:                attrList.put(SchemaSymbols.ATT_ID, allAttrs[ATT_ID_N]);
0716:                oneEle = new OneElement(attrList);
0717:                fEleAttrsMap.put(PRE_LOC_NAME + SchemaSymbols.ELT_SIMPLETYPE,
0718:                        oneEle);
0719:
0720:                // for element "restriction" - local name
0721:                // already registered for complexType
0722:
0723:                // for element "list" - local name
0724:                attrList = new Hashtable();
0725:                // id = ID
0726:                attrList.put(SchemaSymbols.ATT_ID, allAttrs[ATT_ID_N]);
0727:                // itemType = QName
0728:                attrList.put(SchemaSymbols.ATT_ITEMTYPE,
0729:                        allAttrs[ATT_ITEMTYPE_N]);
0730:                oneEle = new OneElement(attrList);
0731:                fEleAttrsMap.put(PRE_LOC_NAME + SchemaSymbols.ELT_LIST, oneEle);
0732:
0733:                // for element "union" - local name
0734:                attrList = new Hashtable();
0735:                // id = ID
0736:                attrList.put(SchemaSymbols.ATT_ID, allAttrs[ATT_ID_N]);
0737:                // memberTypes = List of QName
0738:                attrList.put(SchemaSymbols.ATT_MEMBERTYPES,
0739:                        allAttrs[ATT_MEMBER_T_N]);
0740:                oneEle = new OneElement(attrList);
0741:                fEleAttrsMap
0742:                        .put(PRE_LOC_NAME + SchemaSymbols.ELT_UNION, oneEle);
0743:
0744:                // for element "schema" - global
0745:                attrList = new Hashtable();
0746:                // attributeFormDefault = (qualified | unqualified) : unqualified
0747:                attrList.put(SchemaSymbols.ATT_ATTRIBUTEFORMDEFAULT,
0748:                        allAttrs[ATT_ATTRIBUTE_FD_D]);
0749:                // blockDefault = (#all | List of (substitution | extension | restriction | list | union))  : ''
0750:                attrList.put(SchemaSymbols.ATT_BLOCKDEFAULT,
0751:                        allAttrs[ATT_BLOCK_D_D]);
0752:                // elementFormDefault = (qualified | unqualified) : unqualified
0753:                attrList.put(SchemaSymbols.ATT_ELEMENTFORMDEFAULT,
0754:                        allAttrs[ATT_ELEMENT_FD_D]);
0755:                // finalDefault = (#all | List of (extension | restriction))  : ''
0756:                attrList.put(SchemaSymbols.ATT_FINALDEFAULT,
0757:                        allAttrs[ATT_FINAL_D_D]);
0758:                // id = ID
0759:                attrList.put(SchemaSymbols.ATT_ID, allAttrs[ATT_ID_N]);
0760:                // targetNamespace = anyURI
0761:                attrList.put(SchemaSymbols.ATT_TARGETNAMESPACE,
0762:                        allAttrs[ATT_TARGET_N_N]);
0763:                // version = token
0764:                attrList
0765:                        .put(SchemaSymbols.ATT_VERSION, allAttrs[ATT_VERSION_N]);
0766:                // xml:lang = language ???
0767:                oneEle = new OneElement(attrList);
0768:                fEleAttrsMap.put(PRE_GLOBAL + SchemaSymbols.ELT_SCHEMA, oneEle);
0769:
0770:                // for element "include" - global
0771:                attrList = new Hashtable();
0772:                // id = ID
0773:                attrList.put(SchemaSymbols.ATT_ID, allAttrs[ATT_ID_N]);
0774:                // schemaLocation = anyURI
0775:                attrList.put(SchemaSymbols.ATT_SCHEMALOCATION,
0776:                        allAttrs[ATT_SCHEMA_L_R]);
0777:                oneEle = new OneElement(attrList);
0778:                fEleAttrsMap
0779:                        .put(PRE_GLOBAL + SchemaSymbols.ELT_INCLUDE, oneEle);
0780:                // for element "redefine" - global
0781:                fEleAttrsMap.put(PRE_GLOBAL + SchemaSymbols.ELT_REDEFINE,
0782:                        oneEle);
0783:
0784:                // for element "import" - global
0785:                attrList = new Hashtable();
0786:                // id = ID
0787:                attrList.put(SchemaSymbols.ATT_ID, allAttrs[ATT_ID_N]);
0788:                // namespace = anyURI
0789:                attrList.put(SchemaSymbols.ATT_NAMESPACE,
0790:                        allAttrs[ATT_NAMESPACE_N]);
0791:                // schemaLocation = anyURI
0792:                attrList.put(SchemaSymbols.ATT_SCHEMALOCATION,
0793:                        allAttrs[ATT_SCHEMA_L_N]);
0794:                oneEle = new OneElement(attrList);
0795:                fEleAttrsMap.put(PRE_GLOBAL + SchemaSymbols.ELT_IMPORT, oneEle);
0796:
0797:                // for element "length" - local name
0798:                attrList = new Hashtable();
0799:                // id = ID
0800:                attrList.put(SchemaSymbols.ATT_ID, allAttrs[ATT_ID_N]);
0801:                // value = nonNegativeInteger
0802:                attrList
0803:                        .put(SchemaSymbols.ATT_VALUE, allAttrs[ATT_VALUE_NNI_N]);
0804:                // fixed = boolean : false
0805:                attrList.put(SchemaSymbols.ATT_FIXED, allAttrs[ATT_FIXED_D]);
0806:                oneEle = new OneElement(attrList);
0807:                fEleAttrsMap.put(PRE_LOC_NAME + SchemaSymbols.ELT_LENGTH,
0808:                        oneEle);
0809:                // for element "minLength" - local name
0810:                fEleAttrsMap.put(PRE_LOC_NAME + SchemaSymbols.ELT_MINLENGTH,
0811:                        oneEle);
0812:                // for element "maxLength" - local name
0813:                fEleAttrsMap.put(PRE_LOC_NAME + SchemaSymbols.ELT_MAXLENGTH,
0814:                        oneEle);
0815:                // for element "totalDigits" - local name
0816:                fEleAttrsMap.put(PRE_LOC_NAME + SchemaSymbols.ELT_TOTALDIGITS,
0817:                        oneEle);
0818:                // for element "fractionDigits" - local name
0819:                fEleAttrsMap.put(PRE_LOC_NAME
0820:                        + SchemaSymbols.ELT_FRACTIONDIGITS, oneEle);
0821:
0822:                // for element "pattern" - local name
0823:                attrList = new Hashtable();
0824:                // id = ID
0825:                attrList.put(SchemaSymbols.ATT_ID, allAttrs[ATT_ID_N]);
0826:                // value = string
0827:                attrList
0828:                        .put(SchemaSymbols.ATT_VALUE, allAttrs[ATT_VALUE_STR_N]);
0829:                oneEle = new OneElement(attrList);
0830:                fEleAttrsMap.put(PRE_LOC_NAME + SchemaSymbols.ELT_PATTERN,
0831:                        oneEle);
0832:
0833:                // for element "enumeration" - local name
0834:                attrList = new Hashtable();
0835:                // id = ID
0836:                attrList.put(SchemaSymbols.ATT_ID, allAttrs[ATT_ID_N]);
0837:                // value = anySimpleType ???
0838:                attrList
0839:                        .put(SchemaSymbols.ATT_VALUE, allAttrs[ATT_VALUE_STR_N]);
0840:                oneEle = new OneElement(attrList);
0841:                fEleAttrsMap.put(PRE_LOC_NAME + SchemaSymbols.ELT_ENUMERATION,
0842:                        oneEle);
0843:
0844:                // for element "whiteSpace" - local name
0845:                attrList = new Hashtable();
0846:                // id = ID
0847:                attrList.put(SchemaSymbols.ATT_ID, allAttrs[ATT_ID_N]);
0848:                // value = preserve | replace | collapse
0849:                attrList.put(SchemaSymbols.ATT_VALUE, allAttrs[ATT_VALUE_WS_N]);
0850:                // fixed = boolean : false
0851:                attrList.put(SchemaSymbols.ATT_FIXED, allAttrs[ATT_FIXED_D]);
0852:                oneEle = new OneElement(attrList);
0853:                fEleAttrsMap.put(PRE_LOC_NAME + SchemaSymbols.ELT_WHITESPACE,
0854:                        oneEle);
0855:
0856:                // for element "maxInclusive" - local name
0857:                attrList = new Hashtable();
0858:                // id = ID
0859:                attrList.put(SchemaSymbols.ATT_ID, allAttrs[ATT_ID_N]);
0860:                // value = anySimpleType ???
0861:                attrList
0862:                        .put(SchemaSymbols.ATT_VALUE, allAttrs[ATT_VALUE_STR_N]);
0863:                // fixed = boolean : false
0864:                attrList.put(SchemaSymbols.ATT_FIXED, allAttrs[ATT_FIXED_D]);
0865:                oneEle = new OneElement(attrList);
0866:                fEleAttrsMap.put(PRE_LOC_NAME + SchemaSymbols.ELT_MAXINCLUSIVE,
0867:                        oneEle);
0868:                // for element "maxExclusive" - local name
0869:                fEleAttrsMap.put(PRE_LOC_NAME + SchemaSymbols.ELT_MAXEXCLUSIVE,
0870:                        oneEle);
0871:                // for element "minInclusive" - local name
0872:                fEleAttrsMap.put(PRE_LOC_NAME + SchemaSymbols.ELT_MININCLUSIVE,
0873:                        oneEle);
0874:                // for element "minExclusive" - local name
0875:                fEleAttrsMap.put(PRE_LOC_NAME + SchemaSymbols.ELT_MINEXCLUSIVE,
0876:                        oneEle);
0877:            }
0878:
0879:            private Hashtable fIdDefs = new Hashtable();
0880:
0881:            // used to store utility reference: error reproter. set via constructor.
0882:            protected XMLErrorReporter fErrorReporter = null;
0883:
0884:            // used to store the mapping from processed element to attributes
0885:            protected Hashtable fProcessedElements = new Hashtable();
0886:
0887:            // used to store the mapping from processed element to attributes
0888:            protected Hashtable fNonSchemaAttrs = new Hashtable();
0889:
0890:            // constructor. Sets fDVRegistry and fErrorReproter
0891:            private GeneralAttrCheck() {
0892:            }
0893:
0894:            public GeneralAttrCheck(XMLErrorReporter er,
0895:                    DatatypeValidatorFactoryImpl datatypeRegistry) {
0896:                fErrorReporter = er;
0897:                synchronized (getClass()) {
0898:                    if (fExtraDVs[DT_ANYURI] == null) {
0899:                        // step 5: register all datatype validators for new types
0900:                        datatypeRegistry.expandRegistryToFullSchemaSet();
0901:                        // anyURI
0902:                        fExtraDVs[DT_ANYURI] = datatypeRegistry
0903:                                .getDatatypeValidator("anyURI");
0904:                        // boolean
0905:                        fExtraDVs[DT_BOOLEAN] = datatypeRegistry
0906:                                .getDatatypeValidator("boolean");
0907:                        // ID
0908:                        fExtraDVs[DT_ID] = datatypeRegistry
0909:                                .getDatatypeValidator("ID");
0910:                        // nonNegtiveInteger
0911:                        fExtraDVs[DT_NONNEGINT] = datatypeRegistry
0912:                                .getDatatypeValidator("nonNegativeInteger");
0913:                        // QName
0914:                        fExtraDVs[DT_QNAME] = datatypeRegistry
0915:                                .getDatatypeValidator("QName");
0916:                        // string
0917:                        fExtraDVs[DT_STRING] = datatypeRegistry
0918:                                .getDatatypeValidator("string");
0919:                        // token
0920:                        fExtraDVs[DT_TOKEN] = datatypeRegistry
0921:                                .getDatatypeValidator("token");
0922:                        // NCName
0923:                        fExtraDVs[DT_NCNAME] = datatypeRegistry
0924:                                .getDatatypeValidator("NCName");
0925:                        // xpath = a subset of XPath expression
0926:                        fExtraDVs[DT_XPATH] = fExtraDVs[DT_STRING];
0927:                        // xpath = a subset of XPath expression
0928:                        fExtraDVs[DT_XPATH] = fExtraDVs[DT_STRING];
0929:                    }
0930:                }
0931:            }
0932:
0933:            // check whether the specified element conforms to the attributes restriction
0934:            // @param: element    - which element to check
0935:            // @param: eleContext - the context in which the element is
0936:            // @return: Hashtable - list of attributes and values
0937:            public Hashtable checkAttributes(Element element, int eleContext)
0938:                    throws Exception {
0939:                if (element == null)
0940:                    return null;
0941:
0942:                Hashtable attrValues = (Hashtable) fProcessedElements
0943:                        .get(element);
0944:                if (attrValues != null)
0945:                    return attrValues;
0946:
0947:                // Get the proper name:
0948:                // G_ for global;
0949:                // LN_ for local + name;
0950:                // LR_ for local + ref;
0951:                String elName = element.getLocalName(), name;
0952:                if (eleContext == ELE_CONTEXT_GLOBAL) {
0953:                    name = PRE_GLOBAL + elName;
0954:                } else {
0955:                    if (element.getAttributeNode(SchemaSymbols.ATT_REF) == null)
0956:                        name = PRE_LOC_NAME + elName;
0957:                    else
0958:                        name = PRE_LOC_REF + elName;
0959:                }
0960:
0961:                // get desired attribute list of this element
0962:                OneElement oneEle = (OneElement) fEleAttrsMap.get(name);
0963:                if (oneEle == null) {
0964:                    reportSchemaError(
0965:                            SchemaMessageProvider.Con3X3ElementAppearance,
0966:                            new Object[] { elName });
0967:                    return null;
0968:                }
0969:
0970:                attrValues = new Hashtable();
0971:                Hashtable attrList = oneEle.attrList;
0972:
0973:                // traverse all attributes
0974:                NamedNodeMap attrs = element.getAttributes();
0975:                Attr sattr = null;
0976:                int i = 0;
0977:                while ((sattr = (Attr) attrs.item(i++)) != null) {
0978:                    // get the attribute name/value
0979:                    String attrName = sattr.getName();
0980:                    String attrVal = sattr.getValue();
0981:
0982:                    // skip anything starts with x/X m/M l/L ???
0983:                    // simply put their values in the return hashtable
0984:                    if (attrName.toLowerCase().startsWith("xml")) {
0985:                        attrValues.put(attrName, new Object[] {
0986:                                sattr.getValue(), Boolean.FALSE });
0987:                        continue;
0988:                    }
0989:
0990:                    // for attributes with namespace prefix
0991:                    String attrURI = sattr.getNamespaceURI();
0992:                    if (attrURI != null && attrURI.length() != 0) {
0993:                        // attributes with schema namespace are not allowed
0994:                        // and not allowed on "document" and "appInfo"
0995:                        if (attrURI.equals(SchemaSymbols.URI_SCHEMAFORSCHEMA)
0996:                                || !oneEle.allowNonSchemaAttr) {
0997:                            reportSchemaError(
0998:                                    SchemaMessageProvider.Con3X3AttributeAppearance,
0999:                                    new Object[] { elName, attrName });
1000:                        } else {
1001:                            // for attributes from other namespace
1002:                            // store them in a list, and TRY to validate them after
1003:                            // schema traversal (because it's "lax")
1004:                            attrValues.put(attrName, new Object[] { attrVal,
1005:                                    Boolean.FALSE });
1006:                            String attrRName = attrURI + ","
1007:                                    + sattr.getLocalName();
1008:                            Vector values = (Vector) fNonSchemaAttrs
1009:                                    .get(attrRName);
1010:                            if (values == null) {
1011:                                values = new Vector();
1012:                                values.addElement(attrName);
1013:                                values.addElement(elName);
1014:                                values.addElement(attrVal);
1015:                                fNonSchemaAttrs.put(attrRName, values);
1016:                            } else {
1017:                                values.addElement(elName);
1018:                                values.addElement(attrVal);
1019:                            }
1020:                        }
1021:                        continue;
1022:                    }
1023:
1024:                    // check whether this attribute is allowed
1025:                    OneAttr oneAttr = (OneAttr) attrList.get(attrName);
1026:                    if (oneAttr == null) {
1027:                        reportSchemaError(
1028:                                SchemaMessageProvider.Con3X3AttributeAppearance,
1029:                                new Object[] { elName, attrName });
1030:                        continue;
1031:                    }
1032:
1033:                    // check the value against the datatype
1034:                    try {
1035:                        // no checking on string needs to be done here.
1036:                        // no checking on xpath needs to be done here.
1037:                        // xpath values are validated in xpath parser
1038:                        if (oneAttr.dvIndex >= 0) {
1039:                            if (oneAttr.dvIndex != DT_STRING
1040:                                    && oneAttr.dvIndex != DT_XPATH
1041:                                    && oneAttr.dvIndex != DT_XPATH1) {
1042:                                DatatypeValidator dv = fExtraDVs[oneAttr.dvIndex];
1043:                                if (dv instanceof  IDDatatypeValidator) {
1044:                                    dv.validate(attrVal, fIdDefs);
1045:                                } else {
1046:                                    dv.validate(attrVal, null);
1047:                                }
1048:                            }
1049:                            attrValues.put(attrName, new Object[] { attrVal,
1050:                                    Boolean.FALSE });
1051:                        } else {
1052:                            attrVal = validate(attrName, attrVal,
1053:                                    oneAttr.dvIndex);
1054:                            attrValues.put(attrName, new Object[] { attrVal,
1055:                                    Boolean.FALSE });
1056:                        }
1057:                    } catch (InvalidDatatypeValueException ide) {
1058:                        reportSchemaError(
1059:                                SchemaMessageProvider.Con3X3AttributeInvalidValue,
1060:                                new Object[] { elName, attrName,
1061:                                        ide.getLocalizedMessage() });
1062:                    }
1063:                }
1064:
1065:                // traverse all required attributes
1066:                Object[] reqAttrs = oneEle.attrArray;
1067:                for (i = 0; i < reqAttrs.length; i++) {
1068:                    OneAttr oneAttr = (OneAttr) reqAttrs[i];
1069:
1070:                    // if the attribute appreared, skip to the next one
1071:                    if (element.getAttributeNode(oneAttr.name) != null)
1072:                        continue;
1073:
1074:                    // if the attribute is required, report an error
1075:                    if (oneAttr.optdflt == ATT_REQUIRED) {
1076:                        reportSchemaError(
1077:                                SchemaMessageProvider.Con3X3AttributeMustAppear,
1078:                                new Object[] { elName, oneAttr.name });
1079:                    }
1080:                    // if the attribute is optional with default value, apply it
1081:                    else if (oneAttr.optdflt == ATT_OPT_DFLT) {
1082:                        attrValues.put(oneAttr.name, new Object[] {
1083:                                oneAttr.dfltValue, Boolean.TRUE });
1084:                    }
1085:                }
1086:
1087:                fProcessedElements.put(element, attrValues);
1088:
1089:                return attrValues;
1090:            }
1091:
1092:            private String validate(String attr, String value, int dvIndex) throws InvalidDatatypeValueException {
1093:        Vector unionBase, enum;
1094:        int choice;
1095:
1096:        if (value == null)
1097:            return null;
1098:
1099:        switch (dvIndex) {
1100:        case DT_BLOCK:
1101:            // block = (#all | List of (substitution | extension | restriction | list | union))
1102:            choice = 0;
1103:            if (value.equals (SchemaSymbols.ATTVAL_POUNDALL)) {
1104:                choice = SchemaSymbols.SUBSTITUTION|SchemaSymbols.EXTENSION|
1105:                         SchemaSymbols.RESTRICTION|SchemaSymbols.LIST|
1106:                         SchemaSymbols.UNION;
1107:            } else {
1108:                StringTokenizer t = new StringTokenizer (value, " ");
1109:                while (t.hasMoreTokens()) {
1110:                    String token = t.nextToken ();
1111:
1112:                    if (token.equals (SchemaSymbols.ATTVAL_SUBSTITUTION) ) {
1113:                        choice |= SchemaSymbols.SUBSTITUTION;
1114:                    } else if (token.equals (SchemaSymbols.ATTVAL_EXTENSION)) {
1115:                        choice |= SchemaSymbols.EXTENSION;
1116:                    } else if (token.equals (SchemaSymbols.ATTVAL_RESTRICTION)) {
1117:                        choice |= SchemaSymbols.RESTRICTION;
1118:                    } else if ( token.equals (SchemaSymbols.ELT_LIST) ) {
1119:                        choice |= SchemaSymbols.LIST;
1120:                    } else if ( token.equals (SchemaSymbols.ELT_UNION) ) {
1121:                        choice |= SchemaSymbols.RESTRICTION;
1122:                    } else {
1123:                        throw new InvalidDatatypeValueException("the value '"+value+"' must match (#all | List of (substitution | extension | restriction | list | union))");
1124:                    }
1125:                }
1126:            }
1127://???            value = Integer.toString(choice);
1128:            break;
1129:        case DT_BLOCK1:
1130:        case DT_FINAL:
1131:            // block = (#all | List of (extension | restriction))
1132:            // final = (#all | List of (extension | restriction))
1133:            choice = 0;
1134:            if (value.equals (SchemaSymbols.ATTVAL_POUNDALL)) {
1135:                choice = SchemaSymbols.EXTENSION|SchemaSymbols.RESTRICTION;
1136:            } else {
1137:                StringTokenizer t = new StringTokenizer (value, " ");
1138:                while (t.hasMoreTokens()) {
1139:                    String token = t.nextToken ();
1140:
1141:                    if (token.equals (SchemaSymbols.ATTVAL_EXTENSION)) {
1142:                        choice |= SchemaSymbols.EXTENSION;
1143:                    } else if (token.equals (SchemaSymbols.ATTVAL_RESTRICTION)) {
1144:                        choice |= SchemaSymbols.RESTRICTION;
1145:                    } else {
1146:                        throw new InvalidDatatypeValueException("the value '"+value+"' must match (#all | List of (extension | restriction))");
1147:                    }
1148:                }
1149:            }
1150://???            value = Integer.toString(choice);
1151:            break;
1152:        case DT_FINAL1:
1153:            // final = (#all | (list | union | restriction))
1154:            choice = 0;
1155:            if (value.equals (SchemaSymbols.ATTVAL_POUNDALL)) {
1156:                choice = SchemaSymbols.RESTRICTION|SchemaSymbols.LIST|
1157:                         SchemaSymbols.UNION;
1158:            } else if (value.equals (SchemaSymbols.ELT_LIST)) {
1159:                choice = SchemaSymbols.LIST;
1160:            } else if (value.equals (SchemaSymbols.ELT_UNION)) {
1161:                choice = SchemaSymbols.UNION;
1162:            } else if (value.equals (SchemaSymbols.ATTVAL_RESTRICTION)) {
1163:                choice = SchemaSymbols.RESTRICTION;
1164:            } else {
1165:                throw new InvalidDatatypeValueException("the value '"+value+"' must match (#all | (list | union | restriction))");
1166:            }
1167://???            value = Integer.toString(choice);
1168:            break;
1169:        case DT_FORM:
1170:            // form = (qualified | unqualified)
1171:            if (!value.equals (SchemaSymbols.ATTVAL_QUALIFIED) &&
1172:                !value.equals (SchemaSymbols.ATTVAL_UNQUALIFIED)) {
1173:                throw new InvalidDatatypeValueException("the value '"+value+"' must match (qualified | unqualified)");
1174:            }
1175:            break;
1176:        case DT_MAXOCCURS:
1177:            // maxOccurs = (nonNegativeInteger | unbounded)
1178:            if (!value.equals("unbounded")) {
1179:                try {
1180:                    fExtraDVs[DT_NONNEGINT].validate(value, null);
1181:                } catch (InvalidDatatypeValueException ide) {
1182:                    throw new InvalidDatatypeValueException("the value '"+value+"' must match (nonNegativeInteger | unbounded)");
1183:                }
1184:            }
1185:            break;
1186:        case DT_MAXOCCURS1:
1187:            // maxOccurs = 1
1188:            if (!value.equals("1"))
1189:                throw new InvalidDatatypeValueException("the value '"+value+"' must be '1'");
1190:            break;
1191:        case DT_MEMBERTYPES:
1192:            // memberTypes = List of QName
1193:            try {
1194:                StringTokenizer t = new StringTokenizer (value, " ");
1195:                while (t.hasMoreTokens()) {
1196:                    String token = t.nextToken ();
1197:                    fExtraDVs[DT_QNAME].validate(token, null);
1198:                }
1199:            } catch (InvalidDatatypeValueException ide) {
1200:                throw new InvalidDatatypeValueException("the value '"+value+"' must match (List of QName)");
1201:            }
1202:            break;
1203:        case DT_MINOCCURS1:
1204:            // minOccurs = (0 | 1)
1205:            if (!value.equals("0") && !value.equals("1"))
1206:                throw new InvalidDatatypeValueException("the value '"+value+"' must be '0' or '1'");
1207:            break;
1208:        case DT_NAMESPACE:
1209:            // namespace = ((##any | ##other) | List of (anyURI | (##targetNamespace | ##local)) )
1210:            if (!value.equals(SchemaSymbols.ATTVAL_TWOPOUNDANY) &&
1211:                !value.equals(SchemaSymbols.ATTVAL_TWOPOUNDOTHER)) {
1212:                StringTokenizer t = new StringTokenizer (value, " ");
1213:                try {
1214:                    while (t.hasMoreTokens()) {
1215:                        String token = t.nextToken ();
1216:                        if (!token.equals(SchemaSymbols.ATTVAL_TWOPOUNDTARGETNS) &&
1217:                            !token.equals(SchemaSymbols.ATTVAL_TWOPOUNDLOCAL)) {
1218:                            fExtraDVs[DT_ANYURI].validate(token, null);
1219:                        }
1220:                    }
1221:                } catch (InvalidDatatypeValueException ide) {
1222:                    throw new InvalidDatatypeValueException("the value '"+value+"' must match ((##any | ##other) | List of (anyURI | (##targetNamespace | ##local)) )");
1223:                }
1224:            }
1225:            break;
1226:        case DT_PROCESSCONTENTS:
1227:            // processContents = (lax | skip | strict)
1228:            if (!value.equals (SchemaSymbols.ATTVAL_SKIP) &&
1229:                !value.equals (SchemaSymbols.ATTVAL_LAX) &&
1230:                !value.equals (SchemaSymbols.ATTVAL_STRICT)) {
1231:                throw new InvalidDatatypeValueException("the value '"+value+"' must match (lax | skip | strict)");
1232:            }
1233:            break;
1234:        case DT_PUBLIC:
1235:            // public = A public identifier, per ISO 8879 ???
1236:            fExtraDVs[DT_TOKEN].validate(value, null);
1237:            break;
1238:        case DT_USE:
1239:            // use = (optional | prohibited | required)
1240:            if (!value.equals (SchemaSymbols.ATTVAL_OPTIONAL) &&
1241:                !value.equals (SchemaSymbols.ATTVAL_PROHIBITED) &&
1242:                !value.equals (SchemaSymbols.ATTVAL_REQUIRED)) {
1243:                throw new InvalidDatatypeValueException("the value '"+value+"' must match (optional | prohibited | required)");
1244:            }
1245:            break;
1246:        case DT_WHITESPACE:
1247:            // value = preserve | replace | collapse
1248:            if (!value.equals (SchemaSymbols.ATT_PRESERVE) &&
1249:                !value.equals (SchemaSymbols.ATT_REPLACE) &&
1250:                !value.equals (SchemaSymbols.ATT_COLLAPSE)) {
1251:                throw new InvalidDatatypeValueException("the value '"+value+"' must match (preserve | replace | collapse)");
1252:            }
1253:            break;
1254:        }
1255:
1256:        return value;
1257:    }
1258:
1259:            // report an error. copied from TraverseSchema
1260:            private void reportSchemaError(int major, Object args[])
1261:                    throws Exception {
1262:                if (fErrorReporter == null) {
1263:                    System.out.println("__TraverseSchemaError__ : "
1264:                            + SchemaMessageProvider.fgMessageKeys[major]);
1265:                    for (int i = 0; i < args.length; i++) {
1266:                        System.out.println((String) args[i]);
1267:                    }
1268:                } else {
1269:                    fErrorReporter.reportError(fErrorReporter.getLocator(),
1270:                            SchemaMessageProvider.SCHEMA_DOMAIN, major,
1271:                            SchemaMessageProvider.MSG_NONE, args,
1272:                            XMLErrorReporter.ERRORTYPE_RECOVERABLE_ERROR);
1273:                }
1274:            }
1275:
1276:            // validate attriubtes from non-schema namespaces
1277:            public void checkNonSchemaAttributes(GrammarResolver grammarResolver) throws Exception {
1278:        // for all attributes
1279:        Enumeration enum = fNonSchemaAttrs.keys();
1280:        while (enum.hasMoreElements()) {
1281:            // get name, uri, localpart
1282:            String attrRName = (String)enum.nextElement();
1283:            String attrURI = attrRName.substring(0,attrRName.indexOf(','));
1284:            String attrLocal = attrRName.substring(attrRName.indexOf(',')+1);
1285:            // find associated grammar
1286:            Grammar grammar = grammarResolver.getGrammar(attrURI);
1287:            if (grammar == null || !(grammar instanceof  SchemaGrammar))
1288:                continue;
1289:            SchemaGrammar sGrammar = (SchemaGrammar)grammar;
1290:            // then get all top-level attributes from that grammar
1291:            Hashtable attrRegistry = sGrammar.getAttributeDeclRegistry();
1292:            if (attrRegistry == null)
1293:                continue;
1294:            // and get the datatype validator, if there is one
1295:            XMLAttributeDecl tempAttrDecl = (XMLAttributeDecl)attrRegistry.get(attrLocal);
1296:            if (tempAttrDecl == null)
1297:                continue;
1298:            DatatypeValidator dv = tempAttrDecl.datatypeValidator;
1299:            if (dv == null)
1300:                continue;
1301:
1302:            // get all values appeared with this attribute name
1303:            Vector values = (Vector)fNonSchemaAttrs.get(attrRName);
1304:            String elName, attrVal;
1305:            String attrName = (String)values.elementAt(0);
1306:            // for each of the values
1307:            int count = values.size();
1308:            for (int i = 1; i < count; i += 2) {
1309:                // normalize it according to the whiteSpace facet
1310:                elName = (String)values.elementAt(i);
1311:                attrVal = normalize((String)values.elementAt(i+1), dv.getWSFacet());
1312:                try {
1313:                    // and validate it using the DatatypeValidator
1314:                    dv.validate(attrVal,null);
1315:                } catch(InvalidDatatypeValueException ide) {
1316:                    reportSchemaError (SchemaMessageProvider.Con3X3AttributeInvalidValue,
1317:                                       new Object[] {elName, attrName, ide.getLocalizedMessage()});
1318:                }
1319:            }
1320:        }
1321:    }
1322:
1323:            // normalize the string according to the whiteSpace facet
1324:            private String normalize(String content, short ws) {
1325:                int len = content == null ? 0 : content.length();
1326:                if (len == 0 || ws == DatatypeValidator.PRESERVE)
1327:                    return content;
1328:
1329:                StringBuffer sb = new StringBuffer();
1330:                if (ws == DatatypeValidator.REPLACE) {
1331:                    char ch;
1332:                    // when it's replace, just replace #x9, #xa, #xd by #x20
1333:                    for (int i = 0; i < len; i++) {
1334:                        ch = content.charAt(i);
1335:                        if (ch != 0x9 && ch != 0xa && ch != 0xd)
1336:                            sb.append(ch);
1337:                        else
1338:                            sb.append((char) 0x20);
1339:                    }
1340:                } else {
1341:                    char ch;
1342:                    int i;
1343:                    boolean isLeading = true;
1344:                    // when it's collapse
1345:                    for (i = 0; i < len; i++) {
1346:                        ch = content.charAt(i);
1347:                        // append real characters, so we passed leading ws
1348:                        if (ch != 0x9 && ch != 0xa && ch != 0xd && ch != 0x20) {
1349:                            sb.append(ch);
1350:                            isLeading = false;
1351:                        } else {
1352:                            // for whitespaces, we skip all following ws
1353:                            for (; i < len - 1; i++) {
1354:                                ch = content.charAt(i + 1);
1355:                                if (ch != 0x9 && ch != 0xa && ch != 0xd
1356:                                        && ch != 0x20)
1357:                                    break;
1358:                            }
1359:                            // if it's not a leading or tailing ws, then append a space
1360:                            if (i < len - 1 && !isLeading)
1361:                                sb.append((char) 0x20);
1362:                        }
1363:                    }
1364:                }
1365:
1366:                return sb.toString();
1367:            }
1368:        }
1369:
1370:        class OneAttr {
1371:            // name of the attribute
1372:            public String name;
1373:            // index of the datatype validator
1374:            public int dvIndex;
1375:            // whether it's optional, and has default value
1376:            public int optdflt;
1377:            // the default value of this attribute
1378:            public String dfltValue;
1379:
1380:            public OneAttr(String name, int dvIndex, int optdflt,
1381:                    String dfltValue) {
1382:                this .name = name;
1383:                this .dvIndex = dvIndex;
1384:                this .optdflt = optdflt;
1385:                this .dfltValue = dfltValue;
1386:            }
1387:        }
1388:
1389:        class OneElement {
1390:            // the list of attributes that can appear in one element
1391:            public Hashtable attrList;
1392:            // the array of attributes that can appear in one element
1393:            public Object[] attrArray;
1394:            // does this element allow attributes from non-schema namespace
1395:            public boolean allowNonSchemaAttr;
1396:
1397:            public OneElement(Hashtable attrList) {
1398:                this (attrList, true);
1399:            }
1400:
1401:            public OneElement (Hashtable attrList, boolean allowNonSchemaAttr) {
1402:        this.attrList = attrList;
1403:
1404:        int count = attrList.size();
1405:        this.attrArray = new Object[count];
1406:        Enumeration enum = attrList.elements();
1407:        for (int i = 0; i < count; i++)
1408:            this.attrArray[i] = enum.nextElement();
1409:
1410:        this.allowNonSchemaAttr = allowNonSchemaAttr;
1411:    }
1412:        }
www.java2java.com | Contact Us
Copyright 2009 - 12 Demo Source and Support. All rights reserved.
All other trademarks are property of their respective owners.