This week's book giveaway is in the OCAJP 8 forum. We're giving away four copies of OCA Java SE 8 Programmer I Study Guide and have Edward Finegan & Robert Liguori on-line! See this thread for details.
Is there a way (using Spring if possible) to create an Xml (file or Dom object) using a template (xslt?) and a byte array / text string?
I'm writing a generic bean to take any text data and a template and create an xml message and I was wondering if this is available in the Spring framework (or any other mechanism) or do I need to write one from scratch?
Your requirements aren't very clear; you need XML in order to use XSL. What, precisely, are you trying to do?
Joined: Aug 26, 2010
I've figured out that xslt can't be used...
The requirement is to convert a text file into xml (using some sort of template). The content and structure of the text file is not currently know, but it has a fixed structure. Thus a template will be used to convert this fixed (text) structure into xml. (The dev's deadline is before the info of the file will be known - don't ask me why, I only work here )
Thus I was wondering if there is already a mechanism to marry the text file with a template to produce xml. But it looks like I'll have to write one from scratch...
I have no way of knowing if something already exists, because it's entirely unclear what you're trying to do.
The content and structure of the text file is not currently know, but it has a fixed structure
So it has a fixed structure but the structure isn't known? Are you just trying to create a known XML output with the file contents in it? If you can't TellTheDetails it's unlikely you'll get much help.
In any case, this doesn't really seem Spring-related at all.
The eXtensible Markup Language is a meta-language which is used to create markup languages. It is not a markup language itself however. The name is a bit misleading.
Since there can be an infinite number of markup languages created with XML, it is very difficult to create tools the "automatically" create instances of "any" markup language.
When building custom binding tools to move from Java object to an XML-based representation, you typically need to perform significant data anaylsis and know a lot of details beforehand. Attempting to design a solution without all the information is not very efficient and your chances of getting it "right" are very small.
However, building a custom solution is usually the best option. The public frameworks out there that attempt to execute "generic" binding introduce a whole lot of unnecessary complexities and unwanted stuff. Moreover, they tend to force you to write your code in a certain complex way which introduces a bunch of other problems and limitations eventually.