User's Manual

154 Chapter 12. Presentation (Bebop) Tutorial
stream from an outside source. This section discusses methods for handling this pre-formatted text
intelligently.
WAF provides an explicit technique for this situation by using the Bebop Label component and by
disabling output escaping in the XSLT processor for the context of the label. The code:
Label l = new Label("This is a
b new /b label.", false);
l.generateXML(pageState, element);
will generate the XML fragment:
bebop:label escape="yes" This is a <b new</b>
label. /bebop:label
The result is that the HTML-preformatted text is a single, text-node child to the bebop:label el-
ement. On output, the escape="yes" means that the angle brackets will not be output-escaped.
They will appear in the HTML stream as angle brackets and be interpreted as such by the user’s web
browser, causing the word new to appear in bold.
Note
The escape="yes" attribute to bebop:label is confusing because it is shorthand for what will be-
come the XSLT attribute disable-output-escaping="yes".
By default, the XSLT processor escapes output according to the output mode specified in the stylesheet
with the xsl:output element. This default makes angle brackets appear as angle brackets in the
user’s browser, which means they are transmitted as <’s in the HTML stream.
If you want angle brackets to show up in your output (e.g less-than signs for mathematics), you want
to enable output escaping, which is the default setting.
Label l = new Label("3.141
pi 3.142");
Caution
Inserting HTML formatting into the Bebop DOM, where it is difficult to style globally, is not generally
recommended.
An alternative solutions is to parse the string argument to the Label constructor as a DOM fragment,
instead of simply disabling output escaping, so that the formatting elements are a full-fledged part of
the DOM and eligible for global styling. A drawback to this is the expense of parsing XML.
An additional drawback is that most people do not write well-formed XHTML, while browsers are
much more tolerant than XML parsers. In other words, it is possible to write the following:
Label l = new Label("
ul li list item 1 li list item 2
/ul ", false);
This will be displayed correctly as an unordered list in the browser, even though the label contents are
not well-formed [X]HTML.