spacer

Webref WebRef   Sitemap · Experts · Tools · Services · Newsletters · About i.com

home / experts / xml / column16

Transforming RSS into HTML and WAP II

WML output

Technical Lead
Thomson Reuters (Markets) LLC
US-NY-New York

Justtechjobs.com Post A Job | Post A Resume
Developer News
Microsoft Shows Off Silverlight 4, IE9 Plans
Metasploit Expands Vulnerability Test Framework
HyperCard Reborn?


The Wireless Markup Language (WML) is a smaller and less powerful variant of HTML, conceived as the display markup for mobile phones and PDAs. Details can be found in column12.

Differences between HTML and WML

For our little example the following differences are relevant: So we develop a sister style sheet to RSS2HTML, called RSS2WML, that transforms the same RSS input into the WML format instead of HTML:
<?xml version="1.0" ?>
<xsl:stylesheet xmlns:xsl="http://www.w3.org/XSL/Transform/1.0">

<xsl:output method="wml"/>
We changed the output method, although WML is not a recognized method yet and therefore currently ignored. We're planning ahead for when this will change.
  <xsl:template match="/">
    <WML><CARD ID="id1" TITLE="RSS newsfeed">
      <xsl:apply-templates/>
    </CARD></WML>
  </xsl:template>
Here we change the familiar structure of HTML and BODY into the WML version of WML and CARD.
  <xsl:template match="channel">
    <DO TYPE="accept">
      <xsl:attribute name="LABEL">
        <xsl:value-of select="title"/>
      </xsl:attribute>
      <GO>
      <xsl:attribute name="HREF">
        <xsl:value-of select="link"/>
      </xsl:attribute>
      </GO>
    </DO>
  </xsl:template>

  <xsl:template match="item">
    <DO TYPE="accept">
      <xsl:attribute name="label">
        <xsl:value-of select="title"/>
      </xsl:attribute>
      <GO>
      <xsl:attribute name="HREF">
        <xsl:value-of select="link"/>
      </xsl:attribute>
      </GO>
    </DO>
  </xsl:template>

  <xsl:template match="text()"/>

</xsl:stylesheet>
Finally we need to replace the TABLE and A anchor formatting with the DO/GO pair of tags specified in WML. The finished product is RSS2WML. If you have a WAP-enabled mobile phone or a WAP development toolkit you can look at the WML output.

Conclusion

XSL is a flexible solution for converting an XML-based input format such as RSS into various output formats. The case study here demonstrated the transformation into HTML with CSS and WAP/WML. Non-XML based output such as RTF, PDF, GIF etc. is also possible, and we might get back to this topic in a later installment of this column.

http://www.internet.com

internet.commediabistro.comJusttechjobs.comGraphics.com

Search:

WebMediaBrands Corporate Info

Legal Notices, Licensing, Permissions, Privacy Policy.
Advertise | Newsletters | Shopping | E-mail Offers | Freelance Jobs

webref The latest from WebReference.com Browse >
Rolling Out Your Own HTML Application Version Control · HTML 5: Client-side Storage · Working with Ajax Server Extensions
Sitemap · Experts · Tools · Services · Email a Colleague · Contact FREE Newsletters 
 The latest from internet.com
Wi-Fi Product Watch, November 2009 · Chip Market Recovering From '08 Collapse · Low-Cost Tools to Kickstart Your New Business

Produced by Michael Claßen
All Rights Reserved. Legal Notices.

URL: http://www.webreference.com/xml/column16/2.html
Created: Aug 01, 2000
Revised: Aug 01, 2000