aspose file tools*
The moose likes Spring and the fly likes Spring: Byte array to xml Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login
JavaRanch » Java Forums » Frameworks » Spring
Bookmark "Spring: Byte array to xml" Watch "Spring: Byte array to xml" New topic
Author

Spring: Byte array to xml

Andre Labuschagne
Greenhorn

Joined: Aug 26, 2010
Posts: 2
Hi All,

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?

Best regards,
TX
David Newton
Author
Rancher

Joined: Sep 29, 2008
Posts: 12617

Welcome to JavaRanch!

Your requirements aren't very clear; you need XML in order to use XSL. What, precisely, are you trying to do?
Andre Labuschagne
Greenhorn

Joined: Aug 26, 2010
Posts: 2
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...
David Newton
Author
Rancher

Joined: Sep 29, 2008
Posts: 12617

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.
Jimmy Clark
Ranch Hand

Joined: Apr 16, 2008
Posts: 2187
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.
Bill Gorder
Bartender

Joined: Mar 07, 2010
Posts: 1648
    
    7

not exactly sure what you are looking to do but maybe this will help

http://freemarker.org/


[How To Ask Questions][Read before you PM me]
 
I agree. Here's the link: http://aspose.com/file-tools
 
subject: Spring: Byte array to xml