1 27 package org.htmlparser.scanners; 28 29 import java.util.Vector ; 30 31 import org.htmlparser.Attribute; 32 import org.htmlparser.Node; 33 import org.htmlparser.NodeFactory; 34 import org.htmlparser.PrototypicalNodeFactory; 35 import org.htmlparser.Remark; 36 import org.htmlparser.Text; 37 import org.htmlparser.lexer.Lexer; 38 import org.htmlparser.Tag; 39 import org.htmlparser.util.NodeList; 40 import org.htmlparser.util.ParserException; 41 42 46 public class StyleScanner extends CompositeTagScanner 47 { 48 51 public StyleScanner () 52 { 53 } 54 55 62 public Tag scan (Tag tag, Lexer lexer, NodeList stack) 63 throws ParserException 64 { 65 Node content; 66 int position; 67 Node node; 68 Attribute attribute; 69 Vector vector; 70 71 content = lexer.parseCDATA (); 72 position = lexer.getPosition (); 73 node = lexer.nextNode (false); 74 if (null != node) 75 if (!(node instanceof Tag) || !( ((Tag)node).isEndTag () 76 && ((Tag)node).getTagName ().equals (tag.getIds ()[0]))) 77 { 78 lexer.setPosition (position); 79 node = null; 80 } 81 82 if (null == node) 84 { 85 attribute = new Attribute ("/style", null); 86 vector = new Vector (); 87 vector.addElement (attribute); 88 node = lexer.getNodeFactory ().createTagNode ( 89 lexer.getPage (), position, position, vector); 90 } 91 tag.setEndTag ((Tag)node); 92 if (null != content) 93 { 94 tag.setChildren (new NodeList (content)); 95 content.setParent (tag); 96 } 97 node.setParent (tag); 98 tag.doSemanticAction (); 99 100 return (tag); 101 } 102 } 103 | Popular Tags |