public static Node[] toNodeArray(Document doc,Object o) throws PageException {
  if (o instanceof Node)   return new Node[]{(Node)o};
  if (o instanceof Node[]) {
    return (Node[])o;
  }
 else   if (o instanceof Collection) {
    Collection coll=(Collection)o;
    Iterator<Object> it=coll.valueIterator();
    List<Node> nodes=new ArrayList<Node>();
    while (it.hasNext()) {
      nodes.add(toNode(doc,it.next(),false));
    }
    return nodes.toArray(new Node[nodes.size()]);
  }
  Node[] nodes=_toNodeArray(doc,o);
  if (nodes != null)   return nodes;
  try {
    return new Node[]{toNode(doc,o,false)};
  }
 catch (  ExpressionException e) {
    throw new XMLException("can't cast Object of type " + Caster.toClassName(o) + " to a XML Node Array");
  }
}

public static Node [ ] toNodeArray ( Document doc , Object o ) throws PageException { if ( o instanceof Node ) return new Node [ ] { ( Node ) o } ; if ( o instanceof Node [ ] ) { return ( Node [ ] ) o ; } else if ( o instanceof Collection ) { Collection coll = ( Collection ) o ; Iterator < Object > it = coll . valueIterator ( ) ; List < Node > nodes = new ArrayList < Node > ( ) ; while ( it . hasNext ( ) ) { nodes . add ( toNode ( doc , it . next ( ) , false ) ) ; } return nodes . toArray ( new Node [ nodes . size ( ) ] ) ; } Node [ ] nodes = _toNodeArray ( doc , o ) ; if ( nodes != null ) return nodes ; try { return new Node [ ] { toNode ( doc , o , false ) } ; } catch ( ExpressionException e ) { throw new XMLException ( "can't cast Object of type " + Caster . toClassName ( o ) + " to a XML Node Array" ) ; } }
casts a value to a xml element array
