Examples of TagNode


Examples of info.bliki.htmlcleaner.TagNode

//      }

      int level = wikiModel.incrementRecursionLevel();

      if (level > Configuration.PARSER_RECURSION_LIMIT) {
        TagNode error = new TagNode("span");
        error.addAttribute("class", "error", true);
        error.addChild(new ContentToken("Error - recursion limit exceeded parsing wiki tags."));
        localStack.append(error);
        return localStack;
      }
      // WikipediaParser parser = new WikipediaParser(rawWikitext,
      // wikiModel.isTemplateTopic(), wikiModel.getWikiListener());
      setModel(wikiModel);
      runParser();
      return localStack;
    } catch (InvalidPreWikiTag ipwt) {
      createOnlyLocalStack = true;
      throw ipwt;
    } catch (Exception e) {
      e.printStackTrace();
      TagNode error = new TagNode("span");
      error.addAttribute("class", "error", true);
      error.addChild(new ContentToken(e.getClass().getSimpleName()));
      localStack.append(error);
    } catch (Error e) {
      e.printStackTrace();
      TagNode error = new TagNode("span");
      error.addAttribute("class", "error", true);
      error.addChild(new ContentToken(e.getClass().getSimpleName()));
      localStack.append(error);
    } finally {
      wikiModel.decrementRecursionLevel();
      if (!createOnlyLocalStack) {
        // append the resursively parsed local stack to the global wiki
View Full Code Here

Examples of info.bliki.htmlcleaner.TagNode

  }

  @Override
  public void renderHTML(ITextConverter converter, Appendable buf, IWikiModel model) throws IOException {

    TagNode node = this;
    Map<String, String> tagAtttributes = node.getAttributes();

    buf.append(HEADER1);
    buf.append(HEADER2);
    String attValue = (String) tagAtttributes.get("xrange");
    if (attValue != null) {
View Full Code Here

Examples of info.bliki.htmlcleaner.TagNode

  /**
   * {@inheritDoc}
   */
  public void appendExternalImageLink(String imageSrc, String imageAltText) {
    TagNode spanTagNode = new TagNode("span");
    append(spanTagNode);
    spanTagNode.addAttribute("class", "image", true);
    TagNode imgTagNode = new TagNode("img");
    spanTagNode.addChild(imgTagNode);
    imgTagNode.addAttribute("src", imageSrc, true);
    imgTagNode.addAttribute("alt", imageAltText, true);
    // "nofollow" keyword is not allowed for XHTML
    // imgTagNode.addAttribute("rel", "nofollow", true);
  }
View Full Code Here

Examples of info.bliki.htmlcleaner.TagNode

  /**
   * {@inheritDoc}
   */
  public TagNode appendToCAnchor(String anchor) {
    TagNode aTagNode = new TagNode("a");
    aTagNode.addAttribute("name", anchor, true);
    aTagNode.addAttribute("id", anchor, true);
    return aTagNode;
  }
View Full Code Here

Examples of net.asfun.jangod.tree.TagNode

      throw new ParseException("Call a macro didn't define yet >>> " + name);
    }
    String[] args = new String[]{};// TODO resolve from macro's helpers
    String[] vals = new String[]{};// TODO resolve from helpers and macro's helpers
    for (int i=0; i<args.length; i++ ) {
      TagNode tn = new TagNode(new TagToken("{%set "+args[i] + " " + vals[i] + " just %}"));
      rebuilder.nodeInsertBefore(current, tn);
    }
    rebuilder.nodeReplace(current, defineNode.clone().children());
  }
View Full Code Here

Examples of org.eclipse.egit.ui.internal.repository.tree.TagNode

        } else if (mappedRef != null
            && mappedRef.startsWith(Constants.R_TAGS)) {
          Ref ref = repo.getRef(mappedRef);
          if (ref == null)
            return false;
          node = new TagNode(tags, repo, ref);
        } else
          return false;
      }
    } catch (IOException e) {
      return false;
View Full Code Here

Examples of org.htmlcleaner.TagNode

 
  public static Collection<String> findAllLinkHref(String html, String hostUrl) throws Exception{
    Collection<String> urls = new ArrayList<String>();
   
    HtmlCleaner cleaner = new HtmlCleaner();
    TagNode node = cleaner.clean(html);
    Object[] ns = node.evaluateXPath("//a[@href]");
    for (Object object : ns) {
      TagNode node2=(TagNode) object;
      String href = node2.getAttributeByName("href");
      if (href == null || href.trim().length() == 0)
        continue;
     
      if (!href.startsWith("https://") && !href.startsWith("http://")){
        StringBuilder sb = new StringBuilder("http://").append(new URL(hostUrl).getHost());
View Full Code Here

Examples of org.htmlcleaner.TagNode

 
  private List<Map<String, Object>> parseHtml(Page page) throws Exception{
    HtmlCleaner cleaner = new HtmlCleaner();
    cleaner.getProperties().setTreatUnknownTagsAsContent(true);
    String html = page.getContent();
    TagNode rootNode = cleaner.clean(html);
    fel.getContext().set("$page_content", html);
        final List<Field> fields = target.getModel().getField();
    String isModelArray = target.getModel().getIsArray();
    String modelXpath = target.getModel().getXpath();
    List<Map<String, Object>> list = new ArrayList<Map<String, Object>>();
    if ("1".equals(isModelArray) || "tre".equals(isModelArray)){
      Object[] nodeVals = rootNode.evaluateXPath(modelXpath);
          if (nodeVals != null && nodeVals.length > 0){
            for (int i = 0; i < nodeVals.length; i++) {
          list.add(parseHtmlMap(nodeVals[i], fields));
            }
          }
View Full Code Here

Examples of org.htmlcleaner.TagNode

        String exp = parser.getExp();
        String regex = parser.getRegex();
        String skipRgxFail = parser.getSkipRgxFail();
        try {
          if (xpath != null && xpath.trim().length() > 0) {
            TagNode tag = (TagNode)item;
            Object[] nodeVals = tag.evaluateXPath(xpath);
            if (nodeVals == null || nodeVals.length == 0)
              continue;
           
            if (attribute != null && attribute.trim().length() > 0){
              for (Object nodeVal : nodeVals){
                TagNode node = (TagNode)nodeVal;
                String attrVal = node.getAttributeByName(attribute);
                values.add(attrVal);
              }
              //正则
              parseByRegex(regex, skipRgxFail, values);
              // EXP表达式
              parseByExp(exp, values);
            }else if (xpath.endsWith("/text()")){
              for (Object nodeVal : nodeVals){
                values.add(nodeVal.toString());
              }
             
              //正则
              parseByRegex(regex, skipRgxFail, values);
             
              // EXP表达式
              parseByExp(exp, values);
            }else {
              for (Object nodeVal : nodeVals){
                TagNode node = (TagNode)nodeVal;
                values.add(node);
              }
             
              // 此种方式获取到的Node节点大部分都不是字符串,因此先执行表达式后执行正则
              // EXP表达式
View Full Code Here

Examples of org.htmlcleaner.TagNode

 
  public static Object evalXpath(String html, String xpath, String attribute){
    List<Object> result = new ArrayList<Object>();
    HtmlCleaner cleaner = new HtmlCleaner();
    try {
      TagNode tagNode = cleaner.clean(html);
      Object[] nodeVals = tagNode.evaluateXPath(xpath);
      for (Object tag : nodeVals){
        TagNode _tag = (TagNode)tag;
        Object val = null;
        if (attribute != null)
          val = _tag.getAttributeByName(attribute);
        else if (xpath.endsWith("/text()")){
          result.add(tag.toString());
        }else
          val = tag;
       
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.