Re: Migrating file from the old gnumeric version to the current version



Just to let know others, if anyone encounter this problem in the future.

The solution was to explicitly specify the encoding in the XML
declaration in the first line of the document. The file itself was not
in the wrong format. Everything was just fine with it. The only thing,
the encoding was not specified. By default, the XML specification says
it is UTF-8, so, it shouldn't have been a problem.

I wrote a small shell script to insert the encoding specification, here it is:
------------------------------------------------------------------------
#!/bin/bash

my_file=$1
tmp=/tmp/conv_$$.gnumeric

if [ -f $tmp ]; then
  rm -f $tmp
fi

type=`file "$my_file" | cut -d: -f2 | cut -d\  -f2`
if [ "$type" != "gzip" ]
then
  echo "$my_file"
  echo "Incompatible file format."
fi

if [ -w "$my_file" ]; then
  gzcat "$my_file" | sed s/'<?xml version="1.0"?>'/'<?xml
version="1.0" encoding="UTF-8"?>'/ | gzip > $tmp
  mv $tmp "$my_file"
fi

exit 0
----------------------------------------------------------------------------------------------------

No extensive error checking, so use it with precaution. It is taking
the filename as the single argument (quote if any blanks in the
pathname).

So, at my sense, this is a bug. Don't know if it is a gnumeric or
libxml bug, but the behavior is clearly not what it should have been.

I am using libxml2-2.6.16 and gnumeric 1.4.1.

-- 
-----------------
Daniel Savard



[Date Prev][Date Next]   [Thread Prev][Thread Next]   [Thread Index] [Date Index] [Author Index]