|
||||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |
java.lang.Objectca.uhn.hl7v2.parser.Parser
ca.uhn.hl7v2.parser.XMLParser
ca.uhn.hl7v2.parser.DefaultXMLParser
public class DefaultXMLParser
A default XMLParser. This class assigns segment elements (in an XML-encoded message) to Segment objects (in a Message object) using the name of a segment and the names of any groups in which the segment is nested. The names of group classes must correspond to the names of group elements (they must be identical except that a dot in the element name, following the message name, is replaced with an underscore, in order to consitute a valid class name).
At the time of writing, the group names in the XML spec are changing. Many of the group names have been automatically generated based on the group contents. However, these automatic names are gradually being replaced with manually assigned names. This process is expected to be complete by November 2002. As a result, mismatches are likely. Messages could be transformed prior to parsing (using XSLT) as a work-around. Alternatively the group class names could be changed to reflect updates in the XML spec. Ultimately, HAPI group classes will be changed to correspond with the official group names, once these are all assigned.
Constructor Summary | |
---|---|
DefaultXMLParser()
Creates a new instance of DefaultXMLParser |
|
DefaultXMLParser(ModelClassFactory theFactory)
Creates a new instance of DefaultXMLParser |
Method Summary | |
---|---|
org.w3c.dom.Document |
encodeDocument(Message source)
Creates an XML Document that corresponds to the given Message object. |
static void |
main(java.lang.String[] args)
Test harness |
protected static java.lang.String |
makeGroupElementName(java.lang.String messageName,
java.lang.String className)
Given the name of a message and a Group class, returns the corresponding group element name in an XML-encoded message. |
Message |
parseDocument(org.w3c.dom.Document XMLMessage,
java.lang.String version)
Creates and populates a Message object from an XML Document that contains an XML-encoded HL7 message. |
Methods inherited from class ca.uhn.hl7v2.parser.XMLParser |
---|
doEncode, doEncode, doEncode, doEncode, doParse, encode, getAckID, getCriticalResponseData, getDefaultEncoding, getEncoding, getKeepAsOriginalNodes, getTextEncoding, getVersion, keepAsOriginal, parse, parse, parse, parse, parse, parseLeaf, removeWhitespace, setKeepAsOriginalNodes, setTextEncoding, supportsEncoding |
Methods inherited from class ca.uhn.hl7v2.parser.Parser |
---|
encode, encode, getFactory, getMessageStructureForEvent, getMessageStructures, getValidationContext, getValidVersions, instantiateMessage, makeControlMSH, parse, setValidationContext, validVersion |
Methods inherited from class java.lang.Object |
---|
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait |
Constructor Detail |
---|
public DefaultXMLParser()
public DefaultXMLParser(ModelClassFactory theFactory)
theFactory
- custom factory to use for model class lookupMethod Detail |
---|
public org.w3c.dom.Document encodeDocument(Message source) throws HL7Exception
Creates an XML Document that corresponds to the given Message object.
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
encode(Segment segmentObject, Element segmentElement)
using the Element for
that segment and the corresponding Segment object from the given Message.
encodeDocument
in class XMLParser
HL7Exception
public Message parseDocument(org.w3c.dom.Document XMLMessage, java.lang.String version) throws HL7Exception
Creates and populates a Message object from an XML Document that contains an XML-encoded HL7 message.
The easiest way to implement this method for a particular message structure is as follows:
parse(Segment segmentObject, Element segmentElement)
,
providing the appropriate Segment from your Message object, and the corresponding Element.
parseDocument
in class XMLParser
HL7Exception
- if the message is not correctly formatted.
EncodingNotSupportedException
- if the message encoded
is not supported by this parser.protected static java.lang.String makeGroupElementName(java.lang.String messageName, java.lang.String className)
public static void main(java.lang.String[] args)
|
||||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |