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.KeyRef; 65 import com.sun.org.apache.xerces.internal.impl.xs.identity.UniqueOrKey; 66 import com.sun.org.apache.xerces.internal.xni.QName; 67 import org.w3c.dom.Element ; 68 69 75 class XSDKeyrefTraverser extends XSDAbstractIDConstraintTraverser { 76 77 public XSDKeyrefTraverser (XSDHandler handler, 78 XSAttributeChecker gAttrCheck) { 79 super(handler, gAttrCheck); 80 } 81 82 void traverse(Element krElem, XSElementDecl element, 83 XSDocumentInfo schemaDoc, SchemaGrammar grammar) { 84 85 Object [] attrValues = fAttrChecker.checkAttributes(krElem, false, schemaDoc); 87 88 String krName = (String )attrValues[XSAttributeChecker.ATTIDX_NAME]; 90 if(krName == null){ 91 reportSchemaError("s4s-att-must-appear", new Object [] {SchemaSymbols.ELT_KEYREF , SchemaSymbols.ATT_NAME }, krElem); 92 fAttrChecker.returnAttrArray(attrValues, schemaDoc); 94 return; 95 } 96 QName kName = (QName)attrValues[XSAttributeChecker.ATTIDX_REFER]; 97 if(kName == null){ 98 reportSchemaError("s4s-att-must-appear", new Object [] {SchemaSymbols.ELT_KEYREF , SchemaSymbols.ATT_REFER }, krElem); 99 fAttrChecker.returnAttrArray(attrValues, schemaDoc); 101 return; 102 } 103 104 UniqueOrKey key = null; 105 IdentityConstraint ret = (IdentityConstraint)fSchemaHandler.getGlobalDecl(schemaDoc, XSDHandler.IDENTITYCONSTRAINT_TYPE, kName, krElem); 106 if (ret != null) { 109 if (ret.getCategory() == IdentityConstraint.IC_KEY || 110 ret.getCategory() == IdentityConstraint.IC_UNIQUE) { 111 key = (UniqueOrKey)ret; 112 } else { 113 reportSchemaError("src-resolve", new Object []{kName.rawname, "identity constraint key/unique"}, krElem); 114 } 115 } 116 117 if(key == null) { 118 fAttrChecker.returnAttrArray(attrValues, schemaDoc); 119 return; 120 } 121 122 KeyRef keyRef = new KeyRef(schemaDoc.fTargetNamespace, krName, element.fName, key); 123 124 traverseIdentityConstraint(keyRef, krElem, schemaDoc, attrValues); 126 127 if(key.getFieldCount() != keyRef.getFieldCount()) { 130 reportSchemaError("c-props-correct.2" , new Object [] {krName,key.getIdentityConstraintName()}, krElem); 131 } else { 132 grammar.addIDConstraintDecl(element, keyRef); 135 } 136 137 fAttrChecker.returnAttrArray(attrValues, schemaDoc); 139 } } 142 | Popular Tags |