Package org.htmlparser.nodes

Examples of org.htmlparser.nodes.TagNode


      NodeList nodes = parser.extractAllNodesThatMatch(nfilter);
      Node node = null;
      for(int i=0;i<nodes.size();i++){
        if(prvContent.length() >= max_count){
          if(node instanceof TagNode){
            TagNode tmp_node = (TagNode)node;
            boolean isEnd = tmp_node.isEndTag();
            if(!isEnd){
              prvContent.setLength(prvContent.length()-tmp_node.getText().length()-2);
            }
          }
          //��������δ�رյı�ǩ
          Node parent = node;
          //System.out.println("current node is . "+parent.getText());
          do{
            parent = parent.getParent()
            //System.out.println("parent = "+parent);         
            if(parent==null) break;
            if(!(parent instanceof TagNode)) continue;
            //System.out.println("Parent node is no ended. "+parent.getText());
            prvContent.append(((TagNode)parent).getEndTag().toHtml());
          }while(true);
          break;
        }
        node = nodes.elementAt(i);
        if(node instanceof TagNode){
          TagNode tag = (TagNode)node;
          prvContent.append('<');
          prvContent.append(tag.getText());
          prvContent.append('>');
          //System.out.println("TAG: " + '<'+tag.getText()+'>');
        }
        else if(node instanceof TextNode){
          int space = max_count - prvContent.length();
View Full Code Here


                                                           Perl5Substitution.INTERPOLATE_ALL),
                                     sTag, Util.SUBSTITUTE_ALL));

    } else if (oNode instanceof TagNode && oNode.toHtml().toLowerCase().startsWith("<link")) {

      TagNode oLnkNode = (TagNode) oNode;
      String sSrc = oLnkNode.getAttribute("href");
    String sType = oLnkNode.getAttribute("type");
    if (sType==null) sType="text/css";
   
    if (sType.equalsIgnoreCase("text/css")) {

      oBuffer.append("<style type=\"text/css\">\n<!--\n");
      try {
        oBuffer.append(oFS.readfile(sSrc));
      } catch (com.enterprisedt.net.ftp.FTPException ftpe) {
        throw new IOException(sSrc, ftpe);
      }
      oBuffer.append("\n-->\n</style>\n");

    } else {

        try {
          oPattern = oCompiler.compile(sSrc);
        } catch (MalformedPatternException neverthrown) {
          if (DebugFile.trace) DebugFile.writeln("MalformedPatternException "+sSrc);
          oPattern=null;
        }

        iSlash = sSrc.lastIndexOf('/');
        if (iSlash>=0) {
          while (sSrc.charAt(iSlash)=='/') { if (++iSlash==sSrc.length()) break; }
          sCid = sSrc.substring(iSlash);
        } else {
          sCid = sSrc;
        } // fi

        if (!oDocumentImages.containsKey(sCid)) {

         if (DebugFile.trace) DebugFile.writeln("HashMap.put(" + sSrc + "," + sCid + ")");

          oDocumentImages.put(sCid, sSrc);
        } // fi (oDocumentImages.containsKey(sCid))

      sTag = oLnkNode.toHtml(true);

      if (DebugFile.trace) DebugFile.writeln("Util.substitute([Perl5Matcher], "+oPattern.getPattern()+", new Perl5Substitution(cid:"+oDocumentImages.get(sCid)+", Perl5Substitution.INTERPOLATE_ALL)"+", "+sTag+ ", Util.SUBSTITUTE_ALL)");

      oBuffer.append(Util.substitute(oMatcher, oPattern,
                                     new Perl5Substitution("cid:"+sCid,
View Full Code Here

                    // moment this splits a tag into two causing a
                    // failure later
                    continue;

                } else if (node instanceof TagNode && ((TagNode) node).getTagName().startsWith("SWF:")) {
                    final TagNode tagNode = (TagNode) node;
                    final String tagName = tagNode.getTagName().toUpperCase();
                    LOG.debug(tagName);

                    // TODO remove context & request from Attributes -- the tags
                    // will be re-used across
                    // requests
                    final Attributes attributes = new Attributes(tagNode, context);
                    int type = 0;
                    if (tagNode.isEndTag()) {
                        type = SwfTag.END;
                    } else {
                        type = tagNode.isEmptyXmlTag() ? SwfTag.EMPTY : SwfTag.START;
                    }
                    testForProcessorForTag(lexer, tagName);
                    lineNumbers = lineNumbering(node);
                    final SwfTag tag = new SwfTag(tagName, attributes, type, lineNumbers, loadFile.getCanonicalPath());
                    tags.push(tag);

                    if (tagName.equals("SWF:IMPORT")) {
                        if (!tagNode.isEmptyXmlTag()) {
                            throw new ScimpiException("Import tag must be empty");
                        }
                        String importFile = tagNode.getAttribute("file");
                        if (context.isDebug()) {
                            context.getWriter().println("<!-- " + "import file " + importFile + " -->");
                        }
                        importFile = context.replaceVariables(importFile);
                        parseHtmlFile(loadPath, importFile, context, tags, tagsForPreviousTemplate);
                    }

                    if (tagName.equals("SWF:TEMPLATE")) {
                        if (!tagNode.isEmptyXmlTag()) {
                            throw new ScimpiException("Template tag must be empty");
                        }
                        if (template != null) {
                            throw new ScimpiException("Template tag can only be used once within a file");
                        }
                        template = tagNode.getAttribute("file");
                        template = context.replaceVariables(template);
                        if (context.isDebug()) {
                            context.getWriter().println("<!-- " + "apply template " + template + " -->");
                        }
                        tags = new Stack<Snippet>();
                    }

                    if (tagName.equals("SWF:CONTENT")) {
                        if (!tagNode.isEmptyXmlTag()) {
                            throw new ScimpiException("Content tag must be empty");
                        }
                        if (context.isDebug()) {
                            context.getWriter().println("<!-- " + "insert content into template -->");
                        }
View Full Code Here

                 i.hasMoreNodes();)
            {
                Node node = i.nextNode();
                if (node instanceof TagNode)
                {
                    TagNode link = (TagNode) node;
                    String href = link.getAttribute("href");

                    String rel = link.getAttribute("rel");
                    if (rel == null) continue;
                    List relations = Arrays.asList(rel.split(" "));
                    if (relations == null) continue;

                    if (relations.contains("openid.server"))
View Full Code Here

                 i.hasMoreNodes();)
            {
                Node node = i.nextNode();
                if (node instanceof TagNode)
                {
                    TagNode link = (TagNode) node;
                    String href = link.getAttribute("href");

                    String rel = link.getAttribute("rel");
                    if (rel == null) continue;
                    List relations = Arrays.asList(rel.split(" "));
                    if (relations == null) continue;

                    if (relations.contains("openid.server"))
View Full Code Here

     * @param attributes The attributes contained in this tag.
     * @return The created Tag node.
     */
    public Tag createTagNode (Page page, int start, int end, Vector attributes)
    {
        return (new TagNode (page, start, end, attributes));
    }
View Full Code Here

            attributes.addElement (new Attribute ("PARAM", null));
            attributes.addElement (new Attribute (" "));
            attributes.addElement (new Attribute ("VALUE", paramValue, '"'));
            attributes.addElement (new Attribute (" "));
            attributes.addElement (new Attribute ("NAME", paramName.toUpperCase (), '"'));
            tag = new TagNode (null, 0, 0, attributes);
            kids.add (tag);
        }
       
        //set kids as new children
        setChildren (kids);
View Full Code Here

            attributes.addElement (new Attribute ("PARAM", null));
            attributes.addElement (new Attribute (" "));
            attributes.addElement (new Attribute ("VALUE", paramValue, '"'));
            attributes.addElement (new Attribute (" "));
            attributes.addElement (new Attribute ("NAME", paramName, '"'));
            tag = new TagNode (null, 0, 0, attributes);
            kids.add (tag);
        }

        //set kids as new children
        setChildren (kids);
View Full Code Here

                    // moment this splits a tag into two causing a
                    // failure later
                    continue;

                } else if (node instanceof TagNode && ((TagNode) node).getTagName().startsWith("SWF:")) {
                    final TagNode tagNode = (TagNode) node;
                    final String tagName = tagNode.getTagName().toUpperCase();
                    LOG.debug(tagName);

                    // TODO remove context & request from Attributes -- the tags
                    // will be re-used across
                    // requests
                    final Attributes attributes = new Attributes(tagNode, context);
                    int type = 0;
                    if (tagNode.isEndTag()) {
                        type = SwfTag.END;
                    } else {
                        type = tagNode.isEmptyXmlTag() ? SwfTag.EMPTY : SwfTag.START;
                    }
                    testForProcessorForTag(lexer, tagName);
                    lineNumbers = lineNumbering(node);
                    final SwfTag tag = new SwfTag(tagName, attributes, type, lineNumbers, loadFile.getCanonicalPath());
                    tags.push(tag);

                    if (tagName.equals("SWF:IMPORT")) {
                        if (!tagNode.isEmptyXmlTag()) {
                            throw new ScimpiException("Import tag must be empty");
                        }
                        String importFile = tagNode.getAttribute("file");
                        if (context.isDebug()) {
                            context.getWriter().println("<!-- " + "import file " + importFile + " -->");
                        }
                        importFile = context.replaceVariables(importFile);
                        parseHtmlFile(loadPath, importFile, context, tags, tagsForPreviousTemplate);
                    }

                    if (tagName.equals("SWF:TEMPLATE")) {
                        if (!tagNode.isEmptyXmlTag()) {
                            throw new ScimpiException("Template tag must be empty");
                        }
                        if (template != null) {
                            throw new ScimpiException("Template tag can only be used once within a file");
                        }
                        template = tagNode.getAttribute("file");
                        template = context.replaceVariables(template);
                        if (context.isDebug()) {
                            context.getWriter().println("<!-- " + "apply template " + template + " -->");
                        }
                        tags = new Stack<Snippet>();
                    }

                    if (tagName.equals("SWF:CONTENT")) {
                        if (!tagNode.isEmptyXmlTag()) {
                            throw new ScimpiException("Content tag must be empty");
                        }
                        if (context.isDebug()) {
                            context.getWriter().println("<!-- " + "insert content into template -->");
                        }
View Full Code Here

                    // TODO need to pick up on comments within tags; at the moment this splits a tag into two causing a
                    // failure later
                    continue;

                } else if (node instanceof TagNode && ((TagNode) node).getTagName().startsWith("SWF:")) {
                    final TagNode tagNode = (TagNode) node;
                    final String tagName = tagNode.getTagName().toUpperCase();
                    LOG.debug(tagName);

                    // TODO remove context & request from Attributes -- the tags will be re-used across
                    // requests
                    final Attributes attributes = new Attributes(tagNode, context);
                    int type = 0;
                    if (tagNode.isEndTag()) {
                        type = SwfTag.END;
                    } else {
                        type = tagNode.isEmptyXmlTag() ? SwfTag.EMPTY : SwfTag.START;
                    }
                    testForProcessorForTag(lexer, tagName);
                    lineNumbers = lineNumbering(node);
                    final SwfTag tag = new SwfTag(tagName, attributes, type, lineNumbers, loadFile.getCanonicalPath());
                    tags.push(tag);

                    if (tagName.equals("SWF:IMPORT")) {
                        if (!tagNode.isEmptyXmlTag()) {
                            throw new ScimpiException("Import tag must be empty");
                        }
                        String importFile = tagNode.getAttribute("file");
                        if (context.isDebug()) {
                            context.getWriter().println("<!-- " + "import file " + importFile + " -->");
                        }
                        importFile = context.replaceVariables(importFile);
                        parseHtmlFile(loadPath, importFile, context, tags, tagsForPreviousTemplate);
                    }

                    if (tagName.equals("SWF:TEMPLATE")) {
                        if (!tagNode.isEmptyXmlTag()) {
                            throw new ScimpiException("Template tag must be empty");
                        }
                        if (template != null) {
                            throw new ScimpiException("Template tag can only be used once within a file");
                        }
                        template = tagNode.getAttribute("file");
                        template = context.replaceVariables(template);
                        if (context.isDebug()) {
                            context.getWriter().println("<!-- " + "apply template " + template + " -->");
                        }
                        tags = new Stack<Snippet>();
                    }

                    if (tagName.equals("SWF:CONTENT")) {
                        if (!tagNode.isEmptyXmlTag()) {
                            throw new ScimpiException("Content tag must be empty");
                        }
                        if (context.isDebug()) {
                            context.getWriter().println("<!-- " + "insert content into template -->");
                        }
View Full Code Here

TOP

Related Classes of org.htmlparser.nodes.TagNode

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.