[XML-DEV Mailing List Archive Home] [By Thread] [By Date] [Recent Entries] [Reply To This Message]

RE: Error in a Class Cast


org.apache.crimson.tree.xmldocument
Title: Message
Hi Joao,
 
the error message tells you everything you need to know: your Document is not a com.sun.tree.xml.Document, but one from the apache crimson project. The Crimson parser is a further development of the older Sun parser. You will find most of the methods in the Crimson parser, that were also in the Sun parser.
But why do you want to do this? Normally you should not work on the specific implementation classes, but on the general interfaces!
 
Best regards,
Patrick
-----Original Message-----
From: João Sarraipa [mailto:jfss@u...]
Sent: Mittwoch, 12. Juni 2002 18:35
To: xml-dev@l...
Subject: Error in a Class Cast

Hi!
 
I have the following exception....
exception java.lang.ClassCastException: org.apache.crimson.tree.XmlDocument
when I try make A class cast from org.w3c.dom.Document to com.sun.tree.xml.XmlDocument
 
The code:
 
(...)
 
private DocumentBuilderFactory m_documentBuilderFactory = DocumentBuilderFactory.newInstance();
 
  /** */
  private DocumentBuilder m_documentBuilder;
 
(...)
    try {
      m_documentBuilder = m_documentBuilderFactory.newDocumentBuilder();
    } catch (Exception e) {
      throw new RuntimeException(e.getMessage());
    }
 
(...)
    Document returnDoc = null;
    Node tempNode =  msg.getContent();
    
    tempNode = FIPA.ACL.Util.getNode(tempNode, FIPAConstants.Apply);
    if (FIPAConstants.Action.equals(tempNode.getFirstChild().getNodeName())) {
      tempNode = FIPA.ACL.Util.getNode(tempNode, FIPAConstants.Apply);
     
      // checks whether it is really a forward action ...
      String messageType = tempNode.getFirstChild().getFirstChild().getFirstChild().getNodeValue();
      if (messageType.indexOf(FIPAConstants.Forward) >= 0 ) {
        
        tempNode = Util.getNode(tempNode, FIPAConstants.Message );
        if (tempNode == null) {
          System.out.println("ACC: message content is null !!");
        }
 
        returnDoc = m_documentBuilder.newDocument();
        try {
          Node copy = tempNode.cloneNode(true);
          com.sun.xml.tree.XmlDocument xmlD=(com.sun.xml.tree.XmlDocument) returnDoc;    ***********Localization of ERROR **************
          xmlD.changeNodeOwner(copy);
          returnDoc.appendChild(copy); //aha
        } catch (Exception e) {
          System.out.print("ACC: caught exception "+e.toString()+"\n");
          e.printStackTrace() ;
        }
 
 
 
Can you help me?
 
Thanks in advanced.
 
João Sarraipa

PURCHASE STYLUS STUDIO ONLINE TODAY!

Purchasing Stylus Studio from our online shop is Easy, Secure and Value Priced!

Buy Stylus Studio Now

Download The World's Best XML IDE!

Accelerate XML development with our award-winning XML IDE - Download a free trial today!

Don't miss another message! Subscribe to this list today.
Email
First Name
Last Name
Company
Subscribe in XML format
RSS 2.0
Atom 0.3
 

Stylus Studio has published XML-DEV in RSS and ATOM formats, enabling users to easily subcribe to the list from their preferred news reader application.


Stylus Studio Sponsored Links are added links designed to provide related and additional information to the visitors of this website. they were not included by the author in the initial post. To view the content without the Sponsor Links please click here.

Site Map | Privacy Policy | Terms of Use | Trademarks
Free Stylus Studio XML Training:
W3C Member
Stylus Studio® and DataDirect XQuery ™are products from DataDirect Technologies, is a registered trademark of Progress Software Corporation, in the U.S. and other countries. © 2004-2013 All Rights Reserved.