I have a better example which better show my problem :
public interface SecNode extends Node { } public interface SecElement extends SecNode { } public class SecElementImpl extends ElementImpl implements SecElement { } public interface SecElementNS extends SecElement { } public class SecElementNSImpl extends ElementNSImpl implements SecElementNS { } public interface SecDocument extends SecNode { } public class SecDocumentImpl extends DocumentImpl implements SecDocument { } In this class, when I try this : SecNode root = (SecNode)this.getDocumentElement(); or SecElement root = (SecElement)this.getDocumentElement(); I get this Exception : java.lang.ClassCastException: org.apache.xerces.dom.ElementNSImpl but only with xerces version >= 2 with previouses it perfectly works. What is the problem ? ---------- Initial Header ----------- From : Michael Glavassevich <[EMAIL PROTECTED]> To : [EMAIL PROTECTED] Cc : Date : Mon, 21 Feb 2005 17:05:17 -0500 Subject : Re: java.lang.ClassCastException: org.apache.xerces.dom.ElementNSImpl Perhaps I'm missing something but it seems you've extended Node but not ElementNSImpl to implement this new interface. You'd also have to return an instance of the subclass from Document.createElementNS(). If you haven't done that then the ClassCastException should be expected since the element doesn't implement SecureDocument. "[EMAIL PROTECTED]" <[EMAIL PROTECTED]> wrote on 02/21/2005 11:11:05 AM: > Hello, > > I got a strange exception. Here is my problem : > > public interface SecureDocument extends Node { > } > > public class SecDocImpl extends DocumentImpl { > > public static void main(String[] args) { > > try { > > InputStream is = new FileInputStream("pathtofile"); > DOMParser p = new DOMParser(); > > > p.setProperty("http://apache.org/xml/properties/dom/document-class-name", > "mypackage.SecDocImpl"); > > p.parse(new InputSource(is)); > SecDocImpl m= (SecDocImpl)p.getDocument() ; > is.close(); > > DocumentImpl tmp = (DocumentImpl)m ; > Element e = tmp.getDocumentElement() ; > Node r = (Node)e ; //it's just to try > here is the error------> SecureDocument root = > (SecureDocument)e ; > > } catch (Exception e) { > System.err.println("error") ; > } > } > } > } > > And the exception is : > java.lang.ClassCastException: > org.apache.xerces.dom.ElementNSImpl > > with no more explanation. > > Can anybody help me ? > > > > ************************ ADSL JUSQU'A 16 MEGA + TELEPHONE GRATUIT > ************************ > L'ultra haut débit à 30EUR/mois seulement ! Et vous téléphonez > gratuitement en France vers les postes fixes, hors numéros spéciaux. > Pour profiter de cette offre exceptionnelle, cliquez ici : http: > //register.tiscali.fr/adsl/ (voir conditions sur le site) > > > > > --------------------------------------------------------------------- > To unsubscribe, e-mail: [EMAIL PROTECTED] > For additional commands, e-mail: [EMAIL PROTECTED] > Michael Glavassevich XML Parser Development IBM Toronto Lab E-mail: [EMAIL PROTECTED] E-mail: [EMAIL PROTECTED] --------------------------------------------------------------------- To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED] ************************ ADSL JUSQU'A 16 MEGA + TELEPHONE GRATUIT ************************ L'ultra haut débit à 30EUR/mois seulement ! Et vous téléphonez gratuitement en France vers les postes fixes, hors numéros spéciaux. Pour profiter de cette offre exceptionnelle, cliquez ici : http://register.tiscali.fr/adsl/ (voir conditions sur le site) --------------------------------------------------------------------- To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED]