Details
-
Type:
Improvement
-
Status:
Closed
-
Priority:
Trivial
-
Resolution: Fixed
-
Affects Version/s: 1.0
-
Fix Version/s: 1.1-rc-1
-
Component/s: XML Processing
-
Labels:None
-
Number of attachments :
Description
Can we alter MarkupBuilder to ignore optional attributes that aren't specified (contain null values).
Currently MarkupBuilder throws a NullPointerException if I create a node using attributes that contain a null map value. For example:
def writer = new StringWriter()
def builder = new MarkupBuilder(writer)
builder.A {
B {
C(D: 'E', F: null) {
}
}
}
// throws NullPointerException in MarkupBuilder.createNode
When building XML using MarkupBuilder, I find it useful to specify all attributes (required or optional) for a node in one line rather than having to implement ugly logic checks myself like follows:
builder.A {
B {
def map = [:]
if (E) {
map['D'] = 'E'
}
if (F) {
map['F'] = 'G'
}
C(map) {
}
}
}
Should be fixed in HEAD