From: Jim K. <ji...@ho...> - 2005-03-22 15:42:48
|
Hey All- I know that updating the XML generation is on tap for the next release (0.4.4?) and you probably already came across this, but just in case you're still making lists: I'm generating ORU messages and I noticed that the root node is being rendered as ORU.R01 instead of the expected ORU_R01. This is being done by the makeGroupElementName method and I assume that its done to accomodate SUPPGRP type classes like ORU_R01_ORCOBRNTEOBXNTECTI where it is legitimate to replace the first underscore with a period. However, since the method doesn't differentiate between AbstractGroup implementers and AbstractMessage implementers, AbstraceMessages have their XML representations mangled. protected static String makeGroupElementName(String className) { String ret = null; int loc = className.lastIndexOf('_'); if (loc >= 0) { StringBuffer elementName = new StringBuffer(); elementName.append(className.substring(0, loc)); elementName.append('.'); elementName.append(className.substring(loc + 1)); ret = elementName.toString(); } else { ret = className; } return ret; } Maybe its possible to put the check in the encode method? private void encode(ca.uhn.hl7v2.model.Group groupObject, org.w3c.dom.Element groupElement) throws HL7Exception { String[] childNames = groupObject.getNames(); try { for (int i = 0; i < childNames.length; i++) { Structure[] reps = groupObject.getAll(childNames[i]); for (int j = 0; j < reps.length; j++) { Element childElement = groupElement.getOwnerDocument().createElement(makeGroupElementName(childNames[i])); groupElement.appendChild(childElement); if (reps[j] instanceof Group) { encode((Group) reps[j], childElement); } else if (reps[j] instanceof Segment) { encode((Segment) reps[j], childElement); } } } } catch (DOMException e) { throw new HL7Exception( "Can't encode group " + groupObject.getClass().getName(), HL7Exception.APPLICATION_INTERNAL_ERROR, e); } } |