`
kongq1983
  • 浏览: 40611 次
  • 性别: Icon_minigender_1
  • 来自: 杭州
社区版块
存档分类
最新评论

Why aren't <FONT>, <B>, etc. tags fully nested?

阅读更多

Authors are sometimes lazy and often fail to close some tags as required by the HTML standard. This causes some problems for the parser.

 

For this heuristic reason, not all possible tags are registered as composite tags, which is what generates the 'parent/child' nesting relationship. It is considered better to have a valid, less nested parse than a possibly invalid parse.

 

You are free to add whatever nodes you like as composite nodes using the prototypical node factory paradigm. First create your class that derives from CompositeTagNode (copy and modify one of the existing tags that is most like your desired tag):

 

public class BoldTag extends CompositeTag
{
    private static final String[] mIds = new String[] {"B"};
    public BoldTag ()
    {
    }
    public String[] getIds ()
    {
        return (mIds);
    }
    public String[] getEnders ()
    {
        return (mIds);
    }
    public String[] getEndTagEnders ()
    {
        return (new String[0]);
    }
}

 

Then, register an instance of your node with a PrototypicalNodeFactory:

 

PrototypicalNodeFactory factory = new PrototypicalNodeFactory ();
factory.registerTag (new BoldTag ());
parser.setNodeFactory (factory);

 

The problem becomes detecting when the tag doesn't have a </B> like it should, so getEnders() and getEndTagEnders() should probably have a longer list of tag names. Enders are the tag names that force an end tag to be generated, while EndTagEnders are the end tags (</xxx>) that force an end tag to be generated.

 

分享到:
评论

相关推荐

    NETCFSERUP

    &lt;summary&gt;This method can be used to obtain subclass information for nested API derived objects within an API object.&lt;/summary&gt; &lt;param name="tParent"&gt;The class type of the Parent Class.&lt;/param&gt; ...

    The Art of Assembly Language Programming

    You are visitor as of October 17, 1996.&lt;br&gt;The Art of Assembly Language Programming&lt;br&gt;&lt;br&gt;Forward Why Would Anyone Learn This Stuff?&lt;br&gt;1 What's Wrong With Assembly Language&lt;br&gt;2 What's Right With ...

    Outline of Programming with C

    Outline of Programming with C&lt;br&gt;&lt;br&gt;Chapter 1 INTRODUCTORY CONCEPTS ......................................................................................... 1 &lt;br&gt;1.1 Introduction to Computers ........

    Struts所有标签详解

    里面包括&lt;html&gt;&lt;bean&gt;&lt;logic&gt;&lt;tiles&gt;&lt;nested&gt;&lt;br&gt;五组标签库的详细讲解,每个标签库都对应着&lt;br&gt;相应的例子(标签多的标签库有两个例子)。&lt;br&gt;另外还有国际化(文字国际化/图片国际化)、&lt;br&gt;表单验证,以及验证...

    Delphi7.1 Update

    Cannot access field &lt;fieldname&gt; as type variant.&quot; * TClientDataSet doesn‘t save data to file when FileName is set and there is no existing file on disk (Quality Central 2307). * Using the Delphi...

    freemarker总结

    &lt;#case refValue&gt;...&lt;#break&gt; &lt;#case refValue&gt;...&lt;#break&gt; &lt;#default&gt;... &lt;/#switch&gt; 3、 list, break指令 list指令是一个迭代输出指令,用于迭代输出数据模型中的集合,list指令的语法格式如下: &lt;#list ...

    freemarker语法完整版

    &lt;#noescape&gt;...&lt;/#noescape&gt; ... &lt;/#escape&gt; &lt;#escape identifier as expression&gt; ... &lt;#noescape&gt;...&lt;/#noescape&gt; ... &lt;/#escape&gt; 用例 主要使用在相似的字符串变量输出,比如某一个模块的所有...

    ICC8051 Micro Series 8051 C-Compiler V4.10A/DOS

    Usage: icc8051 {&lt;options&gt;} &lt;sourcefile&gt; {&lt;options&gt;} Sourcefile: 'C' source file with default extension: .c Environment: QCC8051 Options (specified order is of no importance): -o file Put object on: ...

    java.lang.NoSuchFieldError: Companion

    &lt;dependency&gt; &lt;groupId&gt;com.squareup.okio&lt;/groupId&gt; &lt;artifactId&gt;okio&lt;/artifactId&gt; &lt;version&gt;2.8.0&lt;/version&gt;

    Struts 成功测试

    Struts 成功测试 [jps宝典第24章 书上错误太多了,均已改正]&lt;br&gt;&lt;br&gt;tomcat5.028&lt;br&gt;+&lt;br&gt;jdk1.5&lt;br&gt;+&lt;br&gt;struts-1.2.8&lt;br&gt;+&lt;br&gt;================================================================================...

    Addison.Wesley.The.Java.Programming.Language.4th.Edition.Aug.2005.chm

    These tasks must cooperate to behave correctly, and threads meet the needs of cooperative multitasking.&lt;br&gt;&lt;br&gt;Chapter 15Annotationsdescribes the annotation types used to document some of the extra-...

    lecco sql export pro(SQL优化器)

    在查看执行计划过程中如果有什么不明白的地方,可以点中“SQL信息按钮”,再在执行计划看不明白的地方点 击下,LECCO SQL Expert的上下文敏感帮助系统将提供执行计划该处的解释&lt;br&gt;&lt;br&gt; 优化模块的特点&lt;br&gt;&lt;br&gt; ...

    findbugs-3.0.1.tar.gz

    &lt;Source name="~.*\.groovy" /&gt; &lt;/Match&gt; &lt;/FindBugsFilter&gt; New "-auxclasspathFromFile" and "-analyzeFromFile" command line options. New "nested" ant task attribute. Various bug fixes, also many ...

    海康卫视开发dll文件

    /// &lt;param name="i"&gt;实例化参数&lt;/param&gt; public NewRec(int i) { info = new bool[i]; fileSize = new uint[i]; NewFileName = new string[i]; startTime = new NetSDK.NET_DVR_TIME[i]; stopTime = new ...

    LuaBind 源码 (Lua增强库)

    void print_string() { std::cout &lt;&lt; m_string &lt;&lt; "\n"; } private: std::string m_string; }; 为了注册这个类到Lua环境,可以像下面这样写(假设你使用了名空间): module(L) [ class_&lt;testclass&gt;("testclass") .def...

    hive解析json格式数据所需jar包

    religions map&lt;string,array&lt;int&gt;&gt;) ROW FORMAT SERDE 'org.openx.data.jsonserde.JsonSerDe' STORED AS TEXTFILE; -- data : {"country":"Switzerland","languages":["German","French", -- "Italian"],...

    Jboss启动报Failed to parse WEB-INFweb.xml; - nested throwable错误

    在本例中,我们需要将错误的&lt;servlet&gt;标签改为&lt;welcome-file-list&gt;标签,正确的配置如下: ``` &lt;welcome-file-list&gt; &lt;welcome-file&gt;index.jsp&lt;/welcome-file&gt; &lt;/welcome-file-list&gt; ``` 其他可能的解决方案 除了...

    Addison.Wesley.C++.by.Dissection.2002.pdf

    6.6.1 string and basic_string&lt;&gt;.... . . . 265 6.6.2 vector&lt;&gt; in STL....... 267 6.6.3 Using complex&lt;&gt;...... . . . 267 6.6.4 limits and Other Useful Templates.... . . 268 6.7 Software Engineering: Reuse...

    C++ 标准 ISO 14882-2011

    Contents Contents iii List of Tables xi List of Figures xv 1 General 1 1.1 Scope . . . . ....1.2 Normative references ....1.3 Terms and definitions ....1.4 Implementation compliance ....1.5 Structure of this ...

    happy-grid:干净优雅的手写笔网格系统,让您开心

    快乐格 网格系统应该很简单,让你内心的设计师感到高兴。 创建行、创建列、偏移它们并更改它们的源顺序。 易于使用的 Stylus 混合库。 在转换为 PostCSS 之前,从 Cory ... &lt; div&gt; &lt; h3&gt; Nested Grid 1 &lt;/ h3&gt; &lt;/ di

Global site tag (gtag.js) - Google Analytics