|
You are here: Home / Documentation / XT Tips & Caveats |
XT Tips & CaveatsDoctypeIn addition to the comment tags, doctype declarations are stripped away during the XT template rendering. To compensate for this, we've added a special doctype tag, which can be used as follows. The doctype: <!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "DTD/xhtml1-transitional.dtd"> Can be represented by: <xt:doctype root="html" access="public" name="-//W3C//DTD XHTML 1.0 Transitional//EN" uri="DTD/xhtml1-transitional.dtd" /> Make sure however that the <xt:doctype> tag begins on the first line of the document. So an example document might be: <xt:tpl version="1.0"><xt:doctype root="html" access="public" name="-//W3C//DTD XHTML 1.0 Transitional//EN" uri="DTD/xhtml1-transitional.dtd" /> <html xmlns="http://www.w3.org/1999/xhtml"> <head> <title>Page Title</title> </head> <body> <h1>Page Title</h1> <p>Page Content</p> </body> </html> </xt:tpl> One problem with this is that the doctype declaration isn't present in the template preview, which can cause rendering issues with certain markup techniques in MSIE, which renders more strictly when a doctype is present. To solve this, we can use the fact that the original doctype is stripped out to place both in the template, and end up with a single doctype declaration in each output method (preview and in Sitellite). So our template header becomes: <!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "DTD/xhtml1-transitional.dtd"> <xt:tpl version="1.0"><xt:doctype root="html" access="public" name="-//W3C//DTD XHTML 1.0 Transitional//EN" uri="DTD/xhtml1-transitional.dtd" /> <html xmlns="http://www.w3.org/1999/xhtml"> <head> <title>Page Title</title> </head> <body> <h1>Page Title</h1> <p>Page Content</p> </body> </html> </xt:tpl> Of course, these are wrapped for the purposes of this article. You can leave the doctype declaration and the <xt:doctype> tag each on a single line if you like, making your template a little more readable at the top. XML DeclarationsAs you might guess from the doctype discussion above, I'm about to introduce a tag to render XML declarations. This tag works as follows: <xt:xmldecl version="1.0" encoding="utf-8" /> Becomes: <?xml version="1.0" encoding="utf-8"?> The attributes of this tag are the same as for the standard XML declaration itself, so there's nothing new to remember. I'll also briefly introduce one more related tag: <xt:xmlstyle type="text/css" href="mystylesheet.css" />This creates an XML stylesheet declaration, which renders as: <?xml-stylesheet type="text/css" href="mystylesheet.css"?> Now you've got enough under your belt to not only create valid XHTML template in XT, but also to create custom XML-based output modes as well. Have fun! Page 1: The Basics: HTML Versus XML |
|
Copyright © 2008, SIMIAN systems Inc. All rights reserved. Privacy policy Some of the icons on this site were created by the Gnome Project. |