Home > SOA Tips > XML Developer > XML to DDL imports, synchronizes database schemata
SOA Tips:
EMAIL THIS
 TIPS & NEWSLETTERS TOPICS 

XML DEVELOPER

XML to DDL imports, synchronizes database schemata


Ed Tittel
08.22.2007
Rating: -4.33- (out of 5)


Enterprise IT tips and expert advice
Digg This!    StumbleUpon Toolbar StumbleUpon    Bookmark with Delicious Del.icio.us    Add to Google


The Freshmeat.org project known as xml2ddl provides a set of Python programs under the GNU General Public License, or GPL. Given a working Python runtime environment, this set of tools works on many operating systems, including most Windows, Linux, and UNIX platforms. It also works with the following database engines: PostgreSQL, MySQL, Oracle, and Firebird.

Basically, xml2ddl permits users to convert an XML representation of a database into a corresponding set of SQL or DDL statements. According to its creator and custodian, Scott Kirkwood, "XML to DDL strives to be database independent so that the same XML can be used for a variety of databases. This is great for quickly testing out a variety of databases for performance, for example" [quotation comes from the index.html file included in /doc subdirectory within the project ZIP file].

To get the process started, xml2ddl permits users to point to a schema, designate a target database, and produce the requisite DDL or SQL statements necessary to instantiate that database. Given this simple sample XML schema definition in a file named schema1.xml:


  <table name="students" fullname="List of Students" 
      desc="List of students with their full names">
      <columns>
          <column name="id" fullname="Primary Key" type="integer" key="1"
              desc="Primary key for the table"/>
          <column name="student_name" fullname="Student Name" 
              type="varchar" size="80"
              desc="The full name of the student"/>
      </columns>
  </table>
</schema>

And an invocation to output the information for PostgresSQL using the following command line syntax: xml2ddl --dbms postgres schema1.xml, the following output results:

DROP TABLE students;
CREATE TABLE students (
        id integer,
        student_name varchar(80),
        CONSTRAINT pk_students PRIMARY KEY (id));
COMMENT ON TABLE students IS 'List of students with their full names';
COMMENT ON COLUMN students.id IS 'Primary key for the table';
COMMENT ON COLUMN students.student_name IS 'The full name of the student';

Tailored outputs of the same kind for the other target databases may be generated by substituting firebird, oracle, or mysql instead.

The xml2ddl programs can also examine the differences between two different versions of an XML schema and generate the DDL or SQL statements necessary to push those same changes into the target database as well. This requires two related schemas (let's call the second one schema2.xml and recycle schema1.xml) and uses the following syntax: diffxml2ddl --dbms postgres schema1.xml schema2.xml.

If schema2.xml looks as follows:

<schema>
    <table name="students" fullname="List of Students" 
        desc="List of students">
       <columns>
            <column name="id" fullname="Primary Key" type="integer" key="1"
                desc="Primary key for the table"/>
            <column name="student_name" fullname="Student Name" 
                type="varchar" size="100"
                desc="The full name of the student"/>
            <column name="email" fullname="Electronic mail address" 
                type="varchar" size="100"
                desc="The primary email for the student"/>
        </columns>
    </table>
</schema>

Then the following DDL output is produced for PostgresSQL:

ALTER TABLE students ALTER student_name TYPE varchar(80);
ALTER TABLE students DROP email;
COMMENT ON TABLE students IS 'List of students with their full names';

A complete list of examples is available at the project Web site. What's nice about these tools is that they make it easy to define and manage databases using XML and related structured editing tools, and make short work of translating your structured XML efforts into the proper metalanguage for database implementation and use.

This one's definitely worth checking out, and makes a really nifty data integration and management tool for those lucky enough to be using one of the supported target databases.

[Note: all cited examples here are lifted directly from the xml2ddl help file, as cited earlier in this tip.]

About the author

Ed Tittel is a full-time writer and trainer whose interests include XML and development topics, along with IT Certification and information security topics. Among his many XML projects are XML For Dummies, 4th edition, (Wylie, 2005) and the Shaum's Easy Outline of XML (McGraw-Hill, 2004). E-mail Ed at etittel@techtarget.com with comments, questions, or suggested topics or tools for review.


Rate this Tip
To rate tips, you must be a member of SearchSOA.com.
Register now to start rating these tips. Log in if you are already a member.




Digg This!    StumbleUpon Toolbar StumbleUpon    Bookmark with Delicious Del.icio.us    Add to Google


RELATED CONTENT
XML and XML schema
Ganymede: Modeling tools target SOA, UML
Data services mashups emerge for SOA
Making sense of data services mashups
XML turns 10
SOA helps save 100-year-old business
Oracle maps heterogeneous data services strategy for SOA
Handling XML with Ajax
Efficient XML draft published
Intel boosts XML for SOA
Paul Fremantle on coding SOA and data integration

XML acceleration, transport and messaging
Data services mashups emerge for SOA
Layer 7 adds SPARC
Oracle maps heterogeneous data services strategy for SOA
Cisco builds app delivery network
Boubez: SOA needs practical operational governance
Intel boosts XML for SOA
Paul Fremantle on coding SOA and data integration
Financial firm leverages SOA reuse for mobile services
XML data integration for SOA goes open source
Grid-enabled SOA touted by Oracle

XML security
Layer 7 adds SPARC
Oracle maps heterogeneous data services strategy for SOA
Partnership aims at governance for SOA and Web 2.0
SOA, Web services create software security challenges
Efficient XML Interchange tackles data verbosity
The case against WS-Security
Layer 7 offers SOA 'virtual soft-appliance'
XQuery 1.0: A long time coming, now what?
Forum boosts Web services credit security
Layer 7 supports SOA on Solaris

RELATED GLOSSARY TERMS
Terms from Whatis.com − the technology online dictionary
class diagram  (SearchSOA.com)
Fast Infoset (FI)  (SearchSOA.com)
GeoRSS  (SearchSOA.com)
Keyhole Markup Language  (SearchSOA.com)
RELAX NG  (SearchSOA.com)
state diagram  (SearchSOA.com)
Universal Business Language  (SearchSOA.com)
Vector Markup Language  (SearchSOA.com)
XML infoset  (SearchSOA.com)
XML pipeline  (SearchSOA.com)

RELATED RESOURCES
2020software.com, trial software downloads for accounting software, ERP software, CRM software and business software systems
Search Bitpipe.com for the latest white papers and business webcasts
Whatis.com, the online computer dictionary

DISCLAIMER: Our Tips Exchange is a forum for you to share technical advice and expertise with your peers and to learn from other enterprise IT professionals. TechTarget provides the infrastructure to facilitate this sharing of information. However, we cannot guarantee the accuracy or validity of the material submitted. You agree that your use of the Ask The Expert services and your reliance on any questions, answers, information or other materials received through this Web site is at your own risk.

About Us  |  Contact Us  |  For Advertisers  |  For Business Partners  |  Site Index  |  RSS
SEARCH 
TechTarget provides enterprise IT professionals with the information they need to perform their jobs - from developing strategy, to making cost-effective IT purchase decisions and managing their organizations' IT projects - with its network of technology-specific Web sites, events and magazines.

TechTarget Corporate Web Site  |  Media Kits  |  Reprints  |  Site Map




All Rights Reserved, Copyright 2001 - 2008, TechTarget | Read our Privacy Policy
  TechTarget - The IT Media ROI Experts