summaryrefslogtreecommitdiff
path: root/src/ne_xml.c
diff options
context:
space:
mode:
authorjoe <joe@61a7d7f5-40b7-0310-9c16-bb0ea8cb1845>2007-07-03 12:01:39 +0000
committerjoe <joe@61a7d7f5-40b7-0310-9c16-bb0ea8cb1845>2007-07-03 12:01:39 +0000
commit27a322c25ac9b6ba5f461ed46572cc6bfaefd683 (patch)
tree6ac8c42572c2421fefb99a5e3bb9fafca002f62f /src/ne_xml.c
parentf6a80d9f8f330924078ea0d48d41066d0810f983 (diff)
downloadneon-27a322c25ac9b6ba5f461ed46572cc6bfaefd683.tar.gz
* src/ne_xml.h (ne_xml_resolve_nspace): New interface.
* src/ne_xml.c (ne_xml_resolve_nspace): New function. * test/xml.c: Adjust all callbacks to take 'struct context' pointer. (parse_match): Pass a struct context pointer. (startelm): Add "eval-xmlns-" evaluators. (matches): Test namespace interfaces. git-svn-id: http://svn.webdav.org/repos/projects/neon/trunk@1180 61a7d7f5-40b7-0310-9c16-bb0ea8cb1845
Diffstat (limited to 'src/ne_xml.c')
-rw-r--r--src/ne_xml.c22
1 files changed, 19 insertions, 3 deletions
diff --git a/src/ne_xml.c b/src/ne_xml.c
index 014f727..f6cdd56 100644
--- a/src/ne_xml.c
+++ b/src/ne_xml.c
@@ -1,6 +1,6 @@
/*
Wrapper interface to XML parser
- Copyright (C) 1999-2006, Joe Orton <joe@manyfish.co.uk>
+ Copyright (C) 1999-2007, Joe Orton <joe@manyfish.co.uk>
This library is free software; you can redistribute it and/or
modify it under the terms of the GNU Library General Public
@@ -426,6 +426,22 @@ static const char *resolve_nspace(const struct element *elm,
return NULL;
}
+const char *ne_xml_resolve_nspace(ne_xml_parser *parser,
+ const char *prefix, size_t length)
+{
+ if (prefix) {
+ return resolve_nspace(parser->current, prefix, length);
+ }
+ else {
+ struct element *e = parser->current;
+
+ while (e->default_ns == NULL)
+ e = e->parent;
+
+ return e->default_ns;
+ }
+}
+
ne_xml_parser *ne_xml_create(void)
{
ne_xml_parser *p = ne_calloc(sizeof *p);
@@ -543,7 +559,7 @@ int ne_xml_parse(ne_xml_parser *p, const char *block, size_t len)
/* Parse errors are normally caught by the sax_error() callback,
* which clears p->valid. */
if (p->parser->errNo && p->failure == 0) {
- ne_snprintf(p->error, ERR_SIZE, "XML parse error at line %d.",
+ ne_snprintf(p->error, ERR_SIZE, "XML parse error at line %d",
ne_xml_currentline(p));
p->failure = 1;
NE_DEBUG(NE_DBG_XMLPARSE, "XML: Parse error: %s\n", p->error);
@@ -606,7 +622,7 @@ static void sax_error(void *ctx, const char *msg, ...)
if (p->failure == 0) {
ne_snprintf(p->error, ERR_SIZE,
- _("XML parse error at line %d: %s."),
+ _("XML parse error at line %d: %s"),
p->parser->input->line, buf);
p->failure = 1;
}