throws Exception
{
// XMLOutputFactory ofactory = XMLOutputFactory.newInstance();
ByteArrayOutputStream bos = new ByteArrayOutputStream();
// XMLStreamWriter writer = ofactory.createXMLStreamWriter(bos);
XMLStreamWriter writer = STAXUtils.createXMLStreamWriter(bos, null, null);
TypeMappingRegistry tmr = new DefaultTypeMappingRegistry(true);
TypeMapping tm = tmr.createTypeMapping(true);
registerSimpleBeanType(tm);
registerArrayType(tm);
SimpleBean bean = new SimpleBean();
bean.setBleh("bleh");
bean.setHowdy("howdy");
SimpleBean[] beanArray = new SimpleBean[] { bean, bean };
ArrayType at = (ArrayType) tm.getType(SimpleBean[].class);
at.writeObject(beanArray,
new ElementWriter(writer, "SimpleBean", "urn:Bean"),
new MessageContext());
writer.close();
/*
* TODO: figure out why this doesn't work. It works when you're actually
* reading/writing documents. I think it has something to do with the
* reader.next() in the END_ELEMENT case in LiteralReader.