[
https://issues.apache.org/jira/browse/GROOVY-8100?page=com.atlassian.jira.plugin.system.issuetabpanels:all-tabpanel
]
Jochen Eddelbuettel updated GROOVY-8100:
----------------------------------------
Priority: Major (was: Minor)
> MarkupBuilder cant yield before first tag
> -----------------------------------------
>
> Key: GROOVY-8100
> URL: https://issues.apache.org/jira/browse/GROOVY-8100
> Project: Groovy
> Issue Type: Bug
> Components: XML Processing
> Affects Versions: 2.4.8
> Environment: Oracle Java 1.8.0_112, Windows 10 x64
> Reporter: Jochen Eddelbuettel
> Priority: Major
>
> Trying to produce an HTML5 compliant !DOCTYPE before starting with the
> HTML-Elements. Without setting the private field 'state' to 2, the output
> does not show the yielded output.
> {code}
> def html = new groovy.xml.MarkupBuilder(new PrintWriter(System.out))
> //html.state = 2
> html.mkp.yieldUnescaped("<!DOCTYPE html>\n")
> html.h1("Header")
> {code}
> I suggest fixing this by changing the yield-Method to not check the state
> before doing the output, so that we see some output when the initial state is
> still 0:
> {code}
> void yield(String value, boolean escaping) {
> if (state == 1) {
> state = 2;
> this.nodeIsEmpty = false;
> out.print(">");
> }
> // -- remove -- if (state == 2 || state == 3) {
> out.print(escaping ? escapeElementContent(value) : value);
> // -- remove -- }
> }
> {code}
--
This message was sent by Atlassian Jira
(v8.3.4#803005)