Package org.jdom2.xpath

Examples of org.jdom2.xpath.XPathFactory


    try
    {
      Document xml=this.loadURL(url);
      if(language.equals("en"))
      {
        for(Element div:xml.getDescendants(new ElementFilter("a")))
        {
          if(div.getAttributeValue("href")!=null&&div.getAttributeValue("href").equals("/wiki/Special:Statistics"))
          {
            String str=div.getValue();
            System.out.println(str);
            this.glossCount=Double.parseDouble(str.replace(",", ""));
            break;
          }
        }
      }
      else
      {
        for(Element div:xml.getDescendants(new ElementFilter("li")))
        {
          if(div.getAttributeValue("id")!=null && div.getAttributeValue("id").contains("lang-"))
          {
            for(Element span:div.getDescendants(new ElementFilter("span")))
            {
              if(span.getAttributeValue("lang").equals(language))
              {
                String str=div.getValue();
                str=str.substring(0,str.indexOf(" articles"));
View Full Code Here


    {
      ArrayList<URL> urls=new ArrayList<URL>();
      ArrayList<Integer> levels=new ArrayList<Integer>();
      ArrayList<Integer> hindex=new ArrayList<Integer>();
      ArrayList<String> heads=new ArrayList<String>();
      for(Element div:xml.getDescendants(new ElementFilter("div")))
      {
        if(div.getAttributeValue("id")!=null&&div.getAttributeValue("id").equals("content"))
        {
          ElementFilter f=new ElementFilter("a");
          Filter<? extends Content> or=f.or(new ElementFilter("span"));
          for(Content c:div.getDescendants(or))
          {
            if(c.getCType()==CType.Element)
            {
              Element word=(Element)c;
View Full Code Here

    URL count=new URL(this.path+"/w/index.php?title=Special%3ASearch&profile=default&search="+lemma.replace(" ", "%20")+"&fulltext=Search");   
    Document xml=this.loadURL(count)
    if(xml!=null)
    {
      String aux="mw-search-formheader";
      for(Element e:this.getContentNode(xml).getDescendants(new ElementFilter("div")))
      {
        if(aux.equals(e.getAttributeValue("class")))
        {
          for(Element x:e.getDescendants(new ElementFilter("div")))
          {
            aux="results-info";
            if(aux.equals(x.getAttributeValue("class")))
            {
              aux=e.getValue().substring(e.getValue().indexOf(this.countText)+this.countText.length());;
View Full Code Here

          }
         
        }
      }
      Element navbox=null;
      for(Element e:xml.getRootElement().getDescendants(new ElementFilter("table")))
      {
        if(e.getAttributeValue("class")!=null&&e.getAttributeValue("class").equals("navbox"))
        {
            navbox=e;
            break;
        }
      }
      //Add inNavBox relations
      if(navbox!=null)
      {
        for(Element e:navbox.getDescendants(new ElementFilter("a")))
        {
          String nurl=e.getAttributeValue("href");
          if(nurl!=null&&!this.isNotAnArticle(nurl))
          {
            s.addRelation("inNavBox", new Relation("inNavBox", nurl.replace("/wiki/", ""), ""));
          }
        }
      }
      //Add in CatLinks relations
      Element catlinks=null;
      String aux="catlinks";
      for(Element e:body.getParent().getDescendants(new ElementFilter("div")))
      {
        if(aux.equals(e.getAttributeValue("id")))
        {
          catlinks=e;
          break;
        }
      }
      if(catlinks!=null)
      {
        for(Element e:catlinks.getDescendants(new ElementFilter("a")))
        {
          String nurl=e.getAttributeValue("href");
          if(nurl!=null&&!this.isNotAnArticle(nurl))
          {
            s.addRelation("inCatLinks", new Relation("inCatLinks", nurl.replace("/wiki/", ""), ""));
View Full Code Here

    URL count=new URL(this.path+"/w/index.php?title=Special%3ASearch&profile=default&search="+qry+"&fulltext=Search");   
    Document xml=this.loadURL(count)
    if(xml!=null)
    {
      String aux="mw-search-formheader";
      for(Element e:this.getContentNode(xml).getDescendants(new ElementFilter("div")))
      {
        if(aux.equals(e.getAttributeValue("class")))
        {
          for(Element x:e.getDescendants(new ElementFilter("div")))
          {
            aux="results-info";
            if(aux.equals(x.getAttributeValue("class")))
            {
              aux=e.getValue().substring(e.getValue().indexOf(this.countText)+this.countText.length());;
View Full Code Here

        try
        {
          SAXBuilder builder=new SAXBuilder();
          Document xml=(Document)builder.build(file);
          ArrayList<Element> words=new ArrayList<Element>();
          for(Element word:xml.getDescendants(new ElementFilter("wf")))
            words.add(word);
          for(int w=0;w<words.size();w++)
          {
            Element word=words.get(w);
            if(word.getAttribute("ot")!=null)
View Full Code Here

    @Override
    protected Element resolveRequestPayloadArgument(MethodParameter parameter, Source requestPayload) throws Exception {
        if (requestPayload instanceof DOMSource) {
            Node node = ((DOMSource) requestPayload).getNode();
            DOMBuilder domBuilder = new DOMBuilder();
            if (node.getNodeType() == Node.ELEMENT_NODE) {
                return domBuilder.build((org.w3c.dom.Element) node);
            }
            else if (node.getNodeType() == Node.DOCUMENT_NODE) {
                Document document = domBuilder.build((org.w3c.dom.Document) node);
                return document.getRootElement();
            }
        }
        // we have no other option than to transform
        JDOMResult jdomResult = new JDOMResult();
View Full Code Here

        if (source == null) {
            return null;
        }
        if (!alwaysTransform && source instanceof DOMSource) {
            Node node = ((DOMSource) source).getNode();
            DOMBuilder domBuilder = new DOMBuilder();
            if (node.getNodeType() == Node.ELEMENT_NODE) {
                return domBuilder.build((org.w3c.dom.Element) node);
            }
            else if (node.getNodeType() == Node.DOCUMENT_NODE) {
                Document document = domBuilder.build((org.w3c.dom.Document) node);
                return document.getRootElement();
            }
        }
        // we have no other option than to transform
        JDOMResult jdomResult = new JDOMResult();
View Full Code Here

        public Date getRevisionTimestamp() {
            return revisionTimestamp;
        }

        public ParsePage invoke() throws JDOMException, IOException {
            SAXBuilder builder = new SAXBuilder();
            Document doc = builder.build(new ByteArrayInputStream(pageString.getBytes()));
            pageTitle = textToString(titleXPath.evaluateFirst(doc));
            wikitext = textToString(textXPath.evaluate(doc));
            sourceUrl = "http://en.wikipedia.org/wiki/" + pageTitle;
            String revisionTimestampString = textToString(revisionTimestampXPath.evaluateFirst(doc));
            revisionTimestamp = null;
View Full Code Here

            } else {
                update.offer("device" + UDN + "/value/" + "lightON.png");
            }
        } else if(variable.contentEquals("LastChange")){
          
            SAXBuilder sxb = new SAXBuilder();
            try {
                Document document = sxb.build(new InputSource(new StringReader(value)));
                Element root = document.getRootElement();
                List<Element> children = root.getChildren();
                Iterator<Element> iterator = children.iterator();
                while (iterator.hasNext()) { //for each instanceID
                    Element current = iterator.next();
View Full Code Here

TOP

Related Classes of org.jdom2.xpath.XPathFactory

Copyright © 2018 www.massapicom. 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.