QBO 3 XSLTs should adhere to the following guidelines.
Output HTML Use the <xsl:output method="html"/> tag to avoid HTML tags being incorrectly inline-closed by the XSLT processor. For example:<textarea></textarea> will result in an "illegal": <textarea/> if the output method is XML. Ensure compliance with DataSets, DataReaders and XmlReaders by using <xsl:template match="/"/> instead of <xsl:template match="*"/>. XmlReaders returned directly from SQL are efficient, but typically don't include a root node. The HttpHandler transformation allows document fragments, but match="*" will not work as expected with a document fragment. Large TransformsLarge transforms (e.g. long reports or very complicated XPath expressions) should leverage an XmlReader directly from SQL. To define a method for a class that returns an XmlReader, do the following:
Example statement: SELECT * FROM Contact WHERE Contact.ObjectID = @ObjectID and Contact.Object=@Object FOR XML PATH('ContactItem') Example DbStatement:
Table Headers and FootersUsing thead, tbody, and tfoot enables use of css to create neat effects without extra markup. For example, to get a "zebra" effect on a table, we can do this: .grid tr:nth-child(even) { background-color: #f5f5ff; } However, that class will apply to all rows, including any header and footer rows. To target just the "data" rows, we instead use: .grid tbody> tr:nth-child(even) { background-color: #f5f5ff; } PaginationQBO 3 leverages Mootool's Behaviors, and includes a qbo.Pagination behavior. This means your XSLT needs only to render: <span data-behavior="Paginate" data-paginate-options="{{'display': '{$DisplaySize}', 'start': '{$RecordStart}', 'count': '{$RecordCount}' }}"/> and the qbo.Pagination behavior will parse this data and render the appropriate text and links to other pages. Moreover, a site can override the standard qbo.Pagination behavior and the change will be applied instantly to all XSLTs that use pagination. EventsRead up on event delegation, and use it. For example, qbo.Paginate creates a clickable link for every page. Each link call the same JavaScript function, setting a different start parameter. Rather than creating an event handler on every link, the link is simply: <a class="page" start="25">2</a> and the JavaScript is this: document.id(myDivTagWithPagination).addEvent(' click:relay(a.page) ', function(e, el) { alert(el.get('start')); }); HyperlinksQBO 3 will need to live side-by-side with QBO 2.0, and with some clients, may need to be installed into a virtual folder. In order to ensure hyperlinks are always correct, we use a <base href="MyFolder"/> tag to establish where the root of the QBO 3 install it.Thus, if a Foreclosure page (found in Mortgage/Default) references a Contact page (found in Contact), the property hyperlink is: <a href="Contact/Contact.ashx/Select?ContactID=1">View Contact Details</a> Note that both of the following would be incorrect: <a href="/Contact/Contact.ashx/Select?ContactID=1">View Contact Details</a> <!- breaks if QBO 3 is not in the root folder --> <a href="../../Contact/Contact.ashx/Select?ContactID=1">View Contact Details</a> <!- breaks because of the base href tag --> ParametersBy default, XSLTs have access to the following information as parameters:
The Attachment.Search.xslt supports and uses an Accept parameter:<xsl:param name="Accept">*/*</xsl:param> ... <a href="qbo3.getObject(this).push('Edit', {{..., 'Accept': {$Accept} }}>Upload Document</a> Then, different pages can leverage this feature as follows: <!-- Default Behavior --> ... </div> Items to note:
Extension ObjectsQBO 3 supports the use of Xslt Extension objects defined in a configuration file. These extension objects allow XSLT to call custom C# (or other CLR) methods. To use Xslt extension objects:
<!-- Common configuration files --> ... <section name="XsltConfiguration" type="qbo.Application.Configuration.XsltExtensionConfiguration, qbo.Application"/> ... <XsltConfiguration configSource="config\XsltExtension.config"/>
<XsltConfiguration> <XsltExtensions> <Extension Name="Formatting" Type="qbo.Application.Utilities.XsltFormatting, qbo.Application" Namespace="urn:qbo3-formatting"/> </XsltExtensions> </XsltConfiguration>
<?xml version="1.0" encoding="utf-8"?> <xsl:stylesheet version="1.0" xmlns:xsl="http://www.w3.org/1999/XSL/Transform" xmlns:format="urn:qbo3-formatting" > ... <xsl:value-of select="format:today('yyyy-MM-dd')"/> ... To define a new Xslt Extension object:
The extension objects are wired as follows:
Configuration errors should be trapped and logged, including:
Differences between QBO 3 and QBO 2.0 Xslt Extension objects: in QBO 3
Mistakes to Avoid
|