/** * Starts marshalling of an attribute. * * The marshalling of an attribute will be done by * <ol> * <li>call the startAttribute method * <li>call the text method (several times if necessary) * <li>call the endAttribute method * </ol> * * No two attributes can be marshalled at the same time. * Note that the whole attribute marshalling must be happened * after the startElement method and before the endAttributes method. */ public void startAttribute( String uri, String local ) { _assert(textBuf==null); // allocate a buffer to collect attribute value textBuf = new StringBuffer(); // remember the attribute name. We'll use this value later. this.attNamespaceUri = uri; this.attLocalName = local; }
_assert(textBuf!=null);
/** * Switches to the "marshal child texts/elements" mode. * This method has to be called after the 1st pass is completed. */ public void endAttributes() throws SAXException { // calculate QName of the element String uri = getCurrentElementUri(); String local = getCurrentElementLocal(); String prefix = nsContext.declareNamespace(uri,false); String qname = local; if(prefix!=null) qname = prefix+':'+qname; // fire startPrefixMapping events nsContext.iterateDeclaredPrefixes(startPrefixCallback); // fire the startElement event writer.startElement( uri, local, qname, attributes ); // reset attributes attributes.clear(); // prepare to collect texts _assert(textBuf==null); textBuf = new StringBuffer(); }
/** * Ends marshalling of an element. * Pops the internal stack. */ public void endElement() throws SAXException { writePendingText(); String uri = getCurrentElementUri(); String local = getCurrentElementLocal(); String prefix = nsContext.getPrefix(uri); String qname = local; if(prefix!=null) qname = prefix+':'+qname; writer.endElement( uri, local, qname ); // pop namespace bindings and // fire endPrefixMapping events nsContext.iterateDeclaredPrefixes(endPrefixCallback); popElement(); // prepare to collect texts _assert(textBuf==null); textBuf = new StringBuffer(); nsContext.endElement(); }