• 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

How to achieve this using xsl?

 
Greenhorn
Posts: 2
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Dear Friends,
My xml file is some thing like this * xml file is generated using JSP)so the contents of the xml are not static.xml is generated everytime depending upon the user criteria.I want to present the data in xml as a Report using xsl.
<ROW>
<ID>1</ID>
<DID>4444</DID>
<DATE>2/1/2000</DATE>
<TIME> 8:23PM</TIME>
<SOURCE_NO>668788</SOURCE_NO>
<DESTINATION_NO>6566462</DESTINATION_NO>
<DESTINATION_COUNTRY>Pakistan</DESTINATION_COUNTRY>
<DURATION>6</DURATION>
<CALL_CHARGES>1.65</CALL_CHARGES>
</ROW>
<ROW>
<ID>2</ID>
<DID>4444</DID>
<DATE>2/1/2000</DATE>
<TIME> 9:12PM</TIME>
<SOURCE_NO>76878</SOURCE_NO>
<DESTINATION_NO>687878</DESTINATION_NO>
<DESTINATION_COUNTRY>Pakistan</DESTINATION_COUNTRY>
<DURATION>10</DURATION>
<CALL_CHARGES>2.8</CALL_CHARGES>
</ROW>
<ROW>
<ID>3</ID>
<DID>4444</DID>
<DATE>3/1/2000</DATE>
<TIME> 5:05AM</TIME>
<SOURCE_NO>6877</SOURCE_NO>
<DESTINATION_NO>87787</DESTINATION_NO>
<DESTINATION_COUNTRY>Sri Lanka</DESTINATION_COUNTRY>
<DURATION>12</DURATION>
<CALL_CHARGES>1.2</CALL_CHARGES>
</ROW>
<ROW>
<ID>4</ID>
<DID>5555</DID>
<DATE>1/1/2000</DATE>
<TIME> 9:23AM</TIME>
<SOURCE_NO>422135</SOURCE_NO>
<DESTINATION_NO>6566462</DESTINATION_NO>
<DESTINATION_COUNTRY>india</DESTINATION_COUNTRY>
<DURATION>2</DURATION>
<CALL_CHARGES>0.36</CALL_CHARGES>
</ROW>
<ROW>
<ID>5</ID>
<DID>5555<DID>
<DATE>1/1/2000</DATE>
<TIME>10:10AM</TIME>
<SOURCE_NO>6566462</SOURCE_NO>
<DESTINATION_NO>6566543</DESTINATION_NO>
<DESTINATION_COUNTRY>india</DESTINATION_COUNTRY>
<DURATION>3</DURATION>
<CALL_CHARGES>0.87</CALL_CHARGES>
</ROW>
Main thing to note is that <DID></DID> tag has repeated values eg for first 3 rows it is "4444" then for the next 2 row it is "5555"
What i want to achieve is to present the data in xml file in a way such that when i apply processing to rows then DID should be displayed once then the data contained in rows for that DID then next DID...some thing like this...
DID: 4444
Date Time Org.No Ter.No. Country Dur. Chrgs
2/1/2000 8:23PM 668788 6566462 Pakistan 6 1.65
2/1/2000 9:12PM 76878 687878 Pakistan 10 2.8
3/1/2000 5:05AM 6877 87787 Sri Lanka 12 1.2
DID: 5555

1/1/2000 9:23AM 422135 6566462 india 2 0.36
1/1/2000 10:10AM 6566462 6566543 india 3 0.87
is this possible using xsl?
I THANK Any answer or help in advance.
Regards,
Pankaj
 
Ranch Hand
Posts: 106
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
>is that possible with XSL ?
that could
but it would be difficult (IMHO, XSL is a difficult language, expecially with condition statements... in your case you need to order DID elements and after, merge DID elements with an "if" their values are egal)
if I were in your shoes, and to make something simple (I guess your application is in a application server ...) I would use DOM to generate Java Objects and after in the Java world, you can easily order DID elements/roots and merge them following their values. Since, your XML is generated by JSP ... your XML data is not very large, so the use of DOM will not be a performance bottleneck (DOM consumes memory !).
my 2 �uros of advice.
 
Pankaj Ag
Greenhorn
Posts: 2
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Hi Guillaume
Thanks For Replying
Tell You Very Frankly i m new to xml and related tech.I do not know much abt IMHO,DOM that u have mentioned in ur reply,As a solution i 've already grouped ROWS IN the DID tag i.e Rows particular to a DID .some thing like this:
<DID>
<NO>4444</NO>
<ROW>
....
</ROW>
<ROW>
....
</ROW>
....
</DID>
By doing this i m achieving what i desired but the way i m doing it is not satisfactory to me as i have to write more java in the jsp.One thing more i am creating the xml file using a StringBuffer object (say sb) then using sb.append()i m appending tags with values in the object,after this
String sb1 = sb.substring(0,sb.length());
byte buf[]=sb1.getBytes();
OutputStream f = new FileOutputStream("C:/reports/rep1.xml");
f.write(buf);
f.close();
response.sendRedirect("rep1.xml");
1)is this the right way to produce xml ?
I want a detailed answer.
2)is the method used by me has any disadnatage? ,if any do let me know.
3)One thing more i want to delete the file (i.e the xml i've created when the user closes the browser window(IE).How to do it?
Regards,
Pankaj

Originally posted by Guillaume Compagnon:
>is that possible with XSL ?
that could
but it would be difficult (IMHO, XSL is a difficult language, expecially with condition statements... in your case you need to order DID elements and after, merge DID elements with an "if" their values are egal)
if I were in your shoes, and to make something simple (I guess your application is in a application server ...) I would use DOM to generate Java Objects and after in the Java world, you can easily order DID elements/roots and merge them following their values. Since, your XML is generated by JSP ... your XML data is not very large, so the use of DOM will not be a performance bottleneck (DOM consumes memory !).
my 2 �uros of advice.


 
Consider Paul's rocket mass heater.
reply
    Bookmark Topic Watch Topic
  • New Topic