Changing the DocType in XPages

I’ve been looking into HTML5 development
lately for a couple of different reasons, it is an important new technology
for any web developer to learn and, as we saw at Lotusphere, HTML5 is mentioned
as being part of the back-end technology for Project Vulcan.

When you start looking at HTML5 the
first thing you learn is that you need to change the DOCTYPE to <!DOCTYPE
html>. Here’s what the draft HTML5 specification has to say about the
DOCTYPE

The HTML syntax
of HTML5 requires a DOCTYPE to be specified to ensure that the browser
renders the page in standards mode. The DOCTYPE has no other purpose and
is therefore optional for XML. Documents with an XML media type are always
handled in standards mode.

The DOCTYPE declaration is
 &lt;!DOCTYPE html&gt; and is case-insensitive in the HTML
syntax. DOCTYPEs from earlier versions of HTML were longer because the
HTML language was SGML-based and therefore required a reference to a DTD.
With HTML5 this is no longer the case and the DOCTYPE is only needed to
enable standards mode for documents written using the HTML syntax. Browsers
already do this for &lt;!DOCTYPE html&gt;.

By default any Xpages application you
build will automatically include a doctype for you and it would appear
that there is no way to change it, however, hidden away and documented
only in a sample file xPages , starting in version 8.5.1, allows you to
change the DOCTYPE very easily.

Open the ‘Package Explorer’ eclipse
view as described in this
blog entry
and then open the ‘WebContent -> WEB-INF ->
xsp.properties’ file.

A picture named M2

Now all you have to do is add one additional
line

A picture named M3

Save the file and that is it. Now when
you view this xPage application in a web browser it will have the DOCTYPE
that you have specified as you can see in this ‘View Source’ screenshot.

A picture named M4

Of course you can use this trick to
set any doctype that you want but remember that it will effect all the
pages rendered from the application. As of yet there is now way to set
the doctype on a single xPages unless you use the xPage Agent method.

Advertisements
Tagged with: ,
Posted in None
6 comments on “Changing the DocType in XPages
  1. Philippe Riand says:

    As of 8.5.1, properties can be set at the page level as well. Go to the All properties tab for the page, and you’ll see a ‘properties’ property. You can define the doc type here.The properties defined at this level have a greater priority than the ones defined at the application or server levels.

    Like

  2. Just DocType HTML won’t do the trick. To get the browser into standard mode you need to have th URI (remember the infamous DominoCompleteDocType=1 in the notes.ini). So you would have something like:<!DOCTYPE HTML PUBLIC “-//W3C//DTD HTML 4.01 Transitional//EN” ” http : / / http://www.w3.org/TR/html4/loose.dtd“>

    Like

  3. sorry to drop this message here but I get an error when I try the implement the calendar described here: { Link }The error I get says:The content of elements must consist of well-formed character data or markup.and concern this line of code:<!DATA[#{javascript:if(calIndex != 0){do you have any idea what the cause is?Or could you make available a sample db with the correct code included?thanks!

    Like

  4. Rob Porter says:

    @Stephen: The article is about the doctype in HTML5 which is much simpler than in previous HTML versions. There’s a good explanation of the doctype on this page: { Link }

    Like

  5. Raphael Costa says:

    Cool tip!But, how about the html tag namespace and attributes?Where do I set this?

    Like

  6. Dwain A Wuerfel says:

    Not sure if what Philippe Rand stated is what was posted here or not, but if not this explains how to set the doctype for an individual xpage rather than the entire application.

    http://www.thinksimple.in/archives/30

    Like

Comments are closed.

Archives
%d bloggers like this: