最近在看《构建Oracle XML应用程序》的书,想用表单来实现插入/更新表的数据。
我构建了个template,UtilDataForm.xsl来描述表单如下:
- HTML code
<?xml version="1.0" encoding="windows-1252" ?>
<xsl:stylesheet version="1.0" xmlns:xsl="http://www.w3.org/1999/XSL/Transform">
<!-- Root template -->
<xsl:template match="dataform">
<center>
<form method="POST" action="{@target}">
<table>
<xsl:for-each select="item[@type!="hidden"]">
<tr>
<th align ="right"><xsl:value-of select="@label"/></th>
<td>
<xsl:choose>
<xsl:when test="@type="text"">
<input type="text" name="{@name}" value="{normalize-space(.)}">
<xsl:if test="@size">
<xsl:attribute name="size"><xsl:value-of select="@size"/>
</xsl:attribute>
</xsl:if>
</input>
</xsl:when>
<xsl:when test="@type="textarea"">
<textarea class="code" row="5" name="{@name}">
<xsl:if test="@size">
<xsl:attribute name="cols"><xsl:value-of select="@size"/>
</xsl:attribute>
</xsl:if>
<xsl:value-of select="normalize-space(.)" />
</textarea>
</xsl:when>
<xsl:when test="@type="list"" >
<xsl:variable name="default" select="default"/>
<select name="{@name}">
<xsl:for-each select="ROWSET/ROW">
<option value="{VALUE}">
<xsl:if test="VALUE=$default">
<xsl:attribute name="selected"/>
</xsl:if>
<xsl:value-of select="DISPLAY"/>
</option>
</xsl:for-each>
</select>
</xsl:when>
<xsl:when test="@type="checkboxlist"">
<xsl:variable name="name" select="@name"/>
<xsl:for-each select="ROWSET/ROW">
<input type="checkbox" name="{$name}" value="{VALUE}">
<xsl:if test="SELECTED="Y"">
<xsl:attribute name="checked" />
</xsl:if>
</input>
<xsl:value-of select="DISPLAY"/>
</xsl:for-each>
</xsl:when>
</xsl:choose>
</td>
</tr>
</xsl:for-each>
</table>
<input type="submit" value="{@submit}" />
<input type="reset" value="Clear All" />
</form>
</center>
</xsl:template>
</xsl:stylesheet>
数据挖掘研究院
然后新建了个xsql文件new_company.xsql用来描述表单内容,如下:
- HTML code
<?xml version="1.0" encoding="windows-1252"?>
<!--
| Uncomment the following processing instruction and replace
| the stylesheet name to transform output of your XSQL Page using XSLT
-->
<?xml-stylesheet type="text/xsl" href="new_company.xsl" ?>
<page xmlns:xsql="urn:oracle-xsql" connection="jdbc/ConnectionInfoDS" >
<dataform target="company.xsql" submit="Save">
<item type="text" name="company_id" label="Company ID"></item>
<item type="text" name="company_name" label="Company Name"></item>
<item type="text" name="description" label="Description"></item>
<item type="text" name="ext_link" label="External Link"></item>
<item type="text" name="cust_helpdesk" label="Customer Helpdesk"></item>
<item type="textarea" name="instructions" label="Instruction"></item>
<item type="text" name="rp_supp_grp" label="Support Group"></item>
<item type="text" name="last_upd_user" label="Last Updated By"></item>
<item type="text" name="last_upd_dte" label="Last Updated Date"></item>
</dataform>
</page>
数据挖掘研究院
然后新建一个new_company.xsl来apply template。
最后新建一个Insert_company.xsl的transform文件,来转换表单里的数值到Rowset/row格式,如下:
- HTML code
<?xml version="1.0" encoding="windows-1252" ?>
<xsl:stylesheet version="1.0" xmlns:xsl="http://www.w3.org/1999/XSL/Transform">
<!-- Root template -->
<xsl:template match="/">
<ROWSET>
<xsl:for-each select="request/parameters">
<ROW>
<company_id>
<xsl:value-of select="company_id" />
</company_id>
<company_name>
<xsl:value-of select="company_name" />
</company_name>
<description>
<xsl:value-of select="description" />
</description>
<ext_link>
<xsl:value-of select="ext_link" />
</ext_link>
<cust_helpdesk>
<xsl:value-of select="cust_helpdesk" />
</cust_helpdesk>
<instructions>
<xsl:value-of select="instructions" />
</instructions>
<rp_supp_grp>
<xsl:value-of select="rp_supp_grp" />
</rp_supp_grp>
<last_upd_user>
<xsl:value-of select="last_upd_user" />
</last_upd_user>
<last_upd_dte>
<xsl:value-of select="last_upd_dte" />
</last_upd_dte>
</ROW>
</xsl:for-each>
</ROWSET>
</xsl:template>
</xsl:stylesheet>
数据挖掘论坛
然后在target的文件company.xsql中加入了 <xsql:insert-request table="company" transform="insert_company.xsl"/> 来产生插入动作,但是我点击“Save”的时候,我的company表里并没有插入记录,求大大们指教up我的company表里并没有插入记录 ,跟踪下Oracle ,看看有sql执行没?怎么跟踪啊,大大?不会oracle,帮不上忙.Create By Any-Extract(WL-AE)