DSL Scope: Elements possible at unwanted positions

Hi there,

I just read and played around with the kotlin’s dsl feature (@DslMarker) https://kotlinlang.org/docs/reference/type-safe-builders.html#full-definition-of-the-comexamplehtml-package

But I’m able to place elements at unwanted positions

fun result() =
    html {
        head {
            title { +"XML encoding with Kotlin" }
        }
        head {
            title { +"title of 2nd unwanted head" }
        }
        html {
            head {
                title { +"title of unwanted html" }
            }
        }
    }
  1. Is there a way to disallow a second head?
  2. Is there a way to disallow html within html?