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

w3pop.com :: ÍøÂçѧԺ :: APPML :: °¸ÀýÑо¿£ºÍÐÔËÈË

»áÔ±µÇ½

ÕʺÅ

ÃÜÂë

»Ø´ð

¼ÇסÃÜÂë

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

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

°¸ÀýÑо¿£ºÍÐÔËÈË


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

This chapter demonstrates AppML on the Shippers table in the Northwind database.
ÕâÕ½²ÊöÁËAppML»ùÓÚNorthwindÊý¾Ý¿âÖÐÍÐÔËÈ˱í¸ñµÄÓ¦Óá£


The Shippers XML File
ÍÐÔËÈËXMLÎļþ

The "Shippers" AppML description: northwind/shippers.xml
“ÍÐÔËÈË”AppMLÃèÊö£ºnorthwind/shippers.xml


AppML HTML Report
AppML HTML ±¨¸æ

HTML Report: appml.asp?appname=northwind/shippers&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 ("Shippers"), a table listing the different companies along with their phone numbers. 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 the report.
Õâ·Ý±¨¸æ»¹°üº¬ÁËÒ»¸ö¹ýÂ˰´Å¥¡£Èç¹ûÄãµã»÷Á˹ýÂ˰´Å¥£¬Äã¾Í¿ÉÒÔ±¨¸æ½øÐйýÂ˺ͷÖÀà¡£

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

<filters>
<orderby>Companyname</orderby>
<query>
<field>Companyname</field>
</query>
</filters>

We see that the <filters> tag contains an <orderby> tag and a <query> 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 Shippers table.
<orderby>±êǩָ¶¨Á˱¨¸æ¸ÃÒÔʲô×Ö¶ÎΪ»ù×¼½øÐÐÅÅÐò¡£ÔÚÕâ¸ö°¸ÀýÖУ¬¸Ã±¨¸æ½«ÍÐÔËÈ˱í¸ñÖеĹ«Ë¾Ãû³Æ×ֶνøÐÐÅÅÐò¡£

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

The <filters> tag is used by both <htmlreport> and <htmllist>.
<filters>±êÇ©¿ÉÓÃÓÚ<htmlreport>±êÇ©ºÍ<htmllist>±êÇ©¡£


AppML HTML Form
AppML HTML ±íµ¥

HTML Form: appml.asp?appname=northwind/shippers&displaytype=form
HTML±íµ¥£ºappml.asp?appname=northwind/shippers&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 "shippers.xml" looks like this:
ÎÒÃÇÒѾ­ÒÀ¾ÝHTML´úÂëµÄ±ê×¼Ö¸¶¨ÁË±íµ¥µÄÍâ¹Û¡£“shippers.xml”ÖеÄ<htmlform>±êÇ©ÈçÏ£º

<htmlform>
<sql>SELECT companyname,phone FROM shippers</sql>
<form>
<br/>
<table width="50%">
<tr>
<td>
<fieldset>
<legend style="color:darkblue">Shipper information</legend>
<br/>
<table border="0">
<tr>
<td>Company Name:</td>
<td><input size="40" maxlength="40" id="companyname"/></td>
</tr>
<tr>
<td>Phone:</td>
<td><input size="24" maxlength="24" id="phone"/></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 Ñ¡ÏÖеÄ×Ö¶ÎÃûÊôÐÔµÄЧ¹ûÊÇÒ»ÑùµÄ¡£


AppML HTML List
AppML HTML Áбí

HTML List: appml.asp?appname=northwind/shippers&displaytype=list
HTML ÁÐ±í£ºappml.asp?appname=northwind/shippers&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 ("Shippers"), 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 "shippers.xml" looks like this:
“shippers.xml” ÎļþµÄ<htmllist>±êÇ©ÈçÏ£º

<htmllist>
<sql>
SELECT Companyname,Phone,ShipperID AS Orders FROM shippers
</sql>
<server>
<field name="Orders">
<display>
<a href="appml.asp?appname=northwind/orders&amp;filter=
shippers.companyname&amp;value=#appml:field(name='companyname')">
Orders</a>
</display>
</field>
</server>
</htmllist>

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


AppML XML Report
AppML XML ±¨¸æ

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

XML±¨¸æ£º
appml.asp?appname=northwind/shippers&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 (except XML report) in one, use the following link: appml.asp?appname=northwind/shippers
Ï£ÍûÔËÐÐÉÏÃæµÄAppML·þÎñ£¨³ýÁËXML±¨¸æ£©£¬¿ÉÒÔµã»÷ÏÂÃæµÄÁ´½Ó£ºappml.asp?appname=northwind/products


ÆÀÂÛ (0) All