sparklemotion/nokogiri

JRuby nokogiri incorrectly include xml declaration for html transformation

Open

#1,430 创建于 2016年2月17日

在 GitHub 查看
 (4 评论) (0 反应) (0 负责人)Ruby (5,615 star) (806 fork)batch import
help wantedneeds/researchplatform/jruby

描述

Using the following code:

input_xml = <<-EOS
<?xml version="1.0" encoding="utf-8"?>
<report>
  <title>My Report</title>
</report>
EOS

input_xsl = <<-EOS
<?xml version="1.0" encoding="utf-8"?>
<xsl:stylesheet version="1.0" xmlns:xsl="http://www.w3.org/1999/XSL/Transform">
  <xsl:template match="/">
    <html>
      <head>
        <title><xsl:value-of select="report/title"/></title>
      </head>
      <body>
        <h1><xsl:value-of select="report/title"/></h1>
      </body>
    </html>
  </xsl:template>
</xsl:stylesheet>
EOS

require 'nokogiri'

xml = ::Nokogiri::XML(input_xml)
xsl = ::Nokogiri::XSLT(input_xsl)

puts xsl.apply_to(xml)

expected behavior:

<html>
<head>
<meta http-equiv="Content-Type" content="text/html; charset=UTF-8">
<title>My Report</title>
</head>
<body><h1>My Report</h1></body>
</html>

actual behavior:

<?xml version="1.0" encoding="UTF-8"?><html><head><title>My Report</title></head><body><h1>My Report</h1></body></html>

贡献者指南

JRuby nokogiri incorrectly include xml declaration for html transformation · sparklemotion/nokogiri#1430 | Good First Issue