1 17 package org.apache.ws.jaxme.xs.impl; 18 19 import org.apache.ws.jaxme.xs.XPathMatcher; 20 import org.apache.ws.jaxme.xs.XSAnnotation; 21 import org.apache.ws.jaxme.xs.XSElement; 22 import org.apache.ws.jaxme.xs.XSElementOrAttrRef; 23 import org.apache.ws.jaxme.xs.XSIdentityConstraint; 24 import org.apache.ws.jaxme.xs.XSKeyRef; 25 import org.apache.ws.jaxme.xs.parser.impl.LocSAXException; 26 import org.apache.ws.jaxme.xs.xml.XsEKeyref; 27 import org.xml.sax.SAXException ; 28 29 34 public class XSKeyRefImpl extends XSOpenAttrsImpl 35 implements XSKeyRef 36 { 37 private XSAnnotation[] annotations; 38 private String name; 39 private XSIdentityConstraint identityConstraint; 40 private XsEKeyref keyRef; 41 private XSElementOrAttrRef[][] matchCriteria; 42 43 protected XSKeyRefImpl( XSElement pParent, XsEKeyref keyRef ) 44 throws SAXException 45 { 46 super( pParent, keyRef ); 47 48 this.annotations = getXSSchema().getXSObjectFactory().newXSAnnotations( 49 this, 50 keyRef.getAnnotation() 51 ); 52 53 this.name = keyRef.getName().getValue(); 54 this.keyRef = keyRef; 55 } 56 57 public XSAnnotation[] getAnnotations() { 58 return annotations; 59 } 60 61 64 public String getName() { 65 return name; 66 } 67 68 71 public XSIdentityConstraint getIdentityConstraint() { 72 return identityConstraint; 73 } 74 75 78 public XSElementOrAttrRef[][] getMatchCriteria() { 79 return matchCriteria; 80 } 81 82 public void validate() throws SAXException { 83 validateAllIn( annotations ); 84 85 String referredIdentity = keyRef.getRefer().getLocalName(); 86 identityConstraint = (XSIdentityConstraint) getXSSchema().getIdentityConstraints().get( 87 referredIdentity 88 ); 89 90 if ( identityConstraint == null ) { 91 throw new LocSAXException( 92 "Unknown identity constraint: " + referredIdentity, 93 keyRef.getLocator() 94 ); 95 } 96 97 matchCriteria = XPathMatcher.match( 98 keyRef, 99 (XSElement) getParentObject() 100 ); 101 } 102 } 103 | Popular Tags |