List of usage examples for org.w3c.dom CDATASection setData
public void setData(String data) throws DOMException;
From source file:Main.java
public static void setCDATAContent(Node node, String value) { NodeList nodeList = node.getChildNodes(); if (nodeList != null) { for (int i = 0; i < nodeList.getLength(); i++) { Node child = nodeList.item(i); if (child.getNodeType() == Node.CDATA_SECTION_NODE) { CDATASection cdata = (CDATASection) child; cdata.setData(value); }/*from w w w. j av a 2s .c o m*/ } } }
From source file:Main.java
/** * Sets element CDATA data/*from w w w .j av a2s .c o m*/ * * @param e * the lement * @param data * the new data */ public static void setElementCDataValue(Element e, String data) { CDATASection txt = getElementCDataNode(e); if (txt != null) { txt.setData(data); } else { txt = e.getOwnerDocument().createCDATASection(data); e.appendChild(txt); } }
From source file:Main.java
/** * Sets data to be the CDATA content of element * * @param element the parent element./* w w w . j a v a 2s . c o m*/ * @param data the data to set. */ public static void setCData(Element element, String data) { if (data == null) return; CDATASection txt = getCDataNode(element); if (txt != null) txt.setData(data); else { txt = element.getOwnerDocument().createCDATASection(data); element.appendChild(txt); } }
From source file:org.dhatim.delivery.dom.DOMBuilder.java
public void endCDATA() throws SAXException { CDATASection cdata = (CDATASection) nodeStack.pop(); cdata.setData(cdataNodeBuilder.toString()); cdataNodeBuilder.setLength(0);/*from ww w . j av a2s . co m*/ }
From source file:org.gvnix.flex.ui.MxmlRoundTripUtils.java
/** * Compares and updates script blocks in the MXML document if necessary. * Assumes that there is only a single script block. * /*from w w w.ja v a2s. com*/ * @param original * @param proposed * @param originalDocumentAdjusted * @return the new document if changes are necessary, null if no changes are * necessary */ private static boolean updateScriptBlock(Element original, Element proposed, boolean originalDocumentAdjusted) { Element originalScriptBlock = XmlUtils.findFirstElementByName("fx:Script", original); Element proposedScriptBlock = XmlUtils.findFirstElementByName("fx:Script", proposed); if (originalScriptBlock != null && proposedScriptBlock != null) { if (originalScriptBlock.getTextContent() != null && !originalScriptBlock.getTextContent().equals(proposedScriptBlock.getTextContent())) { originalScriptBlock.setTextContent(proposedScriptBlock.getTextContent()); originalDocumentAdjusted = true; } else if (originalScriptBlock.getChildNodes().getLength() > 0 && proposedScriptBlock.getChildNodes().getLength() > 0) { CDATASection originalCDATA = null; CDATASection proposedCDATA = null; for (int i = 0; i < originalScriptBlock.getChildNodes().getLength(); i++) { if (originalScriptBlock.getChildNodes().item(i).getNodeType() == Node.CDATA_SECTION_NODE) { originalCDATA = (CDATASection) originalScriptBlock.getChildNodes().item(i); break; } } for (int i = 0; i < proposedScriptBlock.getChildNodes().getLength(); i++) { if (proposedScriptBlock.getChildNodes().item(i).getNodeType() == Node.CDATA_SECTION_NODE) { proposedCDATA = (CDATASection) proposedScriptBlock.getChildNodes().item(i); break; } } if (originalCDATA == null || proposedCDATA == null) { return originalDocumentAdjusted; } if (originalCDATA.getData() != null && !originalCDATA.getData().equals(proposedCDATA.getData())) { originalCDATA.setData(proposedCDATA.getData()); originalDocumentAdjusted = true; } } } return originalDocumentAdjusted; }