List of usage examples for org.jdom2.filter ContentFilter TEXT
int TEXT
To view the source code for org.jdom2.filter ContentFilter TEXT.
Click Source Link
From source file:cz.muni.fi.mir.mathmlcanonicalization.modules.OperatorNormalizer.java
License:Apache License
private void normalizeUnicode(final Element ancestor, final Normalizer.Form form) { assert ancestor != null && form != null; final List<Text> texts = new ArrayList<Text>(); final ContentFilter textFilter = new ContentFilter(ContentFilter.TEXT); for (Content text : ancestor.getContent(textFilter)) { texts.add((Text) text);// w ww . ja v a 2s .c o m } for (Element element : ancestor.getDescendants(new ElementFilter())) { for (Content text : element.getContent(textFilter)) { texts.add((Text) text); } } for (Text text : texts) { if (Normalizer.isNormalized(text.getText(), form)) { continue; } final String normalizedString = Normalizer.normalize(text.getText(), form); LOGGER.log(Level.FINE, "Text ''{0}'' normalized to ''{1}''", new Object[] { text.getText(), normalizedString }); text.setText(normalizedString); assert Normalizer.isNormalized(text.getText(), form); } }
From source file:ditatools.translate.DitaTranslator.java
License:Apache License
public DitaTranslator(String api_key, String lang) { apiKey = api_key;//from w w w .jav a 2 s. co m language = lang; translator = new Translator(apiKey); filter = new ContentFilter(ContentFilter.TEXT); // Allow elements through the filter filter.setElementVisible(true); // Allow text nodes through the filter filter.setTextVisible(true); builder = new SAXBuilder(); builder.setFeature("http://xml.org/sax/features/validation", false); builder.setFeature("http://apache.org/xml/features/nonvalidating/load-dtd-grammar", false); builder.setFeature("http://apache.org/xml/features/nonvalidating/load-external-dtd", false); }