最新下载
热门教程
- 1
- 2
- 3
- 4
- 5
- 6
- 7
- 8
- 9
- 10
HTML Just Passing Through
时间:2022-06-30 09:29:15 编辑:袖梨 来源:一聚教程网
XML's many applications include one traditionally handled by HTML,
document source. Sometimes you want to include some HTML in your XML
source; particularly when styling your XML with XSL to HTML, you may
want some literal HTML in the output. In some cases, you'd just like to
include some well-formed mixed-content HTML in your XML, and not worry
too much about controlling its structure.
Writing explicit XSL rules for each HTML tag would be tedious and hard
to maintain. This week, I'll present a quick shortcut that allows you
to include arbitrary mixed-content HTML in your XSL stylesheet's output.
The XSL stylesheet's input includes some XML document, constrained by
(that is, validated against) a particular DTD. To define the element
containing the arbitrary HTML's content model, simply define content
models for each of the HTML elements you want to use and their
attribute lists. For example, define the this:
?!ELEMENT a (#PCDATA)*?BR>
?!ATTLIST a
href CDATA #IMPLIED
target CDATA #IMPLIED
name CDATA #IMPLIED?BR>
(This example is simplified, since it allows only unformatted text
inside the hyperlink text node.) Create a definition like this for each
HTML tag you wish to use. After you've defined the tags, define a
parameter entity that includes all of the HTML "pass-through" tags
you've defined:
?!ENTITY % htmlpassthru
"a|i|b|code|br|tr|td|th|img|font|em"?BR>
Anywhere in the DTD you want to include mixed-content HTML, use this
parameter entity in the DTD. For example:
?!ELEMENT HtmlHelpText (#PCDATA|%htmlpassthru;)*?BR>
Now for the stylesheet. Defining a separate rule for each possible
HTML element within a HtmlHelpText element would be extremely tedious.
Fortunately, a single rule can handle all such elements. Define an XSL
rule that matches the tag name AND uses
document source. Sometimes you want to include some HTML in your XML
source; particularly when styling your XML with XSL to HTML, you may
want some literal HTML in the output. In some cases, you'd just like to
include some well-formed mixed-content HTML in your XML, and not worry
too much about controlling its structure.
Writing explicit XSL rules for each HTML tag would be tedious and hard
to maintain. This week, I'll present a quick shortcut that allows you
to include arbitrary mixed-content HTML in your XSL stylesheet's output.
The XSL stylesheet's input includes some XML document, constrained by
(that is, validated against) a particular DTD. To define the element
containing the arbitrary HTML's content model, simply define content
models for each of the HTML elements you want to use and their
attribute lists. For example, define the this:
?!ELEMENT a (#PCDATA)*?BR>
?!ATTLIST a
href CDATA #IMPLIED
target CDATA #IMPLIED
name CDATA #IMPLIED?BR>
(This example is simplified, since it allows only unformatted text
inside the hyperlink text node.) Create a definition like this for each
HTML tag you wish to use. After you've defined the tags, define a
parameter entity that includes all of the HTML "pass-through" tags
you've defined:
?!ENTITY % htmlpassthru
"a|i|b|code|br|tr|td|th|img|font|em"?BR>
Anywhere in the DTD you want to include mixed-content HTML, use this
parameter entity in the DTD. For example:
?!ELEMENT HtmlHelpText (#PCDATA|%htmlpassthru;)*?BR>
Now for the stylesheet. Defining a separate rule for each possible
HTML element within a HtmlHelpText element would be extremely tedious.
Fortunately, a single rule can handle all such elements. Define an XSL
rule that matches the tag name AND uses
相关文章
- 安全可靠全球交易所现货交易APP前十-最好用虚拟币交易app币安推荐 06-16
- GST Token价值前景:GGUSD引入对价格有何影响? 06-16
- 《七日世界》太阳能电钻获取方法有哪些 06-16
- 《异人之下手游》基础战斗机制哪几种 06-16
- 2025盘点正规币圈十大比特币交易排行-最火现货交易平台币安推荐 06-16
- 《花亦山心之月》何号获取条件说明 06-16