• 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 Pie Elite all forums
this forum made possible by our volunteer staff, including ...
Marshals:
  • Campbell Ritchie
  • Tim Cooke
  • Liutauras Vilda
  • Jeanne Boyarsky
  • paul wheaton
Sheriffs:
  • Ron McLeod
  • Devaka Cooray
  • Henry Wong
Saloon Keepers:
  • Tim Holloway
  • Stephan van Hulst
  • Carey Brown
  • Tim Moores
  • Mikalai Zaikin
Bartenders:
  • Frits Walraven

Convert Data to XML File

 
Ranch Hand
Posts: 1309
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
I am really new to XML technologies and need lots of quidance.

If I have some data that come in the format shown below (only one record is shown):


1. What technology I should use to convert that record to a XML file?
2. Is there an example I may see and study?

Thank you.
 
Ranch Hand
Posts: 2187
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
The eXtensible Markup Language (XML) is a language used for creating "markup languages", e.g. WSDL, SOAP, FpML, XMI, etc. A good starting point would be to learn what a "markup language" actually is. XML is a simplified version of SGML.

In regards to technologies for creating XML-based documents (data), there are many. Basically, any programming language can be used to programatically create an XML-based document (data). However, before you start to think about creating documents in a particular markup language, you first need to create the language itself. This can be accomplished with either a XML DTD or an XML Schema. There is a lot to learn. So I suggest that you take it slowly.
 
Author and all-around good cowpoke
Posts: 13078
6
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
This free on-line book is very complete and is loaded with examples.

Bill
 
JiaPei Jen
Ranch Hand
Posts: 1309
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Thanks for your feedbacks.

I cannot take it slowly. I have a task at work to perform. I have gone through a quick JAXB tutorial.

The XML file to which I convert the data, which are either in text or in bean, has its own schema. Do you have any suggestion of the technology to use? Is it the XSLT processor? Are there any code examples?

Thank you.
 
Jimmy Clark
Ranch Hand
Posts: 2187
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
I would suggest that you inform the individual that assigned you this task that you are really new to XML and don't know how to write XML data conversion code. This is not something simple that can be quickly learned via forum postings. It is best to be honest about your abilities. Good luck!
 
JiaPei Jen
Ranch Hand
Posts: 1309
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Nobody is dishonest.

The entire development team is entering a new territory. None of us is expected to know the technology. However, nobody is supposed to take it slowly.
 
Jimmy Clark
Ranch Hand
Posts: 2187
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Sounds good. Perl is a strong tool for writing data manipulation software. If you want to attempt to write code for your stated requirements using Java, you should learn the java.util.regex package. Regardless of the technology used for creating the XML-based document, you still have to either (1) create a markup language that defines elements, attributes and a structure, or (2) choose an existing markup language.

Aside, the Java Architecture for XML Binding is an API for accessing data that is already in an XML-based format.

An XSLT Engine is also for typically processing data that is already in an XML-based format.

Good luck!
 
JiaPei Jen
Ranch Hand
Posts: 1309
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Is this the right approach? -- Convert the Java bean object to XML using JAXB, and then use XSLT to convert this XML to the format I actually want.

Please correct me if I am wrong - JAXB “forces” the Java class to use the exact element names defined in the target XML file. However, the element names in target XML file may not be exactly the same as those defined in the data model. XSLT enters the picture because XSLT can do element to element mapping.
 
Jimmy Clark
Ranch Hand
Posts: 2187
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator

Is this the right approach? -- Convert the Java bean object to XML using JAXB, and then use XSLT to convert this XML to the format I actually want.



First, there is no single "right" approach to anything. In software design there are many approaches to a requirement. Design skill is measured by an individual's ability to select one that is "best" for a particular situation and to do this on a consistent basis.

In regards to creating a CSV record (as shown above) using data from an object, you can simply create the record using the data directly from the object. There is no need or purpose to create an XML version.

This is not the same as the topic of this post. This post is about creating a XML-based document from the CSV record (as shown above.) Not creating a CSV record from an object's data.

Keep in mind that writing code with XSLT is no simple task and typically will required seasoned programming skills for complex conversions. It looks like your group needs to hire a consulting team to guide you as you begin to learn XML programming. Also, if you rush through this without taking it slow, you will most likely get it wrong and waste time and money.

 
I suggest huckleberry pie. But the only thing on the gluten free menu is this tiny ad:
Gift giving made easy with the permaculture playing cards
https://coderanch.com/t/777758/Gift-giving-easy-permaculture-playing
reply
    Bookmark Topic Watch Topic
  • New Topic