List of usage examples for org.jdom2.filter Filters content
public static final Filter<Content> content()
From source file:at.newmedialab.ldpath.model.functions.XPathFunction.java
License:Apache License
private LinkedList<String> doFilter(String in, Set<String> xpaths) throws IOException { LinkedList<String> result = new LinkedList<String>(); try {/*from w ww . j av a 2 s . c om*/ Document doc = new SAXBuilder(XMLReaders.NONVALIDATING).build(new StringReader(in)); XMLOutputter out = new XMLOutputter(); for (String xp : xpaths) { XPathExpression<Content> xpath = XPathFactory.instance().compile(xp, Filters.content()); for (Content node : xpath.evaluate(doc)) { if (node instanceof Element) result.add(out.outputString((Element) node)); else if (node instanceof Text) result.add(out.outputString((Text) node)); } } return result; } catch (JDOMException xpe) { throw new IllegalArgumentException("error while processing xpath expressions: '" + xpaths + "'", xpe); } }
From source file:org.apache.marmotta.ldpath.model.functions.xml.XPathFunction.java
License:Apache License
private LinkedList<String> doFilter(String in, Set<String> xpaths) throws IOException { LinkedList<String> result = new LinkedList<String>(); try {/*from w w w .j a va2 s . co m*/ Document doc = new SAXBuilder(XMLReaders.NONVALIDATING).build(new StringReader(in)); XMLOutputter out = new XMLOutputter(); for (String xp : xpaths) { XPathExpression<Content> xpath = XPathFactory.instance().compile(xp, Filters.content()); for (Content node : xpath.evaluate(doc)) { if (node instanceof Element) { result.add(out.outputString((Element) node)); } else if (node instanceof Text) { result.add(out.outputString((Text) node)); } } } return result; } catch (JDOMException xpe) { throw new IllegalArgumentException("error while processing xpath expressions: '" + xpaths + "'", xpe); } }