HTML Fragments

There are two major use cases for HTML fragments. First, HTML fragments can be used as styling commands. For example, you can import a <b> tag to make the text bold. The second case is to import HTML content, for example, from a rich text control on a web page. In this case, the HTML is meant to be richly formatted content using HTML markup.

AutoTag's HTML facilities are designed to enable fragments of HTML to be processed as subreports. This guide explains how HTML fragments can be used as Blueprint Document Generation templates.

Inserting HTML Fragments

HTML fragments can be stored in the database as text, or as a link to a file containing the actual HTML data. HTML fragments that are stored as text in a database can be inserted into a report with the out tag.

HTML fragments that are stored as a link to an HTML file can be inserted into a report with the import tag. Whether you use the out tag or the import tag to insert HTML into the report, be sure to set the type attribute of the tag to "TEMPLATE".

Example: Inserting HTML with the out tag

The following XML data file has an HTML fragment stored in the <inline> tag.

<root>

<inline><![CDATA[<b>Hello, World!</b>]]></inline>

</root>

The HTML fragment can be inserted into the report using the following out tag:

<wr:out select="/root/inline" type="TEMPLATE"/>

The produced output will be:

Hello, World!

Example: Inserting HTML with the import tag

Suppose you have the following XML data:

<root>

<file>//fragment.html</file>

</root>

You can insert fragment.html with the following template:

<wr:import select="/root/file" type="TEMPLATE"/>

The produced output will correspond to whatever is in the fragment.html.

Formatting with HTML Fragments

The formatting effects of the imported HTML tags persist throughout the document. For example, if the imported HTML contains only a formatting tag such as the <b> tag, then the character formatting will become bold.

Example: Using imported HTML to format the document

Suppose you have the following XML data:

<root>

<boldOn><![CDATA[<b>]]></boldOn>

<boldOff><![CDATA[</b>]]></boldOff>

</root>

Now suppose you have the following in your template:

Not bold. <wr:out select="/root/boldOn" type="TEMPLATE"/>Bold. <wr:out select="/root/boldOff" type="TEMPLATE"/> Not bold.

The produced output will be:

Not bold. Bold. Not bold.