groovy

MarkupBuilder alignment of special mkp commands compared with StreamingMarkupBuilder

Details

  • Type: Improvement Improvement
  • Status: Closed Closed
  • Priority: Major Major
  • Resolution: Fixed
  • Affects Version/s: 1.7-beta-1, 1.6.5
  • Fix Version/s: 1.7-beta-2, 1.6.6
  • Component/s: XML Processing
  • Labels:
    None
  • Number of attachments :
    2

Description

StreamingMarkupBuilder supports:

mkp.comment
mkp.pi
mkp.xmlDeclaration

They can be emulated using just mkp.yieldUnescaped but MarkupBuilder should also support these convenience methods to ease learning about the two approaches.

Activity

Hide
Paul King added a comment -

Proposed patch. A minor break in backwards compatibility but seems worthwhile for added consistency between the streaming and non-streaming markup builder classes.

Show
Paul King added a comment - Proposed patch. A minor break in backwards compatibility but seems worthwhile for added consistency between the streaming and non-streaming markup builder classes.
Hide
Guillaume Laforge added a comment -

What is the minor break?
But otherwise, yes, a good thing to align the two builders further.

Show
Guillaume Laforge added a comment - What is the minor break? But otherwise, yes, a good thing to align the two builders further.
Hide
Paul King added a comment -

Because mkp is not required for MarkupBuilder given current builder closure semantic behaviour, if you were producing output like:

def builder = new groovy.xml.MarkupBuilder()
builder.numbers {
    pi('3.14159')
}

or

builder.person {
    name('Guillaume')
    comment('Nice guy')
}

Then you would now have trouble. Workaround would be:

builder.numbers {
    pi('3.14159', [:])
}
Show
Paul King added a comment - Because mkp is not required for MarkupBuilder given current builder closure semantic behaviour, if you were producing output like:
def builder = new groovy.xml.MarkupBuilder()
builder.numbers {
    pi('3.14159')
}
or
builder.person {
    name('Guillaume')
    comment('Nice guy')
}
Then you would now have trouble. Workaround would be:
builder.numbers {
    pi('3.14159', [:])
}
Hide
Guillaume Laforge added a comment -

Ok.

Show
Guillaume Laforge added a comment - Ok.
Hide
Paul King added a comment -

B patch uses a helper class to avoid clashes between pi, comment, etc and element names. It requires you to use mkp.pi etc.

Show
Paul King added a comment - B patch uses a helper class to avoid clashes between pi, comment, etc and element names. It requires you to use mkp.pi etc.
Hide
Paul King added a comment -

B patch applied to HEAD which removes the issue with clashes. Now mkp is always required. Port to 1.6.X leaves ability to drop mkp for yield and yieldUnescaped but avoids clashes for pi, comment and xmlDeclaration.

Show
Paul King added a comment - B patch applied to HEAD which removes the issue with clashes. Now mkp is always required. Port to 1.6.X leaves ability to drop mkp for yield and yieldUnescaped but avoids clashes for pi, comment and xmlDeclaration.

People

Vote (0)
Watch (0)

Dates

  • Created:
    Updated:
    Resolved: