code: public static Attr[] toAttrArray(Document doc, Object o) throws PageException {
  	// Node[]
  	if (o instanceof Node[]) {
  	    Node[] nodes = (Node[]) o;
  	    if (_isAllOfSameType(nodes, Node.ATTRIBUTE_NODE)) return (Attr[]) nodes;
  
  	    Attr[] attres = new Attr[nodes.length];
  	    for (int i = 0; i < nodes.length; i++) {
  		attres[i] = toAttr(doc, nodes[i]);
  	    }
  	    return attres;
  	}
  	// Collection
  	else if (o instanceof Collection) {
  	    Collection coll = (Collection) o;
  	    Iterator<Entry<Key, Object>> it = coll.entryIterator();
  	    Entry<Key, Object> e;
  	    List<Attr> attres = new ArrayList<Attr>();
  	    Attr attr;
  	    Collection.Key k;
  	    while (it.hasNext()) {
  		e = it.next();
  		k = e.getKey();
  		attr = doc.createAttribute(Decision.isNumber(k.getString()) ? "attribute-" + k.getString() : k.getString());
  		attr.setValue(Caster.toString(e.getValue()));
  		attres.add(attr);
  	    }
  	    return attres.toArray(new Attr[attres.size()]);
  	}
  	// Node Map and List
  	Node[] nodes = _toNodeArray(doc, o);
  	if (nodes != null) return toAttrArray(doc, nodes);
  	// Single Text Node
  	try {
  	    return new Attr[] { toAttr(doc, o) };
  	}
  	catch (ExpressionException e) {
  	    throw new XMLException("can't cast Object of type " + Caster.toClassName(o) + " to a XML Attributes Array");
  	}
      }
docs: casts a value to a XML Attr Array
  
  @param doc XML Document
  @param o Object to cast
  @return XML Attr Array
  @throws PageException