public void attribute(int prefix, String localName, String value) { String qname; String nsUri; if(prefix==-1) { nsUri = ""; qname = localName; } else { nsUri = nsContext.getNamespaceURI(prefix); String p = nsContext.getPrefix(prefix); if(p.length()==0) // this is more likely a bug in the application code (NamespacePrefixMapper implementation) // this only happens when it tries to assign "" prefix to a non-"" URI, // which is by itself violation of namespace rec. But let's just be safe. // See http://forums.java.net/jive/thread.jspa?messageID=212598#212598 qname = localName; else qname = p +':'+localName; } atts.addAttribute( nsUri, localName, qname, "CDATA", value ); }
/** * Copy an entire Attributes object. * * <p>It may be more efficient to reuse an existing object * rather than constantly allocating new ones.</p> * * @param atts The attributes to copy. */ public void setAttributes (Attributes atts) { clear(); length = atts.getLength(); if (length > 0) { data = new String[length*5]; for (int i = 0; i < length; i++) { data[i*5] = atts.getURI(i); data[i*5+1] = atts.getLocalName(i); data[i*5+2] = atts.getQName(i); data[i*5+3] = atts.getType(i); data[i*5+4] = atts.getValue(i); } } }
/** * Set the type of a specific attribute. * * @param index The index of the attribute (zero-based). * @param type The attribute's type. * @exception java.lang.ArrayIndexOutOfBoundsException When the * supplied index does not point to an attribute * in the list. */ public void setType (int index, String type) { if (index >= 0 && index < length) { data[index*5+3] = type; } else { badIndex(index); } }
public void consumeAttribute( int idx ) throws SAXException { AttributesImpl a = attStack[stackTop]; String uri = a.getURI(idx); String local = a.getLocalName(idx); String qname = a.getQName(idx); String value = a.getValue(idx); // mark the attribute as consumed // we need to remove the attribute before we process it // because the event handler might access attributes. a.removeAttribute(idx); getCurrentHandler().enterAttribute(uri,local,qname); consumeText(value,false); getCurrentHandler().leaveAttribute(uri,local,qname); } public String eatAttribute( int idx ) throws SAXException {
attStack[stackTop] = a = new AttributesImpl(); else a.clear(); a.addAttribute( auri, alocal,
AttributesImpl a = new AttributesImpl(); for( int i=0; i<atts.getLength(); i++ ) a.addAttribute( atts.getURI(i).intern(), atts.getLocalName(i).intern(), int idx = a.getIndex("http://www.w3.org/2001/XMLSchema-instance","nil"); if(idx!=-1) { String v = a.getValue(idx).trim(); if(v.equals("false") || v.equals("0")) a.removeAttribute(idx);
public String eatAttribute( int idx ) throws SAXException { AttributesImpl a = attStack[stackTop]; String value = a.getValue(idx); // mark the attribute as consumed a.removeAttribute(idx); return value; }
AttributesImpl attributes = new AttributesImpl( atts ); atts = attributes; attributes.addAttribute( xsiURI, "schemaLocation", prefix + ":schemaLocation", "CDATA", attributes.addAttribute( xsiURI, "noNamespaceSchemaLocation", prefix + ":noNamespaceSchemaLocation", "CDATA",
/** * Add an attribute to the end of the list. * * <p>For the sake of speed, this method does no checking * to see if the attribute is already in the list: that is * the responsibility of the application.</p> * * @param uri The Namespace URI, or the empty string if * none is available or Namespace processing is not * being performed. * @param localName The local name, or the empty string if * Namespace processing is not being performed. * @param qName The qualified (prefixed) name, or the empty string * if qualified names are not available. * @param type The attribute type as a string. * @param value The attribute value. */ public void addAttribute (String uri, String localName, String qName, String type, String value) { ensureCapacity(length+1); data[length*5] = uri; data[length*5+1] = localName; data[length*5+2] = qName; data[length*5+3] = type; data[length*5+4] = value; length++; }
/** * @param uri,local * has to be interned. */ public int getAttribute( String uri, String local ) { return attStack[stackTop].getIndexFast(uri,local); } public void consumeAttribute( int idx ) throws SAXException {
public void consumeAttribute( int idx ) throws SAXException { AttributesImpl a = attStack[stackTop]; String uri = a.getURI(idx); String local = a.getLocalName(idx); String qname = a.getQName(idx); String value = a.getValue(idx); // mark the attribute as consumed // we need to remove the attribute before we process it // because the event handler might access attributes. a.removeAttribute(idx); getCurrentHandler().enterAttribute(uri,local,qname); consumeText(value,false); getCurrentHandler().leaveAttribute(uri,local,qname); } public String eatAttribute( int idx ) throws SAXException {
attStack[stackTop] = a = new AttributesImpl(); else a.clear(); a.addAttribute( auri, alocal,
public String eatAttribute( int idx ) throws SAXException { AttributesImpl a = attStack[stackTop]; String value = a.getValue(idx); // mark the attribute as consumed a.removeAttribute(idx); return value; }
/** * Add an attribute to the end of the list. * * <p>For the sake of speed, this method does no checking * to see if the attribute is already in the list: that is * the responsibility of the application.</p> * * @param uri The Namespace URI, or the empty string if * none is available or Namespace processing is not * being performed. * @param localName The local name, or the empty string if * Namespace processing is not being performed. * @param qName The qualified (prefixed) name, or the empty string * if qualified names are not available. * @param type The attribute type as a string. * @param value The attribute value. */ public void addAttribute (String uri, String localName, String qName, String type, String value) { ensureCapacity(length+1); data[length*5] = uri; data[length*5+1] = localName; data[length*5+2] = qName; data[length*5+3] = type; data[length*5+4] = value; length++; }
/** * @param uri,local * has to be interned. */ public int getAttribute( String uri, String local ) { return attStack[stackTop].getIndexFast(uri,local); } public void consumeAttribute( int idx ) throws SAXException {
public void consumeAttribute( int idx ) throws SAXException { AttributesImpl a = attStack[stackTop]; String uri = a.getURI(idx); String local = a.getLocalName(idx); String qname = a.getQName(idx); String value = a.getValue(idx); // mark the attribute as consumed // we need to remove the attribute before we process it // because the event handler might access attributes. a.removeAttribute(idx); getCurrentHandler().enterAttribute(uri,local,qname); consumeText(value,false); getCurrentHandler().leaveAttribute(uri,local,qname); } public String eatAttribute( int idx ) throws SAXException {
attStack[stackTop] = a = new AttributesImpl(); else a.clear(); a.addAttribute( auri, alocal,
public void beginStartTag(int prefix, String localName) { elementNsUri = nsContext.getNamespaceURI(prefix); elementLocalName = localName; elementQName = getQName(prefix,localName); atts.clear(); }
/** * Set the value of a specific attribute. * * @param index The index of the attribute (zero-based). * @param value The attribute's value. * @exception java.lang.ArrayIndexOutOfBoundsException When the * supplied index does not point to an attribute * in the list. */ public void setValue (int index, String value) { if (index >= 0 && index < length) { data[index*5+4] = value; } else { badIndex(index); } }
public String eatAttribute( int idx ) throws SAXException { AttributesImpl a = attStack[stackTop]; String value = a.getValue(idx); // mark the attribute as consumed a.removeAttribute(idx); return value; }