class XMLOutputSplitter {

	@SuppressWarnings("unchecked")
	public Map<String, Object> execute(Map<String, String> inputMap)
			throws XMLSplitterExecutionException {

		Map<String, Object> result = new HashMap<String, Object>();
		List<String> outputNameList = Arrays.asList(outputNames);

		String xml = inputMap.get(inputNames[0]);
		try {
			Document doc = new SAXBuilder().build(new StringReader(xml));
			List<Element> children = doc.getRootElement().getChildren();
			if (typeDescriptor instanceof ArrayTypeDescriptor) {
				if (outputNames.length > 1)
					throw new XMLSplitterExecutionException(
							"Unexpected, multiple output names for ArrayType");
				executeForArrayType(result, children);
			} else {
				executeForComplexType(result, outputNameList, children, doc.getRootElement().getAttributes());
			}

			// populate missing outputs with empty strings for basic types,
			// empty elements for complex/array types.
			for (int i = 0; i < outputNames.length; i++) {
				if (result.get(outputNames[i]) == null) {
					if (outputTypes[i].equals("'text/xml'")) {
						result
								.put(outputNames[i], "<" + outputNames[i]
										+ " />");
					} else if (outputTypes[i].startsWith("l('")) {
						result.put(outputNames[i], new ArrayList<Object>());
					} else {
						result.put(outputNames[i], "");
					}

				}
			}
		} catch (JDOMException e) {
			throw new XMLSplitterExecutionException("Unable to parse XML: " + xml, e);
		} catch (IOException e) {
			throw new XMLSplitterExecutionException("IOException parsing XML: " + xml,
					e);
		}

		return result;
	}

	public  XMLOutputSplitter(TypeDescriptor typeDescriptor,
			String[] outputNames, String[] outputTypes,String[] inputNames);

}