[xml/sgml-pkgs] Bug#327551: xmlto: allow generation in an encoding different from the current locale

Nicolas François nicolas.francois at centraliens.net
Sat Sep 10 21:34:43 UTC 2005


Package: xmlto
Version: 0.0.18-5
Severity: wishlist
Tags: patch

Hello,

The apt-ftparchive man page is generated from an XML document. To
translate this document, the French Tranlation Team translated the
original XML, and then generated the man page from this translated XML
document.

This worked nice when the man page was generated by a Franch developer
(with an fr_FR.ISO-8859-1 locale, I supppose). But the man page of the
package is not that nice because it was generated by a buildd, with a C
locale (I suppose): all accents are converted to character entities (e.g.
é), which renders the man page hardly readable. (see #327456)

The attached patch adds a --keep-encoding to xmlto, which disables the
convertion of the XML document to the locale charmap before the xsl
processing.

Thanks in advance,
-- 
Nekral
-------------- next part --------------
--- /usr/bin/xmlto.orig	2004-06-08 05:41:47.000000000 +0200
+++ /usr/bin/xmlto	2005-09-10 23:19:04.000000000 +0200
@@ -41,6 +41,9 @@
   --searchpath    colon-separated list of fallback directories
   --skip-validation
                   do not attempt to validate the input before processing
+  --keep-encoding 
+                  do not use the encoding of the current locale, use the
+                  one of the XML document
 
 Available FORMATs depend on the type of the XML file (which is
 determined automatically).
@@ -124,28 +127,6 @@
 </xsl:stylesheet>
 EOF
 
-# Magic encoding, based on locale
-if [ -x /usr/bin/locale ]
-then
-  charmap=$(locale charmap 2>/dev/null)
-
-  if [ -n "$charmap" ]
-  then
-    encodingmod=$(${MKTEMP} ${TMPDIR:-/tmp}/xmlto-xsl.XXXXXX)
-    CLEANFILES[$CLEANFILE_COUNT]="$encodingmod"
-    CLEANFILE_COUNT=$(($CLEANFILE_COUNT + 1))
-    cat << EOF > "$encodingmod"
-<?xml version='1.0'?>
-<xsl:stylesheet xmlns:xsl="http://www.w3.org/1999/XSL/Transform"
-                version='1.0'>
-<xsl:param name="chunker.output.encoding" select="'$charmap'"/>
-</xsl:stylesheet>
-EOF
-    XSL_MODS[$XSL_MOD_COUNT]="$encodingmod"
-    XSL_MOD_COUNT=$(($XSL_MOD_COUNT + 1))
-  fi
-fi
-
 # Make verbosity level uniformly available to called scripts
 VERBOSE=0
 export VERBOSE
@@ -157,10 +138,11 @@
 XSLTOPTS="$XSLTOPTS --xinclude"
 
 SKIP_VALIDATION=0
+KEEP_ENCODING=0
 
 # Process any options
 ARGS=$(${GETOPT} \
-	--longoptions=help,version,extensions,searchpath:,skip-validation \
+	--longoptions=help,version,extensions,searchpath:,skip-validation,keep-encoding \
 	-n xmlto -- x:m:o:p:v "$@")
 [ $? != 0 ] && { usage; exit 1; }
 eval set -- "$ARGS"
@@ -226,6 +208,10 @@
 	SKIP_VALIDATION=1
 	shift
 	;;
+  --keep-encoding)
+	KEEP_ENCODING=1
+	shift
+	;;
   --)
 	shift
 	break
@@ -239,6 +225,27 @@
   exit 1
 fi
 
+# Magic encoding, based on locale
+if [ "$KEEP_ENCODING" = "0" ] && [ -x /usr/bin/locale ]
+then
+  charmap=$(locale charmap 2>/dev/null)
+
+  if [ -n "$charmap" ]
+  then
+    encodingmod=$(${MKTEMP} ${TMPDIR:-/tmp}/xmlto-xsl.XXXXXX)
+    CLEANFILES[$CLEANFILE_COUNT]="$encodingmod"
+    CLEANFILE_COUNT=$(($CLEANFILE_COUNT + 1))
+    cat << EOF > "$encodingmod"
+<?xml version='1.0'?>
+<xsl:stylesheet xmlns:xsl="http://www.w3.org/1999/XSL/Transform"
+                version='1.0'>
+<xsl:param name="chunker.output.encoding" select="'$charmap'"/>
+</xsl:stylesheet>
+EOF
+    XSL_MODS[$XSL_MOD_COUNT]="$encodingmod"
+    XSL_MOD_COUNT=$(($XSL_MOD_COUNT + 1))
+  fi
+fi
 DEST_FORMAT="$1"
 case "$2" in
 /*) INPUT_FILE="$2" ;;


More information about the debian-xml-sgml-pkgs mailing list