You are viewing a plain text version of this content. The canonical link for it is here.
Posted to issues@commons.apache.org by "Sandro Mario Zbinden (JIRA)" <ji...@apache.org> on 2018/02/19 18:31:00 UTC

[jira] [Comment Edited] (JXPATH-18) createPathAndSetValue fails

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

Sandro Mario Zbinden edited comment on JXPATH-18 at 2/19/18 6:30 PM:
---------------------------------------------------------------------

Is there a way arround this.

This is a requirement when accessing a key inside a hashmap where the key is numeric.

Example:

 
{code:java}
// code placeholder
Map<String, Object> patients = ImmutableMap.of("1", patient1, "2", patient2);
ImmutableMap<String, Map<String, Object>> patientMap = ImmutableMap.of("patients", patients);
JXPathContext context = JXPathContext.newContext(patientMap);
Object value = context.getValue("patients/1");
{code}
 

 

 


was (Author: sandrozbinden):
Is there a way arround this.

 

This is a requirement when accessing a key inside a hashmap where the key is numeric.

 

Example:

 
{code:java}
// code placeholder
Map<String, Object> patients = ImmutableMap.of("1", patient1, "2", patient2);
ImmutableMap<String, Map<String, Object>> patientMap = ImmutableMap.of("patients", patients);
JXPathContext context = JXPathContext.newContext(patientMap);
Object value = context.getValue("patients/1");
{code}
 

 

 

> createPathAndSetValue fails
> ---------------------------
>
>                 Key: JXPATH-18
>                 URL: https://issues.apache.org/jira/browse/JXPATH-18
>             Project: Commons JXPath
>          Issue Type: Bug
>    Affects Versions: 1.1 Final
>         Environment: Operating System: other
> Platform: All
>            Reporter: Thomas Mathis
>            Priority: Major
>
> jXPathContext.createPathAndSetValue("/element1/element2/1_numberelement","val"));
> fails with the following error:
> org.apache.commons.jxpath.JXPathException: Invalid XPath:
> '/element1/element2/1_numberelement'. Syntax error after: '/element1/element2/'
> 	at org.apache.commons.jxpath.ri.Parser.parseExpression(Parser.java:106)
> 	at
> org.apache.commons.jxpath.ri.JXPathContextReferenceImpl.compileExpression(JXPathContextReferenceImpl.java:248)
> 	at
> org.apache.commons.jxpath.ri.JXPathContextReferenceImpl.createPathAndSetValue(JXPathContextReferenceImpl.java:421)
> This does not happen when I rename the path to "/element1/element2/numberelement_1".
> Gtx,
> Thomas



--
This message was sent by Atlassian JIRA
(v7.6.3#76005)