Reply
to transform or not to transform
Old 04-23-2008, 05:48 AM to transform or not to transform
Novice Talker

Posts: 12
Name: Matthew Benton
I've got a news page which is being sent out as an email to our organisation from a java application (which I'm coding). But we don't want the top and left navigation divs.

My boss muttered something about using an XSL transform to select the divs we do want, but I reckon he thinks I'm starting with a load of XML data, (which I'm not, the app is dealing with existing html code). So does applying a transform to an html page to produce another html page make sense? Or do I have to do a load of string manipulation in Java (potentially messy). Or maybe there's a better way?

Thanks in advance!
matt
mattnotfat is offline
Reply With Quote
View Public Profile
 
Sponsored Links (We share ad revenue):
 
Old 04-23-2008, 06:38 AM Re: to transform or not to transform
tripy's Avatar
Fetchez la vache!

Latest Blog Post:
Pretty pretty please….
Posts: 1,689
Name: Thierry
Location: In the void
XSL cannot be applied to HTML.
It can only work on XML, but can output HTML.

I have no past experience in Java, but try to look for a DOM parser.
It allows you to instantiate a tree of the page, and then you should be able to exrtact what is useful for you, and re-create a simple html with an XSL processor.
Here is a PHP dom parser reference:
http://www.php.net/manual/en/domdocument.loadhtml.php

PS:
I just found this via google:
http://java.sun.com/j2se/1.5.0/docs/.../Document.html
__________________
Listen to the ducky: "This is awesome!!!"

tripy is offline
Reply With Quote
View Public Profile
 
Old 04-23-2008, 06:48 AM Re: to transform or not to transform
Novice Talker

Posts: 12
Name: Matthew Benton
Ah, thanks tripy. A Dom passer sounds more appropriate for this
mattnotfat is offline
Reply With Quote
View Public Profile
 
Old 04-23-2008, 10:32 AM Re: to transform or not to transform
willcode4beer's Avatar
Webmaster Talker

Posts: 525
Name: Paul Davis
Location: San Francisco
Quote:
Originally Posted by tripy View Post
XSL cannot be applied to HTML.
But, it can be applied to XHTML

Quote:
Originally Posted by tripy View Post
I have no past experience in Java, but try to look for a DOM parser.
It allows you to instantiate a tree of the page, and then you should be able to exrtact what is useful for you, and re-create a simple html with an XSL processor.
Since version 1.4 all standard java installs come with both a parser and xsl transformer.

For HTML, one option could be to use jTidy to get a DOM object. This can be fed to a transformer, manipulated or just written out.

For your particular case, try jTidy to create a DOM, then remove the nodes corresponding to the divs you don't want, then just output the DOM object as XHTML.

Of note, jTidy is also pretty good at dealing with bad markup.
__________________
Paul Davis
willCode4Beer.com (coding for all the right reasons)
willcode4beer is offline
Reply With Quote
View Public Profile
 
Sponsored Links (We share ad revenue):
 
Reply     « Reply to to transform or not to transform
 

Thread Tools

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

vB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are Off
Pingbacks are Off
Refbacks are Off




   
RSS Feed  Feeds: RSS   JS   XML
RSS Feed  Feeds for this forum: RSS   JS   XML


Page generated in 0.14990 seconds with 14 queries