playOrder in the NCX file is a real nuisance. And unnecessary too: the playOrder follows directly from the order of the navPoints in the NCX file.
There may be no gaps in the playOrder: 10,20,30 etc is not allowed. It MUST be 1,2,3,4,5 etc
But anyway: I built myself a short AWK script to renumber the playOrder attributes. You can use it from the command line or from an ANT build script.
The result will be in the file "tempFile".
Here is the AWK wiki:
http://en.wikipedia.org/wiki/AWK
# this AWK script corrects any mistakes in the playOrder of EPUB NCX files.
# use it in an ANT build script.
# the entire phrase playOrder="234" must be on ONE line !!
BEGIN {counter = 1 }
{
if (match($0, /playOrder="[0-9]*"/ ) )
{
repl = "playOrder=\"" counter "\""
sub(/playOrder="[0-9]*"/, repl )
counter++;
}
print $0 > "tempFile"
}