redundent / kotlin-xml-builder

A lightweight type safe builder to build xml documents in Kotlin
Apache License 2.0
151 stars 17 forks source link

Node with element as empty string, does not care about useSelfClosingTags #40

Closed d-wojciechowski closed 3 years ago

d-wojciechowski commented 3 years ago

Hello.

Firstly, this is a very nice library! Secondly, I found a small bug.

When XML object is created, and as node body is given an empty string, and option useSelfClosingTags is used, the output is still with a closing tag.

            "csvparent" {
                    -parent // content is empty string
            }
// output is <csvparent></csvparent>

What I would expect is to have a self-closing tag

As a workaround following solution is applied:

            "csvparent" {
                if(parent.isNotBlank()){
                    -parent
                }
            }
redundent commented 3 years ago

Hey @d-wojciechowski

  1. Thanks!
  2. I'll take a look tomorrow. Seems like a tiny fix so shouldn't be an issue
redundent commented 3 years ago

@d-wojciechowski This is fixed and published. Version 1.7.2 is available