code: public static Attr toAttr(Document doc, Object o) throws PageException {
  	if (o instanceof Attr) return (Attr) o;
  	if (o instanceof Struct && ((Struct) o).size() == 1) {
  	    Struct sct = (Struct) o;
  	    Entry<Key, Object> e = sct.entryIterator().next();
  	    Attr attr = doc.createAttribute(e.getKey().getString());
  	    attr.setValue(Caster.toString(e.getValue()));
  	    return attr;
  	}
  
  	throw new XMLException("can't cast Object of type " + Caster.toClassName(o) + " to a XML Attribute");
      }
docs: casts a value to a XML Attribute Object
  
  @param doc XML Document
  @param o Object to cast
  @return XML Comment Object
  @throws PageException