Source Code Cross Referenced for XSDocumentInfo.java in  » XML » xerces-2_9_1 » org » apache » xerces » impl » xs » traversers » 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 » XML » xerces 2_9_1 » org.apache.xerces.impl.xs.traversers 
Source Cross Referenced  Class Diagram Java Document (Java Doc) 


001:        /*
002:         * Licensed to the Apache Software Foundation (ASF) under one or more
003:         * contributor license agreements.  See the NOTICE file distributed with
004:         * this work for additional information regarding copyright ownership.
005:         * The ASF licenses this file to You under the Apache License, Version 2.0
006:         * (the "License"); you may not use this file except in compliance with
007:         * the License.  You may obtain a copy of the License at
008:         * 
009:         *      http://www.apache.org/licenses/LICENSE-2.0
010:         * 
011:         * Unless required by applicable law or agreed to in writing, software
012:         * distributed under the License is distributed on an "AS IS" BASIS,
013:         * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
014:         * See the License for the specific language governing permissions and
015:         * limitations under the License.
016:         */
017:
018:        package org.apache.xerces.impl.xs.traversers;
019:
020:        import java.util.Stack;
021:        import java.util.Vector;
022:
023:        import org.apache.xerces.impl.validation.ValidationState;
024:        import org.apache.xerces.impl.xs.SchemaNamespaceSupport;
025:        import org.apache.xerces.impl.xs.SchemaSymbols;
026:        import org.apache.xerces.impl.xs.XMLSchemaException;
027:        import org.apache.xerces.impl.xs.util.XInt;
028:        import org.apache.xerces.util.SymbolTable;
029:        import org.w3c.dom.Element;
030:
031:        /**
032:         * Objects of this class hold all information pecular to a
033:         * particular XML Schema document.  This is needed because
034:         * namespace bindings and other settings on the <schema/> element
035:         * affect the contents of that schema document alone.
036:         *
037:         * @xerces.internal 
038:         *
039:         * @author Neil Graham, IBM
040:         * @version $Id: XSDocumentInfo.java 446725 2006-09-15 20:40:10Z mrglavas $
041:         */
042:        class XSDocumentInfo {
043:
044:            // Data
045:            protected SchemaNamespaceSupport fNamespaceSupport;
046:            protected SchemaNamespaceSupport fNamespaceSupportRoot;
047:            protected Stack SchemaNamespaceSupportStack = new Stack();
048:
049:            // schema's attributeFormDefault
050:            protected boolean fAreLocalAttributesQualified;
051:
052:            // elementFormDefault
053:            protected boolean fAreLocalElementsQualified;
054:
055:            // [block | final]Default
056:            protected short fBlockDefault;
057:            protected short fFinalDefault;
058:
059:            // targetNamespace
060:            String fTargetNamespace;
061:
062:            // represents whether this is a chameleon schema (i.e., whether its TNS is natural or comes from without)
063:            protected boolean fIsChameleonSchema;
064:
065:            // the root of the schema Document tree itself
066:            protected Element fSchemaElement;
067:
068:            // all namespaces that this document can refer to
069:            Vector fImportedNS = new Vector();
070:
071:            protected ValidationState fValidationContext = new ValidationState();
072:
073:            SymbolTable fSymbolTable = null;
074:
075:            // attribute checker to which we'll return the attributes 
076:            // once we've been told that we're done with them
077:            protected XSAttributeChecker fAttrChecker;
078:
079:            // array of objects on the schema's root element.  This is null
080:            // once returnSchemaAttrs has been called.
081:            protected Object[] fSchemaAttrs;
082:
083:            // list of annotations contained in the schema document. This is null
084:            // once removeAnnotations has been called.
085:            protected XSAnnotationInfo fAnnotations = null;
086:
087:            // note that the caller must ensure to call returnSchemaAttrs()
088:            // to avoid memory leaks!
089:            XSDocumentInfo(Element schemaRoot, XSAttributeChecker attrChecker,
090:                    SymbolTable symbolTable) throws XMLSchemaException {
091:
092:                fSchemaElement = schemaRoot;
093:                fNamespaceSupport = new SchemaNamespaceSupport(schemaRoot,
094:                        symbolTable);
095:                fNamespaceSupport.reset();
096:                fIsChameleonSchema = false;
097:
098:                fSymbolTable = symbolTable;
099:                fAttrChecker = attrChecker;
100:
101:                if (schemaRoot != null) {
102:                    Element root = schemaRoot;
103:                    fSchemaAttrs = attrChecker
104:                            .checkAttributes(root, true, this );
105:                    // schemaAttrs == null means it's not an <xsd:schema> element
106:                    // throw an exception, but we don't know the document systemId,
107:                    // so we leave that to the caller.
108:                    if (fSchemaAttrs == null) {
109:                        throw new XMLSchemaException(null, null);
110:                    }
111:                    fAreLocalAttributesQualified = ((XInt) fSchemaAttrs[XSAttributeChecker.ATTIDX_AFORMDEFAULT])
112:                            .intValue() == SchemaSymbols.FORM_QUALIFIED;
113:                    fAreLocalElementsQualified = ((XInt) fSchemaAttrs[XSAttributeChecker.ATTIDX_EFORMDEFAULT])
114:                            .intValue() == SchemaSymbols.FORM_QUALIFIED;
115:                    fBlockDefault = ((XInt) fSchemaAttrs[XSAttributeChecker.ATTIDX_BLOCKDEFAULT])
116:                            .shortValue();
117:                    fFinalDefault = ((XInt) fSchemaAttrs[XSAttributeChecker.ATTIDX_FINALDEFAULT])
118:                            .shortValue();
119:                    fTargetNamespace = (String) fSchemaAttrs[XSAttributeChecker.ATTIDX_TARGETNAMESPACE];
120:                    if (fTargetNamespace != null)
121:                        fTargetNamespace = symbolTable
122:                                .addSymbol(fTargetNamespace);
123:
124:                    fNamespaceSupportRoot = new SchemaNamespaceSupport(
125:                            fNamespaceSupport);
126:
127:                    //set namespace support
128:                    fValidationContext.setNamespaceSupport(fNamespaceSupport);
129:                    fValidationContext.setSymbolTable(symbolTable);
130:                    // pass null as the schema document, so that the namespace
131:                    // context is not popped.
132:
133:                    // don't return the attribute array yet!
134:                    //attrChecker.returnAttrArray(schemaAttrs, null);
135:                }
136:            }
137:
138:            // backup the current ns support, and use the one passed-in.
139:            // if no ns support is passed-in, use the one for <schema> element
140:            void backupNSSupport(SchemaNamespaceSupport nsSupport) {
141:                SchemaNamespaceSupportStack.push(fNamespaceSupport);
142:                if (nsSupport == null)
143:                    nsSupport = fNamespaceSupportRoot;
144:                fNamespaceSupport = new SchemaNamespaceSupport(nsSupport);
145:
146:                fValidationContext.setNamespaceSupport(fNamespaceSupport);
147:            }
148:
149:            void restoreNSSupport() {
150:                fNamespaceSupport = (SchemaNamespaceSupport) SchemaNamespaceSupportStack
151:                        .pop();
152:                fValidationContext.setNamespaceSupport(fNamespaceSupport);
153:            }
154:
155:            // some Object methods
156:            public String toString() {
157:                return fTargetNamespace == null ? "no targetNamspace"
158:                        : "targetNamespace is " + fTargetNamespace;
159:            }
160:
161:            public void addAllowedNS(String namespace) {
162:                fImportedNS.addElement(namespace == null ? "" : namespace);
163:            }
164:
165:            public boolean isAllowedNS(String namespace) {
166:                return fImportedNS.contains(namespace == null ? "" : namespace);
167:            }
168:
169:            // store whether we have reported an error about that this document
170:            // can't access components from the given namespace
171:            private Vector fReportedTNS = null;
172:
173:            // check whether we need to report an error against the given uri.
174:            // if we have reported an error, then we don't need to report again;
175:            // otherwise we reported the error, and remember this fact.
176:            final boolean needReportTNSError(String uri) {
177:                if (fReportedTNS == null)
178:                    fReportedTNS = new Vector();
179:                else if (fReportedTNS.contains(uri))
180:                    return false;
181:                fReportedTNS.addElement(uri);
182:                return true;
183:            }
184:
185:            // return the attributes on the schema element itself:
186:            Object[] getSchemaAttrs() {
187:                return fSchemaAttrs;
188:            }
189:
190:            // deallocate the storage set aside for the schema element's
191:            // attributes
192:            void returnSchemaAttrs() {
193:                fAttrChecker.returnAttrArray(fSchemaAttrs, null);
194:                fSchemaAttrs = null;
195:            }
196:
197:            // adds an annotation to the list of annotations
198:            void addAnnotation(XSAnnotationInfo info) {
199:                info.next = fAnnotations;
200:                fAnnotations = info;
201:            }
202:
203:            // returns the list of annotations conatined in the
204:            // schema document or null if the document contained no annotations.
205:            XSAnnotationInfo getAnnotations() {
206:                return fAnnotations;
207:            }
208:
209:            // removes reference to annotation list
210:            void removeAnnotations() {
211:                fAnnotations = null;
212:            }
213:
214:        } // XSDocumentInfo
www.java2java.com | Contact Us
Copyright 2009 - 12 Demo Source and Support. All rights reserved.
All other trademarks are property of their respective owners.