Skip to content

Commit

Permalink
feat: force standalone="yes" when standalone is set to true on the XM…
Browse files Browse the repository at this point in the history
…L builder #1414
  • Loading branch information
Ronald Holshausen committed Sep 4, 2021
1 parent 3c752cd commit 8ef8611
Show file tree
Hide file tree
Showing 2 changed files with 5 additions and 1 deletion.
Original file line number Diff line number Diff line change
Expand Up @@ -77,6 +77,10 @@ class PactXmlBuilder @JvmOverloads constructor (
fun asBytes(charset: Charset? = null): ByteArray {
val transformer = TransformerFactory.newInstance().newTransformer()
transformer.setOutputProperty(OutputKeys.INDENT, "yes")
if (standalone) {
transformer.setOutputProperty(OutputKeys.STANDALONE, "yes")
}

val source = DOMSource(doc)
val outputStream = ByteArrayOutputStream()
val result = if (charset != null) {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -134,7 +134,7 @@ class PactXmlBuilderSpec extends Specification {
where:

standalone | value
true | '<?xml version="1.0" encoding="UTF-8"?>'
true | '<?xml version="1.0" encoding="UTF-8" standalone="yes"?>'
false | '<?xml version="1.0" encoding="UTF-8" standalone="no"?>'
}
}

0 comments on commit 8ef8611

Please sign in to comment.