/** * <p>Creates an XML Document that corresponds to the given Message object. </p> * <p>If you are implementing this method, you should create an XML Document, and insert XML Elements * into it that correspond to the groups and segments that belong to the message type that your subclass * of XMLParser supports. Then, for each segment in the message, call the method * <code>encode(Segment segmentObject, Element segmentElement)</code> using the Element for * that segment and the corresponding Segment object from the given Message.</p> */ public Document encodeDocument(Message source) throws HL7Exception { String messageClassName = source.getClass().getName(); String messageName = messageClassName.substring(messageClassName.lastIndexOf('.') + 1); try { Document doc = XMLUtils.emptyDocument(messageName); //Element root = doc.createElement(messageName); //doc.appendChild(root); encode(source, doc.getDocumentElement()); return doc; } catch (Exception e) { throw new HL7Exception( "Can't create XML document - " + e.getClass().getName(), e); } }
/** * <p>Creates an XML Document that corresponds to the given Message object. </p> * <p>If you are implementing this method, you should create an XML Document, and insert XML Elements * into it that correspond to the groups and segments that belong to the message type that your subclass * of XMLParser supports. Then, for each segment in the message, call the method * <code>encode(Segment segmentObject, Element segmentElement)</code> using the Element for * that segment and the corresponding Segment object from the given Message.</p> */ public Document encodeDocument(Message source) throws HL7Exception { String messageClassName = source.getClass().getName(); String messageName = messageClassName.substring(messageClassName.lastIndexOf('.') + 1); try { Document doc = XMLUtils.emptyDocument(messageName); //Element root = doc.createElement(messageName); //doc.appendChild(root); encode(source, doc.getDocumentElement()); return doc; } catch (Exception e) { throw new HL7Exception( "Can't create XML document - " + e.getClass().getName(), e); } }