private List<Element> getChildElementsByTagName(Element theElement, String theName) throws HL7Exception { List<Element> result = new ArrayList<Element>(10); NodeList children = theElement.getChildNodes(); for (int i = 0; i < children.getLength(); i++) { Node child = children.item(i); if (child.getNodeType() == Node.ELEMENT_NODE && child.getLocalName().equals(theName)) { assertNamespaceURI(child.getNamespaceURI()); result.add((Element)child); } } return result; }
private List<Element> getChildElementsByTagName(Element theElement, String theName) throws HL7Exception { List<Element> result = new ArrayList<Element>(10); NodeList children = theElement.getChildNodes(); for (int i = 0; i < children.getLength(); i++) { Node child = children.item(i); if (child.getNodeType() == Node.ELEMENT_NODE && child.getLocalName().equals(theName)) { assertNamespaceURI(child.getNamespaceURI()); result.add((Element)child); } } return result; }
/** * <p>Creates and populates a Message object from an XML Document that contains an XML-encoded HL7 message.</p> * <p>The easiest way to implement this method for a particular message structure is as follows: * <ol><li>Create an instance of the Message type you are going to handle with your subclass * of XMLParser</li> * <li>Go through the given Document and find the Elements that represent the top level of * each message segment. </li> * <li>For each of these segments, call <code>parse(Segment segmentObject, Element segmentElement)</code>, * providing the appropriate Segment from your Message object, and the corresponding Element.</li></ol> * At the end of this process, your Message object should be populated with data from the XML * Document.</p> * @throws HL7Exception if the message is not correctly formatted. * @throws EncodingNotSupportedException if the message encoded * is not supported by this parser. */ public Message parseDocument(Document xmlMessage, String version) throws HL7Exception { assertNamespaceURI(xmlMessage.getDocumentElement().getNamespaceURI()); Message message = instantiateMessage(xmlMessage.getDocumentElement().getLocalName(), version, true); // Note: this will change in future to reuse the Parser's/HapiContext's // ValidationContext. // message.setValidationContext(getValidationContext()); parse(message, xmlMessage.getDocumentElement()); return message; }
/** * <p>Creates and populates a Message object from an XML Document that contains an XML-encoded HL7 message.</p> * <p>The easiest way to implement this method for a particular message structure is as follows: * <ol><li>Create an instance of the Message type you are going to handle with your subclass * of XMLParser</li> * <li>Go through the given Document and find the Elements that represent the top level of * each message segment. </li> * <li>For each of these segments, call <code>parse(Segment segmentObject, Element segmentElement)</code>, * providing the appropriate Segment from your Message object, and the corresponding Element.</li></ol> * At the end of this process, your Message object should be populated with data from the XML * Document.</p> * @throws HL7Exception if the message is not correctly formatted. * @throws EncodingNotSupportedException if the message encoded * is not supported by this parser. */ public Message parseDocument(Document xmlMessage, String version) throws HL7Exception { assertNamespaceURI(xmlMessage.getDocumentElement().getNamespaceURI()); Message message = instantiateMessage(xmlMessage.getDocumentElement().getLocalName(), version, true); // Note: this will change in future to reuse the Parser's/HapiContext's // ValidationContext. // message.setValidationContext(getValidationContext()); parse(message, xmlMessage.getDocumentElement()); return message; }
String name = node.getLocalName(); if (node.getNodeType() == Node.ELEMENT_NODE && !unparsedElementList.contains(name)) { assertNamespaceURI(node.getNamespaceURI()); unparsedElementList.add(name);
String name = node.getLocalName(); if (node.getNodeType() == Node.ELEMENT_NODE && !unparsedElementList.contains(name)) { assertNamespaceURI(node.getNamespaceURI()); unparsedElementList.add(name);