Use data link to display XML files and DSO methods

xiaoxiao2021-03-06  74

The visible use of data links to display XML files and DSO methods [book txt]

-------------------------------------------------- ------------- source: easy to get XML author: Michael.J.Young translator: Lin Jiasheng

This information is only available for your own study, without authorization of author and translators, it is not available for commercial purposes.

-------------------------------------------------- ----------------

Two methods of connecting HTML elements to XML elements:

Table Format Data Link - The representative links the Table element of HTML to XML data, so that the table can automatically display the entire collection that belongs to the XML file record. Single Record Data Link - - represents a non-format HTML element (for example, a span element) to the XML element, so only one record is displayed.

Using the Table Format Data Link To display the XML file consisting of a series of records (inventory.xml displayed in List 8-1), the easiest way is to connect HTML's Table elements to XML data so that the table can be Automatically display all data records (or display a page at a time, if you start the paging function). With this method, Internet Explorer5 will help you process all programs; you don't need to write programs or call methods. (But if you choose a paging function, you must do some ways to call, this chapter will introduce this method of processing.)

You can use a single HTML table to display XML files constructed in a simple recordset.

Or you can use the nest set of HTML tables to display the XML files that contain the class record set. The next chapter explains the two ways to display the record set in detail.

Use individual HTML forms to display simple records

Nest-shaped record

---- The XML file constructed in the following manner:. The root element includes a series of Record elements, all of which are the same type. (This chapter sometimes refers to recording elements to Record.). Each record element contains the same group of Field elements. (This chapter sometimes refers to the field element referred to as Field.). Each field element contains only character data. (If the child element of the record element contains one or more of its own proprietary child elements, the DSO will be regarded as a nest record, not a field .INventory.xml is an example of this type of HTML file, in this copy In the file, the root element contains eight elements (Book elements), and each record element has the same set of field elements, which only contains character data. (Title, Author, Binding, Pages PRICE)

Inventory.xml ---------------- The Adventures of Huckleberry Finn </ title> <author> Mark Twain </ author> <binding> mass market paperback </ binding> <pages> $ 5.49 <price> </ book> < Book> <Title> Leaves of Grass </ title> <author> Walt Whitman </ author> <binding> hardcover </ binding> <price> $ 7.75 </ price> </ book> < Book> <title> The Legend of Sleepy Hollow </ Title> <Author> Washington Irving </ Author> <Binding> Mass Market Paperback </ Binding> <Pages> 98 </ pages> <price> $ 2.95 </ price> < / Book> <book> <title> The marble faun </ title> <author> Nathaniel Hawthorne </ author> <binding> Trade Paperback </ binding> <pages> 473 </ pages> <price> $ 10.95 </ price> </ Book> <book> <title> moby-dick </ title> <author> Herman Melville </ author> <binding> hardcover </ binding> <pages> 724 </ pages> <price> $ 9.95 </ price> </ Book> <book> <title> The portrait of a lady </ title> <author> Henry James </ author> <binding> mass market paperback </ binding> <Pages> 256 </ pages> <price> $ 4.95 </ Price> < / Book> <book> <title> The scarlet letter </ title> <author> Nathaniel Hawthorne </ author> <binding> Trade Paperback </ binding> <pages> 253 </ pages> <Price> $ 4.25 </ price> </ Book> <book> <title> The Turn of The Screw <</p> <p>/ Title> <author> Henry James </ author> <binding> Trade Paperback </ binding> <pages> $ 3.35 </ pages> <price> $ 3.35 </ price> </ book> </ inventory> When you connect tables To the XML file, the data belonging to each record element is displayed in a column different from the table, while each subfield element of the record element is displayed in different columns. As in the example, the HTML web page in Listing 8-2 contains a table, which is connected to the data in the inventory.xml file in the list 8-1.</p> <p>Inventory Table.htm --------------------</p> <p><! - file name: inventory table.htm -> <html> <head> <title> book inventory </ title> </ head> <body> <xml id = "dsoinventory" src = "inventory.xml" > </ Xml> <h2> book inventory </ h2> <Table Datasrc = "# DSOINVENTORY" border = "1" cellpadding = "5"> <THEAD> <THOR TITLE </ TH> <TH> Author </ TH> <TH> Binding </ TH> <TH> Pages </ TH> <TH> Price </ th> </ thead> <tr align = "center"> <td> <span datafld = "title" style = "font-style: italic"> </ span> </ td> <td> <span datafld = "author"> </ span> </ td> <td> <span datafld = "binding"> </ span> </ Td> <TD> <span datafld = "Pages"> </ span> </ td> <td> <span datafld = "price"> </ span> </ td> </ tr> </ table> </ Body> </ html></p> <p>Inventory.xml file Links to the Data ISland of DSoinvent in the web page, link to the list inventory table.htm HTML page:</p> <p><XML ID = "DSOINVENTORY" SRC = "Inventory.xml"> </ xml></p> <p>By setting the DataSRC property of the table element in the web page, the Table element will be connected to the entire XML file with an arithmetic symbol (#) character.</p> <p><Table datasrc = "# dsoinventory" border = "1" cellpadding = "5"> form is defined with a standard title (THEAD element) defined by a column (TR element). Each column (i.e., each TD element) contains a SPAN element that is connected to the field of the XML file to allow the element to display the content of the field. For example, the first column contains a span element that links to the title field:</p> <p><TD> <span datafld = "title" style = "font-style: italic"> </ span> </ td></p> <p>The SPAN element is connected to the XML field by setting the name of the field to the DataFld property of the element (in this example, it is Title). Below is a mode of operation of the data link: Although the table element only defines a single column, when the browser displays the table, it repeats the column elements for each record in the XML file. That is, the first column that follows the title shows a field belonging to the first record (Title, Author et al.). The next column is the second record (for the Book element of Leaves of Grass), the third record, and the like display fields. Here is the look at the inin of Internet Explorer 5:</p> <p>Http://jyan.w148.4everdns.com/lycos/xml/images/1.gif</p> <p>You may doubt why the column (TD) element is not directly connected to the XML field. The reason is that the TD element is not a connected HTML element. (Table 8-1 in page 295 lists the canable elements.) So, you need to include a connectable element, usually span, in each TD element.</p> <p>prompt</p> <p>To get more about the operations of HTML and DHTML described in Chapter 5, see the website listed on http://msdn.microsoft.com/Workshop/author/default.asp on MSDN. To refer to the official HTML specification, see the information provided by the WorldWide Web Consortium (W3C) website http://www.w3.org/tr/rec-html40/.</p> <p>Use pagings</p> <p>If the XML file contains a lot of records, you can display records in a group in a group, not all records in a lengthy table. To start a paging feature for a particularly connected table, perform the following steps:</p> <p>1. Set the DataPageSize property of the connected table element to the maximum number of records you want to display once. That is, each page recorded will contain the number of records you specify. For example, the starting tab of the table element specifies 5 as the attribute value for the DataPagesize property, which will cause only 5 records to be displayed at a time:</p> <p><Table datasrc = "# dsoinventory" datapagesize = "5"></p> <p>2. Specify a unique identification code for the ID attribute of the Table element, as shown in the following starting tag:</p> <p>3. <Table ID = "InventoryTable" Datasrc = "# DSoin" datapagesize = "5"> 4. To view inter-record, you can call the method of table elements in the table below. Note that the example in the last line is a hypothesis that the table has an id value of the InventoryTable.</p> <p>Table element method affects call example</p> <p>----- FirstPage Display Record of InventoryTable.firstpage () ----- PreviousPage Display Record Previous InventoryTable.Previouspage () ----- NextPage Display Record Next InventoryTable.NextPage ) ----- LastPage Display Last page inventoryTable.lastPage ()</p> <p>If the first page is currently displaying, the call previouspage method is ignored, not working; if it is displaying the last page, the call nextpage method will be ignored. You can use Script to call any of these methods (as will be discussed later in this chapter). However, the simplest way is to set the method to the onclick property of the Button element in the HTML, as shown below:</p> <p><Button OnClick = "InventoryTable.NextPage ()> Next Page </ button></p> <p>This element displays a button. When the user presses the button, the method of being assigned to the onclick property is -inventoryTable.nextPage, will be called. Listing 8-3 and 8-4 show a paging technology. Listing 8-3 is an extension of the Inventory.xml file displayed in Listing 8-1. Listing 8-4 is an HTML web page, which is responsible for displaying this XML file in its DataPagesize property being set into a table of "5". (You will be able to find in Inventory Big.xml with book CDs and Inventory Big Table.htm files.) There are 4 Button elements at the top of the web page, each button will perform the paging method of the table. When you first turn on the web page, the table will display the first 5 records. Press the Next Page button to display the lower 5 records (if the end portion of the record is displayed, the original five data) is displayed, and the PREVIOUS button will display the top 5 records (if the start part is recorded, or still The original five records). Pressing the first page or the last page button is the top 5 or the last 5 records. Below is a look at the list 8-4 that is turned on in Internet Explorer 5:</p> <p>http://jyan.w148.4everdns.com/lycos/xml/images/2.gif</p> <p>Inventory big.xml -----------------</p> <p><? xml version = "1.0"?> <! - file name: inventory big.xml -> <inventory> <book> <title> the adventures of huckleberry finn </ title> <author> Mark Twain </ authoror > <Binding> mass market paperback </ binding> <pages> 298 </ pages> <price> $ 5.49 </ price> </ book> <book> <title> The Adventures of Tom Sawyer </ Title> <Author> Mark TWAIN </ author> <binding> mass market paperback </ binding> <pages> 205 </ piece> <price> $ 4.75 </ price> </ book> <book> <title> The Ambassadors </ title> <author> Henry James </ author> <binding> mass market paperback </ binding> <pages> 305 </ pages> <price> $ 5.95 <book> <title> The awakenging </ title> <authoror > Kate Chopin </ author> <binding> mass market paperback </ binding> <pages> $ 4.95 </ price> </ book> <book> <title> billy budd </ title> < Author> Herman Melville </ Author> <Binding> Mass Market Paperback </ Binding> <Price> $ 4.49 </ price> <p> <book> <title> a connectionicut yankee in king arthur 'Scourt </ title> <author> Mark Twain </ author> <binding> mass market paperback </ binding> <pages> 385 </ month <pages> $ 5.49 < / Price> </ book> <book> <title> joan of arc </ title> <author> Mark Twain </ author> <binding> Trade Paperback </ binding> <pages> 465 </ pages> <price> $ 6.95 </ Price> </ book> <book> <title> Leaves of grass </ title> <</p> <p>Author> Walt Whitman </ author> <binding> Hardcover </ binding> <pages> 462 </ pages> <price> $ 7.75 </ price> </ book> <book> <title> The Legend of Sleepy Hollow </ Title > <Author> Washington Irving </ author> <binding> mass market paperback </ binding> <pages> 98 </ pages> <price> $ 2.95 </ price> </ book> <book> <title> the marble faun <Title> The Marble Faun / Title> <author> Nathaniel Hawthorne </ author> <binding> Trade Paperback </ binding> <pages> $ 10.95 <book> <book> <title> moby-dick </ Title> <author> Herman Melville </ author> <binding> hardcover </ binding> <price> $ 9.95 </ price> </ book> <book> <title> passing </ Title> <author> Nella larsen </ author> <binding> Trade Paperback </ binding> <pages> 165 </ pages> <price> $ 5.95 </ price> </ book> <book> <title> The portrait of a Lady </ title> <author> Henry James </ author> <binding> mass market paperback </ binding> <pages> 256 </ pages> <price> $ 4.65 <book> <title> Roughing it </ title> <author> Mark Twain </ author> <binding> mass market paperback </ binding> <pages> $ 5.25 </ pages> <price> $ 5.25 </ price> </ book> <book> <TIT Le> The scarlet letter </ title> <author> Nathaniel Hawthorne </ author> <binding> Trade Paperback </ binding> <pages> $ 4.25 </ price> </ book> <book> <Title> The Turn of The Screw <</p> <p>/ Title> <author> Henry James </ author> <binding> Trade Paperback </ binding> <pages> 384 </ pages> <price> $ 3.35 </ price> </ book> </ inventory> List 8-3.</p> <p>Inventory Big Table.htm -------------------------! - File Name: Inventory Big Table.htm -> <HTML> <HEAD> <Title> book inventory </ title> </ head> <body> <xml id = "dsoinventory" src = "inventory big.xml"> </ xml> <h2> book inventory </ h2> <button onclick = InventoryTable.firstPage () "> | <First Page </ BUTTON> <BUTTON onCLICK =" InventoryTable.previousPage () "> <Previous Page </ BUTTON> <BUTTON onCLICK =" InventoryTable.nextPage () "> Next Page> < / Button> <Button OnClick = "InventoryTable.lastpage ()> Last Page> | </ button> <p> <Table ID =" InventoryTable "Datasrc =" # DSOINVENTORY "datapagesize =" 5 "border =" 1 "cellpadding = "5"> <THEAD> <THOR </ TH> <TH> Author </ th> <TH> Binding </ TH> <TH> Pages </ TH> <TH> Price </ TH> </ THEAD> <tr align = "center"> <TD> <span datafld = "title" style = "font-style: italic"> </ span> </ td> <td> <span datafld = "author"> < / Span> </ td> <td> <span datafld = "binding"> </ span> </ td> <td> <span datafld = "pages"> </ span> </ td> <td> <span DataFLD = "Price"> </ span> </ td> </ tr> </ table> </ body> </ html> list 8-4.</p> <p>Use nest form to display class record set</p> <p>In the previous chapter, you have learned how to use a single table to display XML files constructed in a simple recordset, each record contains a fixed set of fields, all of which only store character data. Now you will learn how to use nest forms to display specific XML files, the element of this XML file is constructed in classic recordset. In the classic record set, each record may contain a set of numerous nest records (zero or more) in addition to the fixed set of fields. Listing 8-5 shows an example of XML file constructs constructed to build a hierarchy recording set. (You can find in the Inventory Hierarchy.xml file with the book CD.) In this file, the root element contains a series of Category records. Each Category record is initiated by a CATName field, which only contains character data. The back is then zero or multiple nest BOOK elements. Each neopic book element has five fields (Title, Author, Binding, Pages and Price). Inventory hierarchy.xml -----------------------</p> <p><? XML Version = "1.0"?> <! - file name: inventory hierarchy.xml -> <inventory> <category> <catname> Middle Ages </ CATNAME> <book> <title> The canterbury taTeles </ Title> <author> Geoffrey chaucer </ author> <binding> hardcover </ binding> <pages> 692 </ pages> <price> $ 18.95 </ price> </ book> <book> <title> Piers Plowman </ Title > <Author> William Langland </ author> <binding> Trade Paperback </ binding> <pages> 385 </ pages> <price> $ 10.95 </ price> </ book> <category> <category> <catname> Renaissance </ Catname> <book> <title> The blazing world </ title> <author> Margaret Cavendish </ author> <binding> Trade Paperback </ binding> <price> $ 8.79 </ price > </ Book> <book> <title> Oroonoko </ title> <author> Aphra behn </ author> <binding> mass market paperback </ binding> <price> $ 4.95 </ price> $ 4.95 </ price > </ Book> <book> <title> Doctor Faustus </ title> <author> Christopher Marlowe </ author> <binding> Hardcover </ binding> <pages> 472 </ pages> <price> $ 15.95 </ price> </ Book> </ category> <category> <catname> 18th Century </ catname> <book> <title> gulliver's travels </ title> <author> Jona Than Swift </ author> <binding> Hardcover </ binding> <pages> 324 </ pages> <price> $ 11.89 </ price> </ book> <book> <title> The History of Tom Jones: Afoundling </ TITLE > <Author> Henry Fielding </ author> <</p> <p>Binding> Hardcover </ Binding> <price> $ 16.95 </ price> <book> <book> <title> love in excess </ title> <author> eliza haywood </ author> < Binding> Trade Paperback </ binding> <Pages> 429 </ page> <price> $ 12.95 <book> <title> Tristram shandy </ title> <author> Laurence Sterne </ author> < Binding> Hardcover </ Binding> <Price> $ 9.49 </ price> <price> <cate> <catname> 19th Century </ catname> <book> <title> Dracula </ Title> <author> bram stoker </ author> <binding> hardcover </ binding> <pages> 395 </ pages> <price> $ 17.95 </ price> </ book> <book> <title> Great Expectations < / Title> <author> Charles Dickens </ author> <binding> mass market paperback </ binding> <pages> 639 </ page> <price> $ 6.95 <book> <title> Percival Keene </ Title> <author> Frederick marryat </ author> <binding> Trade Paperback </ binding> <pages> 425 </ pageES> <price> $ 12.89 <p> </ book> <book> <title> treasure island </ Title> <author> Robert Louis Stevenson </ Author> <binding> Trade Paperback </ binding> <pages> 283 </ pages> <price> $ 11.85 </ price> </ book > <Book> <title> Wuthering Heights </ title> <author> Emily bronte </ author> <binding> hardcover </ binding> <piges> $ 12.95 <<p> <price> $ 12.95 </ price> </ book> </ Category> </ inventory> List 8-5.</p> <p>Listing 8-6 includes an HTML web page that uses a nest form to display the class record structure of the XML file in the list 8-5. (You can find it in the Inventory Hierarchy.htm file with the book CD.)</p> <p>Inventory hierarchy.htm -----------------------</p> <p><! - file name: inventory hierarchy.htm -> <html> <head> <title> inventory of classic english literature </ title> </ head> <body> <xml id = "DSOINVENTORY" src = "inventory Hierarchy.xml> </ xml> <Table DataSRC = "# dsoinventory" Border = "1"> <THEAD> <TH> Classic English Litrate </ TH> </ thead> <tr> <TD> <span datafld = "CATNAME"> </ span> <TD> <Table DataSRC = "# dsoinventory" datafld = "book" border = "0" cellspacing = "10"> <THEAD> < TH> Title </ th> <THOR AUTHOR </ TH> <TH> Binding </ TH> <TH> Pages </ TH> <TH> Price </ TH> </ thead> <trilign = "center" > <TD> <span datafld = "title" style = "font-style: italic"> </ span> </ td> <td> <span datafld = "author"> </ span> </ td> <TD > <Span datafld = "binding"> </ span> </ td> <td> <span datafld = "pages"> </ span> </ td> <td> <span datafld = "price"> </ span > </ Td> </ tr> </ table> </ td> </ tr> </ table> </ body> </ html> list 8-6.</p> <p>In Listing 8-6, the external table is connected to the XML file, and you can see the following in its starting tag;</p> <p><Table datasrc = "# dsoinventory" border = "1"></p> <p>The external table also contains a title (this is a THEAD element showing "Classic English Literature", plus the columns of the two tables (two TR elements). The browser will repeat these two columns for each top recording (ie, each Category record). The first two columns show the CATName field. So far, everything works like a sample table of the simple recordset in Listing 8-2. However, the second column contains a nest-like table that displays the contents of each Book record in the current directory, not the display field. Here is a volume label only for nest form: <table DatasRC = # DSOINVENTORY "DataFld =" book "border = 0 Cellspacing = 10> <TH> <THOR TITLE </ TH> <TH> Author </ th> <TH> Binding </ TH> <TH> Pages </ TH> <TH> Price </ TH> </ THEAD> <TR Align = "Center"> <TD> <span datafld = "Title" style = "font -style: italic> </ span> </ td> <TD> <span datafld = "author"> </ span> </ td> <td> <span datafld = "binding"> </ span> </ TD> <TD> <span datafld = "pages"> </ span> </ td> <td> <span datafld = "price"> </ span> </ td> </ tr> </ table></p> <p>Note that you must link the nest form to not just an XML file (DatasRC = # "# dsoinventory), and there is a nest Book record (DataFld =" book "), so the table will display the current category in a nest. Record the contents of each BOOK element. In other words, the column elements (TR) in the table will repeat each of these BOOK elements. (Note that according to the default, the external table is connected to the top of the element - the category record in the example - so it will display each record in step.)</p> <p>Below is it when you turn the list 8-6 in Internet Explorer 5, the list looks like:</p> <p>http://jyan.w148.4everdns.com/lycos/xml/images/3.gif</p> <p>You can use an additional nest form to display files that contain several nest records. For example, refer to the example file of the list 8-5. Suppose you have changed every author field:</p> <p><Author> Geoffrey chaucer </ author></p> <p>Change to zero or multiple nest Author records:</p> <p><Author> <firstname> Geoffrey </ firstname> <lastname> chaucer </ lastname> </ author> In this case, you can use additional nest forms for every Book element, show all the author, this is Util the same technique as used in a single tissue form.</p> <p>Use a single recorded data link</p> <p>Single-Record Data Binding refers to an HTML element that is not a table, and it is not included in the connected table. HTML elements - such as span, button or label elements - are connected to individual XML fields. The HTML element will then automatically display the contents of the XML field they are connected. For example, the SPAN element of the following HTML is connected to the Title field of the XML file, which is accessed by Data Island named DSOBOOK:</p> <p><Span datasrc = "# dsobook" datafld = "title"> </ span></p> <p>However, because the HTML element is not like a table, it can only display the value of the field once a record. To use a single recorded data link, the XML file must be composed of a simple record set. The simple record set introduced in the Chapter of the Simple Record Set in this chapter is already using the individual HTML forms.</p> <p>The simplest example of the data link of a single record is to use the XML file containing only a record, such as the sample file in the list 8-7. (You can find it in the book.xml file with the book CD.)</p> <p>Book.xml ---------- <? XML Version = "1.0"?> <! - file name: book.xml -> <book> <title> The Adventures of Huckleberry Finn </ Title > <Author> Mark Twain </ author> <binding> mass market paperback </ binding> <price> $ 5.49 </ price> </ book> list 8-7.</p> <p>Listing 8-8 shows an HTML web page that connects individual SPAN elements to each field (title, author, binding, pages and Price). (You can find it in the book.htm file with the book CD.)</p> <p>Book.htm ----------- <! - File Name: Book.htm -> <html> <head> <title> book description </ title> </ head> <body> < XML ID = "DSOBOOK" src = "book.xml"> </ xml> <h2> book description </ h2> <span style = "font-style: italic"> Title: </ span> <span style = " Font-weight: bold "Datasrc =" # DSOBOOK "DATAFLD =" Title "> </ span> <br> <span style =" font-style: italic "> author: </ span> <span datasrc =" # DSOBOOK "DataFld =" author "> </ span> <br> <span style =" font-style: italic "> binding type: </ span> <span datarc =" # dsobook "datafld =" binding "> </ span > <br> <span style = "font-style: italic"> Number of page: </ span> <span datarc = "# dsobook" datafld = "pages"> </ span> <br> <span style = " Font-style: italic> Price: </ span> <span datasrc = "# dsobook" datafld = "price"> </ span> </ body> </ html> list 8-8. Below is the Internet Explorer 5 display Listing 8-8 look:</p> <p>Http://jyan.w148.4everdns.com/lycos/xml/images/8-8.gif</p> <p>Browse data records</p> <p>If the XML file contains more than a record (up to them can be included), a single recorded data link becomes a bit complicated because the HTML element can only display a record at a time. Records displayed by HTML elements are called Current Record. (Therefore, another alternative method of single record link is current-record binding, called current record link) At the beginning, the current element is the first (or unique) record in the file. DSO combined with XML files provides a set of methods to make you call on intercombacter. These methods belong to the DSO recordset member object and is listed in the table below. Note that in the last line example call is assumed that the HTML web page contains an XML Data Island, its ID is DSOINVENTORY.</p> <p>DSO record set method (Note: It is a table) --------------------------------------- ---------- Call the current record into the first record of the call sample file MoveFirst MoveFirst ()</p> <p>Previous record DSoinventory.Recordset. MovePrevious moveprevious ()</p> <p>Next record DSOINVENTORY.Recordset. Movenext MoveNext ()</p> <p>The last record in the file DSoinventory.Recordset. MoveLast Moveset ()</p> <p>Specific number of records DSOINVENTORY.RecordSet.move DSoinventory.RecordSet.Move (5) Move to the 6th record. The record is starting from 0. ) ------------------------------------- -</p> <p>Note ------ DSO recordset member object complies with Microsoft Call ActiveX Data Objects (ADO) standard data access technology. You can use a general ADO record set object, as well as a variety of data from the XML DSO described in this chapter. For more information on ADO and Ado records, please refer to Microsoft, located at http://www.microsoft.com/data/ado/default.htm. For a specific record set, please refer to http://msdn.microsoft.com/library/psdk/dasdk/mdap2y7s.htm. You can call any of these methods from the script you write (such as this chapter will be introduced later). However, calling these methods are the simplest way, that is, by specifying the method to the onclick property of the Button element, as shown below:</p> <p><Button OnClick = "DSOINVENTORY.RecordSet.Movefirst ()> First Record </ button></p> <p>This element will display a button. When the user presses the button, the method that is specified to the onclick property is -dsoinventory.Recordset.movefirst, will be called. If the current record is the first, call the MovePrevious method to move the record set to the starting section of the file, and the representative cannot obtain any records, and the elements that are connected will disappear. Similarly, when the current record is the last pen, the call MOVENEXT method moves the recordset to the end of the file, and the elements that are connected will disappear. Fortunately, the RecordSet object provides the BOF attribute with the EOF property. If the record is bits in the start of the file, the property value of the BOF will be set to True. And if the record is bits in the end of the file, the EOF attribute value will be set to TRUE. You can detect these attribute status and set the necessary corrections. For example, when the program code is specified in the following buttons, when the recordset is moved to the start portion of the file, it quickly replays the first data record:</p> <p><Button OnClick = "DSOINVENTORY.Recordset.MovePrevious (); if (dsoinventory.recordset.bof) DSoinventory.Recordset.Movenext ()> Back </ button></p> <p>The following program fixes the status of the end of the file:</p> <p><Button OnClick = "DSOINVENTORY.Recordset.movenext (); if (DSoinventory.Recordset.mb) DSoinventory.RecordSet.MovePrevious ()> Forward </ button> Note that you can set the entire Script program code to Onclick Attributes (or other event properties, such as ONMOUSEOVER). In these examples, the program code is written in Microsoft JScript. In this chapter, you will learn how to write a separate Script program code block to make it easier to contain more instructions. In the following exercises, you will create an HTML web page that records the XML files in the list 8-3. The page provides a button to browse the first, the next, the next one with the last.</p> <p>Display files in a record</p> <p>1. In the text editor, turn on a new, blank text file, then enter the HTML web page in Listing 8-9. (You can find it in the Inventory Single.htm file with the book CD.) Note that the web page contains Data Island linking to the Inventory Big.xml file, which contains 16 records. (Listing 8-3 shows Inventory Big.xml; you can also find this file on the disc.) 2. Use the library instruction of the text editor to store the webpage to the local hard disk, specify its file name inventory. Single.htm.</p> <p>Inventory Single.htm --------------------- <! - file name: inventory single.htm -> <html> <head> <title> book inventory </ Title> </ head> <body> <xml id = "dsoinventory" src = "inventory big.xml"> </ xml> <h2> book description </ h2> <span style = "font-style: italic "> Title: </ span> <span datarc =" # dsoinventory "datafld =" title "style =" font-weight: bold "> </ span> <br> <span style =" font-style: italic "> Author: </ span> <span datasrc = "# dsoinventory" DataFld = "author"> </ span> <br> <span style = "font-style: italic"> binding type: </ span> <span datasrc = "#dsoinventory" datafld = "binding"> </ span> <br> <span style = "font-style: italic"> Number of page: </ span> <span datasrc = "# dsoinventory" datafld = "Pages" > </ Span> <br> <span style = "font-style: italic"> price: </ span> <span datasrc = "# dsoinventory" datafld = "price"> </ span> <hr> <button onclick = "dsoInventory.recordset.moveFirst ()"> | & lt; First </ BUTTON> <BUTTONonCLICK = "dsoInventory.recordset.movePrevious (); if (dsoInventory.recordset.BOF) dsoInventory.recordset.moveNext ()"> & LT; back </ button> <button onclick = "DSOINV entory.recordset.moveNext (); if (dsoInventory.recordset.EOF) dsoInventory.recordset.movePrevious () "> Forward & gt; </ BUTTON> <BUTTON onCLICK =" dsoInventory.recordset.moveLast () "> Last & gt ; </ Button> </ body></p> <p></ Html> List 8-9.3. In the Windows Archive General or Directory window, double-click the file name - Inventory Single.htm, this is the file you store in the previous step: Internet Explorer 5 will turn on and display the file ,As shown below:</p> <p>http://jyan.w148.4everdns.com/lycos/xml/images/single.gif</p> <p>Note that from the beginning, until the user starts to click the button, both the Internet Explorer 5 only displays the first record of the file. Other Data Link Technology In the next chapter, you will learn a number of additional techniques for linking the HTML elements of non-format. These techniques may be individual HTML elements used as a single recorded data link, or HTML elements contained in the connected HTML table. In particular, you will learn: How to connect the HTML element to the XML field. How to make the HTML tag in the XML field. How to update XML data in the cache</p> <p>Table 8-1 summarizes important information to use when you study follow-up chartes. Table lists you can be used to perform HTML elements of a single record data link - that is, in addition to all of the Table Elements other than the Table element. The table describes the purpose of each element. Specifies a particular purpose that is coupled to the XML field element, whether or not the element can be implemented in the HTML volume label included in the XML field connected to the element, and display the content of the elements to update the content of the XML field. . This information is not much more significant before you study the next chapter, and you will provide you with reference. Table 8-1.</p> <p>The connected HTML element (does not include a Table element). Form: http://jyan.w148.4everdns.com/lycos/xml/linkenable.htm</p> <p>As you can see, when you connect the SPAN element to the XML field, the element simply displays the contents of the field. This is because the SPAN element's InnerText property - is responsible for setting the element to which the element is to be displayed - is connected to the XML field.</p> <p>Note ---- In DHTML, each HTML element has a set of properties that you can use to set or read elements different characteristics through the Script program. Internet Explorer 5 has support DHTML. At the same time, as explained in this section, the attribute will automatically be set from the value of the XML field it connects. However, Table 8-1 shows the use of some can be coupled HTML elements, and other properties are connected to the XML field. Note that a SPAN element is actually connected to its InnerText and Inner-HTML properties. The Innertext property sets or acquires text content in the element, but does not contain an HTML tag. The Inner-HTML property is the entire content of the setting or acquisition element, containing any HTML tag.</p> <p>For example, using a connection A (anchor) element (anchor, it is used to create a hyperlink), the HREF attribute is connected to the XML field, as shown below:</p> <p><a datasrc="#dsoinventory" DataFld="reviews"> Click Here for Reviews </A></p> <p>This property is like the HREF attribute of the element, which is responsible for setting the destination URL of the hyperlink. Therefore, the destination URL of the coupled A element is derived from the XML field (the REVIEWS XML field in the examples must of course be a complete URL), not its text content.</p> <p>In another example, the CHECKED Properties - Check Attributes Responsible for changing the elements - the XML field is ligated to the XML field, as shown below: <input type = "Checkbox" DataSRC = "# dsoinventory" DataFld = "Instock"></p> <p>If the Instock XML field is empty, or it contains text "0" or "false", the check square will be cleared. If it contains any other text, the check square will be selected.</p> <p>In the last example, the IMG (image) element is used, the SRC property is connected to the XML field. This property, like the Element's SRC element, indicates the URL that contains the graphics data file. Listing 8-10 and 8-11 describe the skills of connecting IMG elements. (You can find it in the inventory image.xml file with the book CD and the Inventory Image Table.htm file.)</p> <p>Inventory image.xml --------------------- <? XML Version = "1.0"?> <! - file name: inventory.xml -> < Inventory> <book> <CoverImage> Leaves.bmp </ coverImage> <title> Leaves of grass </ title> <author> Walt Whitman </ author> <binding> hardcover </ binding> <pages> 462 </ pages> <Price> $ 7.75 </ price> </ book> <book> <coverImage> Legend.bmp </ coverImage> <title> The legend of sleepy hollow </ title> <author> Washington Irving </ author> <binding> mass Market Paperback </ Binding> <Pages> 98 </ pageES> <price> $ 2.95 <book> <coverImage> moby.bmp </ coverImage> <title> moby-dick </ title> < Author> Herman Melville </ author> <binding> Hardcover </ binding> <pages> 724 </ pages> <price> $ 9.95 </ price> </ book> </ inventory> List 8-10.</p> <p>Inventory Image Table.htm -----------------------------! - File Name: Inventory Image Table.htm -> <HTML > <Head> <title> book inventory </ title> </ head> <body> <xml id = "dsoinventory" src = "inventory means.xml"> </ xml> <h2> book inventory </ h2> < Table DatasRC = "# dsoinventory" border = "1" cellpadding = "5"> <TH> <TH> Cover </ th> <th> title </ tH> <TH> Author </ th> <TH> Binding < / TH> <TH> Pages </ TH> <TH> Price </ TH> </ THEAD> <TR align = "center"> <td> <img datafld = "coverImage> </ td> <td> < Span datafld = "title" style = "font-style: italic"> </ span> </ td> <td> <span datafld = "author> <span> </ td> <td> <span datafld = "Binding"> </ span> </ td> <td> <span datafld = "pages"> </ span> </ td> <td> <span datafld = "price"> </ span> </ td> </ TR> </ Table> </ body> </ html> List 8-11. Listing 8-10 is an XML file that contains a field named Cover-Image in each Book record. Each Cover-Image field contains a URL that stores a book cover graphical file. Listing 8-11 is the same HTML web page as list 8-2, except that the starting portion of each column is more than one column (TD element), which contains an IMG element instead of the span element. The IMG element is coupled to the CoverImage field in the XML file, so it displays the image of each book cover, as shown in the following figure:</p> <p>http://jyan.w148.4everdns.com/lycos/xml/images/8-10.gif</p> <p>You can take a part of the other HTML elements in Table 8-1 to learn how to connect these elements, and how the elements use data in the XML field when you connect these properties. Performance HTML According to the preset, if the character data of the XML field happens to include the HTML volume label, the HTML element linking to this field will handle these volumes with Literal text. Type. For example, consider the following SAPN elements, they are connected to the Author-BIO field:</p> <p><Span datasrc = "# dsoinventory" datafld = "author-bio"> </ span></p> <p>If the Author-BIO field contains a bevel word (i) element, it is like this:</p> <p><Author-bio> Henry James Was An American Author Who Lived from 1843to 1916, And Wrote <i> The Bostonians <i> and many Other Works ofpsychologically realistic fiction. </ Author-bio></p> <p>The span element will treat the characters of the HTML volume as a literal text and the display field is as follows:</p> <p>Use some canable HTML elements such as SPAN. You can set the value of the DataFormatas property to "HTML" to drive the browser to process the HTML volume label in the field text, not just regarded it as a Litral character. For example, suppose you will define the previously displayed sample SPAN elements:</p> <p><Span datasrc = "# dsoinventory" datafld = "author-bio" dataformata = "html"> </ span></p> <p>It will then put the text within the I element to berterally arranged, as shown below:</p> <p>Note ------ To DataFormatas Set the default value "Text", which simply omits the same effect, which makes the HTML volume labeled characters are treated as Litral text. To find out which elements are you can use to schedule HTML through the attribute settings of Data-Formatas = "HTML", see Table 8-1. These elements are "YES" in the penultimate field (marked as "HTML" included in the XML field). Especially useful when adding to the format of the HTML for modifying the text section (for example, using I or B element) in the XML field (for example, using i or b), and the HTML element such as hyperlinks or images is particularly useful. Although XML text violates the basic principles of separation data and format arrangements by using the HTML tag in XML, this tip may be a modified format or the only feasible in the field of HTML elements in the field. Methods. (Conversely, if you use this book to display the other ways of XML, by including the brackets and appropriately handle them, you can modify the format or add the elements to the XML element.) When you join the HTML tag to When you are in the XML field, you cannot add (<) or (&) symbols to the text. (Memories, these characters are inelastic in the character data of the elements.) However, you can use the pre-defined entity to refer to "& lt;" and "& amp;", add them to the text. Another option will make HTML more readable and is particularly useful to the HTML of the large block, and the method is to include the label in the CDATA section, as discussed in Chapter 4. Updating the XML data XML DSO in the Complete Buffer Save allows you to modify XML data in several ways. However, before you extremely excited for this possibility, remember that these techniques only modified the DSO to temporarily get a copy of XML data in memory, not the original XML file on the server. Unless you use a quite complex technique to change files on the original server (this has exceeded the scope of this book), the utility of XML data on the cache is limited, and here I just simply be introduced. By connecting the modified HTML element to a specific XML field, you can make the user to modify the XML field, such as the INPUT element of the Text type. The top right representative in Table 8-1 allows the user to modify the HTML element of the XML field that is coupled to the element.</p> <p>For example, if you connect the INPUT element of the Text type to the Title field, not the SPAN element to the title field, as shown below, but the user can also browse the contents of the title element, but also edit its content:</p> <p><Input Type = "Text" DataSRC = "# dsoinventory" DataFld = "title"> At the same time, the DSO's Recordset member object provides a way to add or remove the entire record from the recordset on the cache, and cancel the pair Record the modification of the set. Note that at the last line call example assumes that the HTML web page contains an XMLData island, its ID is DSOINVENTORY.</p> <p>DSO record set method</p> <p>Impact call example</p> <p>AddNew</p> <p>Add a new record to a quick record set in dsoinventory.recordset.addNew ()</p> <p>DELETE removes the current record from the quick record set concentrated DSOINVENTORY.RecordSet.delete ()</p> <p>Cancelupdate reserves the modifications made to the current record, or cancel the new records to remove DSOINVENTORY.Recordset.cancelupdate () Use DTD and Data Links</p> <p>So far, every sample file you have seen in this chapter has a format correct XML file, which does not contain file type declaration (DTD). However, if you are using a data link to display an XML file, contain DTD and make sure that the file is valid. When you define the element of the file, you will help you ensure that you meet the requirements of the symmetric recordset. DTD also helps ensure that the DSO property is applied from the elements in the file to properly build its cache recordset. Contains DTDs are especially useful for having a more complex hierarchy record structure, you can be displayed in the nest. The file in Listing 8-5 is such an example. In the following exercises, you will add a DTD to the file to make the file valid and make sure the file is in line with the record structure required by the data link. Note that if you contain any valid errors in the XML file displayed by the data link, the information will not be displayed in the connected element, but you will not see any error messages. To view any wrong auxiliary narrative in the connected XML file, use the validity of the XML file in Chapter 9 to check the validity and formatting correctness check Script to test files.</p> <p>caveat</p> <p>When you make a declaration of an element (such as the Category or Book element in Listing 8-12), you must include a content model that explicitly lists all recorded fields and neo records. You can't use the ANY content rules, which will cause the data link to fail.</p> <p>Establish an effective XML file for the data link</p> <p>1. In the text editor, open the inventory hierarchy.xml file you established earlier this chapter. (You can find this file with the list 8-5 and the following book CD.)</p> <p>2. On the component of the file, enter the following file type announcement:</p> <p>3. [DOCTYPE INVENTORY4 "[5. <! Element Inventory (Category *)> 6. <! Element Category (CatName, Book *)> 7. <! Element catname (#pcdata)> 8. <! Element book Title, Author, Binding, Pages, Price> 9. <! Element Author (#pcdata)> 11. <! Element Binding (#pcdata)> 12. <! Element Pages (#Pcdata)> 13. <! Element Price (#pcdata)> 14.]></p> <p>These elements can be explained that the language of the record set and the data link is as follows:</p> <p>o <! Element Inventory (Category *)> file contains zero or multiple Category records. O <! Element Category (CATNAME, BOOK *)> Each Category record contains a category field, followed by zero or multiple nest Book records. O <! Element Book (Title, Author, Binding, Pages, Price "> Each nest Book record contains only one of the following backfields, in accordance with the order is Title, Author, Binding, Pages and Price. o <! Element Title (#pcdata)> and the rest of the announcement. The fields in each Book record contain only character data. 15. To reflect the file name to set, the annotation of the file started from <! - file name: inventory hierarchy.xml -></p> <p>Change to:</p> <p><! - file name: inventory hierarchy valid.xml -></p> <p>16. Save the new file instruction using the text editor to store the modified file in Inventory</p> <p>Hierarchy Valid.xml. A complete XML file is displayed in Listing 8-12. (You can find it in the Inventory Hierarchy Valid.xml file with the book CD.)</p> <p>Inventory hierarchy valid.xml ---------------------------- <? XML Version = "1.0"?> <! - file name: Inventory hierarchy valid.xml -> <! Doctype inventory [<! Element category (catname, book *)> <! Element catname (#pcdata)> <! Element Book (Title, Author , Binding, Pages, Price)> <! Element author (#pcdata)> <! Element binding (#pcdata)> <! Element pages (#pcdata)> <! Element price PCDATA)>]> <Inventory> <category> <catname> Middle Ages </ catname> <book> <title> the canterbury tales </ title> <author> geoffrey chaucer </ author> <binding> hardcover </ binding> <Price> $ 18.95 </ pages> <price> $ 18.95 </ price> </ book> <book> <title> Piers Plowman </ title> <author> William Langland </ author> <binding> trade Paperback </ binding> <Price> $ 10.95 </ pages> <price> $ 10.95 </ price> <category> <catname> Renaissance </ catname> <book> <title> The blazing world </ title> <authoror > Margaret Cavendish </ author> <binding> Trade Paperback </ binding> <pages> 225 </ pages> <price> $ 8.79 </ price> </ book> <book> <title> Oroonoko </ tit Le> <author> Aphra Behn </ author> <binding> mass marketpaperback </ binding> <price> $ 4.95 </ price> </ book> <book> <title> Doctor Faustus </ Title> <author> Christopher Marlowe </ author> <binding> hardcover </ binding> <pages> 472 </ pageES> <price> $ 15.95 </ price> </ book></p> <p></ Category> <category> <catname> 18th Century </ catname> <book> <title> gulliver's travels </ title> <author> jonathan swift </ author> <binding> hardcover </ binding> <Pages> 324 < /PageS>< Priced (Prica) $ 11.89<<<Title: Afoundling </ title> <author> Henry Fielding </ author> <binding> hardcover </ binding> < Pages> 438 </ pages> <Price> $ 16.95 </ price> </ book> <book> <title> love in excessed </ title> <author> eliza haywood </ author> <binding> trade paperback </ binding> <Price> $ 12.95 </ pages> <price> $ 12.95 </ price> <book> <book> <title> Tristram shandy </ title> <author> laurence sterne </ author> <binding> hardcover </ binding> < Pages> 322 </ pages> <Price> $ 9.49 </ price> </ book> <catname> 19th Century </ catname> <book> <title> Dracula </ title> <author> bram Stoker </ author> <binding> Hardcover </ binding> <pages> 395 </ pages> <price> $ 17.95 </ price> </ book> <book> <title> Great Expectations </ title> <author> Charles Dickens </ Author> <binding> mass marketpaperback </ binding> <pages> 639 </ piece> <price> $ 6.95 </ price> </ book> <book> <title> Perciva l Keene </ title> <author> Frederick marryat </ author> <binding> trade paperback </ binding> <pages> 425 </ pages> <price> $ 12.89 </ price> </ book> <book> <title> Treasure Island </ Title> <</p> <p>Author> Robert Louis Stevenson </ Author> <Binding> Trade Paperback </ binding> <pages> 283 </ pages> <price> $ 11.85 </ price> </ book> <book> <title> wuthering heights </ title> <Author> Emily Bronte </ author> <binding> Hardcover </ binding> <pages> 424 </ pages> <price> $ 12.95 </ price> </ book> </ category> </ inventory> List 8-12.17. In the text editor, open the Inventory Hierarchy.htm file created earlier in this chapter. (You can find it in the book CD and list 8-6.)</p> <p>18. Change the SRC property of the web data island, so that it is connected to the new XML file you just established. That is to say, put it from</p> <p><Xml id = "dsoinventory" src = "inventory hierarchy.xml"> </ xml></p> <p>Change to:</p> <p><XML ID = "DSOINVENTORY" src = "inventory hierarchyvalid.xml"> </ xml></p> <p>19. To reflect that you will set the new file name, the annotation of the web start part from</p> <p><! - file name: inventory hierarchy.htm -> change:</p> <p><! - file name: inventory hierarchy valid.htm -></p> <p>20. Save the new file instruction using the text editor to store the modified web page as the InventoryHierarchy Valid.htm file. Listing 8-13 shows a complete HTML page. (You can find it in the Inventory Hierarchyvalid.htm file with the book CD.)</p> <p>Inventory hierarchy valid.htm --------------------------------- <! - file name: inventory hierarchy valid.htm -> <html> <head> <title> Inventory of classic english literature </ title> </ head> <body> <xml id = "dsoinventory" src = "inventory hierarchyvalid.xml> </ xml> <TABLE Datasrc = "# dsoinventory" border = "1"> <THEAD> <TH> Classic English LITERATURE </ TH> </ THEAD> <TR> <TD> <spandatafld = "catname"> </ span> </ td> </ Tr> <tr> <TD> <Table DatasRC = "# dsoinventory" datafld = "book" border = 0Cellspacing = 10> <THEAD> <THOR TITLE </ TH> <TH> Author </ th> <TH > Binding </ th> <TH> Pages </ TH> <TH> Price </ TH> <TR align = "center"> <td> <spandatafld = "Title" style = "font-style: Italic "> </ span> </ td> <td> <spandatafld =" author "> </ span> </ td> <td> <spandatafld =" binding "> </ span> </ td> <td> <Spandatafld = "pages"> </ span> </ td> <td> <spandatafld = "price"> </ span> </ td> </ tr> </ table> </ td> </ tr> < / Table> </ body> </ html> List 8-13.21. This page is turned on in Internet Explorer 5. It looks like this:</p> <p>http://jyan.w148.4everdns.com/lycos/xml/images/8-13.gif</p> <p>22. If the file does not appear, the file must be an error in the correctness or validity of the format. To find out the error, use the validity of the validity of the XML file in Chapter 9 to check the Script. Connect HTML elements to XML properties</p> <p>As of now, the XML file exemplary you have seen so far does not include the property. Although you can connect to an element that contains attributes, it is connected to the attribute itself, but attributes make the data link more complicated. When you use the data link, the property is in nature is processed as a child element. With the Record element, this processing method makes the access properties easier (or ignore only it). For example, the following book elements include a list of instock properties: <book instock = "yes"> <title> The Adventures of Huckleberry Finn </ title> <author> Mark Twain </ author> <binding> mass market paperback < /BINDINGS (PAGES )298</PageES>< Priced $ 5.49</price> </ book></p> <p>This record will be processed, like the instock attribute is a field belonging to the Book, and the value of instock is the content of the field. That is, Book will be seen to have the following structure:</p> <p><Book> <Instock> Yes </ Instock> <title> The Adventures of Huckleberry Finn </ title> <author> Mark Twain </ author> <binding> mass market paperback </ binding> <pages> 298 </ pages> <Price> $ 5.49 </ price> </ book></p> <p>So you can use ordinary data link tips to access the value of the property. For example, the following SPAN elements are connected to the attribute and display the value of the attribute:</p> <p><Span datasrc = "# dsoinventory" datafld = "instock"> </ span></p> <p>(This example assumes that the XML file is connected to the web page through a Data Island named DSoinventory.) However, think about it, add the property to the field elements in the XML file -, for example, add the property to the Author field, such as the following example Show:</p> <p><Book> <title> The Adventures of HuckleBerry Finn </ title> <author born = "1835"> Mark Twain </ author> <binding> mass market paperback </ binding> <pages> 298 </ pages> <price> $ 5.49 </ price> </ book></p> <p>In the data link, the Author element will be interpreted as this:</p> <p><Author> <born> 1835 </ born> Mark TWAIN </ author></p> <p>As a result, DSO will store the element in a nest-like type, rather than in a field. (Memolive Fields can only contain character data, and no sub-elements.) Therefore, the recordset will become a class-type recordset, not a simple normal recordset, and you must use a nest form to display The nest information inside, as this chapter is introduced in this chapter <Using a nest form to display the class record set>. However, you need more things, so that you can display attributes of character data (Mark TWAIN) with neo-recorded properties: DSO uses special name $ text to refer to all character data in the element, not to use the attribute value. The way. Therefore, IE5 will explain the Author element to this: <author> <born> 1835 </ born> <$ text> Mark TWAIN </ $ text> </ author></p> <p>You can use $ TEXT as a field name to link the table's bar to the contents of Author element character data. Listing 8-14 contains an HTML web page that shows all techniques described in this section. (You can find it in the Inventory Attribute.htm file with the book CD.) This web page shows the XML file: Inven-Tory Valid.xml (you can find the file in the list 5-1 in the book CD).</p> <p>Inventory Attribute.htm --------------------------- <! - file name: inventory attribute.htm -> <html> <head> <Title> book inventory </ title> </ head> <body> <xml id = "dsoinventory" src = "inventory valid.xml"> </ xml> <h2> book inventory </ h2> <table datarc = #dsoinventory "Border =" 1 "Cellpadding =" 5 "> <TH> <THOR </ TH> <TH> Author </ th> <tH> Binding </ TH> <TH> Pages </ TH> < TH> Price </ TH> <TH> IN stock? </ Th> <TR align = "center"> <TD> <Table DataSRC = "# dsoinventory" datafld = "title"> <tr> < TD> <spandatafld = "$ text"> </ span> </ td> </ tr> </ table> </ td> <TD> <Table DataSRC = "# DSOINVENTORY" DataFld = "Author"> <TR> <TD> <spandatafld = "$ text"> </ span> </ td> <td> <spandatafld = "born"> </ span> </ td> </ tr> </ table> </ td> < TD> <span datafld = "binding"> </ span> </ td> <td> <span datafld = "pages"> </ span> </ td> <td> <span datafld = "price"> </ Span> </ td> <td> <span datafld = "instock"> </ span> </ td> </ tr> </ table> </ body> </ html> list 8-14. Below is Internet Explorer 5 Show list 8-14 looks like:</p> <p>Http://jyan.w148.4everdns.com/lycos/xml/images/8-14.gif</p> <p>In this web page, the last line of the external table is simply connected to the SAPN element by simply connecting the INSTOCK attribute of the BOOK, showing the contents of the instock attribute:</p> <p><TD> <span datafld = "instock"> </ span> </ td> Because the author child element of the BOOK element contains an attribute (Born), this property is treated as a nest, not a field, so The web page is the content of the properties using the nest form:</p> <p><TD> <Table DataSRC = "# dsoinventory" DataFld = "Author"> <Tr> <TD> <span datafld = "$ text"> </ span> </ td> <td> <span datafld = "born" > </ Span> </ td> </ tr> </ table> </ td></p> <p>Special Name $ TEXT Refer to all text within the Author element, but does not contain attribute values. This text is composed of author name (for example, Mark TWAIN). Note that because the Title element in the Book can include a subtitle, which is also considered a nest record, not a field, and must also use a nest form to display:</p> <p><TD> <Table DataSRC = "# dsoinventory" DataFld = "title"> <tr> <td> <span datafld = "$ text"> </ span> </ td> </ tr> </ table> </ TD></p> <p>Here, $ text is used to display all of the recorded character data. (There is no way to display only the text of the title instead of the subtitle.) Use Script and DSO this chapter to make a summary of a more complex Script sample. This Script operates with DSO to operate with the records of the associated XML file. This example Script uses the method of the Recordset object of the DSO to search for books in the inventory big.xml file. (You can find this file with the list 8-3.) Used to search for technology with the XML file, only the XML file consisting of simple records is appropriate. (For information on the simple record set, see this chapter. This chapter uses the individual HTML tables to display simple record sets.)</p> <p>prompt-----</p> <p>You will see more Script files in Chapter 19. Script in this chapter uses a completely different program object (XML file object model), allowing you to use any type of XML file, not just those XML files constructed with record set. Listing 8-15 Generate an HTML web page containing example Script. You can find it in the Inventory Find.htm file in the book CD.</p> <p>Inventory Find.htm --------------------- <! - file name: inventory find.htm -> <html> <head> <title> book find < / Title> </ head> <body> <XML ID = "DSOINVENTORY" src = "inventory big.xml"> </ xml> <h2> Find A Book </ h2> title text: <input type = "text" ID = "Searchtext"> <Button OnClick = 'FindBooks ()> search </ button> <hr> results: <p> <div id = resultdiv> </ div> <script language = "javascript"> Function Findbooks ) {Search.Value.touppercase (); if (searchString == ") {resultdiv.innerhtml =" <You Must Entext INTO " " 'title text'box ..> "; return;} DSoinVentory.Recordset .moveFirst (); ResultHTML = ""; while (! dsoInventory.recordset.EOF) {titleString = dsoInventory.recordset ( "TITLE") value;. if (. TitleString.toUpperCase () indexOf (SearchString)> = 0) ResultHTML = "<I>" DSOINVENTORY.Recordset ("Title" "</ i>," "<b>" DSoinventory.Recordset ("Author") "</ b>," DSoinventory. Recordset ("Binding") "," DSOINVENTORY.Recordset ("Pages") "Pages," DSOINVENTORY.Recordset ("Price") "<p>"; dsoinventory.Recordset.Movenext ();} If (resulthtml == ")") Resu LTDIV.INNNERHTML = "<no books found>"; Elseresultdiv.innerhtml = Resulthtml;} </ script> </ body> </ html> list 8-15. This HTML page shows the INPUT element of the text type, letting Enter the text of a group to search for:</p> <p><Input Type = "Text" ID = "SearchText"></p> <p>This page also shows a button element that is "Search": <Button OnClick = 'FindBooks ()> Search </ Button></p> <p>When the user selects the button, the Script Funel FindBooks will be called, responsible for removing the text to be searched from the input element, searching for all Book records in the XML file, if the title is compliant, then the compliant book record is displayed, as follows Down:</p> <p>http://jyan.w148.4everdns.com/lycos/xml/images/8-15.gif</p> <p>Script Funken FindBooks is included in its proprietary script element, using JScript to write:</p> <p><SCRIPT LANGUAGE = "javascript"> function FindBooks () {SearchString = SearchText.value.toUpperCase (); if (SearchString == "") {ResultDiv.innerHTML = "<You must enter text into" " 'Title text' box ..> "; return;} dsoInventory.recordset.moveFirst (); ResultHTML =" "; while (! dsoInventory.recordset.EOF) {titleString = dsoInventory.recordset (" TITLE ") value;. if (TitleString.toUpperCase () .indexof (SearchString)> = 0) Resulthtml = "<i>" DSOINVENTORY.Recordset ("Title" "</ i>," "<b>" DSOINVENTORY.Recordset ("author" ) "</ B>," DSOINVENTORY.Recordset ("Binding") ", DSOINVENTORY.Recordset (" Pages ") " Pages, " DSOINVENTORY.Recordset (" Price ") <P > "; DSOINVENTORY.Recordset.movenext ();} if (resulthtml ==") Resultdiv.innerHTML = "<no books found>"; elseresultdiv.innerhtml = Resulthtml;} </ script></p> <p>Tip ------ JScript is a Microsoft version of the JavaScript program language. (In the Script block of the example, the language property provides the name of the general program language.) You will be able to click on the website http://msdn.microsoft.com/Workshop/c-frame.htm#/workshop/languages/ Jscript / handling.asp is found in http://msdn.microsoft.com/ scripting / default/default.htm, finds JScript complete information, including guidelines made by beginners. These two websites are provided by MSDN. The Findbooks in the Findbooks are started with the current input input INPUT element (its ID SearchText), followed by using JScript Version TouPpercase to convert text into capital letters. (FindBooks convert all the words into larger, making the search "There is no case in size.)</p> <p>SearchString = SearchText.Value.touppercase ();</p> <p>If the user does not enter anything in the input element, the function will display an error message and exit execution:</p> <p>IF (SearchString == "") {resultdiv.innerhtml = "<You Must Enter Text Into" "'Title Text' Box ..>"; Return;</p> <p>Resultdiv is the ID of the DIV element at the bottom of the web, responsible for displaying the search results. Specifying text (which can contain HTML volumes) for divines will result in DIV display (and execute it HTML tag). The letter will then make the first XML file a current record, using the RecordSet.MoveFirst method you have seen before:</p> <p>DSoinVentory.Recordset.movefirst ();</p> <p>Next it will set the html string variable used to store the search result (Resulthtml) to set a blank:</p> <p>Resulthtml = "";</p> <p>Now FindBooks will enter the loop to browse all records in the XML file. When the end of the file is reached, it uses the recordset.eof property to stop the loop, and use RecordSet.Movenext to move in each new record:</p> <p>While (! dsoinventory.recordset.eof) {Titlestring = DSOINVENTORY.Recordset ("Title"). Value; IF (Titlestring.touppercase (). Indexof (SearchString)> = 0) ResultHtml = "<i>" DSoinventory. Recordset ("Title" "</ i>," "<b>" DSOINVENTORY.Recordset ("Author") "</ b>," DSOINVENTORY.Recordset ("Binding") "," DSOINVENTORY.Recordset ("Pages") "Pages," DSOINVENTORY.Recordset ("Price") "<p>"; dsoinventory.recordset.movenext ();} The loop will first get the current recorded title field. value:</p> <p>Titlestring = DSOINVENTORY.Recordset ("Title"). Value;</p> <p>The expression on the right side is a speed diak method for the field of the Fields property of the Recordset object. Here is a complete approach:</p> <p>Titlestring = DSOINVENTORY.RecordSet.fields ("Title"). Value;</p> <p>The Fields property contains a collection of all fields that are currently recorded. You can access a specific field by placing the name of the field in the parameter (eg, "Title"), and you can get the content of the field with a string type by an additional value attribute.</p> <p>The loop then uses the JScript Function INDEXOF to determine whether the current record title contains the text to search. If you find the text you want to search, the program in the IF command will put the text in the Resulthtml string with the necessary HTML volume label to display the current record:</p> <p>IF (Titlestring.touppercase (). Indexof (SearchString)> = 0) ResultHtml = "<i>" DSoinVentory.Recordset ("Title" </ i>, " " <b> " DSoinventory. Recordset ("Author") "</ b>," DSOINVENTORY.Recordset ("Binding") "," DSOINVENTORY.Recordset ("Pages") "Pages," DSOINVENTORY.Recordset ("Price" ) "<P>";</p> <p>One, the cycle ends, the function will attach the HTML volume label containing the search result to the INNERHTML attribute of the DIV element, this element is located in the body element used to display the search result web page (the Div element recognition code to resultDIV) :</p> <p>If (resulthtml == ") Resultdiv.innerhtml =" <no books found> "; elseResultdiv.innerhtml = Resulthtml; DIV element will immediately perform HTML volume label and display the results.</p></div><div class="text-center mt-3 text-grey"> 转载请注明原文地址:https://www.9cbs.com/read-92717.html</div><div class="plugin d-flex justify-content-center mt-3"></div><hr><div class="row"><div class="col-lg-12 text-muted mt-2"><i class="icon-tags mr-2"></i><span class="badge border border-secondary mr-2"><h2 class="h6 mb-0 small"><a class="text-secondary" href="tag-2.html">9cbs</a></h2></span></div></div></div></div><div class="card card-postlist border-white shadow"><div class="card-body"><div class="card-title"><div class="d-flex justify-content-between"><div><b>New Post</b>(<span class="posts">0</span>) </div><div></div></div></div><ul class="postlist list-unstyled"> </ul></div></div><div class="d-none threadlist"><input type="checkbox" name="modtid" value="92717" checked /></div></div></div></div></div><footer class="text-muted small bg-dark py-4 mt-3" id="footer"><div class="container"><div class="row"><div class="col">CopyRight © 2020 All Rights Reserved </div><div class="col text-right">Processed: <b>0.039</b>, SQL: <b>9</b></div></div></div></footer><script src="./lang/en-us/lang.js?2.2.0"></script><script src="view/js/jquery.min.js?2.2.0"></script><script src="view/js/popper.min.js?2.2.0"></script><script src="view/js/bootstrap.min.js?2.2.0"></script><script src="view/js/xiuno.js?2.2.0"></script><script src="view/js/bootstrap-plugin.js?2.2.0"></script><script src="view/js/async.min.js?2.2.0"></script><script src="view/js/form.js?2.2.0"></script><script> var debug = DEBUG = 0; var url_rewrite_on = 1; var url_path = './'; var forumarr = {"1":"Tech"}; var fid = 1; var uid = 0; var gid = 0; xn.options.water_image_url = 'view/img/water-small.png'; </script><script src="view/js/wellcms.js?2.2.0"></script><a class="scroll-to-top rounded" href="javascript:void(0);"><i class="icon-angle-up"></i></a><a class="scroll-to-bottom rounded" href="javascript:void(0);" style="display: inline;"><i class="icon-angle-down"></i></a></body></html><script> var forum_url = 'list-1.html'; var safe_token = 'mzlBVg5fr4VVAV2GCWfuvFE_2BaTZi40IrE7UTSi6OONd_2Bc3tyY5tPzVpXh3Lsu1uPjid8FL_2F0XH_2BAgcBHc1mw_2Bw_3D_3D'; var body = $('body'); body.on('submit', '#form', function() { var jthis = $(this); var jsubmit = jthis.find('#submit'); jthis.reset(); jsubmit.button('loading'); var postdata = jthis.serializeObject(); $.xpost(jthis.attr('action'), postdata, function(code, message) { if(code == 0) { location.reload(); } else { $.alert(message); jsubmit.button('reset'); } }); return false; }); function resize_image() { var jmessagelist = $('div.message'); var first_width = jmessagelist.width(); jmessagelist.each(function() { var jdiv = $(this); var maxwidth = jdiv.attr('isfirst') ? first_width : jdiv.width(); var jmessage_width = Math.min(jdiv.width(), maxwidth); jdiv.find('img, embed, iframe, video').each(function() { var jimg = $(this); var img_width = this.org_width; var img_height = this.org_height; if(!img_width) { var img_width = jimg.attr('width'); var img_height = jimg.attr('height'); this.org_width = img_width; this.org_height = img_height; } if(img_width > jmessage_width) { if(this.tagName == 'IMG') { jimg.width(jmessage_width); jimg.css('height', 'auto'); jimg.css('cursor', 'pointer'); jimg.on('click', function() { }); } else { jimg.width(jmessage_width); var height = (img_height / img_width) * jimg.width(); jimg.height(height); } } }); }); } function resize_table() { $('div.message').each(function() { var jdiv = $(this); jdiv.find('table').addClass('table').wrap('<div class="table-responsive"></div>'); }); } $(function() { resize_image(); resize_table(); $(window).on('resize', resize_image); }); var jmessage = $('#message'); jmessage.on('focus', function() {if(jmessage.t) { clearTimeout(jmessage.t); jmessage.t = null; } jmessage.css('height', '6rem'); }); jmessage.on('blur', function() {jmessage.t = setTimeout(function() { jmessage.css('height', '2.5rem');}, 1000); }); $('#nav li[data-active="fid-1"]').addClass('active'); </script>