Improvement on XML processing by Firefox2.0

Source: Internet
Author: User
Tags processing instruction ibm developerworks
Firefox2.0 has several important improvements in XML support. Currently, its users are busy. Understand the improvement of Firefox2.0XML features, including controversial changes in RSSWeb abstract processing. Role assigned to the new application platform

Firefox 2.0 has several important improvements in XML support. Currently, its users are busy. Understand the improvement of Firefox 2.0 XML features, including controversial changes in RSS Web feed processing.

After being assigned the role of a new application platform, Web browsers may be the most popular software. This is an exciting moment for software developers. Dynamic HTML techniques are reborn with Asynchronous JavaScript XML (Ajax), Microsoft®Internet Explorer®And so on. Over the past two years, the developerWorks series of articles on XML and Firefox (see references) first introduced Firefox 1.8, based on the core Mozilla browser engine of version 1.5. Since then, the Mozilla project has spawned Firefox 2.0, which is based on the Gecko 1.8.1 Web emergence engine. Some improvements in Firefox 2.0 involve XML processing. This article first introduces the latest Firefox XML processing capabilities, including the important obstacles that developers should remember.

Reduces the control of Web feeds

A change to Firefox 2.0 has aroused great fear in the user community. If you provide RSS or Atom such Web feeds, you may need to include the XSLT style sheet to convert users to other forms of performance. The Atom feed in listing 1 references such conversions.

Listing 1. Atom feed that contains the style sheet reference



Xml: lang = "en"
Xml: base = "http://www.example.org">
  Http://www.example.org/myfeed
 My Simple Feed
  2005-07-15T12: 00: 00Z
 
 
  Uche Ogbuji
 
  Http://www.example.org/entries/1
  A *** blog entry
 
  2005-07-14T12: 00: 00Z
 

This is a **** blog entry
 
 
  Http://www.example.org/entries/2
 
 
  2005-07-15T12: 00: 00Z
  This is *** blog entry without a title
 

The key point is the style table processing instruction (PI) in the second line ). If you open it with Firefox 1.5, the browser will load atom2html. xslt with due diligence and display the results. As mentioned in Part 1 of this series of articles (see references), you must use "View Source Code" to view the actual XML file ". In Firefox 2.0, the browser ignores the style sheet PI and displays the customized Firefox view, as shown in 1 (screen on Firefox 2.0.0.6 and Mac OS X ).


Figure 1. Firefox 2.0's built-in Web feed View

To avoid this situation and force the selected style sheet to be applied, the only way is to fool Firefox, it finds "rss" or "feed" in the first 512 bytes of the file to determine whether it is a Web feed. Listing 2 uses a well-known measure, specifically inserting a comment to fill these 512 bytes.

Listing 2. bypassing the Atom feed of the default style sheet handling method of Firefox 2.0 and Internet Explorer 7




Xml: lang = "en"
Xml: base = "http://www.example.org">

Taking into account the opposition of the user community, Firefox developers decided to maintain their own attitude, so this action will be retained into the future Firefox version. I personally do not like this method. you can browse the debate and decide whether you like it or not. It is worth mentioning that this approach is similar to Internet Explorer and Apple Safari.

Microsummarization

Microsummarie, also known as Live Title, is a concise new feature of Firefox 2.0. it allows browsers to change titles with meaningful content on websites, especially in bookmarks. For example, the microsummarization on IBM developerWorks can replace the static text "developerWorks: IBM's resource for developers" with the latest article title on the site ". A website can provide a micro-abstract, or you can create it yourself. The latter case is called the "microsummarization Native", which is also a point of more attention in this article, because it requests the client to process XML and XSLT (people who are not familiar with XML can repeat the native devices provided by others ). In listing 3, the microsummarization native extracts the title of the developerWorks main article.

Listing 3. microsummarization native app for IBM developerWorks's main article title


Name = "IBM developerWorks featured article">
 
  Xmlns: html = "http://www.w3.org/1999/xhtml">
 
 
  Featured article:
 
 
 
 
 
 
  Http://www.ibm.com/?works/?a-za-z0-9=#/?
 

The native tool consists of two parts: template and page information. The template contains the XSLT code used to extract the micro-abstract text from webpages. The latter specifies the page on which the browser uses the summary. Micro-summarization is a simple text, and the output command is compatible with this. The key of a micro-abstract is XPath // html: a [@ class = 'feature '] [1], which searches for elements that contain the title of the main article. The regular expression in pages ensures that the micro-summary can be used on the homepage of the website and the homepage of each developerWorks area.

A reference document explains how to install the microdigest native in listing 3. So far, the microsummarization is still a unique feature of Mozilla.

SAX and others

For those who develop Mozilla expansion, the most significant thing is that the Mozilla XPCOM component system now provides a SAX Parser Framework. Without proper high-level processing skills, you can develop Efficient XML processing methods on your own. XPCOM integration means that you can use C, JavaScript, or any other language supported by XPCOM binding to process SAX events.

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.