bool parse_not_unique_attr_error(xmlAttr *attr, error_context_t& ctx) { std::ostringstream oss; oss << "there must be a unique " << XML_CHAR_TO_CHAR(attr->name) << " attribute"; oss << " in <" << XML_CHAR_TO_CHAR(attr->parent->name) << ">"; return add_fatal(ctx, attr, oss.str()); }
bool parse_not_unique_error(xmlNode *node, error_context_t& ctx) { std::ostringstream oss; oss << "there must be a unique <" << XML_CHAR_TO_CHAR(node->name) << "> element"; if(node->parent->name) oss << " in <" << XML_CHAR_TO_CHAR(node->parent->name) << ">"; else oss << " at root level"; return add_fatal(ctx, node, oss.str()); }
bool parse_missing_attr_error(xmlNode *node, const char *name, error_context_t& ctx) { std::ostringstream oss; oss << "missing " << name << " attribute"; oss << " in <" << XML_CHAR_TO_CHAR(node->name) << ">"; return add_fatal(ctx, node, oss.str()); }
bool parse_text_attr(xmlAttr *attr, std::string& s) { if(attr->children != attr->last) return false; if(attr->children->type != XML_TEXT_NODE) return false; s = XML_CHAR_TO_CHAR(attr->children->content); return true; }
bool parse_name_elem(xmlNode *node, std::string& name, xmlChar *content, error_context_t& ctx) { name = XML_CHAR_TO_CHAR(content); if(name.size() == 0) return add_fatal(ctx, node, "name cannot be empty"); for(size_t i = 0; i < name.size(); i++) if(!isalnum(name[i]) && name[i] != '_') return add_fatal(ctx, node, "name must only contain alphanumeric characters or _"); return true; }
bool parse_missing_error(xmlNode *node, const char *name, error_context_t& ctx) { std::ostringstream oss; oss << "missing <" << name << "> element"; if(node->parent->name) oss << " in <" << XML_CHAR_TO_CHAR(node->parent->name) << ">"; else oss << " at root level"; return add_fatal(ctx, node, oss.str()); }
bool parse_unsigned_text(U *node, T& res, xmlChar *content, error_context_t& ctx) { char *end; unsigned long uns = strtoul(XML_CHAR_TO_CHAR(content), &end, 0); if(*end != 0) return add_fatal(ctx, node, "content must be an unsigned integer"); res = uns; if(res != uns) return add_fatal(ctx, node, "value does not fit into allowed range"); return true; }
bool parse_text_attr(xmlAttr *attr, std::string& res, xmlChar *content, error_context_t& ctx) { res = XML_CHAR_TO_CHAR(content); return true; }
bool parse_text_elem(xmlNode *node, std::string& name, xmlChar *content, error_context_t& ctx) { name = XML_CHAR_TO_CHAR(content); return true; }