[25287] | 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:tmx="http://www.lisa.org/tmx14">
|
---|
| 3 | <!-- For character entities: http://www.w3.org/MarkUp/html3/latin1.html -->
|
---|
| 4 | <!-- The necessity for using xml namespaces all over and matching on namespaced element names http://www.stylusstudio.com/xsllist/200302/post70120.html -->
|
---|
| 5 |
|
---|
| 6 | <!-- HOW AND WHEN TO USE THIS FILE
|
---|
| 7 | 1. Generate an xml file containing the chunks requiring work.
|
---|
| 8 | GS2/bin/script> perl -S gti.pl get-first-n-chunks-requiring-work mi coredm 1000 > ../../macros/maori/mi-core.xml
|
---|
| 9 |
|
---|
| 10 | 2. Apply this XSLT to that XML file to obtain a unicode text file containing comma-separated values (a spreadsheet).
|
---|
| 11 | NOTE: Make sure the output is a *.txt file if you wish to open it in Excel without losing the unicode
|
---|
| 12 | (when opened with .csv extension, the unicode is not preserved).
|
---|
| 13 |
|
---|
| 14 | GS2/bin/script> java -cp /research/ak19/gs2-svn/bin/java/ApplyXSLT.jar org.nzdl.gsdl.ApplyXSLT -x ../../macros/maori/mi-core.xml -t ../script/gti-xml-to-spreadsheet.xsl > ../../maori/core-mi-spreadsheet.txt
|
---|
| 15 |
|
---|
| 16 | 3. Translators wishing to read this text file into Excel, need to first open Excel. Then go to File > Open,
|
---|
| 17 | and choose to open the unicode .txt file containing the comma-separated values.
|
---|
| 18 |
|
---|
| 19 | - A wizard will appear, allowing users to open this .txt file as a proper spreadsheet.
|
---|
| 20 | In the first frame of this dialog, need to specify
|
---|
| 21 | a. on the left that the file is "delimited"
|
---|
| 22 | b. in the drop down on the right, select unicode (UTF-8 or UTF-16)
|
---|
| 23 | c. Click next
|
---|
| 24 | In the second frame of the dialog, select "comma" as the delimiter. Click Finish to open the spreadsheet data.
|
---|
| 25 |
|
---|
| 26 | 4. When translators have finished working on the file, they can save it simply as an Excel spreadsheet .xls file
|
---|
| 27 | (File > Save As > Excel 2003 spreadsheet) and mail it back to Greenstone.
|
---|
| 28 | Translators are advised against saving it as a .txt 2003 Excel spreadsheet, since it doesn't seem to preserve the
|
---|
| 29 | comma delimiters.
|
---|
| 30 |
|
---|
| 31 | -->
|
---|
| 32 |
|
---|
| 33 | <xsl:output method="text" encoding="UTF-16"/> <!-- When we save as txt from Excel, we choose UTF-16 too -->
|
---|
| 34 |
|
---|
| 35 | <xsl:template match="GTIResponse">
|
---|
| 36 | <xsl:text>Key,Source,Target</xsl:text><!--column headings-->
|
---|
| 37 | <xsl:text> </xsl:text> <!--newline-->
|
---|
| 38 | <xsl:apply-templates select="ChunksRequiringUpdating"/>
|
---|
| 39 | <xsl:apply-templates select="ChunksRequiringTranslation"/>
|
---|
| 40 | </xsl:template>
|
---|
| 41 |
|
---|
| 42 | <xsl:template match="ChunksRequiringTranslation">
|
---|
| 43 | <xsl:apply-templates select="Chunk">
|
---|
| 44 | <xsl:sort select="@key"/>
|
---|
| 45 | </xsl:apply-templates>
|
---|
| 46 | </xsl:template>
|
---|
| 47 |
|
---|
| 48 | <xsl:template match="ChunksRequiringUpdating">
|
---|
| 49 | <xsl:apply-templates select="Chunk">
|
---|
| 50 | <xsl:sort select="@key"/>
|
---|
| 51 | </xsl:apply-templates>
|
---|
| 52 | </xsl:template>
|
---|
| 53 |
|
---|
| 54 |
|
---|
| 55 | <xsl:template match="Chunk">
|
---|
| 56 | <xsl:value-of select="@key"/>
|
---|
| 57 | <xsl:text>,</xsl:text>
|
---|
| 58 | <xsl:for-each select="SourceFileText">
|
---|
| 59 | <xsl:variable name="escapedText" select='java:org.nzdl.gsdl.ApplyXSLT.replaceAll(., "\n", "&#10;")'/>
|
---|
| 60 | <xsl:value-of select='$escapedText' disable-output-escaping="yes"/>
|
---|
| 61 | </xsl:for-each>
|
---|
| 62 | <!--<xsl:value-of select="SourceFileText"/>-->
|
---|
| 63 | <xsl:text>,</xsl:text>
|
---|
| 64 | <xsl:for-each select="TargetFileText">
|
---|
| 65 | <xsl:variable name="escapedText" select='java:org.nzdl.gsdl.ApplyXSLT.replaceAll(., "\n", "&#10;")'/>
|
---|
| 66 | <xsl:value-of select='$escapedText' disable-output-escaping="yes"/>
|
---|
| 67 | </xsl:for-each>
|
---|
| 68 | <!--<xsl:value-of select="TargetFileText"/>-->
|
---|
| 69 | <xsl:text> </xsl:text>
|
---|
| 70 | </xsl:template>
|
---|
| 71 |
|
---|
| 72 | </xsl:stylesheet>
|
---|