RE: RE: RE: RE: [xsl] Malformed (??) XML and XML 2 SQL XSLTtransformation

Subject: RE: RE: RE: RE: [xsl] Malformed (??) XML and XML 2 SQL XSLTtransformation
From: Guillaume LECERF <guillaume.lecerf@xxxxxxxxxxxxxx>
Date: Sat, 15 Nov 2003 13:31:29 +0100
All I have to say I a big THANK YOU all for your effort.
It rocks solid !



At 22:10 14/11/2003, you wrote:
I figured out how to fix the excess white space and I noticed that I had inadvertently set the output to "xml". In this version it is correctly set to "text".

<?xml version="1.0" encoding="UTF-8" ?>
<xsl:stylesheet version="1.0" xmlns:xsl="http://www.w3.org/1999/XSL/Transform";>
<xsl:output method="text" indent="yes" encoding="UTF-8" />


<xsl:template match="/">
<xsl:for-each select="Orders/Customer/Template/Fields[@FieldName='User Login ID']">
<xsl:text>INSERT INTO ORDERS("</xsl:text><xsl:value-of select="normalize-space(@FieldName)"/><xsl:text>"</xsl:text>
<xsl:choose>
<xsl:when test="following-sibling::*[1][@FieldName != 'User Login ID']">
<xsl:variable name="fs-number" select="2" />
<xsl:call-template name="column-name">
<xsl:with-param name="fs1" select="$fs-number" />
</xsl:call-template>
<xsl:text>VALUES("</xsl:text><xsl:value-of select="normalize-space(.)"/><xsl:text>"</xsl:text>
<xsl:call-template name="column-value">
<xsl:with-param name="fs1" select="$fs-number" />
</xsl:call-template>
</xsl:when>
</xsl:choose>
<xsl:text>
</xsl:text>
</xsl:for-each>
</xsl:template>


<xsl:template name="column-name">
<xsl:param name="fs1" />
<xsl:variable name="fs-number" select="$fs1 + 1" />
<xsl:text>,"</xsl:text><xsl:value-of select="normalize-space(following-sibling::*[$fs1]/@FieldName)" /><xsl:text>"</xsl:text>
<xsl:choose>
<xsl:when test="following-sibling::*[$fs-number][@FieldName != 'User Login ID']">
<xsl:call-template name="column-name">
<xsl:with-param name="fs1" select="$fs-number" />
</xsl:call-template>
</xsl:when>
<xsl:otherwise><xsl:text>)</xsl:text></xsl:otherwise>
</xsl:choose>
</xsl:template>


<xsl:template name="column-value">
<xsl:param name="fs1" />
<xsl:variable name="fs-number" select="$fs1 + 1" />
<xsl:text>,"</xsl:text><xsl:value-of select="normalize-space(following-sibling::*[$fs1])" /><xsl:text>"</xsl:text>
<xsl:choose>
<xsl:when test="following-sibling::*[$fs-number][@FieldName != 'User Login ID']">
<xsl:call-template name="column-value">
<xsl:with-param name="fs1" select="$fs-number" />
</xsl:call-template>
</xsl:when>
<xsl:otherwise><xsl:text>);</xsl:text></xsl:otherwise>
</xsl:choose>
</xsl:template>


</xsl:stylesheet>
--
Charles Knell
cknell@xxxxxxxxxx - email



XSL-List info and archive: http://www.mulberrytech.com/xsl/xsl-list

-- Guillaume LECERF, Directeur I.T. Réseaux Etendus Gage Inter@ctive S.A., Péricentre III - 26, Avenue de Thiès 14000 CAEN Tèl : 02-31-06-67-62 Fax: 02-31-93-52-57 http://www.activprint.com


XSL-List info and archive: http://www.mulberrytech.com/xsl/xsl-list



Current Thread