Wrox Programmer Forums
Go Back   Wrox Programmer Forums > XML > XSLT
|
XSLT General questions and answers about XSLT. For issues strictly specific to the book XSLT 1.1 Programmers Reference, please post to that forum instead.
Welcome to the p2p.wrox.com Forums.

You are currently viewing the XSLT section of the Wrox Programmer to Programmer discussions. This is a community of software programmers and website developers including Wrox book authors and readers. New member registration was closed in 2019. New posts were shut off and the site was archived into this static format as of October 1, 2020. If you require technical support for a Wrox book please contact http://hub.wiley.com
 
Old May 3rd, 2010, 05:35 PM
Registered User
 
Join Date: May 2010
Posts: 1
Thanks: 0
Thanked 0 Times in 0 Posts
Default Need help with insertion of XML data into SQL db using XSLT

Hi,

I have been trying very hard to make this statement work -

<xsl:value-of select="INSERT INTO Table1 VALUES("$a","$b")"/>

where $a and $b are two variables.

I get a syntax error

"Expected end of the expression, found INTO. INSERT <--- INTO ---> Table1 VALUES..."

Any help would be appreciated. This is the first time I am trying to insert two simple values into a table.

Thanking you,

Warm regards,
Sekhar
 
Old May 3rd, 2010, 06:47 PM
mhkay's Avatar
Wrox Author
 
Join Date: Apr 2004
Posts: 4,962
Thanks: 0
Thanked 292 Times in 287 Posts
Default

Firstly, it's not valid XML. An attribute using double-quotes as its delimiters can't contain a double-quotes character within the value.

Secondly, if you fix this (for example by changing the delimiting double-quotes to single-quotes) then it's not valid XSLT, because the value of the select attribute must be an XPath expression.

I think you want something like select="concat('INSERT INTO Table1 VALUES(', $a, ',', $b, ')'" except that

(a) you may want to add quotes around the values of $a and $b, I don't know;

(b) you need to think about whether it's necessary to protect yourself against SQL injection attacks.
__________________
Michael Kay
http://www.saxonica.com/
Author, XSLT 2.0 and XPath 2.0 Programmer\'s Reference





Similar Threads
Thread Thread Starter Forum Replies Last Post
Avoid Duplicate insertion into DB farhhan ASP.NET 3.5 Professionals 0 November 4th, 2009 05:47 AM
ch2 - page 28. nothing in DB after insertion test moulot BOOK: ASP.NET 3.5 Enterprise Application Development with Visual Studio 2008: Problem Design Solutio 2 September 8th, 2009 01:49 PM
Database insertion (blob object) through XSLT script sbutt XSLT 7 May 26th, 2009 01:36 PM
Relational SQL Data to XML - Vet SQL/ASP - New XML JimiTheJett XML 1 December 4th, 2008 06:06 PM
Arabic data insertion into SQL 7.0 zee_ahmed2002 VB How-To 5 December 30th, 2004 07:26 AM





Powered by vBulletin®
Copyright ©2000 - 2020, Jelsoft Enterprises Ltd.
Copyright (c) 2020 John Wiley & Sons, Inc.