View Full Version : NCX playOrder nuisance


erik5000
12-23-2009, 07:56 PM
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"
}

Jellby
12-24-2009, 06:31 AM
I use a vim command ('cause I edit the files with vim):

:let n=1 | g/playOrder=/s/playOrder=".\{-}"/\='playOrder="' . n . '"'/ | let n=n+1

note: they are discussing the playOrder attribute at IDPF, it might be optional in the next ePUB spec revisions.

quillaja
12-24-2009, 06:33 AM
you can just let them all be 0, i think. i've done that, and the TOC works on my prs-600.

Valloric
12-24-2009, 09:08 AM
you can just let them all be 0, i think. i've done that, and the TOC works on my prs-600.

There's a difference between what works on one device, and what is standards-compliant. Because other devices may behave differently is why we have standards in the first place.