[XSL-LIST Mailing List Archive Home] [By Thread] [By Date] [Recent Entries] [Reply To This Message]

RE: RE: RE: RE: Malformed (??) XML and XML 2 SQL XSLTt

Subject: RE: RE: RE: RE: Malformed (??) XML and XML 2 SQL XSLTtransformation
From: Guillaume LECERF <guillaume.lecerf@xxxxxxxxxxxxxx>
Date: Fri, 19 Dec 2003 17:34:29 +0100
xml template orders
Hi all, it's me again

I just realize that I also needed cust-id and Template-id, but can't get it to work.

Thanks in advance

<?xml version="1.0" encoding="iso8859-1" ?>
<Orders>
        <Customer cust-id="C6272">
                <Template Template-id="T37141">
                        <Fields FieldName="User Login ID">
                                <FieldValue>roger.moore</FieldValue>
                        </Fields>
                        <Fields FieldName="External Client ID">
                                <FieldValue>105</FieldValue>
                        </Fields>
                        <Fields FieldName="Job Docket">
                                <FieldValue>P377609</FieldValue>
                        </Fields>
                        <Fields FieldName="Order Date">
                                <FieldValue>10/14/2003</FieldValue>
                        </Fields>
                        <Fields FieldName="Order">
                                <FieldValue>O1084281</FieldValue>
                        </Fields>
                        <Fields FieldName="User Login ID">
                                <FieldValue>bernard</FieldValue>
                        </Fields>
                        <Fields FieldName="External Client ID">
                                <FieldValue>104</FieldValue>
                        </Fields>
                        <Fields FieldName="Job Docket">
                                <FieldValue>P377610</FieldValue>
                        </Fields>
                        <Fields FieldName="Order Date">
                                <FieldValue>10/16/2003</FieldValue>
                        </Fields>
                        <Fields FieldName="Order">
                                <FieldValue>O1084283</FieldValue>
                        </Fields>
                </Template>
        </Customer>
</Orders>


At 16:10 14/11/2003 -0500, 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
Ingenieur Systemes d'Information / Responsable Production - Gage Interactive
http://www.activprint.com - +33 (0)2.31.06.67.62



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



Current Thread

PURCHASE STYLUS STUDIO ONLINE TODAY!

Purchasing Stylus Studio from our online shop is Easy, Secure and Value Priced!

Buy Stylus Studio Now

Download The World's Best XML IDE!

Accelerate XML development with our award-winning XML IDE - Download a free trial today!

Don't miss another message! Subscribe to this list today.
Email
First Name
Last Name
Company
Subscribe in XML format
RSS 2.0
Atom 0.3
Site Map | Privacy Policy | Terms of Use | Trademarks
Free Stylus Studio XML Training:
W3C Member
Stylus Studio® and DataDirect XQuery ™are products from DataDirect Technologies, is a registered trademark of Progress Software Corporation, in the U.S. and other countries. © 2004-2013 All Rights Reserved.