Hi,
The book in question contains the namespace
xmlns:ncx="
http://www.daisy.org/z3986/2005/ncx/"
in the subfile "toc.ncx" - however, the FBReader OEB NCX parser did
not care about namespaces at all and so you will get tagName
"ncx:navMap" which is not equal to "navMap".
To fix that, I suggest to change the following (I've also made the
functions protected since their original definition in the ZLIbrary
core is protected as well, not private):
diff -upr orig/fbreader-0.12.10/fbreader/src/formats/oeb/NCXReader.cpp
fbreader-0.12.10/fbreader/src/formats/oeb/NCXReader.cpp
--- orig/fbreader-0.12.10/fbreader/src/formats/oeb/NCXReader.cpp
2010-04-01 15:14:24.000000000 +0200
+++ fbreader-0.12.10/fbreader/src/formats/oeb/NCXReader.cpp 2010-07-24
20:19:27.000000000 +0200
@@ -32,27 +32,41 @@ static const std::string TAG_NAVLABEL =
static const std::string TAG_CONTENT = "content";
static const std::string TAG_TEXT = "text";
+bool NCXReader::processNamespaces() const {
+ return true;
+}
+
+void NCXReader::namespaceListChangedHandler() {
+ const std::map<std::string,std::string>& namespaces = this-
>namespaces();
+ for (std::map<std::string,std::string>::const_iterator it =
namespaces.begin(); it != namespaces.end(); ++it) {
+ if (it->second == "
http://www.daisy.org/z3986/2005/ncx/") {
+ myNCXNamespacePrefix = it->first + ":";
+ }
+ }
+
+}
+
void NCXReader::startElementHandler(const char *tag, const char
**attributes) {
switch (myReadState) {
case READ_NONE:
- if (TAG_NAVMAP == tag) {
+ if (myNCXNamespacePrefix + TAG_NAVMAP == tag) {
myReadState = READ_MAP;
}
break;
case READ_MAP:
- if (TAG_NAVPOINT == tag) {
+ if (myNCXNamespacePrefix + TAG_NAVPOINT == tag) {
const char *order = attributeValue(attributes, "playOrder");
myPointStack.push_back(NavPoint((order != 0) ? atoi(order) :
myPlayIndex++, myPointStack.size()));
myReadState = READ_POINT;
}
break;
case READ_POINT:
- if (TAG_NAVPOINT == tag) {
+ if (myNCXNamespacePrefix + TAG_NAVPOINT == tag) {
const char *order = attributeValue(attributes, "playOrder");
myPointStack.push_back(NavPoint((order != 0) ? atoi(order) :
myPlayIndex++, myPointStack.size()));
- } else if (TAG_NAVLABEL == tag) {
+ } else if (myNCXNamespacePrefix + TAG_NAVLABEL == tag) {
myReadState = READ_LABEL;
- } else if (TAG_CONTENT == tag) {
+ } else if (myNCXNamespacePrefix + TAG_CONTENT == tag) {
const char *src = attributeValue(attributes, "src");
if (src != 0) {
myPointStack.back().ContentHRef = MiscUtil::decodeHtmlURL(src);
@@ -60,7 +74,7 @@ void NCXReader::startElementHandler(cons
}
break;
case READ_LABEL:
- if (TAG_TEXT == tag) {
+ if (myNCXNamespacePrefix + TAG_TEXT == tag) {
myReadState = READ_TEXT;
}
break;
@@ -74,12 +88,12 @@ void NCXReader::endElementHandler(const
case READ_NONE:
break;
case READ_MAP:
- if (TAG_NAVMAP == tag) {
+ if (myNCXNamespacePrefix + TAG_NAVMAP == tag) {
myReadState = READ_NONE;
}
break;
case READ_POINT:
- if (TAG_NAVPOINT == tag) {
+ if (myNCXNamespacePrefix + TAG_NAVPOINT == tag) {
if (myPointStack.back().Text.empty()) {
myPointStack.back().Text = "...";
}
@@ -88,12 +102,12 @@ void NCXReader::endElementHandler(const
myReadState = myPointStack.empty() ? READ_MAP : READ_POINT;
}
case READ_LABEL:
- if (TAG_NAVLABEL == tag) {
+ if (myNCXNamespacePrefix + TAG_NAVLABEL == tag) {
myReadState = READ_POINT;
}
break;
case READ_TEXT:
- if (TAG_TEXT == tag) {
+ if (myNCXNamespacePrefix + TAG_TEXT == tag) {
myReadState = READ_LABEL;
}
break;
diff -upr orig/fbreader-0.12.10/fbreader/src/formats/oeb/NCXReader.h
fbreader-0.12.10/fbreader/src/formats/oeb/NCXReader.h
--- orig/fbreader-0.12.10/fbreader/src/formats/oeb/NCXReader.h
2010-04-01 15:14:24.000000000 +0200
+++ fbreader-0.12.10/fbreader/src/formats/oeb/NCXReader.h 2010-07-24
20:18:38.000000000 +0200
@@ -44,16 +44,21 @@ public:
NCXReader(BookReader &modelReader);
const std::map<int,NavPoint> &navigationMap() const;
-private:
+protected:
void startElementHandler(const char *tag, const char **attributes);
void endElementHandler(const char *tag);
void characterDataHandler(const char *text, size_t len);
+ void namespaceListChangedHandler();
+ bool processNamespaces() const;
+
+private:
const std::vector<std::string> &externalDTDs() const;
private:
BookReader &myModelReader;
std::map<int,NavPoint> myNavigationMap;
std::vector<NavPoint> myPointStack;
+ std::string myNCXNamespacePrefix;
enum {
READ_NONE,
-----here ends this patch----