1 16 17 package org.apache.xerces.impl.xs.traversers; 18 19 import org.apache.xerces.impl.xs.SchemaGrammar; 20 import org.apache.xerces.impl.xs.SchemaSymbols; 21 import org.apache.xerces.impl.xs.XSAnnotationImpl; 22 import org.apache.xerces.impl.xs.XSParticleDecl; 23 import org.apache.xerces.impl.xs.XSWildcardDecl; 24 import org.apache.xerces.impl.xs.util.XInt; 25 import org.apache.xerces.util.DOMUtil; 26 import org.w3c.dom.Element ; 27 28 56 class XSDWildcardTraverser extends XSDAbstractTraverser { 57 58 65 XSDWildcardTraverser (XSDHandler handler, 66 XSAttributeChecker gAttrCheck) { 67 super(handler, gAttrCheck); 68 } 69 70 71 79 XSParticleDecl traverseAny(Element elmNode, 80 XSDocumentInfo schemaDoc, 81 SchemaGrammar grammar) { 82 83 Object [] attrValues = fAttrChecker.checkAttributes(elmNode, false, schemaDoc); 85 XSWildcardDecl wildcard = traverseWildcardDecl(elmNode, attrValues, schemaDoc, grammar); 86 87 XSParticleDecl particle = null; 89 if (wildcard != null) { 90 int min = ((XInt)attrValues[XSAttributeChecker.ATTIDX_MINOCCURS]).intValue(); 91 int max = ((XInt)attrValues[XSAttributeChecker.ATTIDX_MAXOCCURS]).intValue(); 92 if (max != 0) { 93 if (fSchemaHandler.fDeclPool !=null) { 94 particle = fSchemaHandler.fDeclPool.getParticleDecl(); 95 } else { 96 particle = new XSParticleDecl(); 97 } 98 particle.fType = XSParticleDecl.PARTICLE_WILDCARD; 99 particle.fValue = wildcard; 100 particle.fMinOccurs = min; 101 particle.fMaxOccurs = max; 102 } 103 } 104 105 fAttrChecker.returnAttrArray(attrValues, schemaDoc); 106 107 return particle; 108 } 109 110 111 119 XSWildcardDecl traverseAnyAttribute(Element elmNode, 120 XSDocumentInfo schemaDoc, 121 SchemaGrammar grammar) { 122 123 Object [] attrValues = fAttrChecker.checkAttributes(elmNode, false, schemaDoc); 125 XSWildcardDecl wildcard = traverseWildcardDecl(elmNode, attrValues, schemaDoc, grammar); 126 fAttrChecker.returnAttrArray(attrValues, schemaDoc); 127 128 return wildcard; 129 } 130 131 132 140 XSWildcardDecl traverseWildcardDecl(Element elmNode, 141 Object [] attrValues, 142 XSDocumentInfo schemaDoc, 143 SchemaGrammar grammar) { 144 145 XSWildcardDecl wildcard = new XSWildcardDecl(); 147 XInt namespaceTypeAttr = (XInt) attrValues[XSAttributeChecker.ATTIDX_NAMESPACE]; 149 wildcard.fType = namespaceTypeAttr.shortValue(); 150 wildcard.fNamespaceList = (String [])attrValues[XSAttributeChecker.ATTIDX_NAMESPACE_LIST]; 152 XInt processContentsAttr = (XInt) attrValues[XSAttributeChecker.ATTIDX_PROCESSCONTENTS]; 154 wildcard.fProcessContents = processContentsAttr.shortValue(); 155 156 Element child = DOMUtil.getFirstChildElement(elmNode); 158 XSAnnotationImpl annotation = null; 159 if (child != null) 160 { 161 if (DOMUtil.getLocalName(child).equals(SchemaSymbols.ELT_ANNOTATION)) { 162 annotation = traverseAnnotationDecl(child, attrValues, false, schemaDoc); 163 child = DOMUtil.getNextSiblingElement(child); 164 } 165 else { 166 String text = DOMUtil.getSyntheticAnnotation(elmNode); 167 if (text != null) { 168 annotation = traverseSyntheticAnnotation(elmNode, text, attrValues, false, schemaDoc); 169 } 170 } 171 172 if (child != null) { 173 reportSchemaError("s4s-elt-must-match.1", new Object []{"wildcard", "(annotation?)", DOMUtil.getLocalName(child)}, elmNode); 174 } 175 } 176 else { 177 String text = DOMUtil.getSyntheticAnnotation(elmNode); 178 if (text != null) { 179 annotation = traverseSyntheticAnnotation(elmNode, text, attrValues, false, schemaDoc); 180 } 181 } 182 wildcard.fAnnotation = annotation; 183 184 return wildcard; 185 186 } 188 } | Popular Tags |