<?xml version="1.0" encoding="ISO-8859-1"?>
<!DOCTYPE wml PUBLIC "-//WAPFORUM//DTD WML 1.3//EN" "http://www.wapforum.org/DTD/wml13.dtd">
<wml>
 <!-- page name="templates"-->
 <template>
  <do optional="false" label="Back Up" type="accept">
   <go enctype="application/x-www-form-urlencoded" method="get" sendreferer="true" href="#templates"/>
  </do>
 </template>
 <card ordered="true" newcontext="false" id="templates">
  <do optional="false" label="Back Up" type="accept">
   <noop/>
  </do>
  <do optional="false" label="Back" type="prev">
   <prev/>
  </do>
  <do optional="false" type="options" label="Next">
   <go enctype="application/x-www-form-urlencoded" method="get" sendreferer="true" href="#mobile"/>
  </do>
  <a href="#mobile" accesskey="1">Page 1</a>
  <br/>
  <a href="#samplexhtml" accesskey="2">sample.xml</a>
  <br/>
  <a href="#samplexsl" accesskey="3">sample.xsl</a>
  <br/>
  <a href="#screencss" accesskey="4">screen.css</a>
  <br/>
  <a href="#handheldcss" accesskey="5">handheld.css</a>
  <br/>
  <a href="#htaccess" accesskey="6">.htaccess</a>
  <br/>
 </card>
 <card ordered="true" newcontext="false" id="mobile">
  <do optional="false" type="options" label="Next">
   <go enctype="application/x-www-form-urlencoded" method="get" sendreferer="true" href="#samplexhtml"/>
  </do>
  <!-- h1 -->
  <h1>How to repurpose mobile content for traditional web browsers</h1>
  <p>When content needs to be delivered to both traditional web browsers and smaller mobile devices, one technique for producing content for both channels from the same source is to code the content for one channel and <a href="#repurposingNOTFOUND">repurpose</a> it for the other channel. In most cases, the content for traditional web browsers already exists, so the tendency is to try to repurpose that content for smaller devices. </p>
  <p>However, it's much easier to design the content for the smaller portable devices and use XSL templates to repurpose the content for larger displays by wrapping it with additional markup code. </p>
  <p>This technique is particularly useful for sites using a ".mobi" domain name managed by the dotMobi registry, since the registry <a href="/internet/domains/dotmobi.wml#requirements">requires sites to be designed for mobile devices</a>. For an example see the <a href="http://www.Sample.mobi/">Sample .mobi site</a>
  </p>
  <p align="left">
   <a href="#samplexhtml">Next: sample.xml</a>
   <br/>
   <a href="#templates">Back Up: Menu</a>
   <br/>
  </p>
 </card>
 <card ordered="true" newcontext="false" id="samplexhtml">
  <do optional="false" type="options" label="Next">
   <go enctype="application/x-www-form-urlencoded" method="get" sendreferer="true" href="#samplexsl"/>
  </do>
  <!-- h1 -->
  <h1>Sample XHTML file</h1>
  <p>The XHTML file contains the page-specific content that is delivered to all types of browsers. No site-wide common elements are included, since those are put into separate templates. </p>
  <p align="left">Sample XHTML file</p>
  <p align="left">&lt;?xml version="1.0" encoding="UTF-8"?&gt;&lt;?xml-stylesheet type="text/xsl" href="/sample.xsl"?&gt;&lt;!DOCTYPE html PUBLIC "-//WAPFORUM//DTD XHTML Mobile 1.0//EN" "http://www.wapforum.org/DTD/xhtml-mobile10.dtd"&gt;&lt;html xmlns="http://www.w3.org/1999/xhtml"&gt;&lt;!-- Copyright (c) 2006 Accilent Corp. (http://www.Accilent.com/) for How To Guides (http://www.HowToGuides.com/). Provided AS IS; no warranties are expressed or implied. Permission is hereby granted to use and/or modify. --&gt; &lt;head&gt; &lt;link rel="stylesheet" type="text/css" href="/screen.css" media="screen"/&gt; &lt;link rel="stylesheet" type="text/css" href="/handheld.css" media="handheld"/&gt; &lt;title&gt;Sample .mobi site&lt;/title&gt; &lt;/head&gt; &lt;body&gt; &lt;h1&gt;&lt;/h1&gt; &lt;h2&gt;Home Page&lt;/h2&gt; &lt;p&gt;This is the actual content that shows up on small mobile devices. The content can include &lt;a href="http://www.Acronyms.net/terms/h/Hypertext-Transfer-Protocol/" title="Hypertext Transfer Protocol"&gt;&lt;abbr&gt;HTTP&lt;/abbr&gt;&lt;/a&gt; links to other web pages, such as:&lt;/p&gt; &lt;p&gt;&lt;a href="/detect.cgi?test" accesskey="d"&gt;Detect browser type&lt;/a&gt;&lt;/p&gt; &lt;p&gt;as well as specialized links for mobile devices with phone functions, such as:&lt;/p&gt; &lt;p&gt;&lt;a href="wtai://wp/mc;14123373113" accesskey="w"&gt;Call the webmaster&lt;/a&gt;&lt;/p&gt; &lt;/body&gt;&lt;/html&gt;</p>
  <p>See <a href="/internet/domains/dotmobi.wml#issues">.mobi sites in Internet Explorer</a> for issues displaying ".mobi" web sites in an IE browser. </p>
  <p align="left">
   <a href="#samplexsl">Next: sample.xsl</a>
   <br/>
   <a href="#mobile">Prev: Page 1</a>
   <br/>
   <a href="#templates">Back Up: Menu</a>
   <br/>
  </p>
 </card>
 <card ordered="true" newcontext="false" id="samplexsl">
  <do optional="false" type="options" label="Next">
   <go enctype="application/x-www-form-urlencoded" method="get" sendreferer="true" href="#screencss"/>
  </do>
  <!-- h1 -->
  <h1>Sample XSL templates</h1>
  <p>Common elements that need to appear on every page throughout the site would be put into templates in an XSL file referenced by the XHTML pages. </p>
  <p align="left">sample.xsl</p>
  <p align="left">&lt;?xml version="1.0" encoding="UTF-8"?&gt;&lt;!-- uncomment to validate XSLT&lt;!DOCTYPE xsl:transform SYSTEM "http://www.sample.mobi/dtd/xslt.dtd"&gt;--&gt;&lt;xsl:transform version="1.0" xmlns:xsl="http://www.w3.org/1999/XSL/Transform" xmlns:html="http://www.w3.org/1999/xhtml" xmlns="http://www.w3.org/1999/xhtml" exclude-result-prefixes="html"&gt;&lt;!-- Copyright (c) 2006 Accilent Corp. (http://www.Accilent.com/) for How To Guides (http://www.HowToGuides.com/). Provided AS IS; no warranties are expressed or implied. Permission is hereby granted to use and/or modify. --&gt;&lt;xsl:output method="xml" version="1.0" omit-xml-declaration="no" indent="yes" doctype-system="http://www.sample.mobi/dtd/xhtml1-strict.dtd" doctype-public="-//W3C//DTD XHTML 1.0 Strict//EN"/&gt;<br/> &lt;xsl:template match="/"&gt; &lt;xsl:apply-templates select="*"/&gt; &lt;/xsl:template&gt;<br/> &lt;xsl:template match="html:head"&gt; &lt;xsl:copy&gt; &lt;xsl:apply-templates select="@*"/&gt; &lt;link rel="stylesheet" type="text/css" href="/screen.css" media="screen"/&gt; &lt;link rel="stylesheet" type="text/css" href="/handheld.css" media="handheld"/&gt; &lt;xsl:apply-templates select="node()"/&gt; &lt;/xsl:copy&gt; &lt;/xsl:template&gt;<br/> &lt;xsl:template match="html:body"&gt; &lt;xsl:copy&gt; &lt;xsl:apply-templates select="@*"/&gt; &lt;h1 style="display:inline"&gt;Sample .mobi site&lt;/h1&gt; &amp;#160;a working example of repurposing mobile content as explained by&amp;#160; &lt;a href="http://www.HowToGuides.com/internet/xml/templates.xml#mobile"&gt;&lt;img src="/images/howtoguides.jpg" width="143" height="27" alt="How To Guides logo"/&gt;&lt;/a&gt; &lt;p style="color: gray"&gt;This is a sample showing how templates can be used to make a web site that has been designed for mobile devices look good in a normal web browser. The important content, which you can do "View Source" to see, is put into &lt;a href="http://www.Acronyms.net/terms/e/Extensible-Hypertext-Markup-Language/" title="Extensible Hypertext Markup Language"&gt;&lt;abbr&gt;XHTML&lt;/abbr&gt;&lt;/a&gt; pages that are delivered to mobile devices, and any additional layout and styling for traditional browsers is put into templates and style sheets. Since the templates and style sheets can be reused for all pages on the site and are cached separately, this has the added advantage of reducing bandwidth requirements by as much as one half or more.&lt;/p&gt; &lt;hr/&gt; &lt;xsl:apply-templates select="node()"/&gt; &lt;hr/&gt; &lt;p&gt;Click on the following link to verify that this page conforms to the &lt;a href="http://www.Acronyms.net/terms/e/Extensible-Hypertext-Markup-Language/" title="Extensible Hypertext Markup Language"&gt;&lt;abbr&gt;XHTML&lt;/abbr&gt;&lt;/a&gt; Mobile Profile as required by the dotMobi registry Switch On! guidelines:&lt;/p&gt; &lt;p&gt; &lt;a href="http://validator.w3.org/check/referer" target="w3cvalidator"&gt; &lt;img src="/images/valid-xhtml10.png" alt="Valid XHTML 1.0!" height="31" width="88"/&gt;&lt;/a&gt; &amp;#160; &lt;a href="http://ready.mobi/start.jsp?uri=sample.mobi"&gt;MobiReady Report&lt;/a&gt; &lt;/p&gt; &lt;p&gt;The "Mandatory Registrant Rules" for .mobi domains states:&lt;/p&gt; &lt;p style="margin: 0 3em"&gt;The "Mandatory Registrant Rules" for .mobi domains states that "Requests for URIs consisting only of "example.mobi" or "www.example.mobi" must result in a response that is encoded in a format the device supports or valid &lt;a href="http://www.Acronyms.net/terms/e/Extensible-Hypertext-Markup-Language/" title="Extensible Hypertext Markup Language"&gt;&lt;abbr&gt;XHTML&lt;/abbr&gt;&lt;/a&gt;-Mobile Profile 1.0 or later released version, where "example" stands for any domain name.&lt;/p&gt; &lt;p&gt;For a site that satisfies these registration requirements for a .mobi domain, the W3C Validator will display:&lt;/p&gt; &lt;p style="margin: 0 3em; background-color: #55b05a; color: white; text-align: center; font-family: Bitstream Vera Sans, sans-serif; font-size-adjust: .53; font-size: 1.5em; font-weight: 500"&gt;This Page Is Valid -//WAPFORUM//DTD XHTML Mobile 1.0//EN!&lt;/p&gt; &lt;p&gt;Copyright &amp;#169; 2006 Sample .mobi. All rights reserved.&lt;/p&gt; &lt;/xsl:copy&gt; &lt;/xsl:template&gt;<br/> &lt;xsl:template match="@*|node()"&gt; &lt;xsl:copy&gt; &lt;xsl:apply-templates select="@*|node()"/&gt; &lt;/xsl:copy&gt; &lt;/xsl:template&gt;<br/>&lt;/xsl:transform&gt;</p>
  <p>More sophisticated sites could have various groups of pages which are similar to each other, but are different from the pages in other groups. In this case, more than one level of templates would be used. For each group of similar pages, a separate template would be created for the common elements on the pages within that group. Those templates would all import a single site-wide template containing the common elements that would appear on all pages across the entire site. </p>
  <p align="left">
   <a href="#screencss">Next: screen.css</a>
   <br/>
   <a href="#samplexhtml">Prev: sample.xml</a>
   <br/>
   <a href="#templates">Back Up: Menu</a>
   <br/>
  </p>
 </card>
 <card ordered="true" newcontext="false" id="screencss">
  <do optional="false" type="options" label="Next">
   <go enctype="application/x-www-form-urlencoded" method="get" sendreferer="true" href="#handheldcss"/>
  </do>
  <!-- h1 -->
  <h1>Style sheet for traditional web browsers</h1>
  <p align="left">screen.css</p>
  <p align="left">img { border: 0;}</p>
  <p align="left">
   <a href="#handheldcss">Next: handheld.css</a>
   <br/>
   <a href="#samplexsl">Prev: sample.xsl</a>
   <br/>
   <a href="#templates">Back Up: Menu</a>
   <br/>
  </p>
 </card>
 <card ordered="true" newcontext="false" id="handheldcss">
  <do optional="false" type="options" label="Next">
   <go enctype="application/x-www-form-urlencoded" method="get" sendreferer="true" href="#htaccess"/>
  </do>
  <!-- h1 -->
  <h1>Style sheet for handheld devices</h1>
  <p align="left">handheld.css</p>
  <p align="left">img { border: 0;}</p>
  <p align="left">
   <a href="#htaccess">Next: .htaccess</a>
   <br/>
   <a href="#screencss">Prev: screen.css</a>
   <br/>
   <a href="#templates">Back Up: Menu</a>
   <br/>
  </p>
 </card>
 <card ordered="true" newcontext="false" id="htaccess">
  <!-- h1 -->
  <h1>.htaccess file</h1>
  <p>To deliver the XHTML and WML pages with the correct MIME types, you will need an .htaccess file will the following directives, or their equivalent for the web server software you are using: </p>
  <p align="left">.htaccess</p>
  <p align="left">DirectoryIndex index.xmlErrorDocument 404 /pagenotfound.xml<br/>AddType application/xhtml+xml;charset=utf-8 xml xhtmlAddType text/vnd.wap.wml;charset=iso-8859-1 wml<br/>RewriteEngine on<br/>RewriteCond %{HTTP_USER_AGENT} \(compatible;[[:space:]]*MSIE[[:space:]]+[[:digit:]]+\.[[:digit:]][[:alnum:]]*;RewriteRule ^$ http://%{HTTP_HOST}/index.xml [L,R=temp]</p>
  <p>Contrary to the HTTP standards, Internet Explorer pays more attention to the file extension than to the MIME types specified by the server. Therefore, the default DirectoryIndex document has a .xml extension. See <a href="/internet/domains/dotmobi.wml#issues">.mobi sites in Internet Explorer</a> for more information on the issues with displaying the default DirectoryIndex document in IE. </p>
  <p align="left">
   <a href="#handheldcss">Prev: handheld.css</a>
   <br/>
   <a href="#templates">Back Up: Menu</a>
   <br/>
  </p>
 </card>
</wml>

