homepage Welcome to WebmasterWorld Guest from 107.20.131.154
register, free tools, login, search, subscribe, help, library, announcements, recent posts, open posts,
Pubcon Website
Home / Forums Index / Code, Content, and Presentation / XML Development
Forum Library, Charter, Moderators: httpwebwitch

XML Development Forum

    
[XML] XML databases - general questions
fm86




msg:3797121
 8:18 pm on Nov 30, 2008 (gmt 0)

Hi everybody!

I'm new in the magic world of XML so I will ask for some general suggestions:

I have an XML form description T1 and an XML database description T2 I'd like to write a program which stores the data collected in T1 in the format of T2 (T1 may be different from T2, for example in the form I may ask for "name" and "surname" but in the database these 2 fields will be stored together in the field "person"). Which tools should I use to get this result? Do I have to write a PHP script or are there other ways?

Thank you for your attention!

 

httpwebwitch




msg:3797630
 6:04 pm on Dec 1, 2008 (gmt 0)

Hi fm86, Welcome to WebmasterWorld!

I agree you should probably write a PHP script to accomplish that. Since you mention PHP, I presume you have PHP available on the server; the same deal could be accomplished using C#, Java, ColdFusion, Perl, Ruby... or whatever you have available on the back end.

You'll be using a server-side script anyways, to take the data collected from the <form> and tucking it into an XML format, and into the database? So this name concatenation could easily be accomplished at the same time.

However
If you have authority to change the XML schema, I'd recommend you store first and last name separately...

<person>
<name>
<firstname>Joe</firstname>
<lastname>DiMaggio</lastname>
</name>
</person>

You can never tell whether you'll be able to parse apart someone's full name. What if someone enters a first but not a last, or a last but no first. Or they enter two names as their first? as in "F. Scott Fitzgerald". Is the first name "F.", or "F. Scott"?

If you store the data just as you accept it, in separate fields, you will prevent much suffering

Cheers

fm86




msg:3798173
 11:26 am on Dec 2, 2008 (gmt 0)

Hi and thank you for your kind reply!

Unfortunately my task is not clear at all. I just figured out what I should do. Could you please tell me if it makes sense?

I have 2 given XML database description (T1 and T2) that are somehow different but very similar. From T1 with a tool (could you please suggest me one?) I generate an input form and from T2, with another tool (could you please suggest me one?), I generate a database SQL.

When the user fills and sends the form, I have to write a PHP script which collects the data into an XML T1 description form, send them to another PHP script which performs the transformation T1->T2 and save the data in SQL.

Did I miss something? Could I skip some step? Is there some way to make it automatic?

My biggest doubt is about T2->SQL. How can a program generate a SQL from an XML description? If it were an XML schema I'd understand, but in this case...

The surname-name problem was just an example to underline that T1 is different from T2.

Thank you again!

httpwebwitch




msg:3798423
 6:59 pm on Dec 2, 2008 (gmt 0)

I'm a little confused because you seem to use the word "form" to mean different things in different sentences. And I don't know why you're using XML at all, if the goal is to have your data inserted into a SQL database.

clarify:
1) is this a web application?
2) does the user input their information into an HTML <form>?
3) are you storing the data as XML, like, in an XML database?
4) or are you just taking someone's data from a web form and putting it in a database of relational tables?
5) At what point does the data need to be in XML format?

How can a program generate a SQL from an XML description

you use PHP to parse the XML, iterate through the nodes and construct SQL statements. Then you execute those statements

You really ought to be able to do all this with one PHP script, not several

Global Options:
 top home search open messages active posts  
 

Home / Forums Index / Code, Content, and Presentation / XML Development
rss feed

All trademarks and copyrights held by respective owners. Member comments are owned by the poster.
Terms of Service ¦ Privacy Policy ¦ Report Problem ¦ About
© Webmaster World 1996-2014 all rights reserved