Source Code Cross Referenced for XSDAttributeGroupTraverser.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:        package org.apache.xerces.impl.xs.traversers;
018:
019:        import org.apache.xerces.impl.xs.SchemaGrammar;
020:        import org.apache.xerces.impl.xs.SchemaSymbols;
021:        import org.apache.xerces.impl.xs.XSAnnotationImpl;
022:        import org.apache.xerces.impl.xs.XSAttributeGroupDecl;
023:        import org.apache.xerces.impl.xs.util.XSObjectListImpl;
024:        import org.apache.xerces.util.DOMUtil;
025:        import org.apache.xerces.util.XMLSymbols;
026:        import org.apache.xerces.xni.QName;
027:        import org.apache.xerces.xs.XSObjectList;
028:        import org.w3c.dom.Element;
029:
030:        /**
031:         * The attribute group definition schema component traverser.
032:         *
033:         * <attributeGroup
034:         *   id = ID
035:         *   name = NCName
036:         *   ref = QName
037:         *   {any attributes with non-schema namespace . . .}>
038:         *   Content: (annotation?, ((attribute | attributeGroup)*, anyAttribute?))
039:         * </attributeGroup>
040:         *
041:         * @xerces.internal 
042:         *
043:         * @author Rahul Srivastava, Sun Microsystems Inc.
044:         * @author Sandy Gao, IBM
045:         *
046:         * @version $Id: XSDAttributeGroupTraverser.java 449424 2006-09-24 16:22:30Z mrglavas $
047:         */
048:        class XSDAttributeGroupTraverser extends XSDAbstractTraverser {
049:
050:            XSDAttributeGroupTraverser(XSDHandler handler,
051:                    XSAttributeChecker gAttrCheck) {
052:
053:                super (handler, gAttrCheck);
054:            }
055:
056:            XSAttributeGroupDecl traverseLocal(Element elmNode,
057:                    XSDocumentInfo schemaDoc, SchemaGrammar grammar) {
058:
059:                // General Attribute Checking for elmNode declared locally
060:                Object[] attrValues = fAttrChecker.checkAttributes(elmNode,
061:                        false, schemaDoc);
062:
063:                // get attribute
064:                QName refAttr = (QName) attrValues[XSAttributeChecker.ATTIDX_REF];
065:
066:                XSAttributeGroupDecl attrGrp = null;
067:
068:                // ref should be here.
069:                if (refAttr == null) {
070:                    reportSchemaError("s4s-att-must-appear", new Object[] {
071:                            "attributeGroup (local)", "ref" }, elmNode);
072:                    fAttrChecker.returnAttrArray(attrValues, schemaDoc);
073:                    return null;
074:                }
075:
076:                // get global decl
077:                attrGrp = (XSAttributeGroupDecl) fSchemaHandler.getGlobalDecl(
078:                        schemaDoc, XSDHandler.ATTRIBUTEGROUP_TYPE, refAttr,
079:                        elmNode);
080:
081:                // no children are allowed here except annotation, which is optional.
082:                Element child = DOMUtil.getFirstChildElement(elmNode);
083:                if (child != null) {
084:                    String childName = DOMUtil.getLocalName(child);
085:                    if (childName.equals(SchemaSymbols.ELT_ANNOTATION)) {
086:                        traverseAnnotationDecl(child, attrValues, false,
087:                                schemaDoc);
088:                        child = DOMUtil.getNextSiblingElement(child);
089:                    } else {
090:                        String text = DOMUtil.getSyntheticAnnotation(child);
091:                        if (text != null) {
092:                            traverseSyntheticAnnotation(child, text,
093:                                    attrValues, false, schemaDoc);
094:                        }
095:                    }
096:
097:                    if (child != null) {
098:                        Object[] args = new Object[] { refAttr.rawname,
099:                                "(annotation?)", DOMUtil.getLocalName(child) };
100:                        reportSchemaError("s4s-elt-must-match.1", args, child);
101:                    }
102:                } // if
103:
104:                fAttrChecker.returnAttrArray(attrValues, schemaDoc);
105:                return attrGrp;
106:
107:            } // traverseLocal
108:
109:            XSAttributeGroupDecl traverseGlobal(Element elmNode,
110:                    XSDocumentInfo schemaDoc, SchemaGrammar grammar) {
111:
112:                XSAttributeGroupDecl attrGrp = new XSAttributeGroupDecl();
113:
114:                // General Attribute Checking for elmNode declared globally
115:                Object[] attrValues = fAttrChecker.checkAttributes(elmNode,
116:                        true, schemaDoc);
117:
118:                String nameAttr = (String) attrValues[XSAttributeChecker.ATTIDX_NAME];
119:
120:                // global declaration must have a name
121:                if (nameAttr == null) {
122:                    reportSchemaError("s4s-att-must-appear", new Object[] {
123:                            "attributeGroup (global)", "name" }, elmNode);
124:                    nameAttr = "no name";
125:                }
126:
127:                attrGrp.fName = nameAttr;
128:                attrGrp.fTargetNamespace = schemaDoc.fTargetNamespace;
129:
130:                // check the content
131:                Element child = DOMUtil.getFirstChildElement(elmNode);
132:                XSAnnotationImpl annotation = null;
133:
134:                if (child != null
135:                        && DOMUtil.getLocalName(child).equals(
136:                                SchemaSymbols.ELT_ANNOTATION)) {
137:                    annotation = traverseAnnotationDecl(child, attrValues,
138:                            false, schemaDoc);
139:                    child = DOMUtil.getNextSiblingElement(child);
140:                } else {
141:                    String text = DOMUtil.getSyntheticAnnotation(elmNode);
142:                    if (text != null) {
143:                        annotation = traverseSyntheticAnnotation(elmNode, text,
144:                                attrValues, false, schemaDoc);
145:                    }
146:                }
147:
148:                // Traverse the attribute and attribute group elements and fill in the 
149:                // attributeGroup structure
150:
151:                Element nextNode = traverseAttrsAndAttrGrps(child, attrGrp,
152:                        schemaDoc, grammar, null);
153:                if (nextNode != null) {
154:                    // An invalid element was found...
155:                    Object[] args = new Object[] {
156:                            nameAttr,
157:                            "(annotation?, ((attribute | attributeGroup)*, anyAttribute?))",
158:                            DOMUtil.getLocalName(nextNode) };
159:                    reportSchemaError("s4s-elt-must-match.1", args, nextNode);
160:                }
161:
162:                // Remove prohibited attributes from the set
163:                attrGrp.removeProhibitedAttrs();
164:
165:                // check for restricted redefine:
166:                XSAttributeGroupDecl redefinedAttrGrp = (XSAttributeGroupDecl) fSchemaHandler
167:                        .getGrpOrAttrGrpRedefinedByRestriction(
168:                                XSDHandler.ATTRIBUTEGROUP_TYPE, new QName(
169:                                        XMLSymbols.EMPTY_STRING, nameAttr,
170:                                        nameAttr, schemaDoc.fTargetNamespace),
171:                                schemaDoc, elmNode);
172:                if (redefinedAttrGrp != null) {
173:                    Object[] errArgs = attrGrp.validRestrictionOf(nameAttr,
174:                            redefinedAttrGrp);
175:                    if (errArgs != null) {
176:                        reportSchemaError((String) errArgs[errArgs.length - 1],
177:                                errArgs, child);
178:                        reportSchemaError("src-redefine.7.2.2", new Object[] {
179:                                nameAttr, errArgs[errArgs.length - 1] }, child);
180:                    }
181:                }
182:
183:                XSObjectList annotations;
184:                if (annotation != null) {
185:                    annotations = new XSObjectListImpl();
186:                    ((XSObjectListImpl) annotations).add(annotation);
187:                } else {
188:                    annotations = XSObjectListImpl.EMPTY_LIST;
189:                }
190:
191:                attrGrp.fAnnotations = annotations;
192:
193:                // make an entry in global declarations.
194:                grammar.addGlobalAttributeGroupDecl(attrGrp);
195:
196:                fAttrChecker.returnAttrArray(attrValues, schemaDoc);
197:                return attrGrp;
198:
199:            } // traverseGlobal
200:
201:        } // XSDAttributeGroupTraverser
www.java2java.com | Contact Us
Copyright 2009 - 12 Demo Source and Support. All rights reserved.
All other trademarks are property of their respective owners.