3 15 Document Type Declaration DOCTYPE

LANSA WAM

3.15 Document Type Declaration (DOCTYPE)

This topic covers the use of the DOCTYPE declaration for directing a layout mode (what is called browser DOCTYPE "sniffing" or switching), not for DTD validation.

To add a DOCTYPE declaration to a WAM, use the xsl:output element. For example:

<xsl:output method="xml" omit-xml-declaration="yes" encoding="UTF-8"
      indent="no" doctype-public="-//W3C//DTD XHTML 1.0 Strict//EN"
      doctype-system="http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd" />

 

To avoid conflict between the different weblets and the main webroutine XSL, we recommend you define your DOCTYPE declaration in your layout weblet only.

The LANSA shipped themelets use the strict DOCTYPE to trigger standards mode. The older layout weblets don't use any DOCTYPE.

HTML5 uses the simplified DTD-less <!DOCTYPE html> to trigger standards mode in browsers. XSL doesn't support this DOCTYPE declaration.

As some devices might look for the simplified DOCTYPE to detect if the document is HTML5, the WAM runtime outputs the simplified HTML5 DOCTYPE if the xsl:output uses the XSL-friendly legacy-compat DOCTYPE:

<xsl:output method="xml" omit-xml-declaration="yes" encoding="UTF-8"
      indent="no" doctype-system="about:legacy-compat" />