Ruud,

I recently made some changes in JXPath that are supposed to make this
issue go away.  When you have a chance, could you try and let me know?

Thanks,

- Dmitri

--- Ruud Diterwich <[EMAIL PROTECTED]> wrote:
> Hi all,
> 
> I'm experiencing problems with variables that have been assigned DOM
> nodes. In particular, the JXPathContext.getValue method ends up
> calling
> Element.toString, which does not result in the value of a DOM node
> according to the XPath spec. 
> 
>       public void testJXPathDOMVariable() throws Exception {
>       
>               // read book xml
>               String xmlString = "<book>This is my book</book>";
>               Document doc =
> DocumentBuilderFactory.newInstance().newDocumentBuilder().parse(new
> ByteArrayInputStream(xmlString.getBytes()));
>               Element book = doc.getDocumentElement();
>               
>               // evaluate the value of book directly
>               JXPathContext context = JXPathContext.newContext(book);
>               String value = (String) context.getValue(".",
> String.class);
>               System.out.println("value: " + value);
>               
>               // evaluate the value of book using a variable
>               Variables variables = context.getVariables();
>               variables.declareVariable("i", book);
>               value = (String) context.getValue("$i", String.class);
>               System.out.println("value: " + value);
> 
>               // evaluate the value of book using a variable, second
> attempt
>               variables.declareVariable("i", new DOMNodePointer(book,
> Locale.getDefault()));
>               value = (String) context.getValue("$i", String.class);
>               System.out.println("value: " + value);
>       }
> 
> result:
> 
>       value: This is my book
>       value: [book: null]
>       value:
> 
> I expected the second value to be 'This is my book' as well. The
> value
> '[book: null]' is produced by Xerces' DOM.toString method. What am I
> doing wrong?
> 
> Ruud Diterwich
> 
> 
> --
> To unsubscribe, e-mail:  
> <mailto:[EMAIL PROTECTED]>
> For additional commands, e-mail:
> <mailto:[EMAIL PROTECTED]>
> 


__________________________________________________
Do you Yahoo!?
Yahoo! Mail Plus - Powerful. Affordable. Sign up now.
http://mailplus.yahoo.com

--
To unsubscribe, e-mail:   <mailto:[EMAIL PROTECTED]>
For additional commands, e-mail: <mailto:[EMAIL PROTECTED]>

Reply via email to