Index: other-projects/gti/gti-generate-excel-xml.xsl
===================================================================
--- other-projects/gti/gti-generate-excel-xml.xsl	(revision 25081)
+++ other-projects/gti/gti-generate-excel-xml.xsl	(revision 25242)
@@ -54,5 +54,5 @@
 
   <xsl:template match="ChunksRequiringTranslation">
-    <xsl:apply-templates>
+    <xsl:apply-templates select="Chunk">
       <xsl:sort select="@key"/>
     </xsl:apply-templates>
@@ -61,5 +61,5 @@
 
   <xsl:template match="ChunksRequiringUpdating">
-    <xsl:apply-templates>
+    <xsl:apply-templates select="Chunk">
       <xsl:sort select="@key"/>
     </xsl:apply-templates>
@@ -79,5 +79,6 @@
 	    <xsl:variable name="tempText1" select='java:org.nzdl.gsdl.ApplyXSLT.replaceAll(., "\n", "&amp;#10;&#10;")'/>
 	    <xsl:variable name="tempText2" select='java:org.nzdl.gsdl.ApplyXSLT.replaceAll($tempText1, "&#60;", "&amp;lt;")'/>
-	    <xsl:variable name="escapedText" select='java:org.nzdl.gsdl.ApplyXSLT.replaceAll($tempText2, "&#62;", "&amp;gt;")'/>
+	    <xsl:variable name="tempText3" select='java:org.nzdl.gsdl.ApplyXSLT.replaceAll($tempText2, "&#62;", "&amp;gt;")'/>
+	    <xsl:variable name="escapedText" select='java:org.nzdl.gsdl.ApplyXSLT.replaceAll($tempText3, "&#38;", "&amp;amp;")'/> <!-- ampersands-->
 	    <xsl:value-of select='$escapedText' disable-output-escaping="yes"/>
           </xsl:for-each>
@@ -95,5 +96,6 @@
 	    <xsl:variable name="tempText1" select='java:org.nzdl.gsdl.ApplyXSLT.replaceAll(., "\n", "&amp;#10;&#10;")'/>
 	    <xsl:variable name="tempText2" select='java:org.nzdl.gsdl.ApplyXSLT.replaceAll($tempText1, "&#60;", "&amp;lt;")'/>
-	    <xsl:variable name="escapedText" select='java:org.nzdl.gsdl.ApplyXSLT.replaceAll($tempText2, "&#62;", "&amp;gt;")'/>
+	    <xsl:variable name="tempText3" select='java:org.nzdl.gsdl.ApplyXSLT.replaceAll($tempText2, "&#62;", "&amp;gt;")'/>
+	    <xsl:variable name="escapedText" select='java:org.nzdl.gsdl.ApplyXSLT.replaceAll($tempText3, "&#38;", "&amp;amp;")'/> <!-- ampersands-->
 	    <xsl:value-of select='$escapedText' disable-output-escaping="yes"/>
           </xsl:for-each>
Index: other-projects/gti/gti-generate-tmx-xml.xsl
===================================================================
--- other-projects/gti/gti-generate-tmx-xml.xsl	(revision 25242)
+++ other-projects/gti/gti-generate-tmx-xml.xsl	(revision 25242)
@@ -0,0 +1,89 @@
+<?xml version="1.0" encoding="UTF-8"?>
+<!--<xsl:stylesheet version="1.0" xmlns:xsl="http://www.w3.org/1999/XSL/Transform" xmlns:java="http://xml.apache.org/xslt/java" xmlns:ss="urn:schemas-microsoft-com:office:spreadsheet">-->
+<xsl:stylesheet version="1.0" xmlns:xsl="http://www.w3.org/1999/XSL/Transform" xmlns:java="http://xml.apache.org/xslt/java">
+<!--On Translation Memory eXchange open-XML: http://www.opentag.com/tmx.htm and http://www.gala-global.org/oscarStandards/tmx/tmx14b.html
+And for character entities: http://www.w3.org/MarkUp/html3/latin1.html-->
+
+  <xsl:output method="xml" encoding="UTF-8"/>
+  <xsl:param name="sourcelang"/>
+  <xsl:param name="targetlang"/>
+
+  <xsl:template match="GTIResponse">
+    <tmx version="1.4" xmlns="http://www.lisa.org/tmx14"><xsl:text>&#10;</xsl:text> <!--newline-->
+    <header creationtool="Greenstone Translator Interface" creationtoolversion="Greenstone2.85"
+	    datatype="PlainText" segtype="sentence"
+	    adminlang="en-us" srclang="EN"
+	    o-tmf="ABCTransMem">
+    </header><xsl:text>&#10;</xsl:text> <!--newline-->
+    <body><xsl:text>&#10;</xsl:text> <!--newline-->
+      <xsl:text>&#10;</xsl:text> <!--newline-->
+      <!--<xsl:apply-templates select="*"/>-->
+      <xsl:apply-templates select="TranslationFile"/>
+      <!-- control the order: first all the strings needing to be updated, then all those that need translating-->
+      <xsl:apply-templates select="ChunksRequiringUpdating"/>
+      <xsl:apply-templates select="ChunksRequiringTranslation"/>
+    </body>
+    </tmx> 
+  </xsl:template>
+
+
+  <!-- The input file contains information as follows:
+     <TranslationFile key="coredm" target_file_path="macros/mongolian.dm" num_chunks_translated="353" num_chunks_requiring_translation="32" num_chunks_requiring_updating="18"/>
+     We want this useful information to be present in the output TMX file too. Each attribute of a TranslationFile element will be a separate <prop> property value,
+       where the TranslationFile attribute names become the values of each property's type attribute, and the TranslationFile attribute values are the property contents.-->
+  <xsl:template match="TranslationFile">
+    <xsl:for-each select="@*">
+      <prop type="{name()}"><xsl:value-of select="."/></prop>
+      <xsl:text>&#10;</xsl:text><!--newline-->
+    </xsl:for-each>
+  </xsl:template>
+
+  <xsl:template match="ChunksRequiringTranslation">
+    <xsl:text>&#10;</xsl:text> <!--newline-->
+    <note><xsl:text xml:lang="en">Chunks requiring translating</xsl:text></note><xsl:text>&#10;</xsl:text> <!--newline-->
+    <xsl:apply-templates select="Chunk">
+      <xsl:sort select="@key"/>
+    </xsl:apply-templates>
+  </xsl:template>
+
+  <xsl:template match="ChunksRequiringUpdating">
+    <xsl:text>&#10;</xsl:text> <!--newline-->
+    <note><xsl:text xml:lang="en">Chunks requiring updating</xsl:text></note><xsl:text>&#10;</xsl:text> <!--newline-->
+    <xsl:apply-templates select="Chunk">
+      <xsl:sort select="@key"/>
+    </xsl:apply-templates>
+  </xsl:template>
+
+
+  <xsl:template match="Chunk">
+    <tu><xsl:text>&#10;</xsl:text> <!--newline-->
+      <tuv xml:lang="{$sourcelang}">
+	<prop type="source"><xsl:value-of select="@key"/></prop><xsl:text>&#10;</xsl:text> <!--newline-->
+	<seg>
+	  <xsl:for-each select="SourceFileText">
+	    <xsl:variable name="tempText1" select='java:org.nzdl.gsdl.ApplyXSLT.replaceAll(., "\n", "&amp;#10;&#10;")'/>
+	    <xsl:variable name="tempText2" select='java:org.nzdl.gsdl.ApplyXSLT.replaceAll($tempText1, "&#60;", "&amp;lt;")'/>
+	    <xsl:variable name="tempText3" select='java:org.nzdl.gsdl.ApplyXSLT.replaceAll($tempText2, "&#62;", "&amp;gt;")'/>
+	    <xsl:variable name="escapedText" select='java:org.nzdl.gsdl.ApplyXSLT.replaceAll($tempText3, "&#38;", "&amp;amp;")'/> <!-- ampersands-->
+	    <xsl:value-of select='$escapedText' disable-output-escaping="yes"/>
+          </xsl:for-each>
+	</seg><xsl:text>&#10;</xsl:text> <!--newline-->
+      </tuv><xsl:text>&#10;</xsl:text> <!--newline-->
+      <tuv xml:lang="{$targetlang}">
+	<prop type="target"><xsl:value-of select="@key"/></prop><xsl:text>&#10;</xsl:text> <!--newline-->
+	<seg>
+	  <xsl:for-each select="TargetFileText">
+	    <xsl:variable name="tempText1" select='java:org.nzdl.gsdl.ApplyXSLT.replaceAll(., "\n", "&amp;#10;&#10;")'/>
+	    <xsl:variable name="tempText2" select='java:org.nzdl.gsdl.ApplyXSLT.replaceAll($tempText1, "&#60;", "&amp;lt;")'/>
+	    <xsl:variable name="tempText3" select='java:org.nzdl.gsdl.ApplyXSLT.replaceAll($tempText2, "&#62;", "&amp;gt;")'/>
+	    <xsl:variable name="escapedText" select='java:org.nzdl.gsdl.ApplyXSLT.replaceAll($tempText3, "&#38;", "&amp;amp;")'/> <!-- ampersands-->
+	    <xsl:value-of select='$escapedText' disable-output-escaping="yes"/>
+          </xsl:for-each>
+	</seg><xsl:text>&#10;</xsl:text> <!--newline-->
+      </tuv><xsl:text>&#10;</xsl:text> <!--newline-->
+    </tu><xsl:text>&#10;&#10;</xsl:text> <!--newline-->
+  </xsl:template>
+
+  <!--<xsl:template match="*">Do nothing for all other templates matched</xsl:template>-->
+
+</xsl:stylesheet>
Index: other-projects/gti/gti-tmx-to-txt.xsl
===================================================================
--- other-projects/gti/gti-tmx-to-txt.xsl	(revision 25242)
+++ other-projects/gti/gti-tmx-to-txt.xsl	(revision 25242)
@@ -0,0 +1,49 @@
+<?xml version="1.0" encoding="UTF-8"?>
+<xsl:stylesheet version="1.0" xmlns:xsl="http://www.w3.org/1999/XSL/Transform" xmlns:java="http://xml.apache.org/xslt/java" xmlns:tmx="http://www.lisa.org/tmx14">
+  <!-- The necessity for using xml namespaces all over and matching on namespaced element names http://www.stylusstudio.com/xsllist/200302/post70120.html -->
+
+  <xsl:output method="text" encoding="UTF-16"/> <!-- When we save as txt from Excel, we choose UTF-16 too -->
+
+  <xsl:template match="tmx:tmx">
+    <xsl:apply-templates select="tmx:body"/>
+  </xsl:template>
+
+  <xsl:template match="tmx:body">
+    <xsl:text>Key&#09;Text</xsl:text>
+    <xsl:text>&#10;&#10;</xsl:text> <!--2 newlines-->  
+    <xsl:apply-templates select="tmx:tu"/>
+  </xsl:template>
+
+  <xsl:template match="tmx:tu">
+    <xsl:for-each select="tmx:tuv">
+      <xsl:if test="tmx:prop[@type='source']">
+	<xsl:text>source::</xsl:text>
+	<xsl:value-of select="tmx:prop"/>
+	<xsl:text>&#09;</xsl:text><!-- tab -->
+	<xsl:variable name="tempText1"><xsl:value-of select="tmx:seg"/></xsl:variable>
+	<xsl:variable name="tempText2" select='java:org.nzdl.gsdl.ApplyXSLT.replaceAll($tempText1, "&amp;#10;&#10;", "\n")'/>
+	<xsl:variable name="tempText3" select='java:org.nzdl.gsdl.ApplyXSLT.replaceAll($tempText2, "&amp;lt;", "&#60;")'/>
+	<xsl:variable name="tempText4" select='java:org.nzdl.gsdl.ApplyXSLT.replaceAll($tempText3, "&amp;gt;", "&#62;")'/>
+	<xsl:variable name="escapedText" select='java:org.nzdl.gsdl.ApplyXSLT.replaceAll($tempText4, "&amp;amp;", "&#38;")'/>
+	<xsl:value-of select='$escapedText' disable-output-escaping="yes"/>
+	<xsl:text>&#10;</xsl:text><!-- newline -->
+	</xsl:if>
+    </xsl:for-each>
+
+    <xsl:for-each select="tmx:tuv">
+      <xsl:if test="tmx:prop[@type='target']">
+	<xsl:text>target::</xsl:text>
+	<xsl:value-of select="tmx:prop"/>
+	<xsl:text>&#09;</xsl:text><!-- tab -->
+	<xsl:variable name="tempText1"><xsl:value-of select="tmx:seg"/></xsl:variable>
+	<xsl:variable name="tempText2" select='java:org.nzdl.gsdl.ApplyXSLT.replaceAll($tempText1, "&amp;#10;&#10;", "\n")'/>
+	<xsl:variable name="tempText3" select='java:org.nzdl.gsdl.ApplyXSLT.replaceAll($tempText2, "&amp;lt;", "&#60;")'/>
+	<xsl:variable name="tempText4" select='java:org.nzdl.gsdl.ApplyXSLT.replaceAll($tempText3, "&amp;gt;", "&#62;")'/>
+	<xsl:variable name="escapedText" select='java:org.nzdl.gsdl.ApplyXSLT.replaceAll($tempText4, "&amp;amp;", "&#38;")'/>
+	<xsl:value-of select='$escapedText' disable-output-escaping="yes"/>
+	<xsl:text>&#10;&#10;</xsl:text><!-- 2 newlines -->
+      </xsl:if>
+    </xsl:for-each>
+  </xsl:template>
+
+</xsl:stylesheet>
