List of usage examples for org.w3c.dom Node appendChild
public Node appendChild(Node newChild) throws DOMException;
newChild
to the end of the list of children of this node. From source file:org.corpus_tools.pepper.cli.PepperStarter.java
/** * This method writes a module configuration of GroupId, ArtifactId and * Maven repository back to the modules.xml file *//*from ww w .ja va 2s .c om*/ private boolean write2ConfigFile(String groupId, String artifactId, String repository) { DocumentBuilderFactory dbFactory = DocumentBuilderFactory.newInstance(); try { boolean changes = false; File configFile = new File(MODULES_XML_PATH); DocumentBuilder docBuilder = dbFactory.newDocumentBuilder(); Document doc = docBuilder.parse(configFile); NodeList configuredModules = doc.getElementsByTagName(ModuleTableReader.TAG_ARTIFACTID); if (configuredModules.getLength() == 0) { return false; } /* check, if the module is already in the modules.xml file */ Node item = configuredModules.item(0); int j = 0; while (j + 1 < configuredModules.getLength() && !artifactId.equals(item.getTextContent())) { item = configuredModules.item(++j); } if (artifactId.equals(item.getTextContent())) {// already contained // -> edit Node itemGroupId = null; Node itemRepo = null; Node node = null; for (int i = 0; i < item.getParentNode().getChildNodes().getLength() && (itemGroupId == null || itemRepo == null); i++) { node = item.getParentNode().getChildNodes().item(i); if (ModuleTableReader.TAG_GROUPID.equals(node.getLocalName())) { itemGroupId = node; } if (ModuleTableReader.TAG_REPO.equals(node.getLocalName())) { itemRepo = node; } } if (itemGroupId != null) { itemGroupId.setTextContent(groupId); changes = true; } else { if (!groupId.equals(doc.getElementsByTagName(ModuleTableReader.ATT_DEFAULTGROUPID).item(0) .getTextContent())) { itemGroupId = doc.createElement(ModuleTableReader.TAG_GROUPID); itemGroupId.setTextContent(groupId); item.getParentNode().appendChild(itemGroupId); changes = true; } } if (itemRepo != null) { itemRepo.setTextContent(repository); changes = true; } else { // if // (!repository.equals(doc.getElementsByTagName(ModuleTableReader.ATT_DEFAULTREPO).item(0).getTextContent())) // { // itemRepo = doc.createElement(ModuleTableReader.TAG_REPO); // itemRepo.setTextContent(repository); // item.getParentNode().appendChild(itemRepo); // changes = true; // } } itemGroupId = null; itemRepo = null; node = null; } else {// not contained yet -> insert changes = true; Node listNode = doc.getElementsByTagName(ModuleTableReader.TAG_LIST).item(0); Node newModule = doc.createElement(ModuleTableReader.TAG_ITEM); Node groupIdNode = doc.createElement(ModuleTableReader.TAG_GROUPID); groupIdNode.appendChild(doc.createTextNode(groupId)); Node artifactIdNode = doc.createElement(ModuleTableReader.TAG_ARTIFACTID); artifactIdNode.appendChild(doc.createTextNode(artifactId)); Node repositoryNode = doc.createElement(ModuleTableReader.TAG_REPO); repositoryNode.appendChild(doc.createTextNode(repository)); newModule.appendChild(groupIdNode); newModule.appendChild(artifactIdNode); newModule.appendChild(repositoryNode); listNode.appendChild(newModule); listNode = null; newModule = null; groupIdNode = null; artifactIdNode = null; repository = null; } if (changes) { // write back to file TransformerFactory trFactory = TransformerFactory.newInstance(); // trFactory.setAttribute("indent-number", 2); Transformer transformer = trFactory.newTransformer(); transformer.setOutputProperty(OutputKeys.INDENT, "yes"); transformer.setOutputProperty(OutputKeys.ENCODING, "UTF-8"); DOMSource src = new DOMSource(doc); StreamResult result = new StreamResult(configFile); transformer.transform(src, result); trFactory = null; transformer = null; src = null; result = null; } docBuilder = null; doc = null; configuredModules = null; item = null; } catch (ParserConfigurationException | SAXException | IOException | FactoryConfigurationError | TransformerFactoryConfigurationError | TransformerException e) { logger.error("Could not read module table."); logger.trace(" ", e); return false; } return true; }
From source file:org.cruxframework.crux.core.declarativeui.ViewParser.java
/** * @param cruxPageElement/*from www . ja v a 2s. c o m*/ * @param htmlElement */ private void translateDocument(Node cruxPageElement, Node htmlElement, boolean copyHtmlNodes) { NodeList childNodes = cruxPageElement.getChildNodes(); if (childNodes != null) { for (int i = 0; i < childNodes.getLength(); i++) { Node child = childNodes.item(i); String namespaceURI = child.getNamespaceURI(); if (namespaceURI != null && namespaceURI.equals(CRUX_CORE_NAMESPACE)) { translateCruxCoreElements((Element) child, (Element) htmlElement, htmlDocument); } else if (namespaceURI != null && namespaceURI.startsWith(WIDGETS_NAMESPACE_PREFIX)) { String widgetType = getCurrentWidgetTag(); updateCurrentWidgetTag((Element) child); translateCruxInnerTags((Element) child, (Element) htmlElement, htmlDocument); setCurrentWidgetTag(widgetType); } else { Node htmlChild; if (copyHtmlNodes) { htmlChild = htmlDocument.importNode(child, false); htmlElement.appendChild(htmlChild); } else { htmlChild = htmlElement; } translateDocument(child, htmlChild, copyHtmlNodes); } } } }
From source file:org.deri.any23.extractor.html.HCardExtractor.java
private void fixIncludes(HTMLDocument document, Node node) { NamedNodeMap attributes = node.getAttributes(); // header case test 32 if ("TD".equals(node.getNodeName()) && (null != attributes.getNamedItem("headers"))) { String id = attributes.getNamedItem("headers").getNodeValue(); Node header = document.findNodeById(id); if (null != header) { node.appendChild(header.cloneNode(true)); attributes.removeNamedItem("headers"); }/*from ww w .j a v a 2 s . c o m*/ } // include pattern, test 31 for (Node current : document.findAll("//*[@class]")) { if (!DomUtils.hasClassName(current, "include")) continue; // we have to remove the field soon to avoid infinite loops // no null check, we know it's there or we won't be in the loop current.getAttributes().removeNamedItem("class"); ArrayList<TextField> res = new ArrayList<TextField>(); HTMLDocument.readUrlField(res, current); TextField id = res.get(0); if (null == id) continue; id = new TextField(StringUtils.substringAfter(id.value(), "#"), id.source()); Node included = document.findNodeById(id.value()); if (null == included) continue; current.appendChild(included.cloneNode(true)); } }
From source file:org.devgateway.eudevfin.reports.core.utils.ReportTemplate.java
private void appendReportSumRows(HashMap<String, Node> matchingRows, HashMap<String, Node> matchingColumns, RowReport row, Document doc, boolean swapAxis) { Node rowNode = matchingRows.get("r_" + row.getName()); if (rowNode == null) return;//from w ww. ja va2 s . c om HashMap<String, String> columns = new HashMap<String, String>(); HashMap<String, String> emptyColumns = new HashMap<String, String>(); XPath xPath = XPathFactory.newInstance().newXPath(); for (String rowCode : row.getRowCodes()) { try { NodeList nodes = (NodeList) xPath .evaluate("/jasperReport/detail/band/textField/reportElement[starts-with(@key, 'r_" + rowCode + "_c_')]", doc.getDocumentElement(), XPathConstants.NODESET); for (int i = 0; i < nodes.getLength(); ++i) { Element e = (Element) nodes.item(i); String columnKey = e.getAttribute("key"); String columnCode = columnKey.replaceFirst("r_" + rowCode + "_c_", ""); String expression = columns.get(columnCode) != null ? columns.get(columnCode) : ""; if (!e.getParentNode().getTextContent().equals("")) { expression += e.getParentNode().getTextContent(); expression += "+"; } columns.put(columnCode, expression); } NodeList nodesEmpty = (NodeList) xPath .evaluate("/jasperReport/detail/band/staticText/reportElement[starts-with(@key, 'r_" + rowCode + "_c_')]", doc.getDocumentElement(), XPathConstants.NODESET); for (int i = 0; i < nodesEmpty.getLength(); ++i) { Element e = (Element) nodesEmpty.item(i); String columnKey = e.getAttribute("key"); String columnCode = columnKey.replaceFirst("r_" + rowCode + "_c_", ""); String expression = columns.get(columnCode) != null ? columns.get(columnCode) : ""; if (!e.getParentNode().getTextContent().equals("")) { expression += e.getParentNode().getTextContent(); expression += "+"; } emptyColumns.put(columnCode, expression); } } catch (XPathExpressionException e) { e.printStackTrace(); } } Integer yCoord, xCoord, width, height; xCoord = yCoord = 0; //Set default height height = 15; //Set default width width = 55; if (swapAxis) { xCoord = rowNode.getAttributes().getNamedItem("x") != null ? Integer.parseInt(rowNode.getAttributes().getNamedItem("x").getNodeValue()) : 0; } else { yCoord = rowNode.getAttributes().getNamedItem("y") != null ? Integer.parseInt(rowNode.getAttributes().getNamedItem("y").getNodeValue()) : 0; } for (Map.Entry<String, String> column : columns.entrySet()) { String cellStyle = (rowNode.getAttributes().getNamedItem("style") != null) ? rowNode.getAttributes().getNamedItem("style").getNodeValue() : ""; Element textField = doc.createElement("textField"); textField.setAttribute("pattern", "#,##0.00"); Node columnNode = matchingColumns.get("c_" + column.getKey()); if (columnNode == null) continue; Node parentNode; if (swapAxis) { parentNode = columnNode.getParentNode().getParentNode(); yCoord = columnNode.getAttributes().getNamedItem("y") != null ? Integer.parseInt(columnNode.getAttributes().getNamedItem("y").getNodeValue()) : 0; } else { parentNode = rowNode.getParentNode().getParentNode(); xCoord = columnNode.getAttributes().getNamedItem("x") != null ? Integer.parseInt(columnNode.getAttributes().getNamedItem("x").getNodeValue()) : 0; width = columnNode.getAttributes().getNamedItem("width") != null ? Integer.parseInt(columnNode.getAttributes().getNamedItem("width").getNodeValue()) : 0; height = rowNode.getAttributes().getNamedItem("height") != null ? Integer.parseInt(rowNode.getAttributes().getNamedItem("height").getNodeValue()) : 0; if (cellStyle.equals("") && (columnNode.getAttributes().getNamedItem("style") != null)) { cellStyle = columnNode.getAttributes().getNamedItem("style").getNodeValue(); } } Element reportElement = doc.createElement("reportElement"); reportElement.setAttribute("key", "r_" + row.getName() + "_c_" + column.getKey()); reportElement.setAttribute("x", xCoord.toString()); reportElement.setAttribute("y", yCoord.toString()); reportElement.setAttribute("width", width.toString()); reportElement.setAttribute("height", height.toString()); if (!cellStyle.equals("")) { reportElement.setAttribute("style", cellStyle); } Element textElement = doc.createElement("textElement"); textElement.setAttribute("textAlignment", "Right"); Element textFieldExpression = doc.createElement("textFieldExpression"); String columnValue = column.getValue(); if (columnValue.endsWith("+")) { columnValue = columnValue.substring(0, columnValue.length() - 1); } CDATASection cdata = doc.createCDATASection(columnValue); textFieldExpression.appendChild(cdata); textField.appendChild(reportElement); textField.appendChild(textElement); textField.appendChild(textFieldExpression); parentNode.appendChild(textField); } for (Map.Entry<String, String> column : emptyColumns.entrySet()) { if (columns.containsKey(column.getKey())) { continue; } String cellStyle = (rowNode.getAttributes().getNamedItem("style") != null) ? rowNode.getAttributes().getNamedItem("style").getNodeValue() : ""; Element staticText = doc.createElement("staticText"); Node columnNode = matchingColumns.get("c_" + column.getKey()); if (columnNode == null) continue; Node parentNode; if (swapAxis) { parentNode = columnNode.getParentNode().getParentNode(); yCoord = columnNode.getAttributes().getNamedItem("y") != null ? Integer.parseInt(columnNode.getAttributes().getNamedItem("y").getNodeValue()) : 0; } else { parentNode = rowNode.getParentNode().getParentNode(); xCoord = columnNode.getAttributes().getNamedItem("x") != null ? Integer.parseInt(columnNode.getAttributes().getNamedItem("x").getNodeValue()) : 0; width = columnNode.getAttributes().getNamedItem("width") != null ? Integer.parseInt(columnNode.getAttributes().getNamedItem("width").getNodeValue()) : 0; height = rowNode.getAttributes().getNamedItem("height") != null ? Integer.parseInt(rowNode.getAttributes().getNamedItem("height").getNodeValue()) : 0; if (cellStyle.equals("") && (columnNode.getAttributes().getNamedItem("style") != null)) { cellStyle = columnNode.getAttributes().getNamedItem("style").getNodeValue(); } } Element reportElement = doc.createElement("reportElement"); reportElement.setAttribute("key", "r_" + row.getName() + "_c_" + column.getKey()); reportElement.setAttribute("x", xCoord.toString()); reportElement.setAttribute("y", yCoord.toString()); reportElement.setAttribute("width", width.toString()); reportElement.setAttribute("height", height.toString()); if (!cellStyle.equals("")) { reportElement.setAttribute("style", cellStyle); } Element textElement = doc.createElement("textElement"); textElement.setAttribute("textAlignment", "Right"); Element textFieldExpression = doc.createElement("text"); CDATASection cdata = doc.createCDATASection("////////"); textFieldExpression.appendChild(cdata); staticText.appendChild(reportElement); staticText.appendChild(textElement); staticText.appendChild(textFieldExpression); parentNode.appendChild(staticText); } }
From source file:org.devgateway.eudevfin.reports.core.utils.ReportTemplate.java
private void appendReportRows(HashMap<String, Node> matchingRows, HashMap<String, Node> matchingColumns, RowReport row, Document doc, boolean swapAxis) { Node rowNode = matchingRows.get("r_" + row.getName()); if (rowNode == null) return;//from w w w. j a v a 2 s. co m Integer rowMultiplier = 1; //TODO: Remove this terrible hack for the two columns of DAC2a that needs to subtract if (row.getName().equals("205") || row.getName().startsWith("205_") || row.getName().equals("215") || row.getName().startsWith("215_") || row.getName().equals("219") || row.getName().startsWith("219_")) { rowMultiplier = -1; } Integer yCoord, xCoord, width, height; xCoord = yCoord = 0; //Set default height height = 15; //Set default width width = 55; if (swapAxis) { xCoord = rowNode.getAttributes().getNamedItem("x") != null ? Integer.parseInt(rowNode.getAttributes().getNamedItem("x").getNodeValue()) : 0; } else { yCoord = rowNode.getAttributes().getNamedItem("y") != null ? Integer.parseInt(rowNode.getAttributes().getNamedItem("y").getNodeValue()) : 0; } Set<ColumnReport> columns = row.getColumns(); //Store multipliers for later use HashMap<String, Integer> multipliersByColumn = new HashMap<String, Integer>(); for (ColumnReport column : columns) { multipliersByColumn.put(column.getName(), column.getMultiplier()); } for (ColumnReport column : columns) { // UUID uuid = UUID.randomUUID(); String cellStyle = (rowNode.getAttributes().getNamedItem("style") != null) ? rowNode.getAttributes().getNamedItem("style").getNodeValue() : ""; Node columnNode = matchingColumns.get("c_" + column.getName()); if (columnNode == null) continue; Node parentNode; if (swapAxis) { parentNode = columnNode.getParentNode().getParentNode(); yCoord = columnNode.getAttributes().getNamedItem("y") != null ? Integer.parseInt(columnNode.getAttributes().getNamedItem("y").getNodeValue()) : 0; } else { parentNode = rowNode.getParentNode().getParentNode(); xCoord = columnNode.getAttributes().getNamedItem("x") != null ? Integer.parseInt(columnNode.getAttributes().getNamedItem("x").getNodeValue()) : 0; width = columnNode.getAttributes().getNamedItem("width") != null ? Integer.parseInt(columnNode.getAttributes().getNamedItem("width").getNodeValue()) : 0; height = rowNode.getAttributes().getNamedItem("height") != null ? Integer.parseInt(rowNode.getAttributes().getNamedItem("height").getNodeValue()) : 0; if (cellStyle.equals("") && (columnNode.getAttributes().getNamedItem("style") != null)) { cellStyle = columnNode.getAttributes().getNamedItem("style").getNodeValue(); } } Element textField = doc.createElement("textField"); textField.setAttribute("pattern", column.getPattern() != null ? column.getPattern() : "#,##0.00"); Element reportElement = doc.createElement("reportElement"); reportElement.setAttribute("key", "r_" + row.getName() + "_c_" + column.getName()); reportElement.setAttribute("x", xCoord.toString()); reportElement.setAttribute("y", yCoord.toString()); reportElement.setAttribute("width", width.toString()); if (row.getVisible() != null && !row.getVisible()) { reportElement.setAttribute("height", "0"); } else { reportElement.setAttribute("height", height.toString()); } if (!cellStyle.equals("")) { reportElement.setAttribute("style", cellStyle); } Element textElement = doc.createElement("textElement"); textElement.setAttribute("textAlignment", "Right"); Element textFieldExpression = doc.createElement("textFieldExpression"); if (column.getType() == Constants.CALCULATED) { StringBuffer expression = new StringBuffer(); if (column.getSlicer().equals("All")) { String fieldName = row.getName() + "_" + column.getName() + "_All_" + column.getMeasure(); expression.append("checkNull($F{" + fieldName + "}).doubleValue()"); } else { String[] types = column.getSlicer().split(","); for (int i = 0; i < types.length; i++) { if (!types[i].equals("")) { String fieldName = row.getName() + "_" + column.getName() + "_" + shortenType(types[i]) + "_" + column.getMeasure(); if (nonFlowItems.contains(column.getSlicer())) { expression.append("$F{" + fieldName + "}"); } else { expression.append("checkNull($F{" + fieldName + "}).doubleValue()"); } if (i != types.length - 1) { expression.append("+"); } } } } String finalExpression = ""; Integer multiplier = rowMultiplier * column.getMultiplier(); if (expression.length() > 0) { finalExpression = "checkZero((" + expression.toString() + "), " + multiplier + ").doubleValue()"; } CDATASection cdata = doc.createCDATASection(finalExpression); textFieldExpression.appendChild(cdata); } else if (column.getType() == Constants.SUM) { StringBuffer expression = new StringBuffer(); Set<String> subcols = column.getColumnCodes(); for (Iterator<String> it = subcols.iterator(); it.hasNext();) { String code = it.next(); String[] types = code.split(","); for (int i = 0; i < types.length; i++) { String fieldName = row.getName() + "_" + types[i]; expression.append("("); expression.append("checkNull($F{" + fieldName + "}).doubleValue()"); String extractedColumnName = types[i].split("_")[0]; Integer multiplier = multipliersByColumn.get(extractedColumnName); if (multiplier == null) { multiplier = 1; } if (multiplier != null && multiplier < 0) { expression.append("* (" + multiplier + ")"); } expression.append(")"); if (i != types.length - 1) { expression.append("+"); } } if (it.hasNext()) { expression.append("+"); } } String finalExpression = ""; if (expression.length() > 0) finalExpression = "checkZero((" + expression.toString() + "), " + rowMultiplier + ").doubleValue()"; CDATASection cdata = doc.createCDATASection(finalExpression); textFieldExpression.appendChild(cdata); } else { textField = doc.createElement("staticText"); textFieldExpression = doc.createElement("text"); CDATASection cdata = doc.createCDATASection("////////"); textFieldExpression.appendChild(cdata); } textField.appendChild(reportElement); textField.appendChild(textElement); textField.appendChild(textFieldExpression); parentNode.appendChild(textField); } }
From source file:org.devgateway.eudevfin.reports.core.utils.ReportTemplate.java
private void generateMDX(List<RowReport> rows, Document doc, String slicer) { if (slicer == null || slicer.equals("")) slicer = "[Type of Finance].[Code].Members"; StringBuffer str = new StringBuffer(); List<RowReport> calculatedRows = new ArrayList<RowReport>(); for (RowReport row : rows) { if (row.getType() == Constants.CALCULATED) { calculatedRows.add(row);//from ww w . java 2s . c o m } } str.append("WITH\n"); ArrayList<String> measures = new ArrayList<String>(); for (RowReport row : calculatedRows) { if (row.getType() == Constants.CALCULATED) { for (ColumnReport column : row.getColumns()) { String measure = column.getMeasure(); if (measure != null && !measure.equals("") && !measures.contains(measure)) measures.add(measure); } str.append("MEMBER "); str.append("[Type of Aid].[" + row.getName() + "]"); str.append(" as SUM("); String formula = row.getFormula(); if (formula.equals("")) { formula = "[BiMultilateral].Members"; } str.append(formula); str.append(")\n"); } } str.append("\n"); for (String measure : measures) { str.append("MEMBER " + measure + " AS " + measureMap.get(measure) + " \n"); } str.append("SELECT {"); for (Iterator<RowReport> it = calculatedRows.iterator(); it.hasNext();) { RowReport row = it.next(); str.append("[Type of Aid].[" + row.getName() + "]"); if (it.hasNext()) str.append(","); } str.append("} ON ROWS, \n"); str.append(" NON EMPTY {"); str.append(StringUtils.join(measures.toArray(), ",")); str.append("}*" + slicer + " ON COLUMNS \n"); str.append("FROM [Financial] \n"); str.append( "WHERE {[Reporting Year].[$P{REPORTING_YEAR}]} * {[Form Type].[bilateralOda.CRS], [Form Type].[multilateralOda.CRS], [Form Type].[nonOda.nonExport], [Form Type].[nonOda.export], [Form Type].[nonOda.privateGrants], [Form Type].[nonOda.privateMarket], [Form Type].[nonOda.otherFlows], [Form Type].[Unspecified]}\n"); Node queryString = doc.getElementsByTagName("queryString").item(0); CDATASection cdata = doc.createCDATASection(str.toString()); queryString.appendChild(cdata); }
From source file:org.dhatim.delivery.dom.DOMBuilder.java
public void startElement(StartElementEvent startEvent) throws SAXException { Element newElement = null;//from w w w .j a va 2 s .c om int attsCount = startEvent.atts.getLength(); Node currentNode = (Node) nodeStack.peek(); try { if (startEvent.uri != null && startEvent.qName != null && !startEvent.qName.equals("")) { newElement = ownerDocument.createElementNS(startEvent.uri.intern(), startEvent.qName); } else { newElement = ownerDocument.createElement(startEvent.localName.intern()); } currentNode.appendChild(newElement); if (!emptyElements.contains(startEvent.qName != null ? startEvent.qName : startEvent.localName)) { nodeStack.push(newElement); } } catch (DOMException e) { logger.error("DOMException creating start element: namespaceURI=" + startEvent.uri + ", localName=" + startEvent.localName, e); throw e; } for (int i = 0; i < attsCount; i++) { String attNamespace = startEvent.atts.getURI(i); String attQName = startEvent.atts.getQName(i); String attLocalName = startEvent.atts.getLocalName(i); String attValue = startEvent.atts.getValue(i); try { if (attNamespace != null && attQName != null) { attNamespace = attNamespace.intern(); if (attNamespace.equals(XMLConstants.NULL_NS_URI)) { if (attQName.startsWith(XMLConstants.XMLNS_ATTRIBUTE)) { attNamespace = XMLConstants.XMLNS_ATTRIBUTE_NS_URI; } else if (attQName.startsWith("xml:")) { attNamespace = XMLConstants.XML_NS_URI; } } newElement.setAttributeNS(attNamespace, attQName, attValue); } else { newElement.setAttribute(attLocalName.intern(), attValue); } } catch (DOMException e) { logger.error("DOMException setting element attribute " + attLocalName + "=" + attValue + "[namespaceURI=" + startEvent.uri + ", localName=" + startEvent.localName + "].", e); throw e; } } }
From source file:org.dhatim.delivery.dom.DOMBuilder.java
public void characters(char[] ch, int start, int length) throws SAXException { try {/* w w w. ja va 2 s .c o m*/ Node currentNode = (Node) nodeStack.peek(); switch (currentNode.getNodeType()) { case Node.ELEMENT_NODE: if (inEntity && !rewriteEntities) { currentNode.appendChild(ownerDocument.createTextNode("&#" + (int) ch[start] + ";")); } else { currentNode.appendChild(ownerDocument.createTextNode(new String(ch, start, length))); } break; case Node.CDATA_SECTION_NODE: cdataNodeBuilder.append(ch, start, length); break; default: break; } } catch (DOMException e) { logger.error("DOMException appending character data [" + new String(ch, start, length) + "]", e); throw e; } }
From source file:org.dhatim.delivery.dom.DOMBuilder.java
public void startCDATA() throws SAXException { CDATASection newCDATASection = ownerDocument.createCDATASection("dummy"); Node currentNode; currentNode = (Node) nodeStack.peek(); currentNode.appendChild(newCDATASection); nodeStack.push(newCDATASection);//from w w w .j a va 2s. c om cdataNodeBuilder.setLength(0); }
From source file:org.dhatim.delivery.dom.DOMBuilder.java
public void comment(char[] ch, int start, int length) throws SAXException { try {//from ww w. j a v a2 s.c o m Node currentNode = (Node) nodeStack.peek(); Comment newComment; newComment = ownerDocument.createComment(new String(ch, start, length)); currentNode.appendChild(newComment); } catch (DOMException e) { logger.error("DOMException comment data [" + new String(ch, start, length) + "]", e); throw e; } }