Subject: [bug#32947] Add java-xalan.

From: Frank Pursel <[email-masked]>
Date: Wed, 23 Mar 2022 07:14:44 -0700

Oops, I, somehow, dropped some prior work.  I think it's now all here.

>From f9c96acbf38ecbe3dc0e73077f92c6a8be1eb93d Mon Sep 17 00:00:00 2001
Message-Id: <f9c9[email-masked]>
From: Frank Pursel <[email-masked]>
Date: Wed, 23 Feb 2022 13:59:26 -0800
Subject: [PATCH] gnu: Add java-xalan-interp

     * gnu/packages/xml.scm (java-xalan-interp): New variable
---
 gnu/packages/xml.scm | 66 ++++++++++++++++++++++++++++++++++++++++++++
 1 file changed, 66 insertions(+)

diff --git a/gnu/packages/xml.scm b/gnu/packages/xml.scm
index 3ce5e771c7..a4d77b51d7 100644
--- a/gnu/packages/xml.scm
+++ b/gnu/packages/xml.scm
@@ -33,6 +33,8 @@
 ;;; Copyright © 2021 Guillaume Le Vaillant <[email-masked]>
 ;;; Copyright © 2021 David Larsson <[email-masked]>
 ;;; Copyright © 2021 Matthew James Kraai <[email-masked]>
+;;; Copyright © 2022 Frank Pursel <[email-masked]>
+;;; Copyright © 2022 Maxime Devos <[email-masked]>
 ;;;
 ;;; This file is part of GNU Guix.
 ;;;
@@ -2592,3 +2594,67 @@ (define-public python-xmltodict
     (description "This package provides a Python library to convert XML to
 @code{OrderedDict}.")
     (license license:expat)))
+
+(define-public java-xalan-interp
+  (package
+    (name "java-xalan-interp")
+    (version "2.7.2")
+    (source
+     (origin
+       (method url-fetch)
+       (uri (string-append "mirror://apache/xalan/xalan-j/source/xalan-j_"
+                           (string-replace-substring
+                            version "." "_")
+                           "-src.tar.gz"))
+       (sha256
+        (base32 "166vg9i11qzi0vbv09abfb50q8caq8wr6zrwg0cwqws9k394l62w"))
+       (modules '((guix build utils)))
+       (snippet '(begin
+                   (for-each
+                    delete-file
+                    (cons* 
+                     ;; jflex and cup generated files
+                     ;; for removal
+                     "src/org/apache/xalan/xsltc/compiler/XPathLexer.java"
+                     "src/org/apache/xalan/xsltc/compiler/XPathParser.java"
+                     ;; Removing bundled jars
+                     (find-files "." "\\.(jar|tar\\.gz)$")))))))
+    (build-system ant-build-system)
+    (arguments
+     `(#:phases (modify-phases
+                %standard-phases
+                (add-after 'unpack 'prepare-for-build
+                  (lambda* (#:key inputs outputs #:allow-other-keys)
+                    (setenv "ANT_OPTS" "-Dxsltc.java_cup.not_needed=true")
+                    (substitute* "build.xml"
+                      ;; Only the interpretive compiler.  xsltc contains a
+                      ;; circular reference java_cup.
+                      (("(<target name=\"jar\" depends=\"xalan-interpretive.compile),.*"
+                        all pre)
+                       (string-append pre "\""))
+                      (("xml-apis") "jaxp"))
+                    (substitute* (list "src/MANIFEST.MF"
+                                       "src/manifest.xalan-interpretive"
+                                       "src/MANIFEST.SERIALIZER"
+                                       "src/manifest.xsltc")
+                      ;; This stops the indexing phase from searching for
+                      ;; xml-apis in the wrong location -- java-xerces and
+                      ;; java-jaxp are propagated, so the eventual Java
+                      ;; application package will still have access to it.
+                      (("^Class-Path:(.*)$") ""))))
+                (replace 'install
+                  (install-jars "build")))))
+    (native-inputs (list java-junit java-hamcrest-core))
+    (propagated-inputs (list java-jaxp java-xerces))
+    (home-page "https://xalan.apache.org/xalan-j/index.html")
+    (synopsis "Java XSLT processor")
+    (description "XSLT processor in java implementing XSLT Version 1.0, XPath
+Version 1.0, and JAXP 1.3.  It builds on SAX2 and DOM level 3.  This version
+is the fully functional interpreter, xslt, not the xsltc version which may be
+faster.")
+    (license
+     (list
+      license:asl2.0 ; almost everything
+      ;; samples/AppletXMLtoHTML/rabbitwhorn.jpg, according to
+      ;; <https://commons.wikimedia.org/wiki/File:Alice_par_John_Tenniel_37.png>
+      license:public-domain))))
-- 
2.34.0