扫一扫
分享文章到微信
扫一扫
关注官方公众号
至顶头条
catch
{}
return false;
}
public override bool ToXML(System.Xml.XmlElement myElement)
{
if(myElement != null)
{
<xsl:for-each select="*">
myElement.SetAttribute("<xsl:value-of select="translate(@fieldname,'ABCDEFGHIJKLMNOPQRSTUVWXYZ','abcdefghijklmnopqrstuvwxyz')" />",m_<xsl:value-of select="@fieldname" /><xsl:if test="@isstring='0'">.ToString()</xsl:if>);</xsl:for-each>
return true;
}
return false;
}
public override bool FromXML(System.Xml.XmlElement myElement)
{
try
{
if(myElement != null)
{
<xsl:for-each select="*">
m_<xsl:value-of select="@fixname" /> = <xsl:if test="@isstring='0'">Convert.ToInt32(</xsl:if>myElement.GetAttribute("<xsl:value-of select="translate(@fieldname,'ABCDEFGHIJKLMNOPQRSTUVWXYZ','abcdefghijklmnopqrstuvwxyz')" />")<xsl:if test="@isstring='0'">)</xsl:if>;</xsl:for-each>
return true;
}
}
catch
{}
return false;
}
}// 数据库操作类 Struct<xsl:value-of select="@tablename" /> 定义结束
</pre>
</xsl:for-each>
</body>
</html>
</xsl:template>
</xsl:stylesheet>
########################## temp_HTML代码.xml #####################################################
<?xml version="1.0" encoding="utf-8" ?>
<xsl:stylesheet xmlns:xsl="http://www.w3.org/1999/XSL/Transform" version="1.0">
<xsl:output method="xml" indent="yes" />
<xsl:template match="/*">
<html>
<head>
<style>
body{ font-family: "宋体"; font-size: 12px}
table { width:100%; border-collapse:collapse;
border: 1px #CC0066 solid; font-family: "宋体";
font-size: 12px}
.tablehead{background-color:#CCCCFF}
td{ border: 1px #CC0066 solid}
</style>
</head>
<body>
<xsl:for-each select="table">
数据表 <b><xsl:value-of select="translate(@tablename,'abcdefghijklmnopqrstuvwxyz','ABCDEFGHIJKLMNOPQRSTUVWXYZ')" /></b> 结构
共 <xsl:value-of select="count(*)" /> 个字段
<br />
<table >
<tr class="tablehead">
<td>字段名</td>
<td>类型</td>
<td>长度</td>
</tr>
<xsl:for-each select="*">
<tr>
<td>
<xsl:value-of select="@fieldname" />
</td>
<td>
<xsl:value-of select="@fieldtype" />
</td>
<td>
<xsl:value-of select="@fieldwidth" />
</td>
</tr>
</xsl:for-each>
</table>
<p /><hr />
</xsl:for-each>
</body>
</html>
</xsl:template>
</xsl:stylesheet>
################################ temp_Java_Struct.xml ########################################
<?xml version="1.0" encoding="utf-8" ?>
<xsl:stylesheet xmlns:xsl="http://www.w3.org/1999/XSL/Transform" version="1.0">
<xsl:output method="xml" indent="yes" />
<xsl:template match="/">
<html><head></head><body>
<xsl:for-each select="*/table">
<br />-------------- 文件名 <xsl:value-of select="@tablename" />.java -----------------------------
<pre style=" background-color:gainsboro">
package com.haitai.emr.struct;
import java.sql.*;
import java.io.*;
/** <xsl:value-of select="@cname" />
* @author 代码生成器 */
public class <xsl:value-of select="@tablename" /> implements Serializable
{ // 定义数据库字段变量 ////////////////////////////////////////////////////////////////
<xsl:for-each select="*">
<xsl:variable name="javatype">
<xsl:choose>
<xsl:when test="@isstring='1'">String </xsl:when>
<xsl:when test="boolean('true')" >int </xsl:when>
</xsl:choose>
</xsl:variable>
<xsl:variable name="lowfieldname">
<xsl:value-of select="translate(@fixname,'ABCDEFGHIJKLMNOPQRSTUVWXYZ','abcdefghijklmnopqrstuvwxyz')" />
</xsl:variable>
private <xsl:value-of select="$javatype" /> <xsl:text disable-output-escaping="yes"></xsl:text><xsl:value-of select="$lowfieldname" /> ; // 字段 <xsl:value-of select="@cname" />
</xsl:for-each>
public static final String SELECT =
"Select <xsl:for-each select="*">
<xsl:value-of select="normalize-space(@fieldname)" />
<xsl:if test="position() != last()">,</xsl:if>
</xsl:for-each> From <xsl:value-of select="@tablename" />";
/** @param conn
* @exception SQLException */
public java.sql.PreparedStatement makeInsSt (java.sql.Connection conn) throws SQLException{
PreparedStatement pst=conn.prepareStatement("insert into <xsl:value-of select="@tablename" />(<xsl:for-each select="*">
<xsl:value-of select="normalize-space(@fieldname)" />
<xsl:if test="position() != last()">,</xsl:if>
</xsl:for-each>)"
+"values(<xsl:for-each select="*">?<xsl:if test="position() != last()">,</xsl:if></xsl:for-each>)");
int index=0;
<xsl:for-each select="*">
pst.setString(++index,this.get<xsl:value-of select="@fieldname" />()); // <xsl:value-of select="@cname" />
</xsl:for-each>
return pst;
}
/** @param conn
* @exception SQLException */
public java.sql.PreparedStatement makeUpdSt (java.sql.Connection conn) throws SQLException{
// TODO : implement
PreparedStatement pst=conn.prepareStatement("update <xsl:value-of select="@tablename" /> set <xsl:for-each select="*"><xsl:value-of select="normalize-space(@fieldname)" /> =? <xsl:if test="position() != last()">,</xsl:if></xsl:for-each>)"
+"where 数据表关键字段名=?");
int index=0;
<xsl:for-each select="*">
pst.setString(++index,this.get<xsl:value-of select="@fieldname" />()); // <xsl:value-of select="@cname" />
</xsl:for-each>
//关键字
pst.setString(++index,this.get数据表关键字段名());//数据表关键字段说明
return pst;
}
public String toString (){
// TODO : implement
return <xsl:for-each select="*">"<xsl:if test="position() != 1">,</xsl:if><xsl:value-of select="normalize-space(@fieldname)" />="+ <xsl:value-of select="@lowfieldname" /><xsl:if test="position() != last()"> + </xsl:if>
</xsl:for-each>;
}
// 读取和修改数据的接口
<xsl:for-each select="*">
<xsl:variable name="javatype">
<xsl:choose>
<xsl:when test="@isstring='1'">String</xsl:when>
<xsl:when test="boolean('true')">int</xsl:when>
</xsl:choose>
</xsl:variable>
<xsl:variable name="lowfieldname">
<xsl:value-of select="translate(@fieldname,'ABCDEFGHIJKLMNOPQRSTUVWXYZ','abcdefghijklmnopqrstuvwxyz')" />
</xsl:variable>
public <xsl:value-of select="$javatype" /> get<xsl:value-of select="@fieldname" />(){
return <xsl:value-of select="normalize-space($lowfieldname)" /> ;
}
//@param <xsl:value-of select="@cname" />
public void set<xsl:value-of select="@fieldname" />(<xsl:value-of select="@javatype" /> value){
<xsl:value-of select="normalize-space($lowfieldname)" /> = value ;
}
</xsl:for-each>
} // 类 <xsl:value-of select="@tablename" /> 定义结束
</pre>
</xsl:for-each>
</body>
</html>
</xsl:template>
</xsl:stylesheet>
######################################## temp_VB.xml ########################################
<?xml version="1.0" encoding="utf-8" ?>
<xsl:stylesheet xmlns:xsl="http://www.w3.org/1999/XSL/Transform" version="1.0">
<xsl:output method="xml" indent="yes" />
<xsl:template match="/">
<html>
<head></head>
<body>
<xsl:for-each select="*/table">
<br />-------------- 文件名 <xsl:value-of select="@tablename" />.cls -----------------------------
<pre style=" background-color:gainsboro">
'******************************************************************************
'**
'** 数据表 <xsl:value-of select="@cname" />[ <xsl:value-of select="@tablename" /> ]操作的对象
'**
'** 编制:代码生成器
'** 时间:
'**
'******************************************************************************
'** 定义和数据库字段对应的变量 ****************************************
private const c_TableName As String = "<xsl:value-of select="@tablename" />" '** 数据表名称
<xsl:for-each select="*">
<xsl:variable name="vbtype">
<xsl:choose>
<xsl:when test="@isstring='1'">String </xsl:when>
<xsl:when test="boolean('true')" >Integer </xsl:when>
</xsl:choose>
</xsl:variable>
<xsl:variable name="lowfieldname">
<xsl:value-of select="translate(@fieldname,'ABCDEFGHIJKLMNOPQRSTUVWXYZ','abcdefghijklmnopqrstuvwxyz')" />
</xsl:variable>
private m_<xsl:value-of select="@fixname" /> As <xsl:value-of select="$vbtype" /> '** 字段 <xsl:value-of select="@cname" />
</xsl:for-each>
'** 定义数据库字段属性接口 ***************************************************************
Public Property Get TableName() As String
TableName = c_TableName
End Property
<xsl:for-each select="*">
<xsl:variable name="vbtype">
<xsl:choose>
<xsl:when test="@isstring='1'">String </xsl:when>
<xsl:when test="boolean('true')" >Integer </xsl:when>
</xsl:choose>
</xsl:variable>
'** 数据库字段 <xsl:value-of select="@cname" />
Public Property Get m<xsl:value-of select="@fieldname" />() As <xsl:value-of select="$vbtype" />
m<xsl:value-of select="@fieldname" /> = m_<xsl:value-of select="@fieldname" />
End Property
Public Property Let m<xsl:value-of select="@fieldname" />(Byval Value As <xsl:value-of select="$vbtype" />)
m_<xsl:value-of select="@fieldname" /> = m<xsl:value-of select="@fieldname" />
End Property
</xsl:for-each>
'** 获得查询所有数据使用的SQL语句 **
public Function GetBaseSQL() As String
GetBaseSQL ="Select <xsl:for-each select="*">
<xsl:value-of select="@fieldname" />
<xsl:if test="position() != last()">,</xsl:if>
</xsl:for-each> From " <xsl:text disable-output-escaping="yes">&</xsl:text> c_TableName
End Function
'** 定义从数据库记录集获得数据的方法 **
Public Function SelectRS(ByVal rs As ADODB.Recordset) As Boolean
On Error GoTo SelectErr
SelectRS = False
<xsl:for-each select="*">
m_<xsl:value-of select="@fixname" /> = rs.Fields(<xsl:value-of select="position()-1" />).Value '** 字段 <xsl:value-of select="@cname" />
</xsl:for-each>
SelectRS = True
Exit Function
SelectErr:
SelectRS = False
End Function
</pre>
</xsl:for-each>
</body>
</html>
</xsl:template>
</xsl:stylesheet>
####################### temp_表说明文档.xml ##################################
<?xml version="1.0" encoding="utf-8" ?>
<xsl:stylesheet xmlns:xsl="http://www.w3.org/1999/XSL/Transform" version="1.0">
<xsl:template match="/">
<html>
<head></head>
<body>
<xsl:for-each select="*/table">
-------------表 <xsl:value-of select="@tablename" /> 的说明文档 <xsl:value-of select="count(*)" />个字段
<br /><pre style="word-wrap:break-word;background-color:gainsboro">
<xsl:for-each select="*"><xsl:value-of select="@fixname" /><xsl:text disable-output-escaping="yes"> </xsl:text><xsl:value-of select="@fieldtype" />
<xsl:if test="@isstring='1'">(<xsl:value-of select="@fieldwidth" />)</xsl:if> .
<xsl:text disable-output-escaping="yes"></xsl:text>
</xsl:for-each>
</pre>
</xsl:for-each>
</body>
</html>
</xsl:template>
</xsl:stylesheet>
####################### temp_创建表的SQL语句.xml ##################################
<?xml version="1.0" encoding="utf-8" ?>
<xsl:stylesheet xmlns:xsl="http://www.w3.org/1999/XSL/Transform" version="1.0">
<xsl:template match="/">
<html>
<head></head>
<body>
<xsl:for-each select="*/table">
-------------创建表 <xsl:value-of select="@tablename" /> 的SQL语句 <xsl:value-of select="count(*)" />个字段
<br /><pre style="word-wrap:break-word;background-color:gainsboro">
CREATE TABLE <xsl:value-of select="@tablename" />(
<xsl:for-each select="*">
<xsl:text disable-output-escaping="yes"></xsl:text>
<xsl:value-of select="@fixname" />
<xsl:value-of select="@fieldtype" />
<xsl:if test="@isstring='1'">(<xsl:value-of select="@fieldwidth" />)</xsl:if>
<xsl:if test="position() != last()"> ,
</xsl:if>
</xsl:for-each>
)
</pre>
</xsl:for-each>
</body>
</html>
</xsl:template>
</xsl:stylesheet>
####################### temp_选择表使用的SQL语句.xml ##################################
<?xml version="1.0" encoding="utf-8" ?>
<xsl:stylesheet xmlns:xsl="http://www.w3.org/1999/XSL/Transform" version="1.0">
<xsl:template match="/">
<html>
<head></head>
<body>
<xsl:for-each select="*/table">
-------------选择表 <xsl:value-of select="@tablename" /> 的SQL语句 <xsl:value-of select="count(*)" />个字段
<br /><pre style="word-wrap:break-word;background-color:gainsboro">
Select <xsl:for-each select="*">
<xsl:text disable-output-escaping="yes"></xsl:text>
<xsl:value-of select="normalize-space(@fieldname)" />
<xsl:if test="position() != last()"> , </xsl:if>
</xsl:for-each>
From <xsl:value-of select="@tablename" /></pre>
</xsl:for-each>
</body>
</html>
</xsl:template>
</xsl:stylesheet>
如果您非常迫切的想了解IT领域最新产品与技术信息,那么订阅至顶网技术邮件将是您的最佳途径之一。
现场直击|2021世界人工智能大会
直击5G创新地带,就在2021MWC上海
5G已至 转型当时——服务提供商如何把握转型的绝佳时机
寻找自己的Flag
华为开发者大会2020(Cloud)- 科技行者