[Home] [By Thread] [By Date] [Recent Entries]

  • 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

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

Site Map | Privacy Policy | Terms of Use | Trademarks
Free Stylus Studio XML Training:
W3C Member