diff --git a/ext/java/nokogiri/XsltStylesheet.java b/ext/java/nokogiri/XsltStylesheet.java index 856571b9ae..37ba8f71f1 100644 --- a/ext/java/nokogiri/XsltStylesheet.java +++ b/ext/java/nokogiri/XsltStylesheet.java @@ -13,6 +13,7 @@ import java.util.regex.Matcher; import java.util.regex.Pattern; +import javax.xml.transform.OutputKeys; import javax.xml.transform.Templates; import javax.xml.transform.Transformer; import javax.xml.transform.TransformerConfigurationException; @@ -184,9 +185,15 @@ public class XsltStylesheet extends RubyObject XmlDocument xmlDoc = (XmlDocument) doc; ByteArrayOutputStream writer = new ByteArrayOutputStream(); - Serializer serializer = SerializerFactory.getSerializer(this.sheet.getOutputProperties()); + java.util.Properties props = this.sheet.getOutputProperties(); + if (props.getProperty(OutputKeys.METHOD) == null) { + props.setProperty(OutputKeys.METHOD, org.apache.xml.serializer.Method.UNKNOWN); + } + + Serializer serializer = SerializerFactory.getSerializer(props); serializer.setOutputStream(writer); ((SerializationHandler) serializer).serialize(xmlDoc.getNode()); + return context.getRuntime().newString(writer.toString()); }