@Test public void testLoadDocument() throws Exception { Document document = documentXmlConverter.loadDocument(c32); assertNotNull(document); logger.debug(document.getNodeName()); assertEquals("#document", document.getNodeName()); logger.debug(document.getXmlEncoding()); assertEquals("UTF-8", document.getXmlEncoding()); logger.debug(document.getXmlVersion()); assertEquals("1.0", document.getXmlVersion()); logger.debug(document.toString()); assertEquals("[#document: null]", document.toString()); logger.debug(document.getDocumentElement().toString()); assertEquals("[ClinicalDocument: null]", document.getDocumentElement() .toString()); logger.debug(document.getFirstChild().toString()); assertEquals("[ClinicalDocument: null]", document.getFirstChild() .toString()); logger.debug(document.getImplementation().toString()); assertTrue(document .getImplementation() .toString() .startsWith( "org.apache.xerces.dom.DeferredDOMImplementationImpl@")); logger.debug(document.getLastChild().toString()); assertEquals("[ClinicalDocument: null]", document.getLastChild() .toString()); logger.debug(Boolean.toString(document.hasAttributes())); assertFalse(document.hasAttributes()); logger.debug(Boolean.toString(document.hasChildNodes())); assertTrue(document.hasChildNodes()); }
@Override public Document loadDocument(String xmlString) throws DocumentXmlConverterException { DocumentBuilderFactory dbf = DocumentBuilderFactory.newInstance(); dbf.setValidating(false); dbf.setNamespaceAware(true); DocumentBuilder db; Document doc; try { db = dbf.newDocumentBuilder(); InputSource source = new InputSource(new StringReader(xmlString)); doc = db.parse(source); } catch (ParserConfigurationException | SAXException | IOException e) { throw new DocumentXmlConverterException(e); } return doc; }
DocumentXmlConverterImpl implements DocumentXmlConverter { @Override public Document loadDocument(String xmlString) throws DocumentXmlConverterException { DocumentBuilderFactory dbf = DocumentBuilderFactory.newInstance(); dbf.setValidating(false); dbf.setNamespaceAware(true); DocumentBuilder db; Document doc; try { db = dbf.newDocumentBuilder(); InputSource source = new InputSource(new StringReader(xmlString)); doc = db.parse(source); } catch (ParserConfigurationException | SAXException | IOException e) { throw new DocumentXmlConverterException(e); } return doc; } }
DocumentXmlConverterImpl implements DocumentXmlConverter { @Override public Document loadDocument(String xmlString) throws DocumentXmlConverterException { DocumentBuilderFactory dbf = DocumentBuilderFactory.newInstance(); dbf.setValidating(false); dbf.setNamespaceAware(true); DocumentBuilder db; Document doc; try { db = dbf.newDocumentBuilder(); InputSource source = new InputSource(new StringReader(xmlString)); doc = db.parse(source); } catch (ParserConfigurationException | SAXException | IOException e) { throw new DocumentXmlConverterException(e); } return doc; }  }
DocumentXmlConverterImpl implements DocumentXmlConverter { @Override public Document loadDocument(String xmlString) throws DocumentXmlConverterException { DocumentBuilderFactory dbf = DocumentBuilderFactory.newInstance(); dbf.setValidating(false); dbf.setNamespaceAware(true); DocumentBuilder db; Document doc; try { db = dbf.newDocumentBuilder(); InputSource source = new InputSource(new StringReader(xmlString)); doc = db.parse(source); } catch (ParserConfigurationException | SAXException | IOException e) { throw new DocumentXmlConverterException(e); } return doc; }  @Override Document loadDocument(String xmlString); @Override String convertXmlDocToString(Document xmlDocument); }
DocumentXmlConverterImpl implements DocumentXmlConverter { @Override public Document loadDocument(String xmlString) throws DocumentXmlConverterException { DocumentBuilderFactory dbf = DocumentBuilderFactory.newInstance(); dbf.setValidating(false); dbf.setNamespaceAware(true); DocumentBuilder db; Document doc; try { db = dbf.newDocumentBuilder(); InputSource source = new InputSource(new StringReader(xmlString)); doc = db.parse(source); } catch (ParserConfigurationException | SAXException | IOException e) { throw new DocumentXmlConverterException(e); } return doc; }  @Override Document loadDocument(String xmlString); @Override String convertXmlDocToString(Document xmlDocument);  }