• 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:
  • Tim Cooke
  • Campbell Ritchie
  • paul wheaton
  • Ron McLeod
  • Devaka Cooray
Sheriffs:
  • Jeanne Boyarsky
  • Liutauras Vilda
  • Paul Clapham
Saloon Keepers:
  • Tim Holloway
  • Carey Brown
  • Piet Souris
Bartenders:

HTML to XSLT and vice versa generation

 
Ranch Hand
Posts: 109
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Hi all,

I need to generate an XSLT from a HTML and then to combine the XSLT with an xml file to populate data and convert it back to a HTML report.
HTML(with empty data) --------> XSLT ---------> XSLT+XML------->HTML(with data)
Is there is any tool already available to do this? if not how can i acheieve this?

Any help would be appreciated.

Regards,
jeff
 
Ranch Hand
Posts: 290
Oracle Tomcat Server Java
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Dont know of any tools which can do this.

But one approach might be to write an xsl stylesheet to convert HTML to XSL first.

Then this XSL can then be applied to an XML to generate the HTML with data.

Aryan
 
jeff rusty
Ranch Hand
Posts: 109
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
i dont want to write the XSL instead i want it to be automatically generated based on the HTML.

Jeff
 
Author and all-around good cowpoke
Posts: 13078
6
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
You might find it easier to convert your HTML to a Velocity template.

Bill
 
Ranch Hand
Posts: 2187
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator

i dont want to write the XSL instead i want it to be automatically generated based on the HTML.



Can you provide a few examples of the proposed conversion between HTML elements and XSL elements?

For instance, what would a <h4> convert to? Or, what would a <div> convert to?
 
Sheriff
Posts: 28394
100
Eclipse IDE Firefox Browser MySQL Database
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Converting HTML to XSLT seems implausible to me, too. I would like to see an example of how this would work.
 
jeff rusty
Ranch Hand
Posts: 109
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator

For instance, what would a <h4> convert to? Or, what would a <div> convert to?



I am not sure of what will it convert since i am a novice in XSL.I am trying to generate my HTML reports dynamically using the XSLT and XML data and i found that Xalan & Saxon does this very well but i dont want the developers to wirte the XSLT instead i want them to make a proptotype (HTML) of the report with static data and would like to convert it in to a XSLT which adhers to the XML and later on this generated XSLT along with my XML data can transform to a HTML with data populated dynamiclly...

Is it possible to generate XsLT from a HTML automatically?

thanks ,
jeff
 
Paul Clapham
Sheriff
Posts: 28394
100
Eclipse IDE Firefox Browser MySQL Database
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
So, you have an undescribed XML file which is going to be your input, an HTML file which is going to be your output, and an XSLT file which transforms the input to the output. Pretty normal so far.

Now you hope to design an HTML "template" which will somehow represent an idealized form of your output, and you want to take that and somehow generate the XSLT file which does the transformation. I don't see any mention of the XML file which is the input, so if your answer is "yes" then it doesn't matter what's in that XML file. It could even be a bare root element with no content at all. And that's clearly not right. Therefore your answer is "no". The XSLT must have some dependence on the input document.
 
jeff rusty
Ranch Hand
Posts: 109
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator

I don't see any mention of the XML file which is the input



I will pass an XML along with the HTML to generate the XSLT file and that XML will contain the Data in the format required for generating the HTML page. In such a case is it possible to get the XSLT?


Jeff
 
Jimmy Clark
Ranch Hand
Posts: 2187
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator

Is it possible to generate XsLT from a HTML automatically?



Your idea is possible. However, the software needs to be created. I'm not aware of any commercial, proprietary, or open-source product that does what your idea entails.

Good luck!
[ July 15, 2008: Message edited by: James Clark ]
 
Paul Clapham
Sheriff
Posts: 28394
100
Eclipse IDE Firefox Browser MySQL Database
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Yes, every couple of years some new product comes out where you provide the format of the output and it magically produces a program that produces your output from your data. These products are marketed enthusiastically to IT managers and usually end up on a shelf in the server room. I have become cynical about whether program-writing programs are a realistic goal. I don't think they are.

In your case the XSLT is going to include rules like "A <customer> element will be converted to a <table> element, and an <invoice> element will be converted to a <td> element inside that..." and so on. Generally it takes a certain amount of intelligence to intuit those rules by just looking at the inputs and the outputs. It can't be done automatically by a dumb program. And when it can, then the next transformation you need to write turns out to be more complicated than that and your program doesn't work any more. (I'm thinking of my 700-line transformation which turns XML invoices into HTML.)

I'm not saying it couldn't be done. I'm just saying it hasn't been done and you can't do it. And it isn't worthwhile for you to try.
 
Consider Paul's rocket mass heater.
reply
    Bookmark Topic Watch Topic
  • New Topic