File APIs for Java Developers
Manipulate DOC, XLS, PPT, PDF and many others from your application.
http://aspose.com/file-tools
The moose likes XML and Related Technologies and the fly likes awkwardly defined input XML Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login
JavaRanch » Java Forums » Engineering » XML and Related Technologies
Bookmark "awkwardly defined input XML" Watch "awkwardly defined input XML" New topic
Author

awkwardly defined input XML

Matt Spittle
Greenhorn

Joined: May 30, 2002
Posts: 5
The xml source I have (which unfortunately I can't change) is formatted in the hierachy
table->columns->elements
and I need to output it in the normal fashion (as in like HTML) with
table>rows>elements.
Also...this is not a fixed length table and one column may well have more rows than the other(empty elements would be blank). Even worse is that I can't do tables embedded in tables, cos if I could then this would be easy :roll:
Does anyone have any idea how I do this?
Roseanne Zhang
Ranch Hand

Joined: Nov 14, 2000
Posts: 1953
Now we have a FORTAN (column first) to Pascal/c (row first) problem with a Java feature variable length row 2d array, but showing-up in FORTRAN as variable length column 2d array. And also it is not really in FORTRAN, but in XML. You probably need a Java or XSL solution!!!
WOW, what a real fun and exciting problem for an algorithm lover!!!
My suggestion is to define the output requirement with your boss or client before you even think what is the algorithm or how to approach it!
Matt Spittle
Greenhorn

Joined: May 30, 2002
Posts: 5
I have the output defined, and that is row first. My solution has to be pure XSL, as I also cannot define the XSL processor
I would have thought column first to row first transforms were quite common
Does anyone have any ideas?
Thanks in advance for any help
Matt
Roseanne Zhang
Ranch Hand

Joined: Nov 14, 2000
Posts: 1953
Give out a sample input XML file with the required output XML file which is supposed to be transformed from the sample input. Then the problem would become more concrete. You might have better chance to get help from others. Actually, you might have better chance to figure out your own solution by just better organizing and simplifying your problem.
Matt Spittle
Greenhorn

Joined: May 30, 2002
Posts: 5
Good idea
I have something like the following
<root>
<test>
<value>hello1</value>
<value>goodbye1</value>
</test>
<test2>
<value>hello2</value>
<value>goodbye2</value>
</test2>
</root>
and I want to get it into something like the following
<table>
<row>
<entry>hello1</entry>
<entry>hello2</entry>
</row>
<row>
<entry>goodbye1</entry>
<entry>goodbye2</entry>
</row>
</table>
unfortunately the complications that I do not know the length of any of the amount of data in either test* element...i.e. I don't know how manu rows long they will be...is a complication. It'll basically be as long as the longest number of values. Although the numbers of column are fixed :-) so that eases the complication slightly
For a full list of complications read above :-)
in summary...
I wanna switch the columns to rows
Does anyone have any ideas?
Thanks in advance for any help
Matt
Roseanne Zhang
Ranch Hand

Joined: Nov 14, 2000
Posts: 1953
1) I don't think your sample files are representative.
2) Should/should not your each so-called "columns" have different names? Test or test2 or whatever?
3) You did not show your so-called complexity and the anticipated results of your complexity in your sample files at all.
4) If you don't work hard enough on your problems, why should others do??? :roll:
Matt Spittle
Greenhorn

Joined: May 30, 2002
Posts: 5
Fair comments, but in response:
1) You are correct they are not representative, but I was trying to simplify some XML that was massively more complex. I thought that creating a simpler version would make it more attractive for someone to respond. Why make it complex when I can just translate the reponse into my solution?
2) In my input XML they are not infact columns, but explaining the model as such, was a way to simplify the transpose that I wished to achieve. I do however take on board the fact that test and test2 are hardly imaginative names to use
3) As above I don't expect people to read through pages of XML when a simple example will suffice.
4) I think you'll find that copying and pasting in an example of my XML would have been a lot easier for me than creating an analogous but simpler example.
Thanks in advance for any help anyone can provide to me on this issue
Matt
Roseanne Zhang
Ranch Hand

Joined: Nov 14, 2000
Posts: 1953
IMHO, reflecting the complexity of a problem and making it understandable to outsiders do not mean copy/paste, ever! It must be representative and greatly simplified in format. It needs to intentionally ignore irrelevant details, but still reflect the core problem to solve. It requires hard thinking and creative/hard work.
In science terminology, I guess that it is usually called modeling.
Matt Spittle
Greenhorn

Joined: May 30, 2002
Posts: 5
Is there anyone out there who knows anything about this?
I've come across the Muench algorithm, and believe this might be adapted to fit my problem, but I'm not really to sure where to start
The model and details are listed above, but my basic problem is that I need to transpose a column based table into a row based table. I would have thought there was a standard way of doing this (as I'd have thought it was quite a common problem)
Thanks in advance for any help anyone can provide
Matt
 
Don't get me started about those stupid light bulbs.
 
subject: awkwardly defined input XML