Package org.jdom.xpath

Examples of org.jdom.xpath.XPath.selectSingleNode()


          return QueryResult.createCorrectQuery(
              pageId, xpaPageTitle.valueOf(node),
              pageOldRevId, pageNewRevId);
        } else if ("Failure".equalsIgnoreCase(result)) {
          XPath xpaCaptcha = XPath.newInstance("./captcha");
          Element captcha = (Element) xpaCaptcha.selectSingleNode(node);
          if (captcha != null) {
            XPath xpaType = XPath.newInstance("./@type");
            CaptchaException exception = new CaptchaException("Captcha", xpaType.valueOf(captcha));
            XPath xpaMime = XPath.newInstance("./@mime");
            exception.setMime(xpaMime.valueOf(captcha));
View Full Code Here


      throw new APIException("Page is null");
    }
    boolean redirect = false;
    try {
      XPath xpaPage = XPath.newInstance(query);
      Element node = (Element) xpaPage.selectSingleNode(root);
      if (node != null) {
        XPath xpaNamespace = XPath.newInstance("./@ns");
        page.setNamespace(xpaNamespace.valueOf(node));
        if (node.getAttribute("redirect") != null) {
          redirect = true;
View Full Code Here

        page.setPageId(xpaPageId.valueOf(node));
        XPath xpaStartTimestamp = XPath.newInstance("./@starttimestamp");
        page.setStartTimestamp(xpaStartTimestamp.valueOf(node));
      }
      XPath xpa = XPath.newInstance(query + "/revisions/rev");
      node = (Element) xpa.selectSingleNode(root);
      if (node != null) {
        XPath xpaContents = XPath.newInstance(".");
        XPath xpaRevision = XPath.newInstance("./@revid");
        XPath xpaTimestamp = XPath.newInstance("./@timestamp");
        page.setContents(xpaContents.valueOf(node));
View Full Code Here

      page.setExisting(Boolean.FALSE);
    }

    // Retrieve protection information
    XPath xpaProtection = XPath.newInstance("protection/pr[@type=\"edit\"]");
    Element protectionNode = (Element) xpaProtection.selectSingleNode(node);
    if (protectionNode != null) {
      XPath xpaLevel = XPath.newInstance("./@level");
      page.setEditProtectionLevel(xpaLevel.valueOf(protectionNode));
    }
  }
View Full Code Here

    XPath xpaFrom = XPath.newInstance("./@from");
    XPath xpaTo = XPath.newInstance("./@to");

    // Retrieving pages
    XPath xpaPages = XPath.newInstance("/api/query/pages");
    Element listPages = (Element) xpaPages.selectSingleNode(root);
    XPath xpaPageId = XPath.newInstance("./@pageid");
    XPath xpaNamespace = XPath.newInstance("./@ns");
    XPath xpaTitle = XPath.newInstance("./@title");

    // Retrieving normalization information
View Full Code Here

      Iterator<Page> itPage = p.getRedirectIteratorWithPage();
      while (itPage.hasNext()) {
        Page tmp = itPage.next();
        String title = getNormalizedTitle(tmp.getTitle(), normalization);
        XPath xpaPage = createXPath("page", "title", title);
        Element page = (Element) xpaPage.selectSingleNode(listPages);
        if (page != null) {
          List pageId = xpaPageId.selectNodes(page);
          if ((pageId != null) && (!pageId.isEmpty())) {
            tmp.setExisting(Boolean.TRUE);
          } else {
View Full Code Here

      Element root = getRoot(properties, ApiRequest.MAX_ATTEMPTS);
      WikiConfiguration wikiConfiguration = getWiki().getWikiConfiguration();

      // Retrieve general information
      XPath xpa = XPath.newInstance("/api/query/general");
      Element generalNode = (Element) xpa.selectSingleNode(root);
      if (generalNode != null) {
        wikiConfiguration.setArticlePath(generalNode.getAttributeValue("articlepath"));
        wikiConfiguration.setScript(generalNode.getAttributeValue("script"));
        wikiConfiguration.setServer(generalNode.getAttributeValue("server"));
      }
View Full Code Here

        }
      }

      // Retrieve revision id
      XPath xpaPage = XPath.newInstance("/api/parse");
      Element parseNode = (Element) xpaPage.selectSingleNode(root);
      if ((parseNode != null) && (parseNode.getAttributeValue("revid") != null)) {
        page.setRevisionId(parseNode.getAttributeValue("revid"));
      }

      return result;
View Full Code Here

              updatePageInformation(pageNode, page);
 
              // Retrieve revisions
              if (!Boolean.FALSE.equals(page.isExisting())) {
                XPath xpaRevisions = XPath.newInstance("revisions/rev");
                Element revNode = (Element) xpaRevisions.selectSingleNode(pageNode);
                if (revNode != null) {
                  page.setContents(revNode.getText());
                  page.setExisting(Boolean.TRUE);
                  page.setRevisionId(revNode.getAttributeValue("revid"));
                  page.setContentsTimestamp(revNode.getAttributeValue("timestamp"));
View Full Code Here

    }

    private Element getMatch(Object doc, String xpath) {
        try {
            XPath path = XPath.newInstance(xpath);
            return (Element)path.selectSingleNode(doc);
        } catch (JDOMException e) {
            throw new DatabindingException("Error evaluating xpath " + xpath, e);
        }
    }
View Full Code Here

TOP
Copyright © 2018 www.massapi.com. All rights reserved.
All source code are property of their respective owners. Java is a trademark of Sun Microsystems, Inc and owned by ORACLE Inc. Contact coftware#gmail.com.