转载一篇有关转换HTML到WML的文章
2008-02-17 20:23
411 查看
我只在这里转了开头和结尾,感兴趣的朋友可以参看底部给出的URL.
The owners of the TopXML web site asked me if I would consider writing an article about this, and I agreed. The only problem, though, was the code I wrote was in Perl, and ran on an Apache web server. Further, it did not use any XSL. The transformation from HTML to WML was done using string replacement and regular expressions; at the time, there was no decent XSLT Perl module. Still, the concepts would apply to any platform, and I though that building a similar app for IIS using VB would be interesting.
The problem breaks down into a set of tasks(steps):
Provide a WML page where a user can enter a URL into a form field
Receive the web page form request
Pull out the desired URL from the query string
Fetch the desired page
Convert it to well-formed XML (e.g. XHTML)
Transform the XML into WML
Write the new document back to the WAP device
...........
原文出处 TOPXML: http://www.topxml.com/wap/html2wap.asp
What is WAP?
WAP is the Wireless Application Protocol. It is based on familiar Internet technologies, and was developed to deliver web content and services to wireless clients, such as mobile phones. Since, at present, such devices have severe memory, power, and bandwidth restrictions, web pages are formatted using WML (the Wireless Markup Language). It is an application of XML that is much like a restricted version of HTML. Further, there are special WAP servers that compile WML into byte code before sending the page to the device, thereby reducing the page size. However, WML can still be served "straight up" from any web server.Introduction to converting HTML to WML
Recently (meaning around March of 2000), the TopXML mailing list had a discussion thread about WML, or the Wireless Markup Language. Someone asked about developing for WML, and I replied that I had done a little playing around with this. Many months prior I had put together a test web page that would take a URL as a query string parameter, fetch the document, convert it to WML, and return the converted document with a WML MIME type. The idea was to allow a WAP-phone user to be able to view any HTML page on the Internet, not just those specifically formatted in WML. For example, if you wanted to see the “XML Hack” home page (www.xmlhack.com), you would, from your WAP phone, go to a WML page that presented a simple form. The desired URL would be entered, and the form submitted. The web server would receive the submission, fetch the requested page, convert it to WML, and send back the results.The owners of the TopXML web site asked me if I would consider writing an article about this, and I agreed. The only problem, though, was the code I wrote was in Perl, and ran on an Apache web server. Further, it did not use any XSL. The transformation from HTML to WML was done using string replacement and regular expressions; at the time, there was no decent XSLT Perl module. Still, the concepts would apply to any platform, and I though that building a similar app for IIS using VB would be interesting.
The problem breaks down into a set of tasks(steps):
Provide a WML page where a user can enter a URL into a form field
Receive the web page form request
Pull out the desired URL from the query string
Fetch the desired page
Convert it to well-formed XML (e.g. XHTML)
Transform the XML into WML
Write the new document back to the WAP device
...........
Summary
We’ve seen an IIS/ASP/VB implementation of a site that allows a WAP device user to request any HTML page on the Internet and have it sent back as WML. There are a number of problems with the specific code: The object used to fetch web pages from the server may not work under all circumstance; the clean-up of HTML is done using a single-threaded command-line executable; the XSLT for transforming the HTML to WML is incomplete. However, these problems are isolated in dynamically loaded objects, so further enhancement can go on with any disruption to the main code. I would suggest that, if anybody finds this code useful, they take the time to create a more robust version making heavy use of it. This would include reconsidering the interface classes and the methods they define. Expanding the code is much easier if it permits polymorphism; off hand, I can think of a few more methods that the ISimpleHTTP.IRequest interface could define, such as a method for setting POST data, or methods for adding additional headers.原文出处 TOPXML: http://www.topxml.com/wap/html2wap.asp
相关文章推荐
- Proxy源代码分析--谈谈如何学习linux网络编程(转载,又一篇很好的文章) http://www.amobbs.com/thread-706555-1-1.html
- 转载:一篇关于CString类型转换的文章
- 转载一篇搭建svn服务器的文章。出处为http://www.ha97.com/4467.html
- 转载一篇有关ramdisk 的使用的文章
- 转载的一篇有关gdb的不错的文章
- 转载:有关京东和刘强东的一篇文章
- 转载一篇有关黎鸣先生的文章(比较长,读完者必定受益无穷)
- 有关String的转换的一篇好文章
- 转载一篇关于堆栈的好文章
- 转一篇有关Java的内存泄露的文章
- 转一篇有关Java的内存泄露的文章(受益哦)
- 转载一篇memwatch调试相关的文章并加一些补充
- CSDN上看到的一篇有关Spring JDBC事务管理的文章(内容比较全)
- 转载文章一篇
- [转贴]找到一篇有关Java RMI和.NET Remoting的分析文章,大家不妨一读。
- 一篇不错的讲解Java异常的文章(转载)
- 一篇不错的讲解Java异常的文章(转载)----感觉很不错,读了以后很有启发
- 【他山之石】转载一篇文章:别人做毕业设计的思路
- 转载一篇source insight配置文章
- 为什么linux kernel默认的页面大小是4K,而不是4M或8M?(转载一篇文章)