<!--
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'">
评论加载中…
![]() |