Dec's Dom Blog

Changing the DocType in XPages
Sunday, February 28, 2010 2:28 PM
    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 <!DOCTYPE html> 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 <!DOCTYPE html>.
    ]


    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.



    Now all you have to do is add one additional line



    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.



    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.

Reader Comments

Declan Sciolla-Lynch
Sunday, February 28, 2010 2:28 PM
Declan Sciolla-Lynch
Sunday, February 28, 2010 2:28 PM
Declan Sciolla-Lynch
Sunday, February 28, 2010 2:28 PM
Declan Sciolla-Lynch
Sunday, February 28, 2010 2:28 PM
Declan Sciolla-Lynch
Sunday, February 28, 2010 2:28 PM
Declan Sciolla-Lynch
Sunday, February 28, 2010 2:28 PM
Declan Sciolla-Lynch
Sunday, February 28, 2010 2:28 PM
Declan Sciolla-Lynch
Sunday, February 28, 2010 2:28 PM
Declan Sciolla-Lynch
Sunday, February 28, 2010 2:28 PM
Declan Sciolla-Lynch
Sunday, February 28, 2010 2:28 PM
Declan Sciolla-Lynch
Sunday, February 28, 2010 2:28 PM
Declan Sciolla-Lynch
Sunday, February 28, 2010 2:28 PM
Declan Sciolla-Lynch
Sunday, February 28, 2010 2:28 PM
Declan Sciolla-Lynch
Sunday, February 28, 2010 2:28 PM
Declan Sciolla-Lynch
Sunday, February 28, 2010 2:28 PM
Declan Sciolla-Lynch
Sunday, February 28, 2010 2:28 PM
Declan Sciolla-Lynch
Sunday, February 28, 2010 2:28 PM
Declan Sciolla-Lynch
Sunday, February 28, 2010 2:28 PM
Declan Sciolla-Lynch
Sunday, February 28, 2010 2:28 PM
Declan Sciolla-Lynch
Sunday, February 28, 2010 2:28 PM
Declan Sciolla-Lynch
Sunday, February 28, 2010 2:28 PM

Post A Comment

Save Comment
Powered By Blogsphere V4.0.0