• Post Reply Bookmark Topic Watch Topic
  • New Topic
programming forums Java Mobile Certification Databases Caching Books Engineering Micro Controllers OS Languages Paradigms IDEs Build Tools Frameworks Application Servers Open Source This Site Careers Other all forums
this forum made possible by our volunteer staff, including ...
Marshals:
  • Campbell Ritchie
  • Liutauras Vilda
  • Jeanne Boyarsky
  • Devaka Cooray
  • Paul Clapham
Sheriffs:
  • Tim Cooke
  • Knute Snortum
  • Bear Bibeault
Saloon Keepers:
  • Ron McLeod
  • Tim Moores
  • Stephan van Hulst
  • Piet Souris
  • Ganesh Patekar
Bartenders:
  • Frits Walraven
  • Carey Brown
  • Tim Holloway

how to define data types in xml document

 
Ranch Hand
Posts: 36
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Hi
I worte an application in java to retrieve data from xml and insert that data in to the database.
Here I got the problem with datatatypes.
Now I would like to know whether it is possible to know the data types from xml document
Thank u in advance
Saradhi
 
Sheriff
Posts: 5782
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Nope it is not possible. Everything in the XML is interpreted as plain text data. You will have to write an intelligent routine to infer the datatypes during the parsing. One way to do it is to store column descriptions for a particular table and during the XML parsing simply look up the datatype for that particular column.
Or you can have an attirbute called type and store types as string values. For example -
< EmployeeName type = "String">
David Copperfield
</EmployeeName>
<EmployeeSalary type = "Number">
200200.90
</EmployeeSalary>
<EmployeeDateJoined type = "DateTime">
05/15/1993
</EmployeeDateJoined>

Hope that helps!
------------------
Ajith Kallambella M.
Sun Certified Programmer for the Java�2 Platform.
IBM Certified Developer - XML and Related Technologies, V1.
 
It is sorta covered in the JavaRanch Style Guide.
  • Post Reply Bookmark Topic Watch Topic
  • New Topic
Boost this thread!