From e934c83e36dc8ee2719cb82c0602a47e90b6c53d Mon Sep 17 00:00:00 2001
From: mrodzis <weidling@sub.uni-goettingen.de>
Date: Fri, 30 Nov 2018 13:57:27 +0100
Subject: [PATCH] Enable configuration of XInclude handling

---
 configure-xinclude-handling.xsl | 17 +++++++++++++++++
 generic.build.properties        |  1 +
 generic.xml                     | 18 +++++++++++++++++-
 3 files changed, 35 insertions(+), 1 deletion(-)
 create mode 100644 configure-xinclude-handling.xsl

diff --git a/configure-xinclude-handling.xsl b/configure-xinclude-handling.xsl
new file mode 100644
index 0000000..d85820c
--- /dev/null
+++ b/configure-xinclude-handling.xsl
@@ -0,0 +1,17 @@
+<?xml version="1.0" encoding="UTF-8"?>
+<xsl:stylesheet xmlns:xsl="http://www.w3.org/1999/XSL/Transform" version="1.0">
+    <xsl:output method="xml" version="1.0" encoding="UTF-8" indent="no" doctype-public="-//Jetty//Configure//EN" doctype-system="http://www.eclipse.org/jetty/configure_9_3.dtd"/>
+    <xsl:param name="configParam"/>
+    
+    <xsl:template match="@* | node()">
+        <xsl:copy>
+            <xsl:apply-templates select="@* | node()"/>
+        </xsl:copy>
+    </xsl:template>
+      
+    <xsl:template match="@enable-xinclude">
+        <xsl:attribute name="enable-xinclude">
+            <xsl:value-of select="$configParam"/>
+        </xsl:attribute>
+    </xsl:template>
+</xsl:stylesheet>
diff --git a/generic.build.properties b/generic.build.properties
index bd9a587..3c0e004 100644
--- a/generic.build.properties
+++ b/generic.build.properties
@@ -16,6 +16,7 @@ exist.tag=eXist-${exist.version}
 exist.dest=${build.dir}/exist
 exist.dist=${exist.dest}/dist/eXist-db-${exist.version}
 exist.memory=2048
+exist.enable-xinclude=no
 
 # Jetty port configuration
 jetty.http.port=8080
diff --git a/generic.xml b/generic.xml
index 1cc359d..bb5997c 100644
--- a/generic.xml
+++ b/generic.xml
@@ -129,6 +129,22 @@
       <echo>Jetty HTTP port is set to ${jetty.http.port}.</echo>
       <echo>Jetty HTTPS port is set to ${jetty.https.port}.</echo>
     </target>
+    
+    
+    <target name="configure-xinclude-handling" depends="prepare-dist-dir">
+        <xslt 
+            in="${build.dir}/sade/conf.xml" 
+            out="${build.dir}/sade/conf-tmp.xml" 
+            style="configure-xinclude-handling.xsl">   
+            <param name="configParam" expression="${exist.enable-xinclude}"/>
+        </xslt>
+        <move 
+            file="${build.dir}/sade/conf-tmp.xml" 
+            tofile="${build.dir}/sade/conf.xml"/>
+        
+        <echo>Are XIncludes expanded automatically? ${exist.enable-xinclude}.</echo>
+    </target>
+    
 
     <target name="prepare-dist-dir" depends="exist-dist-conf">
         <delete dir="${build.dir}/sade"/>
@@ -151,7 +167,7 @@
     </target>
 
     <!-- SADE -->
-    <target name="sade" depends="prepare-dist-dir, sade-assets, sade-memory">
+    <target name="sade" depends="prepare-dist-dir, sade-assets, sade-memory, configure-xinclude-handling">
         <git repo="${sade.git}" branch="${sade.branch}" dest="${sade.dest}"/>
         <ant antfile="${sade.dest}/build.xml" inheritAll="false"/>
         <move2autodeploy source="${sade.dest}/build/"/>
-- 
GitLab