List of usage examples for org.jdom2.xpath XPathFactory instance
public static final XPathFactory instance()
From source file:AIR.Common.xml.XmlElement.java
License:Open Source License
public List<Element> selectNodes(String xpath) { XPathFactory factory = XPathFactory.instance(); XPathExpression<Element> expr = factory.compile(xpath, Filters.element()); return expr.evaluate(_element); }
From source file:AIR.Common.xml.XmlElement.java
License:Open Source License
public List<Element> selectNodes(String xpath, XmlNamespaceManager nsmgr) { XPathFactory factory = XPathFactory.instance(); XPathExpression<Element> expr = factory.compile(xpath, Filters.element(), null, nsmgr.getNamespaceList()); return expr.evaluate(_element); }
From source file:AIR.Common.xml.XmlElement.java
License:Open Source License
public Element selectSingleNode(String xpath, XmlNamespaceManager nsmgr) { XPathFactory factory = XPathFactory.instance(); XPathExpression<Element> expr = factory.compile(xpath, Filters.element(), null, nsmgr.getNamespaceList()); return expr.evaluateFirst(_element); }
From source file:AIR.Common.xml.XmlElement.java
License:Open Source License
public Element selectSingleNode(String xpath) { XPathFactory factory = XPathFactory.instance(); XPathExpression<Element> expr = factory.compile(xpath, Filters.element()); return expr.evaluateFirst(_element); }
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 w w .j a va 2 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); } }
From source file:ataraxis.passwordmanager.XMLHandler.java
License:Open Source License
/** * Delete the Element with the ID ElementID and all sub-Elements * * @param ElementID ID of Element //from w ww.j av a 2 s . c om * @throws JDOMException if Element does not exist */ private void deleteElement(String ElementID) throws JDOMException { XPathExpression<Element> xpath = XPathFactory.instance().compile("//*[@id='" + ElementID + "']", Filters.element()); Element el = xpath.evaluateFirst(s_doc); if (el != null) { el.detach(); } else { throw new JDOMException("Element not Found"); } }
From source file:ataraxis.passwordmanager.XMLHandler.java
License:Open Source License
/** * Returns true if the Element exist, false otherwise * // www . ja v a 2 s . c o m * @param ElementID the ID of the Element * @return true if exist, false otherwise */ public boolean existID(String EntryID) { boolean exist = false; try { XPathExpression<Element> xpath = XPathFactory.instance().compile("//*[@id='" + EntryID + "']", Filters.element()); Element tempElement = xpath.evaluateFirst(s_doc); if (tempElement != null) exist = true; } catch (Exception e) { logger.debug("Element " + EntryID + " NOT found"); } return exist; }
From source file:ataraxis.passwordmanager.XMLHandler.java
License:Open Source License
/** * Check if ElementID is a Element of type group * /*from w w w .j av a 2 s.co m*/ * @param ElementID the ID of the Element * @return true if it is a group, false otherwise */ public boolean isGroupElement(String ElementID) { boolean isGroupElement = false; try { XPathExpression<Element> xpath = XPathFactory.instance().compile("//group[@id='" + ElementID + "']", Filters.element()); Element tempElement = xpath.evaluateFirst(s_doc); if (tempElement != null) { isGroupElement = true; } } catch (Exception e) { logger.debug("Element " + ElementID + " NOT found"); } return isGroupElement; }
From source file:ataraxis.passwordmanager.XMLHandler.java
License:Open Source License
/** * Return a List of all groups//from w w w.j av a 2 s . c om * @return the GroupList * @throws JDOMException by problems with JDOM */ private List<Element> getGroupList() throws JDOMException { XPathExpression<Element> xpath = XPathFactory.instance().compile("//group", Filters.element()); return xpath.evaluate(s_doc); }
From source file:ataraxis.passwordmanager.XMLHandler.java
License:Open Source License
/** * Return a List of all entries//from w w w . j a v a 2s . c om * @return the GroupList * @throws JDOMException by problems with JDOM */ private List<Element> getAccountList() throws JDOMException { XPathExpression<Element> xpath = XPathFactory.instance().compile("//account", Filters.element()); return xpath.evaluate(s_doc); }