1 57 58 package com.sun.org.apache.xerces.internal.impl.xs.traversers; 59 60 import com.sun.org.apache.xerces.internal.impl.xs.SchemaGrammar; 61 import com.sun.org.apache.xerces.internal.impl.xs.SchemaSymbols; 62 import com.sun.org.apache.xerces.internal.impl.xs.XSElementDecl; 63 import com.sun.org.apache.xerces.internal.impl.xs.identity.IdentityConstraint; 64 import com.sun.org.apache.xerces.internal.impl.xs.identity.UniqueOrKey; 65 import com.sun.org.apache.xerces.internal.util.DOMUtil; 66 import org.w3c.dom.Element ; 67 68 75 class XSDUniqueOrKeyTraverser extends XSDAbstractIDConstraintTraverser { 76 77 public XSDUniqueOrKeyTraverser (XSDHandler handler, 78 XSAttributeChecker gAttrCheck) { 79 super(handler, gAttrCheck); 80 } 81 82 83 void traverse(Element uElem, XSElementDecl element, 84 XSDocumentInfo schemaDoc, SchemaGrammar grammar) { 85 86 Object [] attrValues = fAttrChecker.checkAttributes(uElem, false, schemaDoc); 88 89 String uName = (String )attrValues[XSAttributeChecker.ATTIDX_NAME]; 91 92 if(uName == null){ 93 reportSchemaError("s4s-att-must-appear", new Object [] {DOMUtil.getLocalName(uElem) , SchemaSymbols.ATT_NAME }, uElem); 94 fAttrChecker.returnAttrArray(attrValues, schemaDoc); 96 return; 97 } 98 99 UniqueOrKey uniqueOrKey = null; 100 if(DOMUtil.getLocalName(uElem).equals(SchemaSymbols.ELT_UNIQUE)) { 101 uniqueOrKey = new UniqueOrKey(schemaDoc.fTargetNamespace, uName, element.fName, IdentityConstraint.IC_UNIQUE); 102 } else { 103 uniqueOrKey = new UniqueOrKey(schemaDoc.fTargetNamespace, uName, element.fName, IdentityConstraint.IC_KEY); 104 } 105 109 traverseIdentityConstraint(uniqueOrKey, uElem, schemaDoc, attrValues); 111 112 grammar.addIDConstraintDecl(element, uniqueOrKey); 114 115 fAttrChecker.returnAttrArray(attrValues, schemaDoc); 117 } } | Popular Tags |