Welcome to WebmasterWorld Guest from 18.104.22.168
Forum Moderators: httpwebwitch
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!
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.
If you have authority to change the XML schema, I'd recommend you store first and last name separately...
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
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!
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