The improvement of XML processing by enumerating Firefox2.0

Source: Internet
Author: User
Tags processing instruction xslt

Firefox 2.0 has several important improvements in support for XML. Its users are currently deployed to the zenith. Learn about the improvements to the Firefox 2.0 XML features, including controversial changes in RSS Web feed processing.

After being given the role of the new application platform, Web browsers may now be the hottest software. This is an exciting time for software developers, where dynamic HTML technology is reborn with asynchronous JavaScript + XML (Ajax), Microsoft®internet Explorer® 's development is restored, and so on. Over the past two years, the DeveloperWorks series on XML and Firefox (see Resources) has introduced Firefox version 1.5, based on the 1.8 version of the core Mozilla browser engine. Since then, the never-ending pace of development of the Mozilla project has spawned Firefox 2.0, which is based on the Gecko 1.8.1 Web rendering engine. Some of the improvements to Firefox 2.0 involve XML processing. This article describes the latest Firefox XML processing capabilities, including the major obstacles that developers should remember.


Reduced control of Web feeds

Firefox 2.0 A change has caused great panic in the user community. If you provide Web feeds such as RSS or Atom, you might want to include XSLT style sheets to convert users to other representations. The Atom feed in Listing 1 refers to such a transformation.

Listing 1. Atom feed containing style sheet references

<?xml version= "1.0" encoding= "Utf-8"
<?xml-stylesheet type= "Text/xml" href= "Atom2html.xslt"?>
<feed xmlns= "Http://www.w3.org/2005/Atom"
 xml:lang= "en"
 xml:base= "http://" www.example.org "
 <id>http://www.example.org/myfeed</id>
 <title>my Simple Feed</title>
 <updated>2005-07-15t12:00:00z</updated>
 <link href= "/ Blog "/>
 <link rel=" self "href="/myfeed "/>
 <author><name>uche ogbuji</ Name></author>
 <entry>
 <id>http://www.example.org/entries/1</id>
 <title>a Simple Blog entry</title>
 <link href= "/BLOG/2005/07/1"/>
  <updated>2005-07-14t12:00:00z</updated>


<summary>this is a simple blog entry</summary>
</entry>
<entry>
<id>http://www.example.org/entries/2</id>
<title/>
<link href= "/BLOG/2005/07/2"/>
<updated>2005-07-15T12:00:00Z</updated>
<summary>this is simple blog entry without a title</summary>
</entry>
</feed>

The key is the style sheet processing instruction (PI) in the second row. If opened with Firefox 1.5, the browser will dutifully load the ATOM2HTML.XSLT and display the results. As already mentioned in part 2nd of this series (see Resources), viewing the actual XML must be through "view source code." In Firefox 2.0, the browser ignores the style sheet PI and uses a custom Firefox view, as shown in Figure 1 (Firefox 2.0.0.6, screenshot on Mac OS X platform).

Figure 1. Firefox 2.0 built-in Web feed view


The only way to avoid this situation and force the selected style sheet is to fool the simple-minded Firefox, which determines whether it is a Web feed by looking for "RSS" or "feed" in the first 512 bytes of the file. Listing 2 uses a well-known method of inserting a comment to populate these 512 bytes.

Listing 2. Atom Feed bypassing Firefox 2.0 and Internet Explorer 7 default style sheet processing


<?xml version= "1.0" encoding= "Utf-8"?>
<!--Firefox 2.0 and Internet Explorer 7 use simplistic feeds sniffing to override desired
Presentation behavior for this feed, and thus we are obliged to inserts this comment, a
Bit of a waste of bandwidth, unfortunately. This should ensure the following
Stylesheet processing instruction is honored by this new browser versions. For some
Background you might want to visit the following bug:
https://bugzilla.mozilla.org/show_bug.cgi?id=338621
-->
<?xml-stylesheet type= "Text/xml" href= "Atom2html.xslt"?>
<feed xmlns= "Http://www.w3.org/2005/Atom"
Xml:lang= "en"
xml:base= "http://www.example.org" >
<!--content of the feed identical to listing 1, so trimmed-->

</feed>

After taking into account the objections of the user community, the Firefox developers decided to stick to their position, so the behavior will remain in the future Firefox version. Personally I don't like this way, you can read about the controversy and decide whether you like it or not. It is worth mentioning that this approach is similar to Internet Explorer and Apple Safari.

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.