News Feed
Sections




News Archive
Looking for more information on how to do PHP the right way? Check out PHP: The Right Way

Raphael Stolt's Blog:
Transforming data centered XML into SQL statements
May 08, 2007 @ 10:27:00

In this new post on Raphael Stolt's blog, he shows a way that you can take XML that holds SQL information (in his example INSERTs and DELETEs) and transforms them into SQL statements via XSL stylesheets.

A canny data import technique that emerged from praxis, while working on the import of data-centered XML resources, is utilitizing the abilities of Xslt. The generation of the required SQL statements actually only needs a simple Xsl stylesheet which might import for an PHP XSLTProcessor object or pass to the xsltproc command line tool. Both further described approaches are based upon the libxslt library and are assuming the use of XSLT 1.0.

He starts with an example bit of XML that has the XSL stylesheet at the top that will be used to transform the data and the information to perform inserts on several "partner" values in the XML below. Following this, he creates a PHP class to load the file and apply the stylesheet.

He also mentions a few different approaches to the same problem - XSLTProcessor class approach returning a single SQL string , xsltproc approach and the XSLTProcessor class approach using the ability to use PHP functions as XSLT functions.

0 comments voice your opinion now!
transform xml sql statement xslt insert delete transform xml sql statement xslt insert delete


blog comments powered by Disqus

Similar Posts

Gonzalo Ayuso's Blog: Building a simple SQL wrapper with PHP. Part 2.

NewsForge.com: Using phpMyAdmin

Jakub Zalas' Blog: Managing object creation in PHP with the Symfony2 Dependency Injection component

Paul Stamatiou's Blog: How To: Parse XML with PHP5

php|architect: December 2006 Issue Released


Community Events

Don't see your event here?
Let us know!


api library series framework wordpress release unittest voicesoftheelephpant middleware extension opinion language laravel5 conference development laravel podcast interview community introduction

All content copyright, 2015 PHPDeveloper.org :: info@phpdeveloper.org - Powered by the Solar PHP Framework