Why XForms?
Idealists imagine a global internet: true, fair and free, through which anyone can exchange information freely and openly; Pragmatists hope to finish their work before five o'clock in the afternoon and then go home to spend time with their families. Idealists admire Standard generalized markup language (SGML), Extensible Markup Language (XML), Extensible Vector Graphics (SVG), Cascading Style Sheets (CSS) and Extensible Hypertext Markup Language (XHTML). Pragmatists believe in HTML, JavaScript? 6? 4. Forms and Flash. Idealists participate in World Wide Web Consortium (W3C) and seminars, such as Extreme Markup Language and WWW 2007. On the other hand, pragmatists will attend seminars such as the HTML Authors Association and the Web Design World. Idealists read books such as Weaving the Web and Effective XML, while pragmatists read books such as Ajax in Action and Designing a Black Website. Recently, the focus of debate between the two camps is the next delegate technology: Web 2.0 application or XForms. The two sides are angry and arguing endlessly, because both sides can't understand each other's goals and they have nothing in common. However, the gap between the two camps is not insurmountable. Many idealistic technologies (such as XHTML and CSS) are widely adopted by pragmatists because they bring tangible benefits to their work. Understandably, pragmatists have never caught up with any W3C craze. They will never rush to do the first version of the working draft as soon as it is released, but would rather wait for several years until the new technology becomes truly reliable and available in their user base. They are not early adopters, but they will be early adopters as long as the technology makes sense to them and the tools are fully supported. XForms is an idealistic effort to solve many practical problems that plague Web developers today. From the current situation, the pragmatic solution based on gradually improving the traditional HTML form is not bad, but it will never reach the height of XForms. Because XForms "climbs higher", if it fails, it will "fall harder" and have a greater negative impact. Because XForms is more ambitious, hope and disappointment coexist: hope lies in everything that will become a reality in the near future, and disappointment lies in the fact that it cannot become a reality today. Nevertheless, it is necessary to understand what XForms is trying to achieve in order to fairly judge other alternatives. If XForms' goals are different from yours. Then it's not attractive. And if what XForms is fighting for is exactly what you care about now, it may be worth your efforts to bear the inevitable pain of the birth of new technologies. The first thing you need to understand about XForms is that it is not only Web-oriented or HTML-oriented. Of course, it is not only suitable for classic desktop browsers, such as Firefox and Microsoft? 0? 3 Internet browser. XForms is designed to work well in many other environments, such as mobile phone browsers, voice browsers and some environments that are not browsers at all. For example, OpenOffice 2.0 uses XForms as the underlying form technology. It is hoped that other products that currently use patent form technology, such as Microsoft Word, Adobe Acrobat and Universal Business Language (UBL), will also migrate to XForms in the future. Whether these companies will do this is still unknown. In addition, XForms is designed to separate goals from actions and meanings from expressions, similar to the previous generation of XML. It is designed as a general description of the input that the form needs to collect. XForms has little interference with the presentation of forms and the way users interact with them. The same form can be presented in one way in the browser, in another way by keystroke and voice recognition input in the telephone network, and in the third way on paper, that is, manually filled in and scanned by optical character recognition technology. Edsel or conveyor belt? I personally have reservations about this goal. I call it the edsel problem of technology. Technology that tries to be a panacea often ends in failure. The document object model (DOM) of W3C is a classic example. The specification attempts to develop in an overly general direction, and the result is frustrating. Sometimes, a customized solution for an environment is far better than an overly general approach. On the other hand, sometimes generalization pays off. Maybe XForms is not a failed Edsel. Maybe it's more like a conveyor belt. You must ask yourself, do you really need the same form to be presented in different ways in different environments? Many applications don't need this. For example, if you are writing a simple website voting program, and it is just for entertainment, then HTML in the browser may be enough. However, larger systems may benefit from a more general approach. For example, systems that collect shareholder votes usually require people to vote by telephone, in writing and online. In this case, the form technology that can support all three options through a single source document is very useful. Maybe you don't need this function now, but you will probably use it in the future. For example, imagine that you call the server with your mobile phone and dictate (instead of typing! ) A story to update your blog in real time in this way. The current speech recognition technology is not enough to support this function, but it will definitely develop to this extent in the future. When that day comes, adding voice input support to XForms-based blogs is a piece of cake, because the form itself does not need to be rewritten. However, systems based on HTML forms cannot provide similar support. Maybe my vision is too long-term, maybe I should focus on the present rather than the future interface like science fiction. But these sci-fi problems are exactly what XForms is trying to solve. Back to the top, many devices support the Web, which may promote the sales of many computers, but it certainly does not only focus on computers-at least not just those traditional desktops. In the near future, the most common online device will be the mobile phone. Perhaps the next most popular device will be a human laptop, which uses a low-power processor and runs a customized version of Linux? 0? 3。 Many people will continue to use text mode browsers, such as Lynx. XForms is designed to work well in all these environments, not just the millions of colors of the graphical user interface (GUI) displayed on a 30-inch monitor. The trick to supporting multiple devices is to separate the content collected by the form from the appearance of the form. For example, in a traditional Web browser (such as Firefox), a form requesting delivery and billing addresses may be displayed on one page. But on a small device like a mobile phone, it can also be easily split into two continuous screens. If you fill out the form by voice instead of typing, it can even be a non-visual form. XForms doesn't have to make any assumptions about the type of device used to fill out the form. Back to the top, machine use and automation forms are not only filled out by people. It can also be used for communication between different processes. For example, an office manager can use Microsoft Windows? 0? 3. Enter the office supplies purchase application in the rich client GUI program running on the computer. Subsequently, this program can search the best price of each product on the websites of OfficeMax, Staples, Office Depot and Laser Monks, and then place an order. The office manager fills in a local form in the program, and then the program copies the relevant information to the form of the store offering the best price. Maybe this process doesn't need human intervention. Smart printers can recognize that toner is about to run out and automatically reorder. In order to realize this scenario, the form must be accessible by other programs, not just people. Fields must be marked with names that other programs can recognize. Tags must be clearly attached to specific fields in tags, not just visual representations of pages. In addition, it will be very useful if the form can specify a field that requires an integer, decimal, date, future date, legal postal code, etc. In this use case, the representation is not only separated from the tag, but may even not exist at all. Humans are very smart and can use implicit clues (such as the location of fields on a page) to distinguish where to enter what kind of data. But computers can't. They need more help. XForms is designed to provide this kind of help for computers. The clearer the information about the content that can be entered into the form, the easier it is for the computer to automatically interact with the form. Internationalization and localization of non-ASCII data is one of the most headache problems in form programming and common gateway interface (CGI). Speaking of how to encode and submit words like resumé (not to mention χ ν ο? 0? 9 or? 9? 6) The early HTML and URL specifications left a lot of imagination for developers. In recent ten years, this situation has been improved to some extent, and some emerging standards have emerged. But there is no doubt that we can't retreat for the sake of progress. Unicode must be enabled from the beginning. XForms uses XML as the underlying serialization form. When a browser or other client receives XForm from the server, it receives XML. When it sends the form data back to the server, it encodes the data into an XML document. XML documents are Unicode. Of course, it can also be stored as other encodings, but the conversion between these encodings and Unicode is simple and certain. When dealing with XML, there is no longer any coding problem. It is impossible for one party to read the document with ISO-8859- 1 encoding and the other party to read the document with UTF-8 encoding. This will make it possible to fill out forms in Greek, Chinese, French, Hebrew and hundreds of other languages. To quote Robert Bringhurst, you don't have to hope that "no one will mention French cake or A? 0? 7 ollie; There's no Anthony Devo? 0? 0k、S? 0? Kierkegaard, Stéphane Mallarmé or Chloe? 0? 5 Jones; Nobody lives in? 0? 7bidos? 0? 3rhus、Kromì? 0? 3í? 0? 6、? 0? 1ster Vr? 0? 2、Pr? 0? 1honice、Nagyk? 0? 1r? 0? 2s, Dallas? 0? 7sla、K? 0? 3rka? 0? 6a? 0? 4 or k? 0? 2ln, "(elements of printing style, Hartley & ampMarks Press, 2002, p. 90) Of course, the real internationalization and localization is not just to let people input their names and addresses in non-ASCII letters. For example, it is also necessary to allow Hebrew and Arabic forms to be arranged from right to left, not from left to right. The separation of content and expression once again saved us. There is no requirement for field layout in XForm, so the local renderer is free to choose any reasonable direction. There is no doubt that hints are sometimes useful, for example, it can tell the renderer whether it is processing English or Arabic. It's time for XML to show its power again. XForms completely allows the use of xml:lang attributes, two-way Unicode tags, Ruby text and other techniques that are not related to English but are important to other languages. Finally, the form itself needs to be localized. The same form must be able to load its own tags and other human-visible content from resource files translated into different languages. Just like writing a rich client GUI, you don't want to put translatable strings in the source code because translators are usually not programmers. Accessibility at the top of the page One of the least obvious but most important goals of XForms is accessibility. An XForm form should not only consider users with sound eyesight and dexterity. It also needs to be effective for people with temporary or permanent vision, limbs or other defects. This involves not only users with obvious visual impairment and physical disability, but also everyone else. Because everyone will have inconvenient times. Many people use the small screen and numeric keys of mobile phones to surf the Internet. Some people will use the voice interface to fill in XForms while driving. With the further improvement of jurisdiction, accessibility is not only a good idea. This is the law. It is not surprising that there is an error when entering the verification and filling out the form at the top of the page. You will always be asked to enter your email address twice to make sure there are no spelling mistakes. Many complicated JavaScript codes have been written to check the basic constraints: for example, the digits of a credit card number should be correct and its expiration date should be in the future rather than in the past. Of course, you can write similar checks in JavaScript code. But expressing what constraints are is a hundred times easier than writing code to check. XForms strives to simplify this check through a more intuitive declarative approach. Therefore, they may have been written first. Some constraints can be checked when the user inputs. For example, if the input field indicates that the input should be a model, the browser can ignore any non-numeric keys pressed by the user. Other browsers may check these constraints before submitting the form and warn users when they find violations. Of course, a robust Web application cannot rely on anything submitted by the client. Malicious users can try to crack the system by changing the total price before submitting the order. Only the person who verifies the data can believe the data. The client can trust the data verified by the client, while the server can only trust the data verified by the server. For this reason, XForms is designed to allow server-side and client-side authentication. Trust, but it must be verified. All data submitted by the client can (and should) be tested according to the pattern to ensure that it conforms to the model. It is possible to test the input of traditional Web applications based on HTML forms, but XForms tries its best to make it simpler and more robust, almost to the point where testing is easier than not testing. This will eliminate many small security vulnerabilities related to the network. Go back to the top to avoid data transmission back and forth. The speed of a system depends on its slowest part. In Web applications, the performance bottleneck is usually not the server (if it is handling a large number of connections) or the network connection between the client and the server. It is important to minimize the work that must be done in two aspects at the same time. The performance bottleneck is rarely the client, so if you can transfer any work from the server or network to the client, you will undoubtedly get a performance improvement. A serious limitation of current HTML forms is that every time the form value is changed by calculation, data needs to be transmitted back and forth with the server. The server must receive the input, process it and return a new form to the client. Sometimes this is necessary, such as when the server returns information from a database that only it can access. But sometimes there is no reason to say that work can't be completely performed on the client. For example, the client can easily add up the total price of all the goods in the shopping cart and display it to the user before submitting the form. In fact, almost all the details of shopping carts can be stored in the client and sent to the server only at checkout. At present, this process is implemented in JavaScript, but JavaScript is difficult to read and maintain. Adding calculated fields that depend on the contents of other fields can achieve a more declarative way. In addition, these fields can be pure output fields, which can only be seen by the client. The server does not have to look at them. For security reasons, it recalculates all results based on irrelevant data entered by customers. Related data remains on the client to which it belongs. This method skillfully eliminates all opportunities for server programmers to rely on destructible client computing to open security vulnerabilities. XForms is designed for various environments and is suitable for users (technical and personal) with different abilities. It separates data from form presentation, so that the same form can be presented in many different ways to meet the needs of various users, thus achieving this goal. This requires you to completely change the way you look at and design software. This is similar to changing from representation-based markup in Word to semantic-based markup in XML. In the field of programming, like from Java? 6? This imperative language turns to descriptive languages such as SQL. When designing XForms, you must consider the information you want from users, not the appearance of the form. I am not sure whether this style of form design will be more difficult than traditional visual design, but it is not so intuitive and most web designers are not familiar with it. This of course requires an adaptation process. For simple applications with a one-time delivery mechanism, this higher level of indirection may not be worth it. But for more complex applications, it brings real hope to improve the ideal characteristics such as accessibility, localization, security and robustness. For reference, you can refer to the original English text of this article on the developerWorks global website. Read "Introduction to XForms, Part 1: A New Web Standard for Forms". XForms requirements give a preliminary explanation of the necessity of XForms. The XForms working group charter introduces the original official goals of XForms. Read Wikipedia: XForms: an excellent introductory resource. Wikibooks has a section about XForms: tutorials and recipes, and the information here is updated frequently. The XML technology section of developerWorks China website provides hundreds of articles on various aspects of XML development. DeveloperWorks technical activities and network broadcasting: always pay attention to the latest technology. Get products and technologies Get MozzIE, an open source control that can render XForms in IE. Discuss the developerWorks blog: join the developerWorks community. About the author Elliotte Harold was born in New Orleans, and now he regularly goes back to his hometown to drink a delicious bowl of gumbo. But now he lives in Prospect Heights near Brooklyn with his wife Beth, their dog Xia Na, Cat Charm and Marjory. He is an associate professor of computer science in Polytechnic University, teaching Java and object-oriented programming. His Cafe au Lait website is one of the most popular independent Java sites on the Internet, and its sub-site Cafe con Che Le is one of the most popular XML sites. His works include effective XML, XML processing with Java, Java network programming and XML 1. 1 Bible. His latest book is Java I/O, the second edition. At present, he is engaged in the research of XOM API processing XML, Jaxen XPath engine and Jester test coverage tool. Turn off [x] help for reporting abuse. Report abuse. Thank you! This content has been marked for the attention of the administrator. Close [x] Help on reporting abuse Reporting abuse Reporting abuse failed. Please try again later. Close [x]developerWorks: log in to IBM ID: Need an IBM ID? Forgot IBM ID? Password: Forgot your password? Change your password and stay logged in. By clicking submit, you agree to the terms and conditions of developerWorks. Terms of Use When you log in to developerWorks for the first time, a profile will be created for you. The information you choose to make public in the developerWorks profile will be publicly displayed to others, but you can modify the display status of this information at any time. Your name (unless you choose to hide it) and nickname will be displayed together with your published content in developerWorks. All submitted information is safe. Close [x] Please choose your nickname: When you log in to developerWorks for the first time, a profile will be created for you, and you need to specify a nickname. Your nickname will be displayed along with what you post on developerWorks. The length of the nickname is between 3 and 3 1 character. For privacy reasons, your nickname must be unique in the developerWorks community and cannot be your email address. Nickname: (length is between 3 and 3 1 character) Click Submit to indicate that you agree to the terms and conditions of developerWorks. Terms of use. All submitted information is safe. Grade this article and comment back to the top.