Details
-
Type:
Bug
-
Status:
Closed
-
Priority:
Minor
-
Resolution: Fixed
-
Affects Version/s: 1.7.4
-
Fix Version/s: 1.8.6, 2.0-beta-3
-
Component/s: XML Processing
-
Labels:None
-
Testcase included:yes
-
Number of attachments :
Description
The text() method of groovy.util.Node is coded to return an empty string ("") if you set a value that is not a string or a collection. This means if you set the value as a number you get back an empty string.
Should this method return value.toString() in all cases where value is not a collection?
For instance -
def xml = "<root><node1/></root>" def root = new XmlParser().parseText(xml) root.node1[0].replaceNode() { node2() { childN(5) childS('5') } } assert root.node2[0].childS[0].text() == '5' assert root.node2[0].childN[0].text() == '5'
Activity
Paul King
made changes -
| Field | Original Value | New Value |
|---|---|---|
| Description |
The text() method of groovy.util.Node is coded to return an empty string ("") if you set a value that is not a string or a collection. This means if you set the value as a number you get back an empty string.
Should this method return value.toString() in all cases where value is not a collection? For instance - def xml = "<root><node1/></root>" def root = new XmlParser().parseText(xml) root.node1[0].replaceNode() { node2() { childN(5) childS('5') } } assert root.node2[0].childS[0].text() == '5' assert root.node2[0].childN[0].text() == '5' |
The text() method of groovy.util.Node is coded to return an empty string ("") if you set a value that is not a string or a collection. This means if you set the value as a number you get back an empty string.
Should this method return value.toString() in all cases where value is not a collection? For instance - {code} def xml = "<root><node1/></root>" def root = new XmlParser().parseText(xml) root.node1[0].replaceNode() { node2() { childN(5) childS('5') } } assert root.node2[0].childS[0].text() == '5' assert root.node2[0].childN[0].text() == '5' {code} |
Paul King
made changes -
| Status | Open [ 1 ] | Closed [ 6 ] |
| Assignee | Paul King [ paulk ] | |
| Fix Version/s | 2.0-beta-3 [ 18244 ] | |
| Fix Version/s | 1.8.6 [ 18245 ] | |
| Resolution | Fixed [ 1 ] |
add code tags