@Override public void startElement(String namespaceURI, String localName, String qName, Attributes atts) throws SAXException { // set the root element's prefix qualified name and namespace prefix if (getRootElementName() == null) { setRootElementName(qName); setLocalName(localName); setRootElementNamespaceUri(namespaceURI); } if(Constants.EMPTY_STRING.equals(localName)) { return; } elementCount++; if (elementCount > 1) { // we only want to process characters from the first text child; // if a subelement occurs, we will stop shouldReadChars = false; } }
/** * Return a populated XMLRoot object. */ public Object getCurrentObject() { // this assumes that since we're unmarshalling to a primitive wrapper, the root // element has a single text node. if, however, the root element doesn't have // a text node as a first child, we'll try converting null String val = null; if (characters != null) { val = characters.toString(); } XMLRoot xmlRoot = new XMLRoot(); xmlRoot.setObject(((XMLConversionManager) session.getDatasourcePlatform().getConversionManager()).convertObject(val, targetClass)); xmlRoot.setLocalName(getRootElementName()); xmlRoot.setNamespaceURI(getRootElementNamespaceUri()); return xmlRoot; }
@Override public void startElement(String namespaceURI, String localName, String qName, Attributes atts) throws SAXException { // set the root element's prefix qualified name and namespace prefix if (getRootElementName() == null) { setRootElementName(qName); setLocalName(localName); setRootElementNamespaceUri(namespaceURI); } if(Constants.EMPTY_STRING.equals(localName)) { return; } elementCount++; if (elementCount > 1) { // we only want to process characters from the first text child; // if a subelement occurs, we will stop shouldReadChars = false; } }