From 3a83787836c08951bde1166a077f8cb05a17a5f2 Mon Sep 17 00:00:00 2001 From: "Piotr P. Karwasz" Date: Wed, 20 Dec 2023 22:11:31 +0100 Subject: [PATCH] Fix XML encoding --- .../log4j/docgen/internal/DefaultSchemaGenerator.java | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/log4j-docgen/src/main/java/org/apache/logging/log4j/docgen/internal/DefaultSchemaGenerator.java b/log4j-docgen/src/main/java/org/apache/logging/log4j/docgen/internal/DefaultSchemaGenerator.java index 0ea942fc..31195b49 100644 --- a/log4j-docgen/src/main/java/org/apache/logging/log4j/docgen/internal/DefaultSchemaGenerator.java +++ b/log4j-docgen/src/main/java/org/apache/logging/log4j/docgen/internal/DefaultSchemaGenerator.java @@ -52,6 +52,7 @@ public class DefaultSchemaGenerator implements SchemaGenerator { private static final String LOG4J_NAMESPACE = "http://logging.apache.org/log4j/2.0/config"; private static final String XSD_NAMESPACE = XMLConstants.W3C_XML_SCHEMA_NS_URI; private static final String MULTIPLICITY_UNBOUNDED = "*"; + private static final String UTF_8 = "UTF-8"; @Override public void generateSchema(final SchemaGeneratorRequest request) throws XMLStreamException { @@ -63,7 +64,7 @@ public void generateSchema(final SchemaGeneratorRequest request) throws XMLStrea final TypeLookup lookup = TypeLookup.of(extendedSets); final XMLOutputFactory factory = XMLOutputFactory.newFactory(); final Path schemaPath = request.getOutputDirectory().resolve(request.getFileName()); - final XMLStreamWriter writer = factory.createXMLStreamWriter(Files.newOutputStream(schemaPath)); + final XMLStreamWriter writer = factory.createXMLStreamWriter(Files.newOutputStream(schemaPath), UTF_8); try { writeSchema(lookup, writer); } finally { @@ -75,7 +76,7 @@ public void generateSchema(final SchemaGeneratorRequest request) throws XMLStrea } private static void writeSchema(final TypeLookup lookup, final XMLStreamWriter writer) throws XMLStreamException { - writer.writeStartDocument("UTF-8", "1.0"); + writer.writeStartDocument(UTF_8, "1.0"); writer.setDefaultNamespace(XSD_NAMESPACE); writer.writeStartElement(XSD_NAMESPACE, "schema"); writer.writeDefaultNamespace(XSD_NAMESPACE);