You can place an HTML field on a screen in your Collections application. An HTML field is a database field meant for long, laid-out text. Layout can be applied to the text during editing of the record. You can print the contents of such a field to a Word template or with the aid of an XSLT stylesheet, whilst keeping the layout intact. Although you will see just the laid-out text while you are editing an HTML field, the field contents will actually be stored as HTML code in the background. You can use the HTML field as an alternative for the older and rather narrowly applicable Rich text field type.

For example: a good spot to implement such a field is the field for label text on the Accompanying texts tab of a museum object record (in e.g. a 4.2 model application: in newer model applications this field is already an HTML field), since it would be nice if you could apply layout to a label text during data entry, and maintain that layout in printouts.
You can execute the following procedure in your own application to convert the plain text field from this example to an HTML field, even if the field to be converted already contains data: your data won’t get lost:

1.Create a backup of your database and applications before you make any changes, just to be safe.
2.Open the Collect database table definition in the Application browser in Designer, and select the label.text field (tag AB).
If this field is not present in your application, you can of course pick another field of the Text data type to convert, or create a new field.
3.Open the Data type drop-down list on the Field properties tab (which has Text currently selected) and choose the HTML option.
4.Save the change: right-click the Collect table definition and select Save in the pop-up menu.
5.In the Screen editor, open the labels.fmt screen (Accompanying texts), or another screen on which you want to place the new HTML field.
6.Drag the lower border of the Labels box a few centimetres downwards so that some space is created for the new field. In the menu choose Insert > HTML field.
7.Drag the HTML field into the box to the desired location and make it as big as you like. This type of field will not automatically resize as the user types more text in it, but a scroll bar will appear instead (and the user can also resize the box at any time by dragging its lower right corner up or down). So if there is enough room on the screen, like in this example, then make the HTML field tall enough to allow long text to be visible in its entirety, in most cases. If desired, you can insert a label in front of the HTML field, into which you copy label texts from the already existing Text field label.
8.Now select the old AB field and choose Edit > Delete line in the menu. Label and field will be removed and the fields underneath it will move up a line.
9.Right-click the right or left border of the HTML field (where the cursor changes into a double arrow) and choose Properties in the pop-up menu. (See that you do not open the properties of the Box by accident.) Now enter the Tag of the HTML field, AB in our example, and set the other properties as desired. In this example, the field should be set to Repeated because the old field was repeatable too.
10.Save the changes in the screen and you are done.

Recycle the Collections IIS application pool and log into Collections again to be able to admire the result. Any existing text has no layout yet and hasn’t been stored with HTML code either. The record has to be put in edit mode to apply layout via the icons in the toolbar above the field. Note that existing text in this converted field will only be saved as HTML when the user has placed the cursor in this field once and saved the record again.

Printing, export and WebAPI output

The laid out text in HTML fields can only be printed correctly to Word templates or XSLT stylesheets. In principle, you must create these templates or stylesheets yourself, but templates do not require any special instructions – you can refer to the field tag normally – and an example stylesheet can be seen below; you may still have to adjust the stylesheet to your own situation. A stylesheet must be set up as an output format in the proper data source, before the user can print to it.

If you print HTML fields via an adapl-only output format, then the HTML field contents will be printed: the layout won’t be visible but the HTML codes will be.

When you export records with HTML fields, the HTML field contents will be extracted as HTML code: the code begins and ends with <div> and respectively </div>, and has no <body> or <head> tags. When exporting to XML, the HTML field contents will be produced as HTML within the XML field tags; the same applies to the XML search result of the WebAPI. An Axiell Internet Server web application uses stylesheets to convert the XML output of the WebAPI to HTML.
For both printing and web display, XSLT stylesheets need to be coded for HTML fields in such a way that the HTML field contents will be copied from the XML literally, like for the label.text field in our example:

<xsl:template match="label.text">
 <xsl:copy-of select="."/>
</xsl:template>

A complete example stylesheet (made for unstructured XML) which you can set up as an output format in Collections is the following:

<?xml version="1.0" encoding="utf-8"?>
<xsl:stylesheet version="1.0"
xmlns:xsl="http://www.w3.org/1999/XSL/Transform">
 <xsl:output method="html" indent="yes"/>

 <xsl:template match="/adlibXML">
   <font face="verdana" color="#808080">
     <xsl:apply-templates select="recordList"/>
   </font>
 </xsl:template>

 <xsl:template match="recordList">
     <xsl:apply-templates select="record"/>
 </xsl:template>

 <xsl:template match="record">
   <html>
    <head>
    </head>
    <body>
      <xsl:apply-templates select="object_number"/>
      <xsl:apply-templates select="label.text"/>
    </body>
   </html>
 </xsl:template>

 <xsl:template match="object_number">
   <p>
     <xsl:text>Object: </xsl:text>
     <xsl:value-of select="."/>
     <xsl:apply-templates select="../object_category"/>
   </p>
 </xsl:template>

 <xsl:template match="object_category">
   <xsl:text> (</xsl:text>
   <xsl:value-of select="."/>
   <xsl:text>)</xsl:text>
 </xsl:template>

 <xsl:template match="label.text">
 <table border="1" cellpadding="10" cellspacing="0" style="border-collapse: collapse" bordercolor="#808080"
  width="100%">
  <tr>
   <td width="100%">
 <xsl:value-of select="." disable-output-escaping="yes"/>
   </td>
  </tr>
 </table>
 </xsl:template>
</xsl:stylesheet>

Notes

Existing, filled-in RTF fields cannot be converted to HTML fields automatically. However, as a paid-for service this can be done by Axiell.
After the conversion, hard and soft returns in existing text fields have been converted to <BR/> tags.