xmlutil
xmlutil copied to clipboard
Builder options for specifying the default output kinds
On a few projects now, I've been forced to extend DefaultXmlSerializationPolicy just to change the value of defaultPrimitiveOutputKind.
I think it would be a bit nicer to allow users to specify the value of defaultPrimitiveOutputKind and perhaps defaultObjectOutputKind via the builder syntax.
What I write now
val Xml = XML {
policy = XmlPolicy
}
private object XmlPolicy : DefaultXmlSerializationPolicy({
encodeDefault = XmlSerializationPolicy.XmlEncodeDefault.NEVER
}) {
override val defaultPrimitiveOutputKind: OutputKind = OutputKind.Element
}
What I would like to write
val Xml = XML {
defaultPolicy {
encodeDefault = XmlSerializationPolicy.XmlEncodeDefault.NEVER
defaultPrimitiveOutputKind = OutputKind.Element
}
}
Please let me know if I'm missing something and whether there is already a simpler way of specifying that I want primitives to be encoded as elements by default.