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

Error in a Class Cast

  • To: <xml-dev@l...>
  • Subject: Error in a Class Cast
  • From: Joćo Sarraipa <jfss@u...>
  • Date: Wed, 12 Jun 2002 17:35:04 +0100

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.