This OpenScript script allows you to assign simple XHTML text to a ToolBook field and have it displayed in the same way as a Web browser would. XHTML is a well behaved version of HTML that complies with the rules of XML (see W3C XHTML). Being standards-based, XHTML is well suited to storing rich text for eLearning applications developed in ToolBook.
This native script is a useful alternative to setting text styles by hand or importing formatted text from Rich Text Format (RTF) files. Storing formatted text as XHTML outside of ToolBook allows you to use a wide range of HTML/XHTML editing tools to create rich text content for your ToolBook application. In addition, it opens up the possibility of using XML tools (e.g. MSXML4, XSLT, etc.) to render your textual content in alternative ways - eg. for Web sites, online manuals or printable versions of your content.
The script can be found in the book script of a demonstration ToolBook book (xhtml.zip 22K) that lets you type in XHTML, click the Set button and see the results displayed in a normal ToolBook field. No browser controls or add-ins are required. Although not specifically intended for producting DHTML applications, there’s no reason why your ToolBook fields can’t be populated from XHTML before you export them.
If you already know HTML or XHTML the fragment below gives you an idea of what is possible.
This is a <b>demo</b> of <i>very simple</i> text formatting in xhtml. You can hyperlink to urls like <a href="http://www.click2learn.com" title="Go to clks site">Click2learn</a> or to documents like <a href="mywordstuff.doc" title="open word doc">Word docs</a> etc. <hr/> <ul> <li>bullet 1</li> <li>bullet 2</li> <li>etc.</li> <ul> <hr/> <p>Lucy says this is <font size="16" face="Times New Roman">cool</font> but needs more work...</p> <img src="lucy"/>
To assign a fragment of text to a ToolBook field you use an OpenScript statement like this:
xhtml of field "fred" = "...some xhtml text..."
Look at the demo book to see how this text displays. The only thing that is unusual is that image sources are treated as the names of ToolBook bitmap resources rather than the URL of an image.
Of course, there are limitations! The script only knows about the tags used in the example above, which is just a subset of the XHTML language and is completely ignorent of cascading style sheets. Also, the current capabilities of ToolBook text fields place some severe limits on what can be displayed. Also, the handling of white space is non-standard (although I may fix this soon so don’t rely on hard line breaks behaving like <br/> tags. One annoying quirk is that, until someone volunteers to work out the RTF assignment necessary, the field has to be visible when you assign the xhtml value (if there is an A or FONT tag in your XHTML). However, even with these restrictions, there are plenty of applications for the formatting supported by this script.
