commons-dev mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From "Adam Crume (JIRA)" <j...@apache.org>
Subject [jira] Commented: (JXPATH-86) Children returned instead of self for arrays when using . selector
Date Wed, 30 May 2007 13:59:15 GMT

    [ https://issues.apache.org/jira/browse/JXPATH-86?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel#action_12500135
] 

Adam Crume commented on JXPATH-86:
----------------------------------

My issue is not with the way the document is structured, although I was misunderstanding it.
 My main issue is that, no matter what "/array" resolves to, "/array/." should resolve to
exactly the same thing.  Considering what you quoted from the docs:

    For example, if property "foo" of the context node has a Container as its value, the XPath
"foo" will produce the contents of that Container, not the container itself. 

doesn't that imply that "/array" should return the contents of the array (or the first element
with getPath()) instead of the array itself?

This is still an issue in SVN HEAD.

> Children returned instead of self for arrays when using . selector
> ------------------------------------------------------------------
>
>                 Key: JXPATH-86
>                 URL: https://issues.apache.org/jira/browse/JXPATH-86
>             Project: Commons JXPath
>          Issue Type: Bug
>    Affects Versions: 1.2 Final
>            Reporter: Adam Crume
>
> The . selector should always return the context node, and the * selector should return
child elements.  However, this doesn't work for arrays:
> JXPathContext context = JXPathContext.newContext(new HashMap());
> context.setValue("array", new String[] {"one", "two", "three"});
> context.setValue("array2", new String[][] { {"a", "b"}, {"c", "d"}});
> context.setValue("person", new Person("Bob", 25));
> String[] paths = {"/array", "/array/.", "/array/*", "/person", "/person/.", "/person/*"};
> for(int i = 0; i < paths.length; i++) {
> 	Pointer pointer = context.getPointer(paths[i]);
> 	System.out.println(pointer.asPath());
> 	Object value = context.getValue(paths[i]);
> 	System.out.println(value);
> 	System.out.println();
> }
> This produces the following output:
> /.[@name='array']
> [Ljava.lang.String;@59b659b6
> /.[@name='array'][1]
> one
> /.[@name='array'][1]/bytes[1]
> 111
> /.[@name='person']
> net.cts.jxpathserializer.Person@760076
> /.[@name='person']
> net.cts.jxpathserializer.Person@760076
> /.[@name='person']/age
> 25

-- 
This message is automatically generated by JIRA.
-
You can reply to this email to add a comment to the issue online.


---------------------------------------------------------------------
To unsubscribe, e-mail: commons-dev-unsubscribe@jakarta.apache.org
For additional commands, e-mail: commons-dev-help@jakarta.apache.org


Mime
View raw message