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 Urgent : help needed is XSLT Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login


Win a copy of Soft Skills this week in the Jobs Discussion forum!
JavaRanch » Java Forums » Engineering » XML and Related Technologies
Bookmark "Urgent : help needed is XSLT" Watch "Urgent : help needed is XSLT" New topic
Author

Urgent : help needed is XSLT

chandru ram
Greenhorn

Joined: Jul 03, 2002
Posts: 18
I have an xml in this format :

<Company>
<Employee>
<EmpID>1</EmpID>
<EmpName>XXX</EmpName>
<EmpSal>5000</EmpSal>
<EmpID>2</EmpID>
<EmpName>YYY</EmpName>
<EmpSal>6000</EmpSal>
</Employee>
</Company>
But the html output should be in a table like:
EmpIDEmpNameEmpSal
1XXX5000
2YYY5000
Here there is no possibility of doing <xsl:for-each>
The xml structure should not be changed. So is there is a way to do the transformation.
Pls Help.
Thanks in advance,
Chandru
Andy Bowes
Ranch Hand

Joined: Jan 14, 2003
Posts: 171
Chandra
The XML fragment that you posted makes absolutely no sense. How can a single employee have multiple names and salaries ?
I suggest that you go back to the source of the XML and get it written rather than attempting to apply patched solutions to something that is inherently broken.


Andy Bowes<br />SCJP, SCWCD<br />I like deadlines, I love the whoosing noise they make as they go flying past - Douglas Adams
chandru ram
Greenhorn

Joined: Jul 03, 2002
Posts: 18
Hi Andy,
consider that i have the xml like this
<Company>
<Employees>
<EmpID>1</EmpID>
<EmpName>XXX</EmpName>
<EmpSal>5000</EmpSal>
<EmpID>2</EmpID>
<EmpName>YYY</EmpName>
<EmpSal>6000</EmpSal>
</Employees>
</Company>
The employees tag has all the list of employees.
Gayathri Prasad
Ranch Hand

Joined: Jun 25, 2003
Posts: 116
Dear Chandru,
In the key Employees root tag you need to have Employee tag which encloses all the details like ID,name etc.. But having the employee tag in employees makes sense.. Just check the structure of you XML again.
Cheers,
Gaya3
Perry McKenzie
Greenhorn

Joined: Jul 16, 2003
Posts: 23
Dear Chandru,
Consider reformatting your xml like this;
<Company>
<Employees>
<Employee>
<EmpID>1</EmpID>
<EmpName>XXX</EmpName>
<EmpSal>5000</EmpSal>
</Employee>
<Employee>
<EmpID>2</EmpID>
<EmpName>YYY</EmpName>
<EmpSal>6000</EmpSal>
</Employee>
</Employees>
</Company>
chandru ram
Greenhorn

Joined: Jul 03, 2002
Posts: 18
Hi,
First thanx everyone for the reply.Iam working on a project for a financial domain.In my project we are interfacing with an old legacy application for getting some data.That application sends data in XML format which is similar to the XML that i posted.So in my project i have to parse that XML and show it using JSP's. The legacy application is already existing and it is hard to change the structure of that XML.
Thanks & Regards,
chandru
Gayathri Prasad
Ranch Hand

Joined: Jun 25, 2003
Posts: 116
Dear Chandru,
I happened to work on a similar project and what I employed for my project was.. I kept a count of the tags which are common for all the employees(ID,name,salary etc..)and I kept a counter when I was parsing the xml file and when ever the count was divisible by the count of common tags for each employee I wrapped it up in <employee> and after the # of count tags I enlcosed the data with </employee> By this I ensured that the structure of the data is contained (which lacks in the Legacy system) and then you have lot of flexibility to do whatever u want.
Cheers,
Gaya3
 
I agree. Here's the link: http://aspose.com/file-tools
 
subject: Urgent : help needed is XSLT