public static Attr[] toAttrArray(Document doc,Object o) throws PageException {
  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;
  }
 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[] nodes=_toNodeArray(doc,o);
  if (nodes != null)   return toAttrArray(doc,nodes);
  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");
  }
}

public static Attr [ ] toAttrArray ( Document doc , Object o ) throws PageException { 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 ; } 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 [ ] nodes = _toNodeArray ( doc , o ) ; if ( nodes != null ) return toAttrArray ( doc , nodes ) ; 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" ) ; } }
casts a value to a xml attr array
