1 22 23 package org.xquark.schema.loader; 24 25 import org.xml.sax.Attributes ; 26 import org.xml.sax.SAXException ; 27 import org.xquark.schema.IdentityConstraint; 28 import org.xquark.schema.SchemaConstants; 29 import org.xquark.schema.SchemaException; 30 import org.xquark.util.DefaultElementHandler; 31 import org.xquark.util.ElementHandler; 32 33 class IdentityConstraintHandler extends DefaultElementHandler implements SchemaConstants { 34 private static final String RCSRevision = "$Revision: 1.1 $"; 35 private static final String RCSName = "$Name: $"; 36 private Loader loader = null; 37 private IdentityConstraint identityConstraint = null; 38 39 IdentityConstraintHandler(Loader loader, IdentityConstraint identityConstraint) 40 throws SAXException { 41 this.loader = loader; 42 this.identityConstraint = identityConstraint; 43 } 44 45 public ElementHandler startElement(String namespaceURI, String localName, Attributes atts) 46 throws SAXException { 47 if ( namespaceURI.equals(XMLSCHEMA_URI) ) { 48 if ( localName.equals(SELECTOR_TAG) ) { 50 String xpath = atts.getValue("", XPATH_ATTR); 51 try { 52 identityConstraint.setSelector(loader.buildXPaths(xpath)); 53 } 54 catch ( SchemaException se ) { 55 String errMsg = "Error while processing localName -> " + localName; 56 loader.reportLoadingError(errMsg, se); 57 } 58 return this; 59 } 60 61 if ( localName.equals(FIELD_TAG) ) { 63 String xpath = atts.getValue("", XPATH_ATTR); 64 try { 65 identityConstraint.addField(loader.buildXPaths(xpath)); 66 } 67 catch ( SchemaException se ) { 68 String errMsg = "Error while processing localName -> " + localName; 69 loader.reportLoadingError(errMsg, se); 70 } 71 return this; 72 } 73 74 if ( localName.equals(ANNOTATION_TAG) ) { 75 return new AnnotationHandler(); 76 } 77 } 78 79 loader.notifyUnknownElement(namespaceURI, localName); 80 return this; 81 } 82 83 } 84 | Popular Tags |