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

w3pop.com :: ÍøÂçѧԺ :: APPML :: °¸ÀýÑо¿£º¹©Ó¦ÉÌ

»áÔ±µÇ½

ÕʺÅ

ÃÜÂë

»Ø´ð

¼ÇסÃÜÂë

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

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

°¸ÀýÑо¿£º¹©Ó¦ÉÌ


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

This chapter demonstrates AppML on the Suppliers table in the Northwind database.
ÕâÕ½²ÊöÁËAppML»ùÓÚNorthwindÊý¾Ý¿âÖй©Ó¦É̱í¸ñµÄÓ¦Óá£


The Suppliers XML File
¹©»õÉÌXMLÎļþ

The "Suppliers" AppML description: northwind/suppliers.xml
“¹©Ó¦ÉÌ”AppMLÃèÊö£ºnorthwind/shippers.xml


AppML HTML Report
AppML HTML ±¨¸æ

HTML Report: appml.asp?appname=northwind/suppliers&displaytype=report
HTML ±¨¸æ£ºappml.asp?appname=northwind/shippers&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 ("Suppliers"), a table listing the different companies along with their contact person, address, city, and country. 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 "suppliers.xml" looks like this:
“suppliers.xml” ÖеÄ<filters>±êÇ©ÏÔʾÈçÏ£º

<filters>
<orderby>Companyname</orderby>
<query>
<field>Companyname</field>
</query>
<query>
<field>City</field>
</query>
<query>
<field>Country</field>
</query>
<orderselect>
<field>Companyname</field>
<field>City</field>
<field>Country</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 companyname field in the Suppliers table.
<orderby>±êǩָ¶¨Á˱¨¸æ¸ÃÒÔʲô×Ö¶ÎΪ»ù×¼½øÐÐÅÅÐò¡£ÔÚÕâ¸ö°¸ÀýÖУ¬¸Ã±¨¸æ½«¹©Ó¦É̱í¸ñÖеĹ«Ë¾Ãû³Æ×ֶνøÐÐÅÅÐò¡£

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 "Companyname", "City", and "Country".
<query>±êÇ©¶¨ÒåÁËÓû§¿ÉÒÔ¸ù¾Ýʲô×ֶνøÐÐËÑË÷¡£<field>±êÇ©¶¨ÒåÁ˱í¸ñÖеÄ×Ö¶ÎÃû³Æ£¬<label>±êÇ©¶¨ÒåÁ˱êÇ©¶ÔÓÚÓû§À´ËµÊÇ·ñ¿ÉÊÓ¡£ÔÚÕâ¸ö°¸ÀýÖУ¬Óû§¿ÉÒÔ¸ù¾Ý “¹«Ë¾Ãû³Æ” ¡¢“³ÇÊД ÒÔ¼° “¹ú¼Ò” ½øÐÐËÑË÷¡£

The <orderselect> tag specifies other order-by options for the user. Here, the user can determine if the report should be ordered by "Companyname", "City", or "Country".
<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/suppliers&displaytype=form
HTML ±íµ¥£ºappml.asp?appname=northwind/suppliers&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ÃèÊö±ØÐë°üº¬Ò»¸ö<htmlform>±êÇ©¡£AppMLÃèÊö±ØÐ뻹Ҫ°üº¬Ò»¸ö<maintable>±êÇ©ºÍ Ò»¸ö<keyfield>±êÇ©£¨Î»ÓÚ<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 "suppliers.xml" looks like this:
ÎÒÃÇÒѾ­ÒÀ¾ÝHTML´úÂëµÄ±ê×¼Ö¸¶¨ÁË±íµ¥µÄÍâ¹Û¡£“suppliers.xml”ÖеÄ<htmlform>±êÇ©ÈçÏ£º

<htmlform>
<sql>
SELECT companyname,contactname,contacttitle,address,city,
region,postalcode,country,phone,fax,homepage
FROM suppliers
</sql>
<elements>
<field name="companyname">
<required/>
</field>
<field name="contactname">
<required/>
</field>
</elements>
<form>
<br/>
<table width="70%">
<tr>
<td>
<fieldset>
<legend style="color:darkblue">Supplier information</legend>
<br/>
<table>
<tr>
<td>Company Name:</td>
<td><input size="35" maxlength="40" id="companyname"/></td>
</tr>
<tr>
<td>Contact Name:</td>
<td><input size="35" maxlength="30" id="contactname"/></td>
</tr>
<tr>
<td>Title:</td>
<td><input size="35" maxlength="30" id="contacttitle"/></td>
</tr>
<tr>
<td>Address:</td>
<td><input size="60" maxlength="60" id="address"/></td>
</tr>
<tr>
<td>City:</td>
<td><input size="15" maxlength="15" id="city"/></td>
</tr>
<tr>
<td>Region:</td>
<td><input size="15" maxlength="15" id="region"/></td>
</tr>
<tr>
<td>Postal Code:</td>
<td><input size="15" maxlength="10" id="postalcode"/></td>
</tr>
<tr>
<td>Country:</td>
<td><input size="15" maxlength="15" id="country"/></td>
</tr>
<tr>
<td>Phone:</td>
<td><input size="24" maxlength="24" id="phone"/></td>
</tr>
<tr>
<td>Fax:</td>
<td><input size="24" maxlength="24" id="fax"/></td>
</tr>
<tr>
<td>HomePage:</td>
<td><input size="100" maxlength="100" id="homepage"/></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 <elements> tag is a container for the data fields in an HTML form or in an editable HTML list that should fulfill special criterions. In the code above, we specify that the fields companyname and contactname are required (cannot be left blank in the form). If a user leave these two fields blank, AppML will generate an error message telling that the fields have to be filled with data.
<element>±êÇ©ÊÇHTML±íµ¥»ò¿É±à¼­µÄHTMLÁÐ±í£¨ÕâЩÁÐ±í±ØÐë×ñÑ­Ò»¶¨µÄ¹æ·¶£©ÖеÄÊý¾Ý×Ö¶ÎÈÝÆ÷¡£ÔÚÉÏÊö´úÂëÖУ¬ÎÒÃÇÖ¸³ö“¹«Ë¾Ãû³Æ” ×ֶκ͓ÁªÏµÃû³Æ” ×Ö¶ÎÊDZØÒªµÄ£¨²»¿ÉÒÔÔÚ±íµ¥ÖÐÒÔ¿Õ°×ÏÔʾ£©¡£Èç¹ûÒ»¸öÓû§¶ÔÕâÁ½¸ö×Ö¶ÎÁôÒÔ¿Õ°×£¬AppML½«²úÉú´íÎóÐÅÏ¢£¬²¢ÌáʾÄãÌîÂú±í¸ñ¡£

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 Ñ¡ÏÖеÄ×Ö¶ÎÃûÊôÐÔµÄЧ¹ûÊÇÒ»ÑùµÄ¡£


AppML HTML List
AppML HTML Áбí

HTML List: appml.asp?appname=northwind/suppliers&displaytype=list
HTMLÁÐ±í£ºappml.asp?appname=northwind/suppliers&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 ("Suppliers"), the number of records in the list, a Filter button, a New button, a Report button, and a table listing the different shippers.
ÎÒÃǶ¼¿´µ½£¬Õâ·Ý±¨¸æ°üº¬ÁËÒ»¸öҳü£¨“¹©Ó¦ÉÌ”£©¡¢ÁбíÖеļǼÊý¡¢Ò»¸ö¹ýÂ˰´Å¥¡¢Ò»¸öа´Å¥¡¢Ò»¸ö±¨¸æ°´Å¥ºÍÒ»¸öÂÞÁв»Í¬²úÆ·µÄ±í¸ñ°´Å¥ÒÔ¼°ÂÞÁÐÁ˲»Í¬ÍÐÔËÈ˵ıí¸ñ¡£

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±íµ¥¡£

The <htmllist> tag in "suppliers.xml" looks like this:
“suppliers.xml” ÎļþµÄ<htmllist>±êÇ©ÈçÏ£º

<htmllist>
<sql>
SELECT Companyname,Contactname,Address,City,Country,
supplierid AS Products
FROM suppliers
</sql>
<server>
<field name="Products">
<display>
<a href="appml.asp?appname=northwind/products&amp;filter=
suppliers.companyname&amp;value=#appml:field(name='companyname')">
Products</a>
</display>
</field>
</server>
</htmllist>

In the list, notice the column called "Products". This column is a link that goes to the "Products" application and shows the products for each supplier company.
ÔÚÁбíÖÐÎÒÃÇ¿ÉÒÔ·¢ÏÖÃûΪ“Products”µÄÁС£Õâ¸öÁÐÁ´½Óµ½“Products” Ó¦ÓóÌÐòÖУ¬²¢ÇÒ£¬Ëü½«ÏÔʾÿ¸ö¹©»õ¹«Ë¾µÄ˳Ðò¡£


AppML XML Report
AppML XML ±¨¸æ

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

XML±¨¸æ£º
appml.asp?appname=northwind/suppliers&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/suppliers
Ï£ÍûÔËÐÐÉÏÃæµÄAppML·þÎñ£¬¿ÉÒÔµã»÷ÏÂÃæµÄÁ´½Ó£ºappml.asp?appname=northwind/suppliers


ÆÀÂÛ (0) All