Home | Contact Us | FAQ | Search & Site Map | Link to Us
Sign In | Join | Other 45 Sites in Network
HomeAnnouncementsWhite Papers
Discussion GroupsFirst AidDatabasesJavaBeansGUIJava 3DVirtual MachineCORBASecurityToolsGeneral
Java DirectoryOpen Source ProjectsSample Book ChaptersUser GroupsWeb Resources
Related Topics
Databases.NETMore Topics ...

Java Forum / General / April 2007

Tip: Looking for answers? Try searching our database.

JTidy Problem

Thread view: 
k4 - 02 Apr 2007 21:01 GMT
Hi

I have problem with JTidy, I can't return text between <p> xx </p> :/

import org.w3c.dom.Document;
import org.w3c.dom.Node;
import org.w3c.dom.NodeList;
import org.w3c.tidy.Tidy;

public static void main(String[] args) {

        try {
        Tidy tdpr = new Tidy();
        Document dc;

        tdpr.setShowWarnings(false);
        tdpr.setXHTML(true);

        FileInputStream zoo = new FileInputStream("index.html");
        BufferedInputStream in = new BufferedInputStream(zoo);
        BufferedOutputStream out = new BufferedOutputStream(new
  FileOutputStream("bar.html"));

        dc = tdpr.parseDOM(in, null);
        NodeList tag = dc.getElementsByTagName("p");
        System.out.print(tag.getLength());
        Node uchwyt = tag.item(0);
        System.out.print(uchwyt.getFirstChild().getTextContent());

    }catch (Exception z) {}

any idee ?
k4 - 02 Apr 2007 22:34 GMT
k4 napisał(a):
> Hi
>
[quoted text clipped - 28 lines]
>
> any idee ?

My error:
Exception in thread "main" java.lang.AbstractMethodError:
org.w3c.tidy.DOMElementImpl.setTextContent(Ljava/lang/String;)V

Why ???? All day i spend time to run this Jtidy :(
Tom Hawtin - 02 Apr 2007 23:10 GMT
> My error:
> Exception in thread "main" java.lang.AbstractMethodError:
> org.w3c.tidy.DOMElementImpl.setTextContent(Ljava/lang/String;)V

That's a /little/ more information than "I can't return text between <p>
xx </p>".

AbstractMethodError API docs say:

"Thrown when an application tries to call an abstract method. Normally,
this error is caught by the compiler; this error can only occur at run
time if the definition of some class has incompatibly changed since the
currently executing method was last compiled."

Essentially you've called an abstract method (as interface methods are)
and the implementing class hasn't implemented it. How? Probably it was
compiled with an earlier version of the interface that didn't have that
method.

API docs for Node.setTextContent/getTextContent:

"Since:
    DOM Level 3"

JTidy doesn't support DOM Level 3 (or fully support Level 2 come to
that). So you need to use the old school methods, which I believe is to
iterate through the tree looking for Text nodes.

Tom Hawtin


Free Magazines

Get these publications absolutely FREE for up to 12 months. There are no hidden fees and no obligation. Simply choose a title, complete the application form and submit it. Read more ...

Oracle MagazineNetwork ComputingComputer WorldBio-IT WorldeWeekInformation WeekInfosecurity
 
Sign In
Join
My Latest Posts
My Monitored Threads
My Blog
My Photo Gallery
My Profile
My Homepage

Start New Thread
Enable EMail Alerts
Rate this Thread



©2008 Advenet LLC   Privacy Policy - Terms of Use
This website includes both content owned or controlled by Advenet as well as content owned or controlled by third parties.