Xml For Dummies Chapter 16 Xml And Forms it-slideshares.blogspot.com


Published on


Published in: Technology
1 Like
  • Be the first to comment

No Downloads
Total views
On SlideShare
From Embeds
Number of Embeds
Embeds 0
No embeds

No notes for slide

Xml For Dummies Chapter 16 Xml And Forms it-slideshares.blogspot.com

  1. 1. XML FOR DUMMIES<br />Book author: Lucinda Dykes and Ed Tittel<br />Slides Prepared by Cong Tan<br />Part V : XML Application Development<br />Chapter 16: XML and Forms.<br />
  2. 2. Contents<br />Collecting Information with Forms: The Basics.<br />HMTL Forms<br />XML Forms<br />
  3. 3. 1. Collecting Information with Forms: The Basics.<br /> Most of us are used to filling in blanks and checking boxes to provide requested information on a printed form.<br />Web users have also become very familiar with completing online HTML forms, including text in boxes, choosing radio buttons, checking boxes, and selecting options from scrolling lists.<br />Most interaction on the Web takes place through the use of forms. But form is involved.<br /> Data collection and submission with forms, HTML form elements can create interactivity via scripting languages such as JavaScript.<br />
  4. 4. 2. HTML Forms.<br />You can use HTML to create forms for display on Web pages.<br />HTML includes elements for creating text boxes, text areas, radio buttons, check boxes, and menus.<br /> These forms have a standard look and structure, which makes it easy for Web users to use them to enter data. Figure 16-1 shows a standard HTML form.<br />
  5. 5. 2. HTML Forms(cont…).<br /> HTML form elements, can create only the structure of a form for display on a Web page.<br />Collecting the data that’s entered on an HTML form requires the use of a scripting or programming language in addition HMTL. <br /> Perl, PHP, and Java are programming languages commonly used for forms processing.<br />Form data is submitted to a Web server and processed by a server-side script that conforms to the CGI specification.<br />The form results can then be returned to a Web page, sent in a e-mail message, saved as a data file, or submitted to a database.<br />You can use XML files to create XML forms and collect data with Xforms or InfoPath.<br />
  6. 6. 3. XML Forms.<br /> XML and forms go together well — both XML and forms have to do with collecting and exchanging data.<br />You can use XSLT to generate HTML forms code, two new options(Xforms and InfoPath) provide easier solutions for XML data exchange.<br />
  7. 7. 3.1 XForms.<br />XForms is an XML application created by the W3C.<br />Xforms allows the separation of presentation and content, expanded form capabilities, and a decreased reliance on scripting for forms validation and processing.<br />Why use Xforms?Using Xformsfor your XML data has several advangtages over using HTML forms:<br />Form data can be collected and submitted as XML.<br />External XML documents can be loaded as initial form data.<br />XPath expressions and XML Schema datatypes can be used with Xforms.<br />Xforms can be integrated with Web services.<br />Xforms is device independent .<br />XForms properties. XForms markup is shown in Listing 16-1.<br />
  8. 8. • XForms does not include a form element; the form markup is divided between the head section and the body section of the document.<br />• The head element contains a model element with a submission element that includes the attributes that are usually contained in an HTML form element: action, method, and id..<br />• XFormsis the default namespace, and the XHTML namespace uses an h: prefix.<br />• The input element include ref attribute.<br />
  9. 9. 3.1 XForms(cont…) .<br />XForms includes all the form control elements of HTML forms.<br /> In the case of XForms, markup is used to control the action of form elements. For example:<br />XForms includes a select and a select1 element.<br />You use the selectelement when there are zero or more choices and a select1element when only one choice can be selected.<br /> An appearance attribute specifies the appearance of select or select1 elements, as in.<br />For radio-button markup<br />&lt;select1 appearance=”full” ref=”bk1”&gt;<br />&lt;label&gt;Content Type&lt;/label&gt;<br />&lt;item&gt;&lt;label&gt;Fiction&lt;/label&gt;&lt;value&gt;F&lt;/value&gt;&lt;/item&gt;<br />&lt;item&gt;&lt;label&gt;Nonfiction&lt;/label&gt;&lt;value&gt;NF&lt;/value&gt;&lt;/item&gt;<br />&lt;/select1&gt;<br />For check-box markup<br />&lt;select appearance=”full” ref=”bk1”&gt;<br />&lt;label&gt;Shipping Options&lt;/label&gt;<br />&lt;item&gt;&lt;label&gt;Gift Wrap&lt;/label&gt;&lt;value&gt;GW&lt;/value&gt;&lt;/item&gt;<br />&lt;item&gt;&lt;label&gt;Gift Card&lt;/label&gt;&lt;value&gt;GC&lt;/value&gt;&lt;/item&gt;<br />&lt;/select&gt;<br />
  10. 10. 3.1 XForms(cont…) .<br />XForms includes the following built-in features that require scripting when used in HTML forms:<br />Required values: A required value must be entered in the form before the form can be submitted.<br />Value containts: A value must be within a certain range of values.<br />Datatypes for values: An XML Schema datatype can be specified for a value.<br />Values that are calculated form other values: An Xpath expression is used to calculate a new value from other values in the form…<br />XForms also provides these additional features:<br />The capability to specify an initial value for form data.<br />P3ptypes for privacy-related values: P3P datatypes can be used for private monitoring.<br />A switch element for creating wizard-like behavior for form completion(as shown in Figure 16-2).<br />A repeat element that allows items to be added and deleted, as in a shopping cart.<br /> Function galore — including arithmetic functions, string manipulation, date handling, and conditional statements using if.<br />
  11. 11.
  12. 12. 3.1 XForms(cont…) .<br />Submission options.<br />XForms includes several options for the method of submitting form data.<br />Three of these methods are similar to those available with HTML forms:<br />method=“get”<br />method=“urlencodedpost”<br />method=“form-data-post”<br />In addition, XForms offers:<br />method=“post” (posts the results as an XML document)<br />method=“put”(puts the result in an XML document)<br /> For example: Figure 16-3, 16-4, and 16-5 show the use of “put” method.<br />
  13. 13. Show an XML document with content.<br />Shows an XForms form to<br />edit this content<br />
  14. 14. Shows the same XML document with new content.<br />
  15. 15. 3.2 InfoPath.<br /> InfoPath is a WYSIWYG XML forms editor that can create an XML form from an XML document or XML Schema document.<br /> InfoPath forms can be used online or downloaded and completed offline.<br />
  16. 16. 3.2.1 Why use InfoPath?<br />You should consider using InfoPath for several reasons:<br />InfoPath is easy to use and doesn’t require any knowledge of XML.<br />Form data from InfoPath can be exported to other Microsoft applications, such as Excel 2003.<br />InfoPath allows you to select multiple forms and combine the data into one form.<br />You can use an existing XML Schema document and automatically create a form based on the structure of the schema.<br />InfoPath can be integrated with Web services.<br />InfoPath includes data validation and conditional formatting fearures.<br />
  17. 17. 3.2.2 Automated form design from an XML Schema.<br />You can easily design a form an existing XML Schema in InfoPath:<br />Open InfoPath, and select File➪Design a Form .<br />From the Design a New Form list in the task pane on the right side of the page, select New from XML Document or Schema.<br />Click the Browse button in the Data Source Wizard window, and browse to the location of the bookstore.xsd file.<br />Select the bookstore.xsd file, click Open, and then click Next in the Data Source Wizard window.<br /> Choose No in response to the question and then click the Finish button.<br /> Select the Layout task pane from the list at the top of the task pane and then select Two Column Table from the Insert Layout Tables menu in the task pane.<br /> Select the Data Source task pane, highlight the book element in the task pane, and then drag the book element into the left column of the table.<br /> Choose Section with Controls from the contextual menu.<br /> Select and drag the totalCost element into the bottom of the left column, below the repeating section. Then select and drag the cus-tomerelement into the lower-right cell.<br /> Choose Section with Controls from the contextual menu.<br />The bottom of your form should now resemble Figure 16-6.<br />
  18. 18. 11. Choose File➪SaveAs➪Save➪ to open the Save As dialog box. Enter<br />bookstore.xsn for the file name and then click the Save button.<br />12. Choose File➪Preview Form. Then choose With Data File from the submenu.<br />13. Browse to the location of bookstore_schema.xml from Chapter 9, select it, and then click Preview (Figure 16-7 shows the InfoPath Preview file).<br />14. Publish your file to a folder, and put your form to work.<br />
  19. 19. • Now you can see why we included InfoPath in this chapter — it’s fast, and it’s easy to<br /> • Create a working XML form document that can be opulated with data from any XML document that corresponds to the XML Schema the form is based on.<br /> • Fill out new data in a blank form based on a form template document.<br />
  20. 20. THE END<br />