I finally had time to try this out.

I tried the code, and I wrote some of my own.  I could have sworn that when
I used selectObject("//threadsafe"), I got an error saying "false was not a
List or Node" or something like that.  But, I can't duplicate the error, in
either your test or my code.  Sigh.  
I'd say it must be me.  If I ever do find it, I'll be sure to document the
issue.

In the + side, I've been able to dispel two issue I thought I had with
dom4j.  So, good for it.

I did notice something in my work on this supposed issue:

Doing a selectObject(//threadsafe) returns a List of Nodes, but there is
only 1 node in there.  Why does it do that?

Code:

import org.dom4j.*;
import org.dom4j.io.*;
import java.io.*;
import java.util.*;

public class test {
  public static void main(String args[]) {
    try {
      SAXReader r=new SAXReader();
      Document d=r.read(new FileInputStream("test.xml"));
      Object o=d.selectObject("//threadsafe");
      if(o instanceof List)  {
        System.out.println("List");
        for(int i=0,size=((List)o).size();i<size;i++) {
          Node n=((Node)((List)o).get(i));
          System.out.println("Item #" + i + ":" + n.getText() + "End");
        }
      }
      else if(o instanceof Node) {
        System.out.println("Node");
      }

    } catch (Exception e) {
      e.printStackTrace();
    }
  }
}

Jim Brain, [EMAIL PROTECTED]
"Researching tomorrow's decisions today."
(319) 369-2070 (work)
SYSTEMS ARCHITECT, INDIVIDUAL ITS, LIFE INVESTORS INSURANCE COMPANY OF
AMERICA

 -----Original Message-----
From:   James Strachan [mailto:[EMAIL PROTECTED]] 
Sent:   Sunday, November 11, 2001 3:07 AM
To:     Brain, Jim; DOM4J Mailing List (E-mail)
Subject:        Re: [dom4j-user] Issue with dom4j 1.1

Hi Jim

I've added your test case to CVS. The xml document is in
xml/test/jimBrain.xml and I've added a JUnit test case to demonstrate what I
think you're trying to do at

dom4j/src/test/org/dom4j/xpath/TestSelectSingleNode.java

>From my testing it appears that dom4j 1.1 is working correctly for
selectSingleNode using your XML document. Is there a chance you're doing
something else differently?

BTW you can find an Element and add a comment to it. e.g.

Element server = (Element) document.selectSingleNode(
"/properties/server" );
server.addComment( "this is a comment..." );

For example, could you modify the test case to try reproduce your problem?
The test case is available in the daily build as well as via CVS...

James
----- Original Message -----
From: "Brain, Jim" <[EMAIL PROTECTED]>
To: "DOM4J Mailing List (E-mail)" <[EMAIL PROTECTED]>
Sent: Friday, November 09, 2001 10:58 PM
Subject: [dom4j-user] Issue with dom4j 1.1


> A couple actually:
>
> I had some XML like this:
>
> <?xml version="1.0"?>
> <!-- THis is a comment -->
>
> <properties>
>   <client>
>     <threadsafe>false</threadsafe>
>     <GUI-type>simple</GUI-type>
>   </client>
>   <server id="jimmy">Server Stuff here
>     <db name="Jim">
>       <connection>
>         <URL>http://www.digitalsymbiosis.net</URL>
>         <name>jdcasey</name>
>         <password>nothing</password>
>       </connection>
>       <connection>
>         <URL>http://www.digitalsymbiosis.net</URL>
>         <name>jdcasey</name>
>         <password>nothing</password>
>       </connection>
>       This is a test. This should be the server/db property...
> Sure.
>     </db>
>     <connections>
>       <limit>5</limit>
>       <initial>1</initial>
>     </connections>
>   </server>
> </properties>
>
> When I grab the Document and do
> selectSingleNode("/properties/client/threadsafe");  I get an exception
that
> the item is not a node, I need to use getObject...  Can someone tell me
what
> I am doing wrong?
>
> Also, is ther a way to add a comment to a Node?  I see methods for
> document.addComment, but not ode.addComment.  Did I miss something?
>
> Finally, I can't seem to get relative XPath exp to work.  In the above,
> /properties/server gives Server Stuff here, but server or
properties/server
> (both in document.selectSingleNode() return null.
>
> Jim
>
>
> Jim Brain, [EMAIL PROTECTED] <mailto:[EMAIL PROTECTED]>
> "Researching tomorrow's decisions today."
> (319) 369-2070 (work)
> Systems Architect, Individual ITS, Life Investors Insurance Company of
> America
>
>
> _______________________________________________
> dom4j-user mailing list
> [EMAIL PROTECTED]
> https://lists.sourceforge.net/lists/listinfo/dom4j-user
>


_________________________________________________________
Do You Yahoo!?
Get your free @yahoo.com address at http://mail.yahoo.com

_______________________________________________
dom4j-user mailing list
[EMAIL PROTECTED]
https://lists.sourceforge.net/lists/listinfo/dom4j-user

Reply via email to