2006-12-08

如何将XML文件中的数据传送并保存在关系数据库中

来源: 开发者在线 作者:佚名 评论 0 条
 

<!--

Stylesheet:sample.xsl

Creation Date:October 25, 2006

Programmer:Edmond Woychowsky

Purpose:The purpose of this XSL style sheet is to generate multiple SQL insert statements.

Template:match="/"

Creation Date:October 25, 2006

Programmer:Edmond Woychowsky

Purpose:The purpose of this template is to create the outer sql element and invoke the template for the individual INSERT statements.

Update Date:Programmer:Description:

-->

<xsl:template match="/">

<xsl:element name="sql">

<xsl:apply-templates select="//row"/>

</xsl:element>

</xsl:template>

<!--

Template:match="row"

Programmer:Edmond Woychowsky

Purpose:The purpose of this template is to control the creation of the INSERT statements.

Update Date:Programmer:Description:

-->

<xsl:template match="row">

<xsl:element name="statement">

<xsl:value-of select="concat('INSERT INTO ',$table,' (')"/>

<xsl:apply-templates select="*" mode="name"/>

<xsl:text>) VALUES (</xsl:text>

<xsl:apply-templates select="*" mode="value"/>

<xsl:text>)</xsl:text>

</xsl:element>

</xsl:template>

<!--

Template:match="*" mode="name"

Programmer:Edmond Woychowsky

Purpose:The purpose of this template is to list the column names.

Update Date:Programmer:Description:

-->

<xsl:template match="*" mode="name">

<xsl:if test="position() != 1">

<xsl:text>, </xsl:text>

</xsl:if>

<xsl:value-of select="name(.)"/>

</xsl:template>

<!--

Template:match="*" mode="value"

Programmer:Edmond Woychowsky

Purpose:The purpose of this template is to list the column values.

Update Date:Programmer:Description:

-->

<xsl:template match="*" mode="value">

<xsl:variable name="text">

<xsl:call-template name="in">

<xsl:with-param name="list" select="$textColumns"/>

<xsl:with-param name="value" select="name(.)"/>

</xsl:call-template>

</xsl:variable>

<xsl:variable name="date">

<xsl:call-template name="in">

<xsl:with-param name="list" select="$dateColumns"/>

<xsl:with-param name="value" select="name(.)"/>

</xsl:call-template>

</xsl:variable>

<xsl:if test="position() != 1">

<xsl:text>, </xsl:text>

</xsl:if>

<xsl:choose>

<xsl:when test="$text = 'true'">
共4页: 上一页 [1] 2 [3] [4] 下一页

(本文仅表明作者个人观点,不代表本站及其管理员立场.) 推荐 收藏 投稿 打印 返回 关闭
上一篇:如何从一个php文件向另一个地址post数据,不用表单和隐藏的变量  
下一篇:Mashups:Web 应用程序新成员
    评论加载中…
 推荐文章
     

网站首页  -  网站地图 -   站长论坛  -  网站投稿  -    -  网站管理
Copyright © 2008 芜湖站长站 All Rights Reserved 皖ICP备07500611号