List of usage examples for org.jdom2.filter ElementFilter ElementFilter
public ElementFilter()
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. j a v a 2s. co 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:cz.muni.fi.mir.mathmlcanonicalization.modules.ScriptNormalizer.java
License:Apache License
private void replaceDescendants(final Element ancestor, final Map<String, String> map) { assert ancestor != null && map != null; final List<Element> toReplace = new ArrayList<Element>(); for (Element element : ancestor.getDescendants(new ElementFilter())) { if (map.containsKey(element.getName())) { toReplace.add(element);//from w w w .ja v a2 s .c o m } } for (Element element : toReplace) { replaceElement(element, map.get(element.getName())); } }
From source file:esiptestbed.mudrod.ontology.pre.AggregateTriples.java
License:Apache License
/** * Method of going through OWL structure *//*w ww . j a v a 2 s.com*/ public void loopxml() { Iterator<?> processDescendants = rootNode.getDescendants(new ElementFilter()); String text = ""; while (processDescendants.hasNext()) { Element e = (Element) processDescendants.next(); String currentName = e.getName(); text = e.getTextTrim(); if ("".equals(text)) { LOG.info(currentName); } else { LOG.info("{} : {}", currentName, text); } } }
From source file:esiptestbed.mudrod.ontology.pre.AggregateTriples.java
License:Apache License
/** * Method of identifying a specific child given a element name * @param str element name//from ww w . j ava 2s.co m * @param ele parent element * @return the element of child */ public Element findChild(String str, Element ele) { Iterator<?> processDescendants = ele.getDescendants(new ElementFilter()); String name = ""; Element result = null; while (processDescendants.hasNext()) { Element e = (Element) processDescendants.next(); name = e.getName(); if (name.equals(str)) { result = e; return result; } } return result; }
From source file:net.instantcom.mm7.MM7Message.java
License:Open Source License
@Override public void load(Element element) { Element body = element.getChild("Body", element.getNamespace()); // Extract MM7 namespace from SOAP body Iterator<?> i = body.getDescendants(new ElementFilter()); while (i.hasNext()) { Element e = (Element) i.next(); Namespace ns = e.getNamespace(); if (ns != null && ns.getURI().contains("MM7")) { this.namespace = ns; break; }/*from www .j a va2s.co m*/ } if (this.namespace == null) { throw new IllegalStateException("can't autodetect MM7 namespace: " + body.toString()); } Element header = element.getChild("Header", element.getNamespace()); setTransactionId(header.getChildTextTrim("TransactionID", namespace)); }
From source file:org.apache.marmotta.ldclient.provider.mediawiki.MediawikiProvider.java
License:Apache License
protected static Element queryElement(Document n, String query) { return XPathFactory.instance().compile(query, new ElementFilter()).evaluateFirst(n); }
From source file:org.apache.marmotta.ldclient.provider.mediawiki.MediawikiProvider.java
License:Apache License
protected static List<Element> queryElements(Document n, String query) { return XPathFactory.instance().compile(query, new ElementFilter()).evaluate(n); }
From source file:org.apache.marmotta.ucuenca.wk.provider.orcid.ORCIDRawProvider.java
License:Apache License
protected static List<Element> queryElements(Document n, String query) { return XPathFactory.instance() .compile(query, new ElementFilter(), null, Namespace.getNamespace("external-identifier", "http://www.orcid.org/ns/external-identifier"), Namespace.getNamespace("email", "http://www.orcid.org/ns/email"), Namespace.getNamespace("other-name", "http://www.orcid.org/ns/other-name"), Namespace.getNamespace("personal-details", "http://www.orcid.org/ns/personal-details"), Namespace.getNamespace("person", "http://www.orcid.org/ns/person"), Namespace.getNamespace("record", "http://www.orcid.org/ns/record"), Namespace.getNamespace("search", "http://www.orcid.org/ns/search"), Namespace.getNamespace("keyword", "http://www.orcid.org/ns/keyword"), Namespace.getNamespace("employment", "http://www.orcid.org/ns/employment"), Namespace.getNamespace("researcher-url", "http://www.orcid.org/ns/researcher-url"), Namespace.getNamespace("activities", "http://www.orcid.org/ns/activities"), Namespace.getNamespace("education", "http://www.orcid.org/ns/education"), Namespace.getNamespace("work", "http://www.orcid.org/ns/work"), Namespace.getNamespace("common", "http://www.orcid.org/ns/common")) .evaluate(n);//from w ww . j a v a 2 s . c o m }
From source file:org.apache.marmotta.ucuenca.wk.provider.scopus.ScopusAuthorSearchProvider.java
License:Apache License
protected static List<Element> queryElements(Document n, String query) { return XPathFactory.instance().compile(query, new ElementFilter(), null, n.getNamespacesInherited()) .evaluate(n);/*from ww w . j a va 2s .co m*/ }
From source file:org.jumpmind.metl.core.runtime.component.AbstractXMLComponentRuntime.java
License:Open Source License
protected Map<Element, Namespace> removeNamespaces(Document document) { Map<Element, Namespace> namespaces = new HashMap<Element, Namespace>(); if (ignoreNamespace && document.hasRootElement()) { namespaces.put(document.getRootElement(), document.getRootElement().getNamespace()); document.getRootElement().setNamespace(null); for (Element el : document.getRootElement().getDescendants(new ElementFilter())) { Namespace nsp = el.getNamespace(); if (nsp != null) { el.setNamespace(null);/*from w ww . j av a 2 s . com*/ namespaces.put(el, nsp); } } } return namespaces; }