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.XSElementDecl; 22 import org.apache.xerces.impl.xs.identity.IdentityConstraint; 23 import org.apache.xerces.impl.xs.identity.UniqueOrKey; 24 import org.apache.xerces.util.DOMUtil; 25 import org.w3c.dom.Element ; 26 27 36 class XSDUniqueOrKeyTraverser extends XSDAbstractIDConstraintTraverser { 37 38 public XSDUniqueOrKeyTraverser (XSDHandler handler, 39 XSAttributeChecker gAttrCheck) { 40 super(handler, gAttrCheck); 41 } 42 43 44 void traverse(Element uElem, XSElementDecl element, 45 XSDocumentInfo schemaDoc, SchemaGrammar grammar) { 46 47 Object [] attrValues = fAttrChecker.checkAttributes(uElem, false, schemaDoc); 49 50 String uName = (String )attrValues[XSAttributeChecker.ATTIDX_NAME]; 52 53 if(uName == null){ 54 reportSchemaError("s4s-att-must-appear", new Object [] {DOMUtil.getLocalName(uElem) , SchemaSymbols.ATT_NAME }, uElem); 55 fAttrChecker.returnAttrArray(attrValues, schemaDoc); 57 return; 58 } 59 60 UniqueOrKey uniqueOrKey = null; 61 if(DOMUtil.getLocalName(uElem).equals(SchemaSymbols.ELT_UNIQUE)) { 62 uniqueOrKey = new UniqueOrKey(schemaDoc.fTargetNamespace, uName, element.fName, IdentityConstraint.IC_UNIQUE); 63 } else { 64 uniqueOrKey = new UniqueOrKey(schemaDoc.fTargetNamespace, uName, element.fName, IdentityConstraint.IC_KEY); 65 } 66 70 traverseIdentityConstraint(uniqueOrKey, uElem, schemaDoc, attrValues); 72 73 grammar.addIDConstraintDecl(element, uniqueOrKey); 75 76 fAttrChecker.returnAttrArray(attrValues, schemaDoc); 78 } } | Popular Tags |