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

A. Bargull commented on JXPATH-145:
-----------------------------------

> Is it a bug or a special feature of XPath ?

It isn't a bug. Only "-" is a valid NameChar [1], so "+" must not appear in 
valid xml element names [2]. That means your expression "keywords/A+Rate" is 
treated as "keywords/A  +  Rate", so as an additive expression [3]. Also see 
the note on [4]:
---
NOTE: Since XML allows - in names, the - operator typically needs to be 
preceded by whitespace. For example, foo-bar evaluates to a node-set containing 
the child elements named foo-bar; foo - bar evaluates to the difference of the 
result of converting the string-value of the first foo child element to a 
number and the result of converting the string-value of the first bar child to 
a number.
---

[1] http://www.w3.org/TR/REC-xml/#NT-NameChar
[2] http://www.w3.org/TR/REC-xml-names/#NT-NCName
[3] http://www.w3.org/TR/xpath/#NT-AdditiveExpr
[4] http://www.w3.org/TR/xpath/#numbers

> Problem Setting Value to an XPath containing a "+" in the XPATH Name
> --------------------------------------------------------------------
>
>                 Key: JXPATH-145
>                 URL: https://issues.apache.org/jira/browse/JXPATH-145
>             Project: Commons JXPath
>          Issue Type: Bug
>    Affects Versions: 1.3
>            Reporter: Alexandre GIGLEUX
>
> Hi,
> Here is the code which fail into Exception:
> {code}
>     Trade trade = new Trade();
>     JXPathContext ctx = JXPathContext.newContext(trade);
>     ctx.setValue("keywords", new Hashtable());
>     ctx.setValue("keywords/ExternalSystem", "TEST");
>     ctx.setValue("keywords/A+Rate", "1.2");
> {code}
> When I try to set the value of "keywords/A+Rate" I get the Exception:
> Exception in thread "main" org.apache.commons.jxpath.JXPathException: 
> Exception trying to set value with xpath keywords/A+Rate; Cannot set value 
> for xpath: keywords/A+Rate
> When I change the "A+Rate" to "A-Rate". It's OK.
> Is it a bug or a special feature of XPath ?
> Thanks

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

Reply via email to