* @throws TeiidComponentException
* @throws TeiidProcessingException
*/
public static XMLType xmlElement(CommandContext context, final String name,
final Evaluator.NameValuePair<String>[] namespaces, final Evaluator.NameValuePair<?>[] attributes, final List<?> contents) throws TeiidComponentException, TeiidProcessingException {
XMLType result = new XMLType(XMLSystemFunctions.saveToBufferManager(context.getBufferManager(), new XMLTranslator() {
@Override
public void translate(Writer writer) throws TransformerException,
IOException {
try {
XMLOutputFactory factory = getOutputFactory();
XMLEventWriter eventWriter = factory.createXMLEventWriter(writer);
XMLEventFactory eventFactory = XMLEventFactory.newInstance();
addElement(name, writer, eventWriter, eventFactory, namespaces, attributes, contents);
eventWriter.close();
} catch (XMLStreamException e) {
throw new TransformerException(e);
}
}
}));
result.setType(Type.ELEMENT);
return result;
}