mirror of
https://github.com/geometer/FBReaderJ.git
synced 2025-10-04 18:29:23 +02:00
fixed svg namespace processing
This commit is contained in:
parent
8b57df7dc9
commit
9711842566
9 changed files with 140 additions and 99 deletions
|
@ -4,6 +4,7 @@
|
|||
* Plural forms in Belarusian and Czech translations
|
||||
* Fixed issue with rendering during backward page turning with no amimation
|
||||
* xlarge screens support declared in AndroidManifest.xml
|
||||
* ePub: fixed svg namespace processing
|
||||
|
||||
===== 1.6.8 (Nov 30, 2012) =====
|
||||
* Fixed NPE during adding a custom catalog with no search link
|
||||
|
|
|
@ -86,7 +86,7 @@ protected:
|
|||
~FB2Reader();
|
||||
|
||||
protected:
|
||||
const NamespaceAttributeNamePredicate myHrefPredicate;
|
||||
const FullNamePredicate myHrefPredicate;
|
||||
};
|
||||
|
||||
inline FB2Reader::~FB2Reader() {}
|
||||
|
|
|
@ -44,7 +44,7 @@ void XHTMLImageFinder::startElementHandler(const char *tag, const char **attribu
|
|||
reference = attributeValue(attributes, "src");
|
||||
} else if (TAG_IMAGE == tag) {
|
||||
reference = attributeValue(
|
||||
attributes, NamespaceAttributeNamePredicate(ZLXMLNamespace::XLink, "href")
|
||||
attributes, FullNamePredicate(ZLXMLNamespace::XLink, "href")
|
||||
);
|
||||
}
|
||||
if (reference != 0) {
|
||||
|
|
|
@ -38,6 +38,7 @@
|
|||
#include "../../bookmodel/BookModel.h"
|
||||
|
||||
std::map<std::string,XHTMLTagAction*> XHTMLReader::ourTagActions;
|
||||
std::map<shared_ptr<XHTMLReader::FullNamePredicate>,XHTMLTagAction*> XHTMLReader::ourNsTagActions;
|
||||
|
||||
XHTMLTagAction::~XHTMLTagAction() {
|
||||
}
|
||||
|
@ -96,20 +97,20 @@ public:
|
|||
class XHTMLTagImageAction : public XHTMLTagAction {
|
||||
|
||||
public:
|
||||
XHTMLTagImageAction(shared_ptr<ZLXMLReader::AttributeNamePredicate> predicate);
|
||||
XHTMLTagImageAction(shared_ptr<ZLXMLReader::NamePredicate> predicate);
|
||||
XHTMLTagImageAction(const std::string &attributeName);
|
||||
|
||||
void doAtStart(XHTMLReader &reader, const char **xmlattributes);
|
||||
void doAtEnd(XHTMLReader &reader);
|
||||
|
||||
private:
|
||||
shared_ptr<ZLXMLReader::AttributeNamePredicate> myPredicate;
|
||||
shared_ptr<ZLXMLReader::NamePredicate> myPredicate;
|
||||
};
|
||||
|
||||
class XHTMLSvgImageAttributeNamePredicate : public ZLXMLReader::NamespaceAttributeNamePredicate {
|
||||
class XHTMLSvgImageNamePredicate : public ZLXMLReader::FullNamePredicate {
|
||||
|
||||
public:
|
||||
XHTMLSvgImageAttributeNamePredicate();
|
||||
XHTMLSvgImageNamePredicate();
|
||||
bool accepts(const ZLXMLReader &reader, const char *name) const;
|
||||
|
||||
private:
|
||||
|
@ -121,12 +122,12 @@ friend class XHTMLTagSvgAction;
|
|||
class XHTMLTagSvgAction : public XHTMLTagAction {
|
||||
|
||||
public:
|
||||
XHTMLTagSvgAction(XHTMLSvgImageAttributeNamePredicate &predicate);
|
||||
XHTMLTagSvgAction(XHTMLSvgImageNamePredicate &predicate);
|
||||
void doAtStart(XHTMLReader &reader, const char **xmlattributes);
|
||||
void doAtEnd(XHTMLReader &reader);
|
||||
|
||||
private:
|
||||
XHTMLSvgImageAttributeNamePredicate &myPredicate;
|
||||
XHTMLSvgImageNamePredicate &myPredicate;
|
||||
};
|
||||
|
||||
class XHTMLTagItemAction : public XHTMLTagAction {
|
||||
|
@ -275,12 +276,12 @@ void XHTMLTagItemAction::doAtEnd(XHTMLReader &reader) {
|
|||
endParagraph(reader);
|
||||
}
|
||||
|
||||
XHTMLTagImageAction::XHTMLTagImageAction(shared_ptr<ZLXMLReader::AttributeNamePredicate> predicate) {
|
||||
XHTMLTagImageAction::XHTMLTagImageAction(shared_ptr<ZLXMLReader::NamePredicate> predicate) {
|
||||
myPredicate = predicate;
|
||||
}
|
||||
|
||||
XHTMLTagImageAction::XHTMLTagImageAction(const std::string &attributeName) {
|
||||
myPredicate = new ZLXMLReader::FixedAttributeNamePredicate(attributeName);
|
||||
myPredicate = new ZLXMLReader::SimpleNamePredicate(attributeName);
|
||||
}
|
||||
|
||||
void XHTMLTagImageAction::doAtStart(XHTMLReader &reader, const char **xmlattributes) {
|
||||
|
@ -307,7 +308,7 @@ void XHTMLTagImageAction::doAtStart(XHTMLReader &reader, const char **xmlattribu
|
|||
}
|
||||
}
|
||||
|
||||
XHTMLTagSvgAction::XHTMLTagSvgAction(XHTMLSvgImageAttributeNamePredicate &predicate) : myPredicate(predicate) {
|
||||
XHTMLTagSvgAction::XHTMLTagSvgAction(XHTMLSvgImageNamePredicate &predicate) : myPredicate(predicate) {
|
||||
}
|
||||
|
||||
void XHTMLTagSvgAction::doAtStart(XHTMLReader&, const char**) {
|
||||
|
@ -318,11 +319,11 @@ void XHTMLTagSvgAction::doAtEnd(XHTMLReader&) {
|
|||
myPredicate.myIsEnabled = false;
|
||||
}
|
||||
|
||||
XHTMLSvgImageAttributeNamePredicate::XHTMLSvgImageAttributeNamePredicate() : ZLXMLReader::NamespaceAttributeNamePredicate(ZLXMLNamespace::XLink, "href"), myIsEnabled(false) {
|
||||
XHTMLSvgImageNamePredicate::XHTMLSvgImageNamePredicate() : ZLXMLReader::FullNamePredicate(ZLXMLNamespace::XLink, "href"), myIsEnabled(false) {
|
||||
}
|
||||
|
||||
bool XHTMLSvgImageAttributeNamePredicate::accepts(const ZLXMLReader &reader, const char *name) const {
|
||||
return myIsEnabled && NamespaceAttributeNamePredicate::accepts(reader, name);
|
||||
bool XHTMLSvgImageNamePredicate::accepts(const ZLXMLReader &reader, const char *name) const {
|
||||
return myIsEnabled && FullNamePredicate::accepts(reader, name);
|
||||
}
|
||||
|
||||
void XHTMLTagImageAction::doAtEnd(XHTMLReader&) {
|
||||
|
@ -407,81 +408,104 @@ XHTMLTagAction *XHTMLReader::addAction(const std::string &tag, XHTMLTagAction *a
|
|||
return old;
|
||||
}
|
||||
|
||||
XHTMLTagAction *XHTMLReader::addAction(const std::string &ns, const std::string &name, XHTMLTagAction *action) {
|
||||
shared_ptr<FullNamePredicate> predicate = new FullNamePredicate(ns, name);
|
||||
XHTMLTagAction *old = ourNsTagActions[predicate];
|
||||
ourNsTagActions[predicate] = action;
|
||||
return old;
|
||||
}
|
||||
|
||||
XHTMLTagAction *XHTMLReader::getAction(const std::string &tag) {
|
||||
const std::string lTag = ZLUnicodeUtil::toLower(tag);
|
||||
XHTMLTagAction *action = ourTagActions[lTag];
|
||||
if (action != 0) {
|
||||
return action;
|
||||
}
|
||||
for (std::map<shared_ptr<FullNamePredicate>,XHTMLTagAction*>::const_iterator it = ourNsTagActions.begin(); it != ourNsTagActions.end(); ++it) {
|
||||
if (it->first->accepts(*this, lTag)) {
|
||||
return it->second;
|
||||
}
|
||||
}
|
||||
return 0;
|
||||
}
|
||||
|
||||
void XHTMLReader::fillTagTable() {
|
||||
if (ourTagActions.empty()) {
|
||||
//addAction("html", new XHTMLTagAction());
|
||||
addAction("body", new XHTMLTagBodyAction());
|
||||
//addAction("title", new XHTMLTagAction());
|
||||
//addAction("meta", new XHTMLTagAction());
|
||||
//addAction("script", new XHTMLTagAction());
|
||||
//addAction("html", new XHTMLTagAction());
|
||||
addAction("body", new XHTMLTagBodyAction());
|
||||
//addAction("title", new XHTMLTagAction());
|
||||
//addAction("meta", new XHTMLTagAction());
|
||||
//addAction("script", new XHTMLTagAction());
|
||||
|
||||
//addAction("font", new XHTMLTagAction());
|
||||
addAction("style", new XHTMLTagStyleAction());
|
||||
//addAction("font", new XHTMLTagAction());
|
||||
addAction("style", new XHTMLTagStyleAction());
|
||||
|
||||
addAction("p", new XHTMLTagParagraphAction());
|
||||
addAction("h1", new XHTMLTagParagraphWithControlAction(H1));
|
||||
addAction("h2", new XHTMLTagParagraphWithControlAction(H2));
|
||||
addAction("h3", new XHTMLTagParagraphWithControlAction(H3));
|
||||
addAction("h4", new XHTMLTagParagraphWithControlAction(H4));
|
||||
addAction("h5", new XHTMLTagParagraphWithControlAction(H5));
|
||||
addAction("h6", new XHTMLTagParagraphWithControlAction(H6));
|
||||
addAction("p", new XHTMLTagParagraphAction());
|
||||
addAction("h1", new XHTMLTagParagraphWithControlAction(H1));
|
||||
addAction("h2", new XHTMLTagParagraphWithControlAction(H2));
|
||||
addAction("h3", new XHTMLTagParagraphWithControlAction(H3));
|
||||
addAction("h4", new XHTMLTagParagraphWithControlAction(H4));
|
||||
addAction("h5", new XHTMLTagParagraphWithControlAction(H5));
|
||||
addAction("h6", new XHTMLTagParagraphWithControlAction(H6));
|
||||
|
||||
//addAction("ol", new XHTMLTagAction());
|
||||
//addAction("ul", new XHTMLTagAction());
|
||||
//addAction("dl", new XHTMLTagAction());
|
||||
addAction("li", new XHTMLTagItemAction());
|
||||
//addAction("ol", new XHTMLTagAction());
|
||||
//addAction("ul", new XHTMLTagAction());
|
||||
//addAction("dl", new XHTMLTagAction());
|
||||
addAction("li", new XHTMLTagItemAction());
|
||||
|
||||
addAction("strong", new XHTMLTagControlAction(STRONG));
|
||||
addAction("b", new XHTMLTagControlAction(BOLD));
|
||||
addAction("em", new XHTMLTagControlAction(EMPHASIS));
|
||||
addAction("i", new XHTMLTagControlAction(ITALIC));
|
||||
addAction("code", new XHTMLTagControlAction(CODE));
|
||||
addAction("tt", new XHTMLTagControlAction(CODE));
|
||||
addAction("kbd", new XHTMLTagControlAction(CODE));
|
||||
addAction("var", new XHTMLTagControlAction(CODE));
|
||||
addAction("samp", new XHTMLTagControlAction(CODE));
|
||||
addAction("cite", new XHTMLTagControlAction(CITE));
|
||||
addAction("sub", new XHTMLTagControlAction(SUB));
|
||||
addAction("sup", new XHTMLTagControlAction(SUP));
|
||||
addAction("dd", new XHTMLTagControlAction(DEFINITION_DESCRIPTION));
|
||||
addAction("dfn", new XHTMLTagControlAction(DEFINITION));
|
||||
addAction("strike", new XHTMLTagControlAction(STRIKETHROUGH));
|
||||
addAction("strong", new XHTMLTagControlAction(STRONG));
|
||||
addAction("b", new XHTMLTagControlAction(BOLD));
|
||||
addAction("em", new XHTMLTagControlAction(EMPHASIS));
|
||||
addAction("i", new XHTMLTagControlAction(ITALIC));
|
||||
addAction("code", new XHTMLTagControlAction(CODE));
|
||||
addAction("tt", new XHTMLTagControlAction(CODE));
|
||||
addAction("kbd", new XHTMLTagControlAction(CODE));
|
||||
addAction("var", new XHTMLTagControlAction(CODE));
|
||||
addAction("samp", new XHTMLTagControlAction(CODE));
|
||||
addAction("cite", new XHTMLTagControlAction(CITE));
|
||||
addAction("sub", new XHTMLTagControlAction(SUB));
|
||||
addAction("sup", new XHTMLTagControlAction(SUP));
|
||||
addAction("dd", new XHTMLTagControlAction(DEFINITION_DESCRIPTION));
|
||||
addAction("dfn", new XHTMLTagControlAction(DEFINITION));
|
||||
addAction("strike", new XHTMLTagControlAction(STRIKETHROUGH));
|
||||
|
||||
addAction("a", new XHTMLTagHyperlinkAction());
|
||||
addAction("a", new XHTMLTagHyperlinkAction());
|
||||
|
||||
addAction("img", new XHTMLTagImageAction("src"));
|
||||
addAction("object", new XHTMLTagImageAction("data"));
|
||||
XHTMLSvgImageAttributeNamePredicate *predicate = new XHTMLSvgImageAttributeNamePredicate();
|
||||
addAction("image", new XHTMLTagImageAction(predicate));
|
||||
addAction("svg", new XHTMLTagSvgAction(*predicate));
|
||||
addAction("img", new XHTMLTagImageAction("src"));
|
||||
addAction("object", new XHTMLTagImageAction("data"));
|
||||
XHTMLSvgImageNamePredicate *predicate = new XHTMLSvgImageNamePredicate();
|
||||
addAction("svg", new XHTMLTagSvgAction(*predicate));
|
||||
addAction("image", new XHTMLTagImageAction(predicate));
|
||||
addAction(ZLXMLNamespace::Svg, "svg", new XHTMLTagSvgAction(*predicate));
|
||||
addAction(ZLXMLNamespace::Svg, "image", new XHTMLTagImageAction(predicate));
|
||||
|
||||
//addAction("area", new XHTMLTagAction());
|
||||
//addAction("map", new XHTMLTagAction());
|
||||
//addAction("area", new XHTMLTagAction());
|
||||
//addAction("map", new XHTMLTagAction());
|
||||
|
||||
//addAction("base", new XHTMLTagAction());
|
||||
//addAction("blockquote", new XHTMLTagAction());
|
||||
addAction("br", new XHTMLTagRestartParagraphAction());
|
||||
//addAction("center", new XHTMLTagAction());
|
||||
//addAction("base", new XHTMLTagAction());
|
||||
//addAction("blockquote", new XHTMLTagAction());
|
||||
addAction("br", new XHTMLTagRestartParagraphAction());
|
||||
//addAction("center", new XHTMLTagAction());
|
||||
addAction("div", new XHTMLTagParagraphAction());
|
||||
addAction("dt", new XHTMLTagParagraphAction());
|
||||
//addAction("head", new XHTMLTagAction());
|
||||
//addAction("hr", new XHTMLTagAction());
|
||||
addAction("link", new XHTMLTagLinkAction());
|
||||
//addAction("param", new XHTMLTagAction());
|
||||
//addAction("q", new XHTMLTagAction());
|
||||
//addAction("s", new XHTMLTagAction());
|
||||
//addAction("head", new XHTMLTagAction());
|
||||
//addAction("hr", new XHTMLTagAction());
|
||||
addAction("link", new XHTMLTagLinkAction());
|
||||
//addAction("param", new XHTMLTagAction());
|
||||
//addAction("q", new XHTMLTagAction());
|
||||
//addAction("s", new XHTMLTagAction());
|
||||
|
||||
addAction("pre", new XHTMLTagPreAction());
|
||||
//addAction("big", new XHTMLTagAction());
|
||||
//addAction("small", new XHTMLTagAction());
|
||||
//addAction("u", new XHTMLTagAction());
|
||||
addAction("pre", new XHTMLTagPreAction());
|
||||
//addAction("big", new XHTMLTagAction());
|
||||
//addAction("small", new XHTMLTagAction());
|
||||
//addAction("u", new XHTMLTagAction());
|
||||
|
||||
//addAction("table", new XHTMLTagAction());
|
||||
addAction("td", new XHTMLTagParagraphAction());
|
||||
addAction("th", new XHTMLTagParagraphAction());
|
||||
//addAction("tr", new XHTMLTagAction());
|
||||
//addAction("caption", new XHTMLTagAction());
|
||||
//addAction("span", new XHTMLTagAction());
|
||||
//addAction("table", new XHTMLTagAction());
|
||||
addAction("td", new XHTMLTagParagraphAction());
|
||||
addAction("th", new XHTMLTagParagraphAction());
|
||||
//addAction("tr", new XHTMLTagAction());
|
||||
//addAction("caption", new XHTMLTagAction());
|
||||
//addAction("span", new XHTMLTagAction());
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -542,7 +566,7 @@ void XHTMLReader::startElementHandler(const char *tag, const char **attributes)
|
|||
}
|
||||
myDoPageBreakAfterStack.push_back(myStyleSheetTable.doBreakAfter(sTag, sClass));
|
||||
|
||||
XHTMLTagAction *action = ourTagActions[sTag];
|
||||
XHTMLTagAction *action = getAction(sTag);
|
||||
if (action != 0) {
|
||||
action->doAtStart(*this, attributes);
|
||||
}
|
||||
|
@ -569,7 +593,7 @@ void XHTMLReader::endElementHandler(const char *tag) {
|
|||
myStylesToRemove = myCSSStack.back();
|
||||
myCSSStack.pop_back();
|
||||
|
||||
XHTMLTagAction *action = ourTagActions[ZLUnicodeUtil::toLower(tag)];
|
||||
XHTMLTagAction *action = getAction(tag);
|
||||
if (action != 0) {
|
||||
action->doAtEnd(*this);
|
||||
myNewParagraphInProgress = false;
|
||||
|
|
|
@ -53,10 +53,12 @@ class XHTMLReader : public ZLXMLReader {
|
|||
|
||||
public:
|
||||
static XHTMLTagAction *addAction(const std::string &tag, XHTMLTagAction *action);
|
||||
static XHTMLTagAction *addAction(const std::string &ns, const std::string &name, XHTMLTagAction *action);
|
||||
static void fillTagTable();
|
||||
|
||||
private:
|
||||
static std::map<std::string,XHTMLTagAction*> ourTagActions;
|
||||
static std::map<shared_ptr<FullNamePredicate>,XHTMLTagAction*> ourNsTagActions;
|
||||
|
||||
public:
|
||||
XHTMLReader(BookReader &modelReader);
|
||||
|
@ -65,6 +67,8 @@ public:
|
|||
const std::string normalizedReference(const std::string &reference) const;
|
||||
|
||||
private:
|
||||
XHTMLTagAction *getAction(const std::string &tag);
|
||||
|
||||
void startElementHandler(const char *tag, const char **attributes);
|
||||
void endElementHandler(const char *tag);
|
||||
void characterDataHandler(const char *text, std::size_t len);
|
||||
|
|
|
@ -29,3 +29,4 @@ const std::string ZLXMLNamespace::OpenSearch = "http://a9.com/-/spec/opensearch/
|
|||
const std::string ZLXMLNamespace::CalibreMetadata = "http://calibre.kovidgoyal.net/2009/metadata";
|
||||
const std::string ZLXMLNamespace::Opds = "http://opds-spec.org/2010/catalog";
|
||||
const std::string ZLXMLNamespace::DaisyNCX = "http://www.daisy.org/z3986/2005/ncx/";
|
||||
const std::string ZLXMLNamespace::Svg = "http://www.w3.org/2000/svg";
|
||||
|
|
|
@ -38,6 +38,7 @@ public:
|
|||
static const std::string CalibreMetadata;
|
||||
static const std::string Opds;
|
||||
static const std::string DaisyNCX;
|
||||
static const std::string Svg;
|
||||
};
|
||||
|
||||
#endif /* __ZLXMLNAMESPACE_H__ */
|
||||
|
|
|
@ -149,7 +149,7 @@ const std::vector<std::string> &ZLXMLReader::externalDTDs() const {
|
|||
void ZLXMLReader::collectExternalEntities(std::map<std::string,std::string> &entityMap) {
|
||||
}
|
||||
|
||||
const char *ZLXMLReader::attributeValue(const char **xmlattributes, const char *name) {
|
||||
const char *ZLXMLReader::attributeValue(const char **xmlattributes, const char *name) const {
|
||||
while (*xmlattributes != 0) {
|
||||
bool useNext = strcmp(*xmlattributes, name) == 0;
|
||||
++xmlattributes;
|
||||
|
@ -164,34 +164,41 @@ const char *ZLXMLReader::attributeValue(const char **xmlattributes, const char *
|
|||
return 0;
|
||||
}
|
||||
|
||||
ZLXMLReader::AttributeNamePredicate::~AttributeNamePredicate() {
|
||||
ZLXMLReader::NamePredicate::~NamePredicate() {
|
||||
}
|
||||
|
||||
ZLXMLReader::FixedAttributeNamePredicate::FixedAttributeNamePredicate(const std::string &attributeName) : myAttributeName(attributeName) {
|
||||
ZLXMLReader::SimpleNamePredicate::SimpleNamePredicate(const std::string &name) : myName(name) {
|
||||
}
|
||||
|
||||
bool ZLXMLReader::FixedAttributeNamePredicate::accepts(const ZLXMLReader&, const char *name) const {
|
||||
return myAttributeName == name;
|
||||
bool ZLXMLReader::SimpleNamePredicate::accepts(const ZLXMLReader&, const char *name) const {
|
||||
return myName == name;
|
||||
}
|
||||
|
||||
ZLXMLReader::NamespaceAttributeNamePredicate::NamespaceAttributeNamePredicate(const std::string &ns, const std::string &name) : myNamespaceName(ns), myAttributeName(name) {
|
||||
bool ZLXMLReader::SimpleNamePredicate::accepts(const ZLXMLReader&, const std::string &name) const {
|
||||
return myName == name;
|
||||
}
|
||||
|
||||
bool ZLXMLReader::NamespaceAttributeNamePredicate::accepts(const ZLXMLReader &reader, const char *name) const {
|
||||
const std::string full(name);
|
||||
const std::size_t index = full.find(':');
|
||||
ZLXMLReader::FullNamePredicate::FullNamePredicate(const std::string &ns, const std::string &name) : myNamespaceName(ns), myName(name) {
|
||||
}
|
||||
|
||||
bool ZLXMLReader::FullNamePredicate::accepts(const ZLXMLReader &reader, const char *name) const {
|
||||
return accepts(reader, std::string(name));
|
||||
}
|
||||
|
||||
bool ZLXMLReader::FullNamePredicate::accepts(const ZLXMLReader &reader, const std::string &name) const {
|
||||
const std::size_t index = name.find(':');
|
||||
const std::string namespaceId =
|
||||
index == std::string::npos ? std::string() : full.substr(0, index);
|
||||
index == std::string::npos ? std::string() : name.substr(0, index);
|
||||
|
||||
const nsMap &namespaces = reader.namespaces();
|
||||
nsMap::const_iterator it = namespaces.find(namespaceId);
|
||||
return
|
||||
it != namespaces.end() &&
|
||||
it->second == myNamespaceName &&
|
||||
full.substr(index + 1) == myAttributeName;
|
||||
name.substr(index + 1) == myName;
|
||||
}
|
||||
|
||||
const char *ZLXMLReader::attributeValue(const char **xmlattributes, const AttributeNamePredicate &predicate) {
|
||||
const char *ZLXMLReader::attributeValue(const char **xmlattributes, const NamePredicate &predicate) const {
|
||||
while (*xmlattributes != 0) {
|
||||
bool useNext = predicate.accepts(*this, *xmlattributes);
|
||||
++xmlattributes;
|
||||
|
|
|
@ -34,32 +34,35 @@ class ZLXMLReaderInternal;
|
|||
class ZLXMLReader {
|
||||
|
||||
public:
|
||||
class AttributeNamePredicate {
|
||||
class NamePredicate {
|
||||
|
||||
public:
|
||||
virtual ~AttributeNamePredicate();
|
||||
virtual ~NamePredicate();
|
||||
virtual bool accepts(const ZLXMLReader &reader, const char *name) const = 0;
|
||||
virtual bool accepts(const ZLXMLReader &reader, const std::string &name) const = 0;
|
||||
};
|
||||
|
||||
class FixedAttributeNamePredicate : public AttributeNamePredicate {
|
||||
class SimpleNamePredicate : public NamePredicate {
|
||||
|
||||
public:
|
||||
FixedAttributeNamePredicate(const std::string &attributeName);
|
||||
SimpleNamePredicate(const std::string &name);
|
||||
bool accepts(const ZLXMLReader &reader, const char *name) const;
|
||||
bool accepts(const ZLXMLReader &reader, const std::string &name) const;
|
||||
|
||||
private:
|
||||
const std::string myAttributeName;
|
||||
const std::string myName;
|
||||
};
|
||||
|
||||
class NamespaceAttributeNamePredicate : public AttributeNamePredicate {
|
||||
class FullNamePredicate : public NamePredicate {
|
||||
|
||||
public:
|
||||
NamespaceAttributeNamePredicate(const std::string &ns, const std::string &name);
|
||||
FullNamePredicate(const std::string &ns, const std::string &name);
|
||||
bool accepts(const ZLXMLReader &reader, const char *name) const;
|
||||
bool accepts(const ZLXMLReader &reader, const std::string &name) const;
|
||||
|
||||
private:
|
||||
const std::string myNamespaceName;
|
||||
const std::string myAttributeName;
|
||||
const std::string myName;
|
||||
};
|
||||
|
||||
protected:
|
||||
|
@ -77,8 +80,8 @@ public:
|
|||
typedef std::map<std::string,std::string> nsMap;
|
||||
const nsMap &namespaces() const;
|
||||
|
||||
const char *attributeValue(const char **xmlattributes, const char *name);
|
||||
const char *attributeValue(const char **xmlattributes, const AttributeNamePredicate &predicate);
|
||||
const char *attributeValue(const char **xmlattributes, const char *name) const;
|
||||
const char *attributeValue(const char **xmlattributes, const NamePredicate &predicate) const;
|
||||
|
||||
private:
|
||||
void initialize(const char *encoding = 0);
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue