diff --git a/Makefile.top b/Makefile.top
index 8fd5620aa9d9..e188cdcbcc26 100644
--- a/Makefile.top
+++ b/Makefile.top
@@ -133,6 +133,7 @@ sal\
salhelper\
sane\
sax\
+saxon\
sc\
scaddins\
sccomp\
@@ -245,7 +246,6 @@ postprocess\
python\
redland\
rhino\
-saxon\
setup_native\
stax\
stlport\
diff --git a/config_host.mk.in b/config_host.mk.in
index 9814f16d775c..473ab5dd69fa 100644
--- a/config_host.mk.in
+++ b/config_host.mk.in
@@ -483,6 +483,7 @@ export RTL_ARCH=@RTL_ARCH@
export SAC_JAR=@SAC_JAR@
export SAL_ENABLE_FILE_LOCKING=1
export SAXON_JAR=@SAXON_JAR@
+export SAXON_TARBALL=@SAXON_TARBALL@
export SCPDEFS=@SCPDEFS@
export SERVLETAPI_JAR=@SERVLETAPI_JAR@
export SHOWINCLUDES_PREFIX=@SHOWINCLUDES_PREFIX@
diff --git a/configure.in b/configure.in
index ac9266cb8d3f..7c7ce66297b6 100644
--- a/configure.in
+++ b/configure.in
@@ -7697,9 +7697,11 @@ else
AC_MSG_RESULT([internal])
SYSTEM_SAXON=NO
NEED_SAXON=TRUE
+ SAXON_TARBALL=ada24d37d8d638b3d8a9985e80bc2978-source-9.0.0.7-bj.zip
fi
fi
AC_SUBST(SYSTEM_SAXON)
+AC_SUBST(SAXON_TARBALL)
AC_SUBST(SAXON_JAR)
if test -n "$NEED_SAXON"; then
diff --git a/saxon/ExternalProject_saxon.mk b/saxon/ExternalProject_saxon.mk
new file mode 100644
index 000000000000..03f0b94436fa
--- /dev/null
+++ b/saxon/ExternalProject_saxon.mk
@@ -0,0 +1,38 @@
+# -*- Mode: makefile-gmake; tab-width: 4; indent-tabs-mode: t -*-
+#
+# This file is part of the LibreOffice project.
+#
+# This Source Code Form is subject to the terms of the Mozilla Public
+# License, v. 2.0. If a copy of the MPL was not distributed with this
+# file, You can obtain one at http://mozilla.org/MPL/2.0/.
+#
+
+$(eval $(call gb_ExternalProject_ExternalProject,saxon))
+
+$(eval $(call gb_ExternalProject_use_unpacked,saxon,saxon))
+
+$(eval $(call gb_ExternalProject_register_targets,saxon,\
+ build \
+))
+
+$(call gb_ExternalProject_get_state_target,saxon,build) :
+ cd "$(call gb_UnpackedTarball_get_dir,saxon)" && \
+ ANT_OPTS="$$ANT_OPTS -Dfile.encoding=ISO-8859-1" \
+ "$(ANT)" \
+ -q \
+ -f build.xml \
+ -Dbuild.label="build-libreoffice" \
+ $(if $(filter YES,$(SYSTEM_TOMCAT))\
+ ,-Dservletapi.jar=$(SERVLETAPI_JAR) \
+ ,-Dservletapi.jar=$(SOLARVER)/$(INPATH)/bin/servlet-api.jar \
+ )\
+ $(if $(filter yes,$(JAVACISGCJ))\
+ ,-Dbuild.compiler=gcj \
+ ,-Dant.build.javac.source=$(JAVA_SOURCE_VER) \
+ -Dant.build.javac.target=$(JAVA_TARGET_VER) \
+ ) \
+ $(if $(debug),-Dbuild.debug="on") \
+ -Dsolarbindir=$(SOLARBINDIR) jar-bj && \
+ touch $@
+
+# vim: set noet sw=4 ts=4:
diff --git a/saxon/Makefile b/saxon/Makefile
new file mode 100644
index 000000000000..ccb1c85a04da
--- /dev/null
+++ b/saxon/Makefile
@@ -0,0 +1,7 @@
+# -*- Mode: makefile-gmake; tab-width: 4; indent-tabs-mode: t -*-
+
+module_directory:=$(dir $(realpath $(firstword $(MAKEFILE_LIST))))
+
+include $(module_directory)/../solenv/gbuild/partial_build.mk
+
+# vim: set noet sw=4 ts=4:
diff --git a/saxon/Module_saxon.mk b/saxon/Module_saxon.mk
new file mode 100644
index 000000000000..0ac17febdc0c
--- /dev/null
+++ b/saxon/Module_saxon.mk
@@ -0,0 +1,22 @@
+# -*- Mode: makefile-gmake; tab-width: 4; indent-tabs-mode: t -*-
+#
+# This file is part of the LibreOffice project.
+#
+# This Source Code Form is subject to the terms of the Mozilla Public
+# License, v. 2.0. If a copy of the MPL was not distributed with this
+# file, You can obtain one at http://mozilla.org/MPL/2.0/.
+#
+
+$(eval $(call gb_Module_Module,saxon))
+
+ifneq ($(SOLAR_JAVA),)
+ifneq ($(filter SAXON,$(BUILD_TYPE)),)
+$(eval $(call gb_Module_add_targets,saxon,\
+ ExternalProject_saxon \
+ Package_saxon \
+ UnpackedTarball_saxon \
+))
+endif
+endif
+
+# vim: set noet sw=4 ts=4:
diff --git a/saxon/Package_saxon.mk b/saxon/Package_saxon.mk
new file mode 100644
index 000000000000..ba19d97a8324
--- /dev/null
+++ b/saxon/Package_saxon.mk
@@ -0,0 +1,16 @@
+# -*- Mode: makefile-gmake; tab-width: 4; indent-tabs-mode: t -*-
+#
+# This file is part of the LibreOffice project.
+#
+# This Source Code Form is subject to the terms of the Mozilla Public
+# License, v. 2.0. If a copy of the MPL was not distributed with this
+# file, You can obtain one at http://mozilla.org/MPL/2.0/.
+#
+
+$(eval $(call gb_Package_Package,saxon_inc,$(call gb_UnpackedTarball_get_dir,saxon)))
+
+$(eval $(call gb_Package_use_external_project,saxon_inc,saxon))
+
+$(eval $(call gb_Package_add_file,saxon_inc,bin/saxon9.jar,saxon-build/9.0.0.7/bj/saxon9.jar))
+
+# vim: set noet sw=4 ts=4:
diff --git a/saxon/UnpackedTarball_saxon.mk b/saxon/UnpackedTarball_saxon.mk
new file mode 100644
index 000000000000..206257b851f1
--- /dev/null
+++ b/saxon/UnpackedTarball_saxon.mk
@@ -0,0 +1,16 @@
+# -*- Mode: makefile-gmake; tab-width: 4; indent-tabs-mode: t -*-
+#
+# This file is part of the LibreOffice project.
+#
+# This Source Code Form is subject to the terms of the Mozilla Public
+# License, v. 2.0. If a copy of the MPL was not distributed with this
+# file, You can obtain one at http://mozilla.org/MPL/2.0/.
+#
+
+$(eval $(call gb_UnpackedTarball_UnpackedTarball,saxon))
+
+$(eval $(call gb_UnpackedTarball_set_tarball,saxon,$(SAXON_TARBALL)))
+
+$(eval $(call gb_UnpackedTarball_add_file,saxon,build.xml,saxon/build.xml))
+
+# vim: set noet sw=4 ts=4:
diff --git a/saxon/build.xml b/saxon/build.xml
new file mode 100644
index 000000000000..c9026f7778ea
--- /dev/null
+++ b/saxon/build.xml
@@ -0,0 +1,1026 @@
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+ net.sf.saxon.xpath.XPathFactoryImpl
+http\://java.sun.com/jaxp/xpath/dom: net.sf.saxon.xpath.XPathFactoryImpl
+http\://saxon.sf.net/jaxp/xpath/om: net.sf.saxon.xpath.XPathFactoryImpl
+http\://www.xom.nu/jaxp/xpath/xom: net.sf.saxon.xpath.XPathFactoryImpl
+http\://jdom.org/jaxp/xpath/jdom: net.sf.saxon.xpath.XPathFactoryImpl
+http\://www.dom4j.org/jaxp/xpath/dom4j: net.sf.saxon.xpath.XPathFactoryImpl
+
+
+
+
+ com.saxonica.jaxp.SchemaFactoryImpl
+http\://www.w3.org/2001/XMLSchema: com.saxonica.jaxp.SchemaFactoryImpl
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+ set NET="%PROGRAMFILES%\Microsoft.NET\SDK\v1.1\Bin"
+ %NET%\gacutil /if IKVM.Runtime.dll
+ %NET%\gacutil /if IKVM.GNU.Classpath.dll
+ %NET%\gacutil /if saxon9.dll
+ %NET%\gacutil /if saxon9api.dll
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+ set NET="%PROGRAMFILES%\Microsoft.NET\SDK\v1.1\Bin"
+ %NET%\gacutil /if IKVM.Runtime.dll
+ %NET%\gacutil /if IKVM.GNU.Classpath.dll
+ %NET%\gacutil /if saxon9.dll
+ %NET%\gacutil /if saxon9sa.dll
+ %NET%\gacutil /if saxon9api.dll
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
diff --git a/saxon/makefile.mk b/saxon/makefile.mk
deleted file mode 100644
index 40a74043b233..000000000000
--- a/saxon/makefile.mk
+++ /dev/null
@@ -1,69 +0,0 @@
-#*************************************************************************
-#
-# DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
-#
-# Copyright 2000, 2010 Oracle and/or its affiliates.
-#
-# OpenOffice.org - a multi-platform office productivity suite
-#
-# This file is part of OpenOffice.org.
-#
-# OpenOffice.org is free software: you can redistribute it and/or modify
-# it under the terms of the GNU Lesser General Public License version 3
-# only, as published by the Free Software Foundation.
-#
-# OpenOffice.org is distributed in the hope that it will be useful,
-# but WITHOUT ANY WARRANTY; without even the implied warranty of
-# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
-# GNU Lesser General Public License version 3 for more details
-# (a copy is included in the LICENSE file that accompanied this code).
-#
-# You should have received a copy of the GNU Lesser General Public License
-# version 3 along with OpenOffice.org. If not, see
-#
-# for a copy of the LGPLv3 License.
-#
-#*************************************************************************
-
-PRJ=.
-
-PRJNAME=saxon
-TARGET=saxon
-
-# --- Settings -----------------------------------------------------
-
-.INCLUDE : settings.mk
-.INCLUDE : antsettings.mk
-
-.IF "$(SOLAR_JAVA)" != ""
-.IF "$(SYSTEM_SAXON)" == "YES"
-all:
- @echo "An already available installation of saxon should exist on your system."
- @echo "Therefore the version provided here does not need to be built in addition."
-.ENDIF
-
-# --- Files --------------------------------------------------------
-
-TARFILE_NAME=source-9.0.0.7-bj
-TARFILE_MD5=ada24d37d8d638b3d8a9985e80bc2978
-ADDITIONAL_FILES=build.xml
-TARFILE_ROOTDIR=src
-
-PATCH_FILES=saxon-9.0.0.7-bj.patch
-
-BUILD_ACTION="$(ANT)" $(ANT_FLAGS) -Dsolarbindir=$(SOLARBINDIR) jar-bj
-
-OUT2CLASS= saxon-build$/9.0.0.7$/bj$/saxon9.jar
-
-.ELSE # $(SOLAR_JAVA)!= ""
-nojava:
- @echo "Not building $(PRJNAME) because Java is disabled"
-.ENDIF # $(SOLAR_JAVA)!= ""
-# --- Targets ------------------------------------------------------
-
-.INCLUDE : set_ext.mk
-.INCLUDE : target.mk
-.IF "$(SOLAR_JAVA)" != ""
-.INCLUDE : tg_ext.mk
-.ENDIF
-
diff --git a/saxon/prj/build.lst b/saxon/prj/build.lst
index 813097c66d90..a69eba0832e7 100644
--- a/saxon/prj/build.lst
+++ b/saxon/prj/build.lst
@@ -1,2 +1,2 @@
xx saxon : solenv stax NULL
-xx saxon nmake - all xx_saxon NULL
+xx saxon\prj nmake - all xx_saxon NULL
diff --git a/saxon/prj/d.lst b/saxon/prj/d.lst
index 0793dadfcfb1..e69de29bb2d1 100644
--- a/saxon/prj/d.lst
+++ b/saxon/prj/d.lst
@@ -1 +0,0 @@
-..\%__SRC%\class\saxon9.jar %_DEST%\bin\saxon9.jar
diff --git a/saxon/prj/dmake b/saxon/prj/dmake
deleted file mode 100644
index e69de29bb2d1..000000000000
diff --git a/saxon/saxon-9.0.0.7-bj.patch b/saxon/saxon-9.0.0.7-bj.patch
deleted file mode 100644
index 11d30914e985..000000000000
--- a/saxon/saxon-9.0.0.7-bj.patch
+++ /dev/null
@@ -1,1031 +0,0 @@
---- misc/src/build.xml 2008-07-11 12:11:50.079281000 +0200
-+++ misc/build/src/build.xml 2008-07-11 12:17:29.848740000 +0200
-@@ -1 +1,1027 @@
--dummy
-+
-+
-+
-+
-+
-+
-+
-+
-+
-+
-+
-+
-+
-+
-+
-+
-+
-+
-+
-+
-+
-+
-+
-+
-+
-+
-+
-+
-+
-+
-+
-+
-+
-+
-+
-+
-+
-+
-+
-+
-+
-+
-+
-+
-+
-+
-+
-+
-+
-+
-+
-+
-+
-+
-+
-+
-+
-+
-+
-+
-+
-+
-+
-+
-+
-+
-+
-+
-+
-+
-+
-+
-+
-+
-+
-+
-+
-+
-+
-+
-+
-+
-+
-+
-+
-+
-+
-+
-+
-+
-+
-+
-+
-+
-+
-+
-+
-+
-+
-+
-+
-+
-+
-+
-+
-+
-+
-+
-+
-+
-+
-+
-+
-+
-+
-+
-+
-+
-+
-+
-+
-+
-+
-+
-+
-+
-+
-+
-+
-+
-+
-+
-+
-+
-+
-+
-+
-+
-+
-+
-+
-+
-+
-+
-+
-+
-+
-+
-+
-+
-+
-+
-+
-+
-+
-+
-+
-+
-+
-+
-+
-+
-+
-+
-+
-+
-+
-+
-+
-+
-+
-+
-+
-+
-+
-+
-+
-+
-+
-+
-+
-+
-+
-+
-+
-+
-+
-+
-+
-+
-+
-+
-+
-+
-+
-+
-+
-+
-+
-+
-+
-+
-+
-+
-+
-+
-+
-+
-+
-+
-+
-+
-+
-+
-+
-+
-+
-+
-+
-+
-+
-+
-+
-+ net.sf.saxon.xpath.XPathFactoryImpl
-+http\://java.sun.com/jaxp/xpath/dom: net.sf.saxon.xpath.XPathFactoryImpl
-+http\://saxon.sf.net/jaxp/xpath/om: net.sf.saxon.xpath.XPathFactoryImpl
-+http\://www.xom.nu/jaxp/xpath/xom: net.sf.saxon.xpath.XPathFactoryImpl
-+http\://jdom.org/jaxp/xpath/jdom: net.sf.saxon.xpath.XPathFactoryImpl
-+http\://www.dom4j.org/jaxp/xpath/dom4j: net.sf.saxon.xpath.XPathFactoryImpl
-+
-+
-+
-+
-+ com.saxonica.jaxp.SchemaFactoryImpl
-+http\://www.w3.org/2001/XMLSchema: com.saxonica.jaxp.SchemaFactoryImpl
-+
-+
-+
-+
-+
-+
-+
-+
-+
-+
-+
-+
-+
-+
-+
-+
-+
-+
-+
-+
-+
-+
-+
-+
-+
-+
-+
-+
-+
-+
-+
-+
-+
-+
-+
-+
-+
-+
-+
-+
-+
-+
-+
-+
-+
-+
-+
-+
-+
-+
-+
-+
-+
-+
-+
-+
-+
-+
-+
-+
-+
-+
-+
-+
-+
-+
-+
-+
-+
-+
-+
-+
-+
-+
-+
-+
-+
-+
-+
-+
-+
-+
-+
-+
-+
-+
-+
-+
-+
-+
-+
-+
-+
-+
-+
-+
-+
-+
-+
-+
-+
-+
-+
-+
-+
-+
-+
-+
-+
-+
-+
-+
-+
-+
-+
-+
-+
-+
-+
-+
-+
-+
-+
-+
-+
-+
-+
-+
-+
-+
-+
-+
-+
-+
-+
-+
-+
-+
-+
-+
-+
-+
-+
-+
-+
-+
-+
-+
-+
-+
-+
-+
-+
-+
-+
-+
-+
-+
-+
-+
-+
-+
-+
-+
-+
-+
-+
-+
-+
-+
-+
-+
-+
-+
-+
-+
-+
-+
-+
-+
-+
-+
-+
-+
-+
-+
-+
-+
-+
-+
-+
-+
-+
-+
-+
-+
-+
-+
-+
-+
-+
-+
-+
-+
-+
-+
-+
-+
-+
-+
-+
-+
-+
-+
-+
-+
-+
-+
-+
-+
-+
-+
-+
-+
-+
-+
-+
-+
-+
-+
-+
-+
-+
-+
-+
-+
-+
-+
-+
-+ set NET="%PROGRAMFILES%\Microsoft.NET\SDK\v1.1\Bin"
-+ %NET%\gacutil /if IKVM.Runtime.dll
-+ %NET%\gacutil /if IKVM.GNU.Classpath.dll
-+ %NET%\gacutil /if saxon9.dll
-+ %NET%\gacutil /if saxon9api.dll
-+
-+
-+
-+
-+
-+
-+
-+
-+
-+
-+
-+
-+
-+
-+
-+
-+
-+
-+ set NET="%PROGRAMFILES%\Microsoft.NET\SDK\v1.1\Bin"
-+ %NET%\gacutil /if IKVM.Runtime.dll
-+ %NET%\gacutil /if IKVM.GNU.Classpath.dll
-+ %NET%\gacutil /if saxon9.dll
-+ %NET%\gacutil /if saxon9sa.dll
-+ %NET%\gacutil /if saxon9api.dll
-+
-+
-+
-+
-+
-+
-+
-+
-+
-+
-+
-+
-+
-+
-+
-+
-+
-+
-+
-+
-+
-+
-+
-+
-+
-+
-+
-+
-+
-+
-+
-+
-+
-+
-+
-+
-+
-+
-+
-+
-+
-+
-+
-+
-+
-+
-+
-+
-+
-+
-+
-+
-+
-+
-+
-+
-+
-+
-+
-+
-+
-+
-+
-+
-+
-+
-+
-+
-+
-+
-+
-+
-+
-+
-+
-+
-+
-+
-+
-+
-+
-+
-+
-+
-+
-+
-+
-+
-+
-+
-+
-+
-+
-+
-+
-+
-+
-+
-+
-+
-+
-+
-+
-+
-+
-+
-+
-+
-+
-+
-+
-+
-+
-+
-+
-+
-+
-+
-+
-+
-+
-+
-+
-+
-+
-+
-+
-+
-+
-+
-+
-+
-+
-+
-+
-+
-+
-+
-+
-+
-+
-+
-+
-+
-+
-+
-+
-+
-+
-+
-+
-+
-+
-+
-+
-+
-+
-+
-+
-+
-+
-+
-+
-+
-+
-+
-+
-+
-+
-+
-+
-+
-+
-+
-+
-+
-+
-+
-+
-+
-+
-+
-+
-+
-+
-+
-+
-+
-+
-+
-+
-+
-+
-+
-+
-+
-+
-+
-+
-+
-+
-+
-+
-+
-+
-+
-+
-+
-+
-+
-+
-+
-+
-+
-+
-+
-+
-+
-+
-+
-+
-+
-+
-+
-+
-+
-+
-+
-+
-+
-+
-+
-+
-+
-+
-+
-+
-+
-+
-+
-+
-+
-+
-+
-+
-+
-+
-+
-+
-+
-+
-+
-+
-+
-+
-+
-+