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

Re: SQL DTD and related questions


sql dtd
Do you mean something like the following? Transform the XML document:

   <Order>
      <Number>123</Number>
      <Date>2/4/02</Date>
      <Customer>XYZ Corp.</Customer>
      <Item>
         <Number>1</Number>
         <Part>14-3</Part>
         <Quantity>12</Quantity>
      </Item>
      <Item>
         <Number>2</Number>
         <Part>347</Part>
         <Quantity>23</Quantity>
      </Item>
   </Order>

into the document:

   <SQL>
      <Statement>INSERT INTO Order (Number, Date, Customer) VALUES (123,
2/4/02, 'XYZ Corp.')</Statement>
      <Statement>INSERT INTO Item (Number, Part, Quantity) VALUES (1,
'14-3', 12)</Statement>
      <Statement>INSERT INTO Item (Number, Part, Quantity) VALUES (2,
'347', 23)</Statement>
   </SQL>

I have seen this suggested several times, but I don't know anybody who
has actually done it. Note that this strategy has a number of problems:

1) It assumes that XML names and database names are the same. This is
unlikely. First, table names are often plural (e.g. Orders) while XML
names are often singular (Order). Second, database names are often all
upper case or all lower case, while XML names are often mixed case.

2) There is no way to detect data type from an XML document. For
example, how do I know that part number 347 is a string and not an
integer?

3) This does not use prepared statements and is therefore not very
efficient. You could construct statements with parameters, but if a
complex element has optional children, doing so might be difficult.

4) There is no way to tell from the XML document how to link related
tables. For example, the order number might be repeated in the items
table as a foreign key, but there is no way to determine this.

etc.

Note that many (most?) of these problems can be solved by using a
different XSLT document for each class of XML documents. You could
probably even write a small XML=>DB mapping language that could be
transformed into an XSLT document. The resulting XSLT document could be
used to do what you want.

Is there a reason you can't use one of the many products already on the
market that transfers data between XML documents and relational
databases?

-- Ron

> Márcio Fernando Keller wrote:
>
> Exist a standard dtd for SQL statements?
> 
> I will transform(xslt) xml documents into xml docs with sql
> statements. Is this useful, advantageous? Sugestions?

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
 

Stylus Studio has published XML-DEV in RSS and ATOM formats, enabling users to easily subcribe to the list from their preferred news reader application.


Stylus Studio Sponsored Links are added links designed to provide related and additional information to the visitors of this website. they were not included by the author in the initial post. To view the content without the Sponsor Links please click here.

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.