• Post Reply Bookmark Topic Watch Topic
  • New Topic
programming forums Java Mobile Certification Databases Caching Books Engineering Micro Controllers OS Languages Paradigms IDEs Build Tools Frameworks Application Servers Open Source This Site Careers Other Pie Elite all forums
this forum made possible by our volunteer staff, including ...
Marshals:
  • Campbell Ritchie
  • Jeanne Boyarsky
  • Ron McLeod
  • Paul Clapham
  • Liutauras Vilda
Sheriffs:
  • paul wheaton
  • Rob Spoor
  • Devaka Cooray
Saloon Keepers:
  • Stephan van Hulst
  • Tim Holloway
  • Carey Brown
  • Frits Walraven
  • Tim Moores
Bartenders:
  • Mikalai Zaikin

Urgent : help needed is XSLT

 
Greenhorn
Posts: 18
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • 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
 
Ranch Hand
Posts: 171
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • 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
    Number of slices to send:
    Optional 'thank-you' note:
  • 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.
 
Ranch Hand
Posts: 116
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • 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
 
Greenhorn
Posts: 23
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • 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
    Number of slices to send:
    Optional 'thank-you' note:
  • 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
    Number of slices to send:
    Optional 'thank-you' note:
  • 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
 
Don't get me started about those stupid light bulbs.
reply
    Bookmark Topic Watch Topic
  • New Topic