XML ' s many applications include one traditionally handled by HTML,
Document source. Sometimes your want to include some HTML in your XML
Source Particularly when styling your XML with XSL to HTML
Want some literal HTML in the output. In some cases, your ' d just like to
Include some well-formed mixed-content HTML in your XML, and not worry
Too much about the controlling its structure.
Writing explicit XSL rules for each HTML tag would is tedious and hard
To maintain. This is 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 your want to use and their
Attribute lists. For example, define the <a?tag for hyperlinks like
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 the
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 with want to include Mixed-content HTML
Parameter entity in the DTD. For example:
?! ELEMENT Htmlhelptext (#PCDATA |%htmlpassthru;) *?br>
Now for the stylesheet. Defining a separate to 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 <xsl:copy-of?to copy the
The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion;
products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the
content of the page makes you feel confusing, please write us an email, we will handle the problem
within 5 days after receiving your email.
If you find any instances of plagiarism from the community, please send an email to:
info-contact@alibabacloud.com
and provide relevant evidence. A staff member will contact you within 5 working days.