homebrew-core/Formula/saxon.rb

44 lines
1.2 KiB
Ruby

class Saxon < Formula
desc "XSLT and XQuery processor"
homepage "https://saxon.sourceforge.io"
url "https://downloads.sourceforge.net/project/saxon/Saxon-HE/10/Java/SaxonHE10-3J.zip"
version "10.3"
sha256 "6cfb72a68418d3b9a0c9dc0d0b399179c23dfe312e792eec578bf745caa58a25"
livecheck do
url :stable
regex(%r{url=.*?/SaxonHE(\d+(?:[.-]\d+)+)J?\.(?:t|zip)}i)
end
bottle :unneeded
def install
libexec.install Dir["*.jar", "doc", "notices"]
bin.write_jar_script libexec/"saxon-he-#{version.major_minor}.jar", "saxon"
end
test do
(testpath/"test.xml").write <<~EOS
<test>It works!</test>
EOS
(testpath/"test.xsl").write <<~EOS
<xsl:stylesheet xmlns:xsl="http://www.w3.org/1999/XSL/Transform" version="2.0">
<xsl:template match="/">
<html>
<body>
<p><xsl:value-of select="test"/></p>
</body>
</html>
</xsl:template>
</xsl:stylesheet>
EOS
assert_equal <<~EOS.chop, shell_output("#{bin}/saxon test.xml test.xsl")
<!DOCTYPE HTML><html>
<body>
<p>It works!</p>
</body>
</html>
EOS
end
end