当前位置: 首页 > 网络学院 > 客户端脚本教程 > APPML > 案例研究:供应商

APPML
AppML 简介
AppML 案例
AppML 案例说明
AppML 网络服务
案例研究简介
案例研究:数据库
案例研究:AppML
案例研究:HTML 报告
案例研究:HTML 表单
案例研究:目录
案例研究:产品
案例研究:托运人
案例研究:供应商
案例研究:客户
案例研究:雇员
案例研究:应用程序
案例研究:下载
AppML FAQ
AppML 文档
AppML 数据库元素

APPML 中的 案例研究:供应商


出处:互联网   整理: 软晨网(RuanChen.com)   发布: 2009-03-01   浏览: 663 ::
收藏到网摘: n/a

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列表(这些列表必须遵循一定的规范)中的数据字段容器。在上述代码中,我们指出“公司名称” 字段和“联系名称” 字段是必要的(不可以在表单中以空白显示)。如果一个用户对这两个字段留以空白,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>标签的内部。在这里,我们使用的是标准的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

登陆 | 还没注册?