ÍøÂçѧԺ w3popÉçÇø ÍøÂç×ÊÔ´ ITÐÂÎÅ

w3pop.com :: ÍøÂçѧԺ :: APPML :: °¸ÀýÑо¿£º²úÆ·

»áÔ±µÇ½

ÕʺÅ

ÃÜÂë

»Ø´ð

¼ÇסÃÜÂë

Íü¼ÇÃÜÂë? ×¢²á

APPML
AppML ¼ò½é
AppML °¸Àý
AppML °¸Àý˵Ã÷
AppML ÍøÂç·þÎñ
°¸ÀýÑо¿¼ò½é
°¸ÀýÑо¿£ºÊý¾Ý¿â
°¸ÀýÑо¿£ºAppML
°¸ÀýÑо¿£ºHTML ±..
°¸ÀýÑо¿£ºHTML ±..
°¸ÀýÑо¿£ºÄ¿Â¼
°¸ÀýÑо¿£º²úÆ·
°¸ÀýÑо¿£ºÍÐÔËÈË
°¸ÀýÑо¿£º¹©Ó¦ÉÌ
°¸ÀýÑо¿£º¿Í»§
°¸ÀýÑо¿£º¹ÍÔ±
°¸ÀýÑо¿£ºÓ¦ÓóÌ..
°¸ÀýÑо¿£ºÏÂÔØ
AppML FAQ
AppML Îĵµ
AppML Êý¾Ý¿âÔªËØ

°¸ÀýÑо¿£º²úÆ·


×÷Õß:w3pop.com ·­Òë/ÕûÀí:w3pop.com ·¢²¼:2007-04-28 ä¯ÀÀ:3723 :: ::

This chapter demonstrates AppML on the Products table in the Northwind database.
ÕâÕ½éÉÜÁËAppMLÔÚNorthwind Êý¾Ý¿âÖвúÆ·±í¸ñµÄÓ¦Óá£


The Products XML File
²úÆ·XMLÎļþ

The "Products" AppML description: northwind/products.xml
“²úÆ·” AppML ÃèÊö£ºnorthwind/products.xml


AppML HTML Report
AppML HTML ±¨¸æ

HTML Report: appml.asp?appname=northwind/products&displaytype=report
HTML ±¨¸æ£ºappml.asp?appname=northwind/products&displaytype=report

The link above runs the AppML HTML report service. To be able to run an AppML HTML report, the AppML description must contain an <htmlreport> tag.
ÉÏÊöÁ´½ÓÔËÐÐÁËAppML HTML ±¨¸æ·þÎñ¡£ÎªÁËÄܹ»ÔËÐÐAppML HTML ±¨¸æ£¬AppMLÃèÊö±ØÐë°üº¬Ò»¸ö<htmlreport>±êÇ©¡£

We see that the report contains a header ("Products"), a table listing the different products along with category, supplier, and quantity per unit. The report also lists the number of records at the bottom. The title and sql selection shown in the report, is taken from the <title> tag (under the <appml> tag) and the <sql> tag inside <htmlreport>. The number of records are automatically added by AppML.
ÎÒÃǶ¼¿´µ½£¬Õâ·Ý±¨¸æ°üº¬ÁËÒ»¸öҳü£¨“²úÆ·”£©£¬Ò»¸ö¸ù¾ÝĿ¼¡¢¹©Ó¦É̺͵¥Î»ÊýÁ¿Áоٲ»Í¬²úÆ·µÄ±í¸ñ¡£±¨¸æ»¹Ôڵײ¿ÁоÙÁ˼ǼµÄÊýÁ¿¡£±¨¸æÖÐչʾµÄ±êÌâ ºÍSQLÑ¡¼¯ÊÇ´Ó<htmlreport>ÄÚ²¿µÄ<title>±êÇ©£¨ÔÚ<appml>֮ϣ©ºÍ< sql>±êÇ©ÌáÈ¡³öÀ´µÄ¡£¼Ç¼ÊýÁ¿Í¨¹ýAppML×Ô¶¯±»Ìí¼ÓµÄ¡£

This report also have a Filter button. If you click on the Filter button, you can filter and sort the report. You can also determine in what format you want to show the report (Normal, Word, Excel, or XML).
Õâ·Ý±¨¸æ»¹°üº¬ÁËÒ»¸ö¹ýÂ˰´Å¥¡£Èç¹ûÄãµã»÷Á˹ýÂ˰´Å¥£¬Äã¾Í¿ÉÒÔ±¨¸æ½øÐйýÂ˺ͷÖÀà¡£ÄãͬÑù¿ÉÒÔ¶¨Ò屨¸æÏÔʾµÄ¸ñʽ£¨Õý³£¡¢Word¡¢Excel »ò XML£©¡£

The <filters> tag in "products.xml" looks like this:
“products.xml” ÖеÄ<filters>±êÇ©ÏÔʾÈçÏ£º

<filters>
<orderby>products.productname</orderby>
<query>
<field>productname</field>
<label>Product name</label>
</query>
<query>
<field>suppliers.companyname</field>
<label>Supplier</label>
<sql>SELECT DISTINCT companyname
FROM suppliers ORDER BY companyname</sql>
</query>
<query>
<field>categories.categoryname</field>
<label>Category</label>
<sql>SELECT DISTINCT categoryname
FROM categories ORDER BY categoryname</sql>
</query>
<orderselect>
<field name="products.productname">Product Name</field>
<field name="suppliers.companyname">Supplier</field>
<field name="categories.categoryname">Category</field>
</orderselect>
</filters>

We see that the <filters> tag contains an <orderby> tag, several <query> tags, and an <orderselect> tag.
ÎÒÃÇ¿´µ½£¬<filters>±êÇ©°üº¬ÁËÒ»¸ö<orderby>±êÇ©¡¢²¿·Ö<query>±êÇ©ºÍÒ»¸ö<orderselect>±êÇ©¡£

The <orderby> tag specifies which field the report should be ordered by. In this case, the report will be ordered by the productname field in the Products table.
<orderby>±êǩָ¶¨Á˱¨¸æ¸ÃÒÔʲô×Ô¶¯Îª»ù×¼½øÐÐÅÅÐò¡£ÔÚÕâ¸ö°¸ÀýÖУ¬¸Ã±¨¸æ½«Í¨¹ý²úÆ·±í¸ñÖеIJúÆ·Ãû³Æ×ֶνøÐÐÅÅÐò¡£

The <query> tags defines which fields the user can search on. The <field> tag defines the name of the field in the table, and the <label> tag defines the label that will be visible for the user. In this case, the user can search on "Product name", "Supplier", and "Category".
<query>±êÇ©¶¨ÒåÁËÓû§¿ÉÒÔ¸ù¾Ýʲô×ֶνøÐÐËÑË÷¡£<field>±êÇ©¶¨ÒåÁ˱í¸ñÖеÄ×Ö¶ÎÃû³Æ£¬<label>±êÇ©¶¨ÒåÁ˱êÇ©¶ÔÓÚÓû§À´ËµÊÇ·ñ¿ÉÊÓ¡£

Inside the "Supplier" and "Category" <query> tag, there is an <sql> tag. The <sql> tag indicates that AppML should create a drop-down box where the user can select an existing supplier and/or category to search on.
ÔÚ“¹©Ó¦ÉÌ” ºÍ “Ŀ¼” <query>±êÇ©ÄÚ²¿°üº¬ÁËÒ»¸ö<sql>±êÇ©¡£<sql>±êǩָʾAppMLÓ¦¸ÃÕë¶ÔÓû§¶ÔÏÖ´æµÄ¹©Ó¦ÉÌ»òĿ¼½øÐÐËÑË÷µÄÐèÒªÀ´´´½¨Ò»¸öÏÂÀ­Áбí¿ò¡£

The <orderselect> tag specifies other order-by options for the user. Here, the user can determine if the report should be ordered by "Product name", "Supplier", or "Category".
<orderselect>±êǩΪÓû§Ö¸¶¨ÁËÆäËüÀàÐ͵ÄÅÅÐòÑ¡Ïî¡£ÕâÀÓû§¿ÉÒÔ¶¨ÒåËüÓ¦¸Ã°´ÕÕ“²úÆ·Ãû³Æ”¡¢“¹©Ó¦ÉÌ” »òÊǓĿ¼”À´½øÐÐÅÅÐò¡£

The <filters> tag is used by both <htmlreport> and <htmllist>.
<filters>±êǩͨ¹ý<htmlreport>ºÍ<htmllist>½øÐÐʹÓá£


AppML HTML Form
AppML HTML ±íµ¥

HTML Form: appml.asp?appname=northwind/products&displaytype=form
HTML ±íµ¥£ºappml.asp?appname=northwind/products&displaytype=form

The link above runs the AppML form service. To be able to run AppML form, the AppML description must contain an <htmlform> tag. The AppML description must also contain a <maintable> tag and a <keyfield> tag (inside the <database> tag).
ÉÏÊöÁ´½ÓÔËÐÐÁËAppML±íµ¥·þÎñ¡£ÎªÁËÄܹ»ÔËÐÐAppML HTML ±¨¸æ£¬AppMLÃèÊö±ØÐë°üº¬Ò»¸ö<htmlreport>±êÇ©¡£AppMLÃèÊö±ØÐ뻹Ҫ°üº¬Ò»¸ö<maintable>±êÇ©ºÍÒ»¸ö<keyword>±êÇ©£¨Î»ÓÚ<database>±êÇ©ÄÚ²¿£©¡£

The link above takes you to a page with a blank form. Here you can add a new record. AppML automatically adds New, Submit, and Delete buttons.
ÉÏÊöÁ´½Ó¿ÉÒÔʹÄãÖØÐ´ò¿ªÒ»¸öȫеĿհ×Ò³Ãæ¡£Äã¿ÉÒÔÔÚÀïÃæÌí¼ÓȫеļǼ¡£AppML»á×Ô¶¯Ìí¼ÓмǼ°´Å¥¡¢Ìá½»°´Å¥ºÍɾ³ý°´Å¥¡£

This time we have specified the look of the form with standard HTML code. The <htmlform> tag in "products.xml" looks like this:
ÎÒÃÇÒѾ­ÒÀ¾ÝHTML´úÂëµÄ±ê×¼Ö¸¶¨ÁË±íµ¥µÄÍâ¹Û¡£“products.xml”ÖеÄ<htmlform>±êÇ©ÈçÏ£º

<htmlform>
<sql>
SELECT productname,supplierid,categoryid,QuantityperUnit,unitprice,
unitsinstock,unitsonorder,reorderlevel,discontinued
FROM products
</sql>
<form>
<br/>
<table width="40%">
<tr>
<td>
<fieldset>
<legend style="color:darkblue">Product information</legend>
<br/>
<table>
<tr>
<td>Product Name:</td>
<td><input size="40" maxlength="40" id="productname"/></td>
</tr>
<tr>
<td>Supplier:</td>
<td>
<field name="supplierid">
<function name="dbselect">
<sql>SELECT supplierid,companyname FROM suppliers
ORDER BY companyname</sql>
<value>supplierid</value>
<options>companyname</options>
</function>
</field>
</td>
</tr>
<tr>
<td>Category:</td>
<td>
<field name="categoryid">
<function name="dbselect">
<sql>SELECT categoryid,categoryname FROM categories
ORDER BY categoryname</sql>
<value>categoryid</value>
<options>categoryname</options>
</function>
</field>
</td>
</tr>
<tr>
<td>Quantity per Unit:</td>
<td><input size="20" maxlength="20" id="quantityperunit"/></td>
</tr>
<tr>
<td>Price per Unit:</td>
<td><input size="6" maxlength="8" id="unitprice"/></td>
</tr>
<tr>
<td>Units in Stock:</td>
<td><input size="6" maxlength="2" id="unitsinstock"/></td>
</tr>
<tr>
<td>Units on Order:</td>
<td><input size="6" maxlength="2" id="unitsonorder"/></td>
</tr>
<tr>
<td>Reorder Level:</td>
<td><input size="6" maxlength="2" id="reorderlevel"/></td>
</tr>
<tr>
<td>Discontinued:</td>
<td><input type="checkbox" id="discontinued"/></td>
</tr>
</table>
<br/>
</fieldset>
</td>
</tr>
</table>
</form>
</htmlform>

The sql selection for the form is specified in the <sql> tag inside <htmlform>.
¹ØÓÚ±íµ¥µÄsqlÑ¡¼¯±»Ö¸¶¨ÔÚÁË<htmlform>ÖÐ<sql>±êÇ©µÄÄÚ²¿¡£

The look of the input form is specified inside the <form> and </form> tags. Here we use standard HTML (like <table> tags, <fieldset> and <legend>, and <input>).
ÊäÈë±íµ¥µÄÍâ¹Û±»Ö¸¶¨ÔÚÁË<form>±êÇ©ºÍ</form>±êÇ©µÄÄÚ²¿¡£ÔÚÕâÀÎÒÃÇʹÓõÄÊDZê×¼µÄHTML´úÂ루È磺< table>±êÇ©¡¢<fieldset>±êÇ©¡¢<legend>±êÇ©ºÍ<input>±êÇ©£©¡£

Notice that to show the data from a database and to make the data updateable, we set the id attribute of the input tags equal to the fieldnames in our sql selection.
×¢Ò⣺¶ÔÓÚÏÔʾÊý¾Ý¿âÊý¾ÝºÍ¸üÐÂÊý¾ÝÀ´Ëµ£¬ÉèÖÃ<input>±êÇ©ÖеÄidÊôÐÔºÍÉèÖÃsql Ñ¡ÏÖеÄ×Ö¶ÎÃûÊôÐÔµÄЧ¹ûÊÇÒ»ÑùµÄ¡£

Another AppML function is also demonstrated in the <htmlform> above. Twice in the code we have used an AppML function called dbselect. Look at the code fragment below:
ÁíÍâÒ»¸öAppMLº¯ÊýͬÑùÔÚÉÏÊöµÄ<htmlform>ÖÐ×÷³öÁ˽âÊÍ¡£ÔÚ´úÂëÖÐÎÒÃÇÁ½´ÎÓõ½ÁËÃûΪ“dbselect” µÄAppMLº¯Êý¡£Çë¿´ÏÂÃæµÄ´úÂëÆ¬¶Ï£º

<td>Supplier:</td>
<td>
<field name="supplierid">
<function name="dbselect">
<sql>SELECT supplierid,companyname FROM suppliers
ORDER BY companyname</sql>
<value>supplierid</value>
<options>companyname</options>
</function>
</field>
</td>

To use the dbselect function, you must first specify the fields you want to use the function on (in this case "supplierid"). The supplierid field contains a supplier ID that refers to a company name in the "Suppliers" table. The <sql> tag selects the supplierid and the companyname fields from the "Suppliers" table. The <value> tag indicates the value that will be saved in the form (supplierid) and the <options> tag indicates the value displayed (companyname) to the user in the drop-down box. This way, AppML gives us the opportunity to create selectable lists inside our forms.

ΪÁËʹÓÃdbselect º¯Êý£¬ÄãÊ×ÏȱØÐëÖÆ¶¨º¯Êý×÷ÓõÄ×ֶΣ¨¼û“supplierid” ÖеݸÀý£©¡£”supplierid“×Ö¶ÎÖаüº¬Á˹©Ó¦É̵ÄID £¬Í¬Ê±Éæ¼°µ½“¹©Ó¦ÉÌ”±í¸ñÖÐËûËùÔڵĹ«Ë¾Ãû³Æ¡£<value>±êǩָʾµÄÖµ½«±»±£´æÔÚ“supplierid” ±íµ¥ÖУ¬<option>±êǩָʾµÄ£¨ÏÔʾ¹«Ë¾Ãû³ÆµÄ£©Öµ½«³öÏÖÔÚÏÂÀ­¿òÖС£Í¨¹ýÕâ¸ö·½·¨£¬AppML½«ÎªÎÒÃÇÌṩһ¸öÔÚ±íµ¥Öд´½¨¿ÉÑ¡ÁÐ±í µÄ»ú»á¡£


AppML HTML List
AppML HTML Áбí

HTML List: appml.asp?appname=northwind/products&displaytype=list
HTML ÁÐ±í£ºappml.asp?appname=northwind/products&displaytype=list

The link above runs the AppML list service. To be able to run AppML list, the AppML description must contain an <htmllist> tag.
ÉÏÊöÁ´½ÓÔËÐÐÁËAppMLÁбí·þÎñ¡£ÎªÁËÄܹ»´´½¨AppMLÁÐ±í£¬AppMLÃèÊö±ØÐë°üº¬Ò»¸ö<htmllist>±êÇ©¡£

We see that the list contains a header ("Products"), the number of records in the list, a Filter button, a New button, a Report button, and a table listing the different products.
ÎÒÃǶ¼¿´µ½£¬Õâ·Ý±¨¸æ°üº¬ÁËÒ»¸öҳü£¨“Ŀ¼”£©¡¢ÁбíÖеļǼÊý¡¢Ò»¸ö¹ýÂ˰´Å¥¡¢Ò»¸öа´Å¥¡¢Ò»¸ö±¨¸æ°´Å¥ºÍÒ»¸öÂÞÁв»Í¬²úÆ·µÄ±í¸ñ°´Å¥¡£

The title and sql selection shown in the report, is taken from the <title> tag and the <sql> tag inside <htmllist>. The number of records and the buttons are automatically added by AppML.
±¨¸æÖÐչʾµÄ±êÌâºÍSQLÑ¡¼¯ÊÇ´Ó<htmllist>ÄÚ²¿µÄ<title>±êÇ©ºÍ<sql>±êÇ©ÌáÈ¡³öÀ´µÄ¡£¼Ç¼µÄÊýÁ¿ºÍ°´Å¥ÊÇ×Ô¶¯Ìí¼Óµ½AppMLÖеġ£

The Filter button is automatically added because the AppML description contains a <filters> tag.
¹ýÂ˰´Å¥ÊÇ×Ô¶¯Ìí¼ÓµÄ£¬ÒòΪAppMLÃèÊö°üº¬ÁËÒ»¸ö<filters>±êÇ©¡£

The New button is automatically added because the AppML description contains an <htmlform> tag.
Р°´Å¥ÊÇ×Ô¶¯Ìí¼ÓµÄ£¬ÒòΪAppMLÃèÊö°üº¬ÁËÒ»¸ö<htmlreport>±êÇ©¡£

The Report button is automatically added because the AppML description contains an <htmlreport> tag.
±¨¸æ°´Å¥ÊÇ×Ô¶¯Ìí¼ÓµÄ£¬ÒòΪAppMLÃèÊö°üº¬ÁËÒ»¸ö<htmlreport>±êÇ©¡£

The Folder image to the left of each records is automatically added because the AppML description contains an <htmlform> tag. If you click on the Folder image, you will be taken to the AppML form.
ÿÌõ¼Ç¼×ó±ßµÄÎļþ¼ÐͼÏñÊÇ×Ô¶¯Ìí¼ÓµÄ£¬ÒòΪAppMLÃèÊö°üº¬ÁËÒ»¸ö<htmlform>±êÇ©¡£Èç¹ûÄãµã»÷ÁËÎļþ¼ÐͼÏñ£¬Ä㽫»á½øÈëAppML±íµ¥¡£

This list is not an editable list (like Categories in the previous chapter). Here you must edit the data in the form.
Õâ¸öÁÐ±í²¢²»ÊÇÒ»¸ö¿É±à¼­ÁÐ±í£¨ÈçͬǰһÕµÄĿ¼ÁбíÒ»Ñù£©¡£ÔÚÕâÀÎÒÃÇ¿ÉÒԱ༭±íµ¥ÖеÄÊý¾Ý¡£


AppML XML Report
AppML XML ±¨¸æ

XML Report:
appml.asp?appname=northwind/products&displaytype=report&type=xml

XML ±¨¸æ£º
appml.asp?appname=northwind/products&displaytype=report&type=xml

The link above runs the AppML XML service.
ÉÏÊöÁ´½ÓÔËÐÐÁËAppML XML ·þÎñ¡£

The AppML XML report service above will generate an XML report based on the sql defined in the <htmlreport> element. The XML report's root element is <table>. The first element after <table> is <sql>, which lists the sql used in the description. Then there will be one <row> element for each record in the sql. The <row> element contains one element for each field in the sql.

ÉÏÊöµÄAppML XML±¨¸æ·þÎñ½«»á²úÉúÒ»¸ö»ùÓÚÔÚ<htmlreport>ÔªËØÖж¨ÒåµÄsqlÀ´²úÉúÒ»¸öXML±¨¸æ¡£XML±¨¸æµÄ¸ùÔªËØÊÇ< table>¡£ÔÚ<table>Ö®ºóµÄµÚÒ»¸öÔªËØÊÇ<sql>£¬ËüÂÞÁÐÁËÔÚÃèÊöÖÐʹÓõÄsql¡£¶ÔÓÚsqlÖÐÿһÌõ¼Ç¼¶ø ÑÔ£¬¶¼»á°üº¬Ò»¸ö<row>ÔªËØ¡£<row>ÔªËØÎªsqlÖеÄÿÌõ×ֶΰüº¬ÁËÒ»¸öÔªËØ¡£


All AppML Services in One
ËùÓеÄAppML ·þÎñ

To run all the AppML services above in one, use the following link:
appml.asp?appname=northwind/products

Ï£ÍûÔËÐÐÉÏÃæµÄAppML·þÎñ£¬¿ÉÒÔµã»÷ÏÂÃæµÄÁ´½Ó£º
appml.asp?appname=northwind/products


ÆÀÂÛ (0) All