StringWriter strWriter = new StringWriter();
Configuration conf = new Configuration();
conf.setImplicitCollections(true);
MappedNamespaceConvention con = new MappedNamespaceConvention(conf);
AbstractXMLStreamWriter w = new MappedXMLStreamWriter(con, strWriter);
w.writeStartDocument();
w.writeStartElement("definition");
w.writeStartElement("structure");
w.writeAttribute("name", "conversation");
w.writeStartElement("symbolic");
w.writeAttribute("name", "reason");
w.writeEndElement();
w.writeStartElement("symbolic");
w.writeAttribute("name", "terms");
w.writeEndElement();
w.writeStartElement("numeric");
w.writeAttribute("name", "amountasked");
w.writeEndElement();
w.writeStartElement("numeric");
w.writeAttribute("name", "amountoffered");
w.writeEndElement();
w.writeStartElement("structure");
w.writeAttribute("name", "check");
w.writeStartElement("symbolic");
w.writeAttribute("name", "date");
w.writeEndElement();
w.writeStartElement("structure");
w.writeAttribute("name", "lines");
w.writeAttribute("repeating", "true");
w.writeStartElement("symbolic");
w.writeAttribute("name", "type");
w.writeEndElement();
w.writeStartElement("numeric");
w.writeAttribute("name", "amount");
w.writeEndElement();
w.writeStartElement("numeric");
w.writeAttribute("name", "cost");
w.writeEndElement();
w.writeEndElement();
w.writeEndElement();
w.writeEndElement();
w.writeEndElement();
w.writeEndDocument();
w.close();
strWriter.close();
assertEquals("{\"definition\":" +
"{\"structure\":{\"@name\":\"conversation\",\"symbolic\":" +
"[{\"@name\":\"reason\"},{\"@name\":\"terms\"}],\"numeric\":[" +