Win a copy of Functional Reactive Programming this week in the Other Languages forum!
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic

Urgent : help needed is XSLT

 
chandru ram
Greenhorn
Posts: 18
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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
Posts: 171
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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.
 
chandru ram
Greenhorn
Posts: 18
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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
Posts: 116
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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
Posts: 23
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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
Posts: 18
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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
Posts: 116
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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
 
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic