1 package org.apache.ws.jaxme.impl; 2 3 import javax.xml.bind.ValidationEvent; 4 5 import org.apache.ws.jaxme.ValidationEvents; 6 import org.apache.ws.jaxme.XMLConstants; 7 import org.apache.ws.jaxme.xs.xml.XsQName; 8 import org.xml.sax.Attributes ; 9 import org.xml.sax.SAXException ; 10 11 12 15 public abstract class JMSAXElementParser extends JMSAXGroupParser { 16 private JMUnmarshallerHandlerImpl handler; 17 protected Object result; 18 private String namespaceURI, localName; 19 private int level; 20 21 public JMUnmarshallerHandlerImpl getHandler() { 22 return handler; 23 } 24 25 27 public boolean isAtomic() { return false; } 28 29 31 public boolean isEmpty() { return false; } 32 33 35 public String getNamespaceURI() { return namespaceURI; } 36 38 public String getLocalName() { return localName; } 39 42 public int getEndLevel() { return level; } 43 44 46 public void init(JMUnmarshallerHandlerImpl pHandler, Object pObject, 47 String pNamespaceURI, String pLocalName, int pLevel) { 48 handler = pHandler; 49 result = pObject; 50 namespaceURI = pNamespaceURI; 51 localName = pLocalName; 52 level = pLevel; 53 } 54 55 59 public void addAttribute(String pNamespaceURI, String pLocalName, 60 String pValue) throws SAXException { 61 if (javax.xml.XMLConstants.XML_NS_URI.equals(pNamespaceURI) 62 || javax.xml.XMLConstants.XMLNS_ATTRIBUTE_NS_URI.equals(pNamespaceURI) 63 || XMLConstants.XML_SCHEMA_URI.equals(pNamespaceURI)) { 64 } else { 66 XsQName qName = new XsQName(pNamespaceURI, pLocalName); 67 handler.validationEvent(ValidationEvent.WARNING, ValidationEvents.EVENT_UNKNOWN_ATTRIBUTE, 68 "Unknown attribute '" + qName + "' with value '" 69 + pValue + "'", null); 70 } 71 } 72 73 76 public void setAttributes(Attributes pAttrs) throws SAXException { 77 if (pAttrs != null) { 78 for (int i = 0; i < pAttrs.getLength(); i++) { 79 addAttribute(pAttrs.getURI(i), pAttrs.getLocalName(i), 80 pAttrs.getValue(i)); 81 } 82 } 83 } 84 } 85 | Popular Tags |