The future of the Web: XHTML 2.0

Source: Internet
Author: User
Tags object final header html form html page new features string version
Web|xhtml for years, HTML has only been growing, but has never been smaller, since the new version must maintain backward compatibility. This situation will be changed. The first working draft of XHTML 2.0 was released on August 5, 2002, with the news that backward compatibility was canceled, and that the language was finally able to evolve. So what are you going to get in return as a developer? What about robust forms and event performance? They are a better way to study frameworks that do not require a lot of JavaScript and even a hierarchy menu.

This article outlines the new features in XHTML 2.0 and how you might use it in the future. Readers should be familiar with HTML and/or XHTML 1.0. Familiarity with cascading style sheets (cascading style Sheet (CSS)) is helpful, but not required.

Farewell to backward compatibility, introducing structure When the World Wide Web Consortium published the first work draft of XHTML 2.0 on August 5, 2002, the most surprising thing was that it was not backwards compatible with its previous version. For previous distributions, such as from HTML 4.01 to XHTML 1.0 and later from XHTML 1.0 to XTHML 1.1, changes are added, and browsers that can read XHTML 1.0 (Transitional) documents can also understand HTML 4.01 documents. and XHTML 2.0 is not like that.

If you announced two years ago that we are going to study HTML versions without an IMG tag or bold tag today, most WEB developers will look at you with a skeptical eye. However, this is the case now. In addition to replacing forms and frames completely, XHTML 2.0 removes the B, I and IMG tags (as well as big, small, and TT), and is not even in favor of using BR to prepare to remove it from future releases. But why is that?

The reason is that most of the tags are representation. Their sole purpose is to give the browser instructions on how their content should be displayed, but without providing information about what the content is. For example, consider the following two sentences:

     
      
       
      presentational elements are, <i>for the most part</i>
     
      


And

     
       
        
      presentational elements are, <em>for the most part</em>
     
       


In the absence of a style sheet, the two sentences look the same in the browser, but only the second sentence provides information about the cause. In fact, from the Start EM (emphasis) and strong tags appear in HTML, but over the years the authors have largely ignored them and focused on the presentation, at the expense of content.

But that doesn't mean that as long as you want to make something bold or italic, you should shove it into both tags. Instead, the whole purpose of removing the presentation element is to try to complete the original intention of the CSS inventor that the content should be tagged based on what the content represents, and that the style sheet should be used to beautify the content. For example, listing 1 uses categories (class) to indicate the content type.

Listing 1. Use categories to specify content types

     
        
         
      


In this page, the date type can be confirmed by the content itself, and the browser can use the category information to decide how to design the style for it, as shown in Figure 1.



Figure 1. A category can determine which type of content to display, and the stylesheet can format it appropriately.

Study it with this view: The purpose of the disconnect (BR) tag is to display, because in fact it does not have any content. XHTML 2.0 is not in favour of using a BR tag and advocates the use of line tags. The line tag specifies a special kind of content: usually a row of text or other content that is rendered in the manner followed by a newline and carriage return. For example, text:

     
         
          
      <p>public class HelloWorld {<br/>public static void Main (string[) args) {<br/>system.out.println (" Hello world! "); <BR/>}<br/>}</p>
     
         


Become

     
          
           
      <p><line>public class HelloWorld {</line><line>public static void main (string[] args) {</ Line><line>system.out.println ("Hello world!"); </line><line>}</line><line>}</line></p>
     
          

In this way, the document has a real object that represents the row, and the segment (p) tag represents a piece of content.

Why is all this important? Because the WEB is increasingly becoming a place for communication between people, it is increasingly becoming a place for communication between software applications, such as servers and search engine indexers. And the days of everyone (or almost everyone) using the same browsers are gone. Developers are continually redesigning content for different devices, such as PDAs and mobile phones. The voice-triggered (voice-activated) system is not far from us. The structural meaning of content is becoming almost as important as the content itself.

Section

XHTML 2.0 adds sections (section) and headings (heading). HTML has always included numbered headings-h1 to h6 until August 5, 2002 when the work draft has not yet been undone, but it is only a matter of time. XHTML 2.0 uses common headings and sections. For example, you can nest sections to give the title meaning. Document previously rendered with a numbered title (Listing 2):

Listing 2. Number headings in a document

     
          
           
      


Can be replaced with common headings and sections (listing 3):

Listing 3. Common headings and sections

           
            


This structure has two advantages. First, applications (such as search engine crawler) can more easily understand the relative importance of content, and secondly, sections are self-contained. In HTML, a section starts with its caption, so the content (such as introductory content) does not appear before the title. The section element cancels this constraint because any content inside it is part of the node.

navigating lists and menus

Adding a structure that would greatly benefit Web developers is the navigation list. The navigation lists specified by the NL tag work the same way as the "Cousin" sequence table (OL) and the unordered list (UL), but one thing is different: the items in the navigation list appear only when the list is active. As a result, the navigation lists are very similar to the hierarchical pop-up menus, which are popular because they provide a lot of navigation information and do not occupy too much screen space. For example, the soap opera site may have the following menu (Listing 4):

Listing 4. Using the navigation list

     
           
            
      <nl>   <name>character options</name>   <li href= "stay.html" >Stay</li>   <nl>      <name>Leave</name>      <li href= "newjob.html" >job transfer</li>      < Li href= "divorce.html" >Divorce</li>      <li href= "fataldisease.html" >fatal disease</li>   </nl>   <li href= "backburner.html" >back burner</li></nl>
     
           


The list item appears when the user activates the name (Character Options). The working draft does not make it clear whether a child list, such as the Leave menu, appears when the user activates the master list, or if the user must activate the child list item itself to appear. The end author may control This behavior through a style or event. In any case, the list item disappears when the input focus is moved away from the primary element.

Links, Links everywhere

You may have noticed that even though you intend to use the previous example as a menu, it does not have an anchor (a) tag. and the HREF attribute has been correctly placed on the LI element. This is not a feature of the navigation list, but a new feature of XHTML 2.0. Hypertext-related properties (such as HREF, Target, and accesskey) are now part of the Public Properties collection (Common attribute Collection), which includes core attributes (class, ID, and title), internationalization attributes (xml: Lang, which replaces the Lang in XHTML 1.1 and event properties, the event attributes come from the XML events proposal, as you will see below.

This means that as soon as you add the href attribute to any element, you can convert it to a link without necessarily enclosing a single element with an anchor tag.

Does this mean that after four years of effort, XLink has been adopted by XHTML 2.0? In short, No. In fact, the difference between the links specified in XLink and XHTML 2.0 is the source of contention among developers working on their respective proposals, so there may be some changes between this initial open work draft and the final proposal. At the same time, you can combine this feature, the navigation list, the link element, and the resource Description Framework (Resource Description Framework (RDF)) to replicate most of the functionality of XLink.

XForms is an XML-related proposal and has indeed become part of XHTML 2.0.

The

XML Form language (XML Forms Language (XForms)) is a new way to study a form-it's like the rest of XHTML-content, structure, and performance are completely independent. The XForms page specifies a model that has information about the form itself, and then spreads the form elements around the page instead of being limited to a single form element. This means that you can even combine elements of different forms in the same area of the page. You can populate a form with an instance document that is referenced from an XPath expression on a form element. Form elements themselves also represent special types of objects, rather than describing how they are displayed on the page. When you update the data in a form element, the instance document is updated. When the user submits the form, the instance document is actually sent. For example, use the following simple form (Listing 5):

Listing 5. Simple HTML form

     
           
            
      


Listing 6 shows the XForms version of the form:

Listing 6. XForms version of the form

            
             


Terminology Description: The XForms proposal specifically illustrates the absence of xforms for a single form. It is a multiple XForms page and is no longer a single XForm page.

Forms generally need to be validated. In other words, the data fields must contain valid data, and so on. XForms uses the XML schema to constrain the submitted data. In addition, you can further enhance the functionality of the XForms page by adding XML Events, which are also included in XHTML 2.0.

XML Events

You may already be familiar with using events on a Web page by adding events such as onclick and onmouseover. It's not going to happen again. These familiar attributes have been superseded by the XML Events module, which is integrated into XHTML 2.0. XML events provides a common way to specify the actions that should be taken when an event occurs. The advantage of this is that you are not limited to predefined events such as mouse clicks. Instead, you can define your own events and what happens when they are triggered.

The XML Events contain the following components. Events such as mouse clicks can be targeted. For example, in the page shown in Listing 7:

Listing 7. The page you want to click

     
            
             
      


The user may click the second LI element Matterhorn. When this occurs, the mouse click event travels from the document root to the target (LI) and returns again. The order is:

     
             
              
      (root)--HTML--body--ul--li----ul--The body--HTML--(root)
     
             


Moving down to the target is called the capture (capture) phase, and moving up again is called the bubbling (bubbling) phase (not all events will bubble). At any time during the journey, an event can pass an object that has already been registered as an observer (which means it is observing a particular event) and performs a specific action if it sees an event. The listener creates the observer. For example, in the following sequence:

     
              
               
      <ev:listener observer= "ridelist" event= "MouseDown" handler= "#myscript"/>
     
              


The listener makes the UL element (or, more accurately, the entire list) an observer, so that when the user clicks on any list item, the Observer (Ridelist) executes the myscript (but must still determine the mechanism to invoke any script).

The widely blamed framework was also replaced in XHTML 2.0. Xframes's first working draft was debut on August 6, 2002, a day after XHTML 2.0 announced that it would use xframes and try to solve problems with the traditional HTML framework. Most of the problems are that search engines that are difficult to create bookmarks and refresh pages, and that do not support frames, cannot index the appropriate content.

In the Xframes document, the URI of the contained content becomes part of the entire document URI. For example, the page in Listing 8 below might represent an HTML page with three frames:

Listing 8. Xframes page

     
              
               
      


Note that you do not specify a URI for each frame, but each frame has its own unique identifier. Therefore, the URI of this document may be:

     
               
                
      Site.xfm#frames (header=header.xhtml,menu=menu.xhtml,content=main.xhtml)
     
               


Then, understanding xframes browsers associate the contents of each frame with the appropriate URI. When the user clicks the link and changes the contents of the individual frame, the entire URI of the page changes, so it always displays the actual content that the user is viewing, and the collection and back buttons provide accurate content.

Image as an object

The last major change in the working draft of August 5, 2002 includes the addition of an IMG tag and an OBJECT tag to replace it. The object tag actually appears in HTML 4.01, but it is used primarily by developers to embed multimedia and Java applets. However, it has always been able to support images. The main advantage of using the OBJECT tag is that it is designed to be subordinate. In other words, if the browser cannot display a particular object, it will display the object's contents. For example, a browser that encounters the following code fragment attempts to load the movie first. Mount the image if the movie failed to load. If the mount image fails, it displays only text.

     
               
                
      <object data= "Rides.mpeg" type= "Application/mpeg" > <object data= "rollercoaster.jpg" type= "Image/jpg"    >        Jack tries to expand he horizons on the racing coasters.    </object></object>
     
               

Subsequent steps

The only thing you can be sure of in the August 5, 2002 XHTML 2.0 work draft is that you can't be sure of anything. In the present draft and in the process of being adopted as a proposal, it is almost certain that it will change in some ways, but the goal of emphasizing structure and semantics cannot change. For this reason, it's a good idea to look at the pages you're building now and start getting into the habit of using structures and styles appropriately. Use tags to specify what things are, rather than how to display them, and use CSS to do the rest of the work. In general, consider more about the structure of the document and what you want them to do, without having to think too much about how they will appear.

reference materials

See the latest version of XHTML 2.0 for information about what it currently contains.

Find out how to control the pages and events in any XML document with XML events.

Read the next generation Web form using XForms.

Read the article "Get Ready for XForms" (developerworks,2002 year September) to learn more about XForms.

Please read xframes quickly.

Read Modularization of XHTML or the modular tutorial on XHTML in the DeveloperWorks Web architecture area (October 2001) to see how XHTML 2.0 is structured.

Please refer to Kendall Grant Clark's comments about XHTML 2.0 and the semantic Web in the XHTML 2.0 the Latest trick.

Please cares in xlink:who? Read Bob Ducharme's ideas about XLink and its future.

Download X-smiles, which is an XForms browser.

about the author

Nicholas Chase has been involved in web development for many companies (such as Lucent Technologies, Sun Microsystems, Oracle and Tampa Bay Buccaneers, etc.). Nick was a high school physics teacher, a low-level radioactive waste equipment manager, an online science fiction magazine editor, multimedia engineer, and Oracle lecturer. Recently, he became CTO of the Site Dynamics Interactive Communications (Clearwater in Florida State), and was a three author of Web development books, including Java and XML from SCRATC H (Que) and the forthcoming publication of Primer Plus XML Programming (Sams). He is willing to listen to the reader's advice and can contact him through nicholas@nicholaschase.com.



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.