source: other-projects/gti/gti-generate-excel-xml.xsl@ 31505

Last change on this file since 31505 was 25242, checked in by ak19, 12 years ago

With Sam's help. 1. Updated gti-generate-excel-xml.xsl file to no longer output an excess of newlines. It now further turns ampersand characters in XML input files into their character entity values in the excel.xml file output. 2. Added 2 new XSLT files gti-generate-tmx-xml and gti-tmx-to-txt, which need to still be tested in practice. The first takes GS translation XML files containing chunks of strings to be translated and generates Translation Memory eXchange from it. TMX is an open-XML format also accepted by the Google Translation toolkit, so that translators can use this toolkit to do the translations if they wish. The 2nd XSLT file takes the TMX file returned by translators and outputs the UTF-16 txt file that was expected when processing spreadsheet translations previously, so that it fits into the same processing pipeline. These 2 new XSLT files, when applied by ApplyXSLT.jar/java on their input XML, require an additional parameter (the targetlanguage) and further take an optional parameter (source language). ApplyXSLT has been updated to work with this.

File size: 4.1 KB
Line 
1<?xml version="1.0" encoding="UTF-8"?>
2<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">
3
4 <xsl:output method="xml" encoding="UTF-8"/>
5
6 <xsl:template match="GTIResponse">
7 <Workbook xmlns="urn:schemas-microsoft-com:office:spreadsheet"
8 xmlns:o="urn:schemas-microsoft-com:office:office"
9 xmlns:x="urn:schemas-microsoft-com:office:excel"
10 xmlns:ss="urn:schemas-microsoft-com:office:spreadsheet"
11 xmlns:html="http://www.w3.org/TR/REC-html40">
12 <DocumentProperties>
13 <Author>Greenstone Translator Interface</Author>
14 <LastAuthor>Greenstone Translator Interface</LastAuthor>
15 <Created>2003-05-05T01:30:36Z</Created>
16 <Company>New Zealand Digital Library Project</Company>
17 <Version>10.2625</Version>
18 </DocumentProperties>
19 <OfficeDocumentSettings>
20 <DownloadComponents/>
21 <LocationOfComponents HRef="blah"/>
22 </OfficeDocumentSettings>
23 <Styles>
24 <Style ss:ID="Default" ss:Name="Normal">
25 <Alignment ss:Vertical="Top"/>
26 <Borders/>
27 <Font/>
28 <Interior/>
29 <NumberFormat/>
30 <Protection/>
31 </Style>
32 <Style ss:ID="Heading">
33 <Font x:Family="Swiss" ss:Bold="1"/>
34 </Style>
35 <Style ss:ID="TextCell">
36 <Alignment ss:Vertical="Bottom" ss:WrapText="1"/>
37 <Font ss:FontName="Arial Unicode MS"/>
38 </Style>
39 </Styles>
40 <Worksheet ss:Name="Greenstone Translation">
41 <Table>
42 <Column ss:Width="250" ss:Index="1" ss:AutoFitWidth="0"/>
43 <Column ss:Width="1000" ss:Index="2" ss:AutoFitWidth="1"/>
44 <Row>
45 <Cell ss:StyleID="Heading"><Data ss:Type="String">Key</Data></Cell>
46 <Cell ss:StyleID="Heading"><Data ss:Type="String">Text</Data></Cell>
47 </Row>
48 <xsl:apply-templates/>
49 </Table>
50 </Worksheet>
51 </Workbook>
52 </xsl:template>
53
54
55 <xsl:template match="ChunksRequiringTranslation">
56 <xsl:apply-templates select="Chunk">
57 <xsl:sort select="@key"/>
58 </xsl:apply-templates>
59 </xsl:template>
60
61
62 <xsl:template match="ChunksRequiringUpdating">
63 <xsl:apply-templates select="Chunk">
64 <xsl:sort select="@key"/>
65 </xsl:apply-templates>
66 </xsl:template>
67
68
69 <xsl:template match="Chunk">
70 <Row xmlns="urn:schemas-microsoft-com:office:spreadsheet"/>
71
72 <Row xmlns="urn:schemas-microsoft-com:office:spreadsheet">
73 <Cell>
74 <Data ss:Type="String">source::<xsl:value-of select="@key"/></Data>
75 </Cell>
76 <Cell ss:StyleID="TextCell">
77 <Data ss:Type="String">
78 <xsl:for-each select="SourceFileText">
79 <xsl:variable name="tempText1" select='java:org.nzdl.gsdl.ApplyXSLT.replaceAll(., "\n", "&amp;#10;&#10;")'/>
80 <xsl:variable name="tempText2" select='java:org.nzdl.gsdl.ApplyXSLT.replaceAll($tempText1, "&#60;", "&amp;lt;")'/>
81 <xsl:variable name="tempText3" select='java:org.nzdl.gsdl.ApplyXSLT.replaceAll($tempText2, "&#62;", "&amp;gt;")'/>
82 <xsl:variable name="escapedText" select='java:org.nzdl.gsdl.ApplyXSLT.replaceAll($tempText3, "&#38;", "&amp;amp;")'/> <!-- ampersands-->
83 <xsl:value-of select='$escapedText' disable-output-escaping="yes"/>
84 </xsl:for-each>
85 </Data>
86 </Cell>
87 </Row>
88
89 <Row xmlns="urn:schemas-microsoft-com:office:spreadsheet">
90 <Cell>
91 <Data ss:Type="String">target::<xsl:value-of select="@key"/></Data>
92 </Cell>
93 <Cell ss:StyleID="TextCell">
94 <Data ss:Type="String">
95 <xsl:for-each select="TargetFileText">
96 <xsl:variable name="tempText1" select='java:org.nzdl.gsdl.ApplyXSLT.replaceAll(., "\n", "&amp;#10;&#10;")'/>
97 <xsl:variable name="tempText2" select='java:org.nzdl.gsdl.ApplyXSLT.replaceAll($tempText1, "&#60;", "&amp;lt;")'/>
98 <xsl:variable name="tempText3" select='java:org.nzdl.gsdl.ApplyXSLT.replaceAll($tempText2, "&#62;", "&amp;gt;")'/>
99 <xsl:variable name="escapedText" select='java:org.nzdl.gsdl.ApplyXSLT.replaceAll($tempText3, "&#38;", "&amp;amp;")'/> <!-- ampersands-->
100 <xsl:value-of select='$escapedText' disable-output-escaping="yes"/>
101 </xsl:for-each>
102 </Data>
103 </Cell>
104 </Row>
105 </xsl:template>
106
107</xsl:stylesheet>
Note: See TracBrowser for help on using the repository browser.