List of usage examples for org.w3c.dom Document getElementById
public Element getElementById(String elementId);
Element
that has an ID attribute with the given value. From source file:uk.ac.manchester.cs.diff.WebDiff.java
/** * Get the diff for the specified ontologies * @param request Http request/*from w w w . java 2 s . c om*/ * @param response Http response * @throws IOException * @throws ServletException * @throws TransformerException * @throws FileUploadException * @throws OWLOntologyCreationException */ private void getDiff(HttpServletRequest request, HttpServletResponse response) throws IOException, ServletException, TransformerException, OWLOntologyCreationException, FileUploadException { PrintWriter pw = response.getWriter(); String xsltPath = "https://raw.github.com/rsgoncalves/ecco-webui/master/WebContent/xslt_full_server.xsl"; String styledXml = ""; EccoRunner runner = new EccoRunner(true, false, true, false, 5, false); // Load ontologies parseRequest(pw, request, response, runner); if (ont1 != null && ont2 != null) { // Get diff report XMLReport report = runner.computeDiff(ont1, ont2, cdiff, xsltPath, false); AxiomChangeSet changeSet = report.getChangeSet(); if (changeSet instanceof StructuralChangeSet) { styledXml = "One of the given ontologies is inconsistent. In such cases we can only detect structural differences.<br/>" + "There will be a separate transform for this specific change set soon..."; // TODO: New xslt for structural change set *only* } else { request.getSession().setAttribute("xsltPath", xsltPath); request.getSession().setAttribute("report", report); // Store name-based XML document in session attribute Document doc = report.getXMLDocumentUsingTermNames(); Element root = doc.getElementById("root"); String uuid = root.getAttribute("uuid"); request.getSession().setAttribute(uuid, doc); // Store gensym-based XML document in session attribute Document genSymDoc = report.getXMLDocumentUsingGenSyms(); Element gs_root = genSymDoc.getElementById("root"); String gs_uuid = gs_root.getAttribute("uuid"); request.getSession().setAttribute(gs_uuid, genSymDoc); // Store label-based XML document in session attribute Document labelDoc = report.getXMLDocumentUsingLabels(); Element lb_root = labelDoc.getElementById("root"); String lb_uuid = lb_root.getAttribute("uuid"); request.getSession().setAttribute(lb_uuid, labelDoc); styledXml = report.getReportAsHTML(labelDoc, xsltPath); request.getSession().setAttribute("curuuid", lb_uuid); } } response.setCharacterEncoding("UTF-8"); response.setContentType("text/html;charset=UTF-8"); pw.println(styledXml); pw.flush(); pw.close(); }
From source file:us.mn.state.health.lims.reports.action.AuditTrailReportBySampleProcessAction.java
private void parseXmlFile(String xml) { //get the factory DocumentBuilderFactory dbf = DocumentBuilderFactory.newInstance(); try {/*from w w w .ja v a2s .c o m*/ //Using factory get an instance of document builder DocumentBuilder db = dbf.newDocumentBuilder(); //parse using builder to get DOM representation of the XML file Document dom = db.parse(xml); System.out.println("This is parsed xml getting changes " + dom.getElementById("accessionNumber")); } catch (ParserConfigurationException pce) { pce.printStackTrace(); } catch (SAXException se) { se.printStackTrace(); } catch (IOException ioe) { ioe.printStackTrace(); } }