W3C home > Mailing lists > Public > www-dom@w3.org > October to December 2000

nullPointerException in importNode

From: Juan J. Merelo <jj.merelo@civista.com>
Date: Tue, 7 Nov 2000 16:39:00 -1200
Message-ID: <00ba01c0493d$d0502580$3001a8c0@CIVISTADTDEV52>
To: <www-dom@w3.org>
Extending a bit in my previous message: this what I want to do. Get a file,
tidy it, and then convert it to xerces DOM (to eventually show it on a web

public class TestDOM3 {

  public TestDOM3() {}

  public static void main(String args[]) {

    FileInputStream in;
    Tidy tidy = new Tidy();
    TestDOM3 t = new TestDOM3();

    try {
      in = new FileInputStream("kk2.html");
      Node myNode = tidy.parseDOM(in, null);
      Document myDoc = new DocumentImpl();
      myDoc.appendChild( myDoc.importNode( myNode, false ));
    catch ( IOException e ) {
      System.err.println( "IO Exception " + e.toString() );



This seems pretty much straight forward, but I get this exception:
C:\progs\jakarta-tomcat\webapps\cocoon\mixsp>java -classpath
aug2000r5\build\Tidy.jar;c:\progs\xerces-1_2_1\tools\xerces.jar TestDOM3
Exception in thread "main" java.lang.NullPointerException
        at TestDOM3.main(TestDOM3.java:27)


Is there something else that must be done to import a Node? Same goes if I
import with "true" as second argument.

Thanks for any hint!

Name: Juan J. Merelo
Title: Consultant
Telephone:   +44 (0) 20 84086.....
Mobile:        +34 627 397239
Facsimile:    +44 (0) 20 84086399

Services and Applications for a Wireless World
This e-mail and the information that it contains may be confidential and
protected by law and is for access by the intended recipient only. Any
liability (in negligence or otherwise) arising from any third party acting,
or refraining from acting, on any information contained in this e-mail is
hereby excluded. If you are not the intended recipient, please notify the
sender immediately and do not disclose the contents to any other person, use
it for any purpose, or store or copy the information in any medium.
Copyright in this e-mail and any attachments belongs to Civista Limited
and/or its subsidiary companies.
While this message is virus checked, Civista can not be held responsible for
its integrity.
Received on Tuesday, 7 November 2000 08:38:05 UTC

This archive was generated by hypermail 2.3.1 : Tuesday, 20 October 2015 10:46:07 UTC