toXMLFields(message, "header", this.header); toXMLFields(message, "body", this); toXMLFields(message, "trailer", this.trailer);
try { toXMLFields(message, "header", this.header); toXMLFields(message, "body", this); toXMLFields(message, "trailer", this.trailer); } catch (FieldNotFound e1) {  throw new RuntimeException(e1); }
    public String toXML() throws FieldNotFound {        try {            Document document = DocumentBuilderFactory.newInstance().newDocumentBuilder()                    .newDocument();            Element message = document.createElement("message");            document.appendChild(message);            toXMLFields(message, "header", this.header);            toXMLFields(message, "body", this);            toXMLFields(message, "trailer", this.trailer);            DOMSource domSource = new DOMSource(document);            ByteArrayOutputStream out = new ByteArrayOutputStream();            StreamResult streamResult = new StreamResult(out);            TransformerFactory tf = TransformerFactory.newInstance();            Transformer serializer = tf.newTransformer();            serializer.setOutputProperty(OutputKeys.ENCODING, "ISO-8859-1");            //serializer.setOutputProperty(OutputKeys.DOCTYPE_SYSTEM,"users.dtd");            serializer.setOutputProperty(OutputKeys.INDENT, "yes");            serializer.transform(domSource, streamResult);            return out.toString();        } catch (ParserConfigurationException e) {            // TODO Auto-generated catch block            e.printStackTrace();        } catch (FactoryConfigurationError e) {            // TODO Auto-generated catch block            e.printStackTrace();        } catch (TransformerConfigurationException e) {            // TODO Auto-generated catch block            e.printStackTrace();        } catch (TransformerException e) {            // TODO Auto-generated catch block            e.printStackTrace();        }        throw new UnsupportedOperationException();    }