2
* FBReader -- electronic book reader
3
* Copyright (C) 2004-2007 Nikolay Pultsin <geometer@mawhrin.net>
4
* Copyright (C) 2005 Mikhail Sobolev <mss@mawhrin.net>
2
* Copyright (C) 2004-2008 Geometer Plus <contact@geometerplus.com>
6
4
* This program is free software; you can redistribute it and/or modify
7
5
* it under the terms of the GNU General Public License as published by
53
static const std::string XMLNS_PREFIX = "xmlns:";
54
50
static const std::string DC_SCHEME_PREFIX = "http://purl.org/dc/elements";
56
52
void OEBDescriptionReader::startElementHandler(const char *tag, const char **attributes) {
57
53
const std::string tagString = ZLUnicodeUtil::toLower(tag);
58
54
if ((METADATA == tagString) || (DC_METADATA == tagString)) {
59
if (attributes != 0) {
60
for (; *attributes != 0; attributes += 2) {
61
if (ZLStringUtil::stringStartsWith(*attributes, XMLNS_PREFIX) &&
62
ZLStringUtil::stringStartsWith(*(attributes + 1), DC_SCHEME_PREFIX)) {
63
myDCSchemeName = *attributes + 6;
64
myDCMetadataTag = tagString;
55
myDCMetadataTag = tagString;
69
56
myReadMetaData = true;
70
57
} else if (myReadMetaData) {
71
if (myDCSchemeName + TITLE == tagString) {
72
myReadState = READ_TITLE;
73
} else if (myDCSchemeName + AUTHOR_TAG == tagString) {
74
const char *role = attributeValue(attributes, "role");
76
myReadState = READ_AUTHOR2;
77
} else if (AUTHOR_ROLE == role) {
78
myReadState = READ_AUTHOR;
58
if (ZLStringUtil::stringEndsWith(tagString, TITLE)) {
59
const std::string namespaceId = tagString.substr(0, tagString.length() - TITLE.length());
60
const std::map<std::string,std::string> &namespaceMap = namespaces();
61
const std::map<std::string,std::string>::const_iterator iter = namespaceMap.find(namespaceId);
62
if ((iter != namespaceMap.end()) && ZLStringUtil::stringStartsWith(iter->second, DC_SCHEME_PREFIX)) {
63
myReadState = READ_TITLE;
65
} else if (ZLStringUtil::stringEndsWith(tagString, AUTHOR_TAG)) {
66
const std::string namespaceId = tagString.substr(0, tagString.length() - AUTHOR_TAG.length());
67
const std::map<std::string,std::string> &namespaceMap = namespaces();
68
const std::map<std::string,std::string>::const_iterator iter = namespaceMap.find(namespaceId);
69
if ((iter != namespaceMap.end()) && ZLStringUtil::stringStartsWith(iter->second, DC_SCHEME_PREFIX)) {
70
const char *role = attributeValue(attributes, "role");
72
myReadState = READ_AUTHOR2;
73
} else if (AUTHOR_ROLE == role) {
74
myReadState = READ_AUTHOR;