MCPcopy Index your code
hub / github.com/processing/processing / trim

Method trim

core/src/processing/data/XML.java:606–622  ·  view source on GitHub ↗

Removes whitespace nodes. Those whitespace nodes are required to reconstruct the original XML's spacing and indentation. If you call this and use saveXML() your original spacing will be gone. @nowebref @brief Removes whitespace nodes

()

Source from the content-addressed store, hash-verified

604 * @brief Removes whitespace nodes
605 */
606 public void trim() {
607 try {
608 XPathFactory xpathFactory = XPathFactory.newInstance();
609 XPathExpression xpathExp =
610 xpathFactory.newXPath().compile("//text()[normalize-space(.) = '']");
611 NodeList emptyTextNodes = (NodeList)
612 xpathExp.evaluate(node, XPathConstants.NODESET);
613
614 // Remove each empty text node from document.
615 for (int i = 0; i < emptyTextNodes.getLength(); i++) {
616 Node emptyTextNode = emptyTextNodes.item(i);
617 emptyTextNode.getParentNode().removeChild(emptyTextNode);
618 }
619 } catch (Exception e) {
620 throw new RuntimeException(e);
621 }
622 }
623
624
625// /** Remove whitespace nodes. */

Callers 15

DoubleListMethod · 0.45
nextToMethod · 0.45
nextValueMethod · 0.45
LongListMethod · 0.45
IntListMethod · 0.45
FloatListMethod · 0.45
formatMethod · 0.45
processMethod · 0.45
loadLanguageMethod · 0.45
readMethod · 0.45
loadMethod · 0.45
readSettingsMethod · 0.45

Calls 2

compileMethod · 0.45
removeChildMethod · 0.45

Tested by

no test coverage detected