/* drop XML element sequencing and mixing */
public int toXML(Element element, Resource rdf, int index, Set<Statement> pending, Context ctx) {
Document doc = element.getOwnerDocument();
Seq seq = rdf.getModel().getSeq(rdf);
Statement stmt = null;
boolean qualify = !namespace.equals("##local");
int max = maxOccurs.equals("unbounded")? Integer.MAX_VALUE : Integer.parseInt(maxOccurs);
int occurs = 0;
for (; occurs<max ; occurs++, index++) {
// consume mixed values
index = produceMixed(seq,index,element);
if (index<seq.size()) {
stmt = (Statement) asStatement((Resource) seq.getObject(index+1));
if (!toXML(element, stmt.getPredicate(), stmt.getObject(), qualify, ctx)) break;
} else break;
}
// do any pending properties match?
Set<Statement> done = new HashSet<Statement>();
for (Iterator ui = pending.iterator(); occurs<max && ui.hasNext(); ) {
Statement s = (Statement) ui.next();
// element.appendChild(doc.createTextNode(s.getString()));
if (toXML(element, s.getPredicate(), s.getObject(), qualify, ctx)) done.add(s);
}
pending.removeAll(done);
return index;
}