How to strip whitespace-only text nodes from a DOM before serialization?

You can find empty text nodes using XPath, then remove them programmatically like so: XPathFactory xpathFactory = XPathFactory.newInstance(); // XPath to find empty text nodes. XPathExpression xpathExp = xpathFactory.newXPath().compile( “//text()[normalize-space(.) = ”]”); NodeList emptyTextNodes = (NodeList) xpathExp.evaluate(doc, XPathConstants.NODESET); // Remove each empty text node from document. for (int i = 0; i < emptyTextNodes.getLength(); i++) … Read more

git whitespace woes

Git1.6.0.4 seems a bit old, especially if you consider that: in 1.6.3.4, “git apply –whitespace=fix” did not fix trailing whitespace on an incomplete line in 1.6.3.2, “whitespace” attribute that is set was meant to detect all errors known to git, but it told git to ignore trailing carriage-returns. Could you try with Git1.6.4.1, and rather … Read more

Specifying Tab-Width?

Use the tab-size property. You’ll need vendor prefixes currently. Example: pre { -moz-tab-size: 4; -o-tab-size: 4; tab-size: 4; } See also the article on developer.mozilla.org: tab-size. .tabstop { -moz-tab-size: 4; -o-tab-size: 4; tab-size: 4; } Unstyled tabs (browser default) <pre> one tab two tabs three tabs </pre> Styled tabs (4em) <pre class=”tabstop”> one tab two … Read more

Trim trailing spaces with PostgreSQL

There are many different invisible characters. Many of them have the property WSpace=Y (“whitespace”) in Unicode. But some special characters are not considered “whitespace” and still have no visible representation. The excellent Wikipedia articles about space (punctuation) and whitespace characters should give you an idea. <rant>Unicode sucks in this regard: introducing lots of exotic characters … Read more