mirror of
https://gitlab.gnome.org/GNOME/libxml2.git
synced 2025-07-29 11:41:22 +03:00
warn on xmlns:prefix="foo" fixed a couple of problem for namespace
* SAX.c: warn on xmlns:prefix="foo" * xmlreader.c python/tests/reader.py: fixed a couple of problem for namespace attributes handling. Daniel
This commit is contained in:
@ -1,3 +1,9 @@
|
|||||||
|
Mon Dec 30 11:53:44 CET 2002 Daniel Veillard <daniel@veillard.com>
|
||||||
|
|
||||||
|
* SAX.c: warn on xmlns:prefix="foo"
|
||||||
|
* xmlreader.c python/tests/reader.py: fixed a couple of problem
|
||||||
|
for namespace attributes handling.
|
||||||
|
|
||||||
Mon Dec 30 00:59:07 CET 2002 Daniel Veillard <daniel@veillard.com>
|
Mon Dec 30 00:59:07 CET 2002 Daniel Veillard <daniel@veillard.com>
|
||||||
|
|
||||||
* entities.c parser.c tree.c include/libxml/entities.h: Fixed
|
* entities.c parser.c tree.c include/libxml/entities.h: Fixed
|
||||||
|
20
SAX.c
20
SAX.c
@ -868,7 +868,7 @@ my_attribute(void *ctx, const xmlChar *fullname, const xmlChar *value,
|
|||||||
if (uri->scheme == NULL) {
|
if (uri->scheme == NULL) {
|
||||||
if ((ctxt->sax != NULL) && (ctxt->sax->warning != NULL))
|
if ((ctxt->sax != NULL) && (ctxt->sax->warning != NULL))
|
||||||
ctxt->sax->warning(ctxt->userData,
|
ctxt->sax->warning(ctxt->userData,
|
||||||
"nmlns: URI %s is not absolute\n", value);
|
"xmlns: URI %s is not absolute\n", value);
|
||||||
}
|
}
|
||||||
xmlFreeURI(uri);
|
xmlFreeURI(uri);
|
||||||
}
|
}
|
||||||
@ -901,6 +901,24 @@ my_attribute(void *ctx, const xmlChar *fullname, const xmlChar *value,
|
|||||||
ctxt->sax->error(ctxt->userData,
|
ctxt->sax->error(ctxt->userData,
|
||||||
"Empty namespace name for prefix %s\n", name);
|
"Empty namespace name for prefix %s\n", name);
|
||||||
}
|
}
|
||||||
|
if (value[0] != 0) {
|
||||||
|
xmlURIPtr uri;
|
||||||
|
|
||||||
|
uri = xmlParseURI((const char *)value);
|
||||||
|
if (uri == NULL) {
|
||||||
|
if ((ctxt->sax != NULL) && (ctxt->sax->warning != NULL))
|
||||||
|
ctxt->sax->warning(ctxt->userData,
|
||||||
|
"xmlns:%s: %s not a valid URI\n", name, value);
|
||||||
|
} else {
|
||||||
|
if (uri->scheme == NULL) {
|
||||||
|
if ((ctxt->sax != NULL) && (ctxt->sax->warning != NULL))
|
||||||
|
ctxt->sax->warning(ctxt->userData,
|
||||||
|
"xmlns:%s: URI %s is not absolute\n", name, value);
|
||||||
|
}
|
||||||
|
xmlFreeURI(uri);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
/* a standard namespace definition */
|
/* a standard namespace definition */
|
||||||
nsret = xmlNewNs(ctxt->node, value, name);
|
nsret = xmlNewNs(ctxt->node, value, name);
|
||||||
xmlFree(ns);
|
xmlFree(ns);
|
||||||
|
@ -264,6 +264,42 @@ if res != expect:
|
|||||||
print res
|
print res
|
||||||
sys.exit(1)
|
sys.exit(1)
|
||||||
|
|
||||||
|
#
|
||||||
|
# a couple of tests for namespace nodes
|
||||||
|
#
|
||||||
|
f = StringIO.StringIO("""<a xmlns="http://example.com/foo">""")
|
||||||
|
input = libxml2.inputBuffer(f)
|
||||||
|
reader = input.newTextReader("test6")
|
||||||
|
ret = reader.Read()
|
||||||
|
if ret != 1:
|
||||||
|
print "test6: failed to Read()"
|
||||||
|
sys.exit(1)
|
||||||
|
ret = reader.MoveToFirstAttribute()
|
||||||
|
if ret != 1:
|
||||||
|
print "test6: failed to MoveToFirstAttribute()"
|
||||||
|
sys.exit(1)
|
||||||
|
if reader.NamespaceUri() != "http://www.w3.org/2000/xmlns/" or \
|
||||||
|
reader.LocalName() != "xmlns" or reader.Name() != "xmlns" or \
|
||||||
|
reader.Value() != "http://example.com/foo" or reader.NodeType() != 2:
|
||||||
|
print "test6: failed to read the namespace node"
|
||||||
|
sys.exit(1)
|
||||||
|
|
||||||
|
f = StringIO.StringIO("""<a xmlns:prefix="http://example.com/foo">""")
|
||||||
|
input = libxml2.inputBuffer(f)
|
||||||
|
reader = input.newTextReader("test7")
|
||||||
|
ret = reader.Read()
|
||||||
|
if ret != 1:
|
||||||
|
print "test7: failed to Read()"
|
||||||
|
sys.exit(1)
|
||||||
|
ret = reader.MoveToFirstAttribute()
|
||||||
|
if ret != 1:
|
||||||
|
print "test7: failed to MoveToFirstAttribute()"
|
||||||
|
sys.exit(1)
|
||||||
|
if reader.NamespaceUri() != "http://www.w3.org/2000/xmlns/" or \
|
||||||
|
reader.LocalName() != "prefix" or reader.Name() != "xmlns:prefix" or \
|
||||||
|
reader.Value() != "http://example.com/foo" or reader.NodeType() != 2:
|
||||||
|
print "test7: failed to read the namespace node"
|
||||||
|
sys.exit(1)
|
||||||
|
|
||||||
del f
|
del f
|
||||||
del input
|
del input
|
||||||
|
@ -1369,6 +1369,7 @@ xmlTextReaderNodeType(xmlTextReaderPtr reader) {
|
|||||||
(reader->state == XML_TEXTREADER_BACKTRACK))
|
(reader->state == XML_TEXTREADER_BACKTRACK))
|
||||||
return(15);
|
return(15);
|
||||||
return(1);
|
return(1);
|
||||||
|
case XML_NAMESPACE_DECL:
|
||||||
case XML_ATTRIBUTE_NODE:
|
case XML_ATTRIBUTE_NODE:
|
||||||
return(2);
|
return(2);
|
||||||
case XML_TEXT_NODE:
|
case XML_TEXT_NODE:
|
||||||
@ -1400,7 +1401,6 @@ xmlTextReaderNodeType(xmlTextReaderPtr reader) {
|
|||||||
case XML_ELEMENT_DECL:
|
case XML_ELEMENT_DECL:
|
||||||
case XML_ATTRIBUTE_DECL:
|
case XML_ATTRIBUTE_DECL:
|
||||||
case XML_ENTITY_DECL:
|
case XML_ENTITY_DECL:
|
||||||
case XML_NAMESPACE_DECL:
|
|
||||||
case XML_XINCLUDE_START:
|
case XML_XINCLUDE_START:
|
||||||
case XML_XINCLUDE_END:
|
case XML_XINCLUDE_END:
|
||||||
return(0);
|
return(0);
|
||||||
@ -1586,10 +1586,8 @@ xmlTextReaderNamespaceUri(xmlTextReaderPtr reader) {
|
|||||||
node = reader->curnode;
|
node = reader->curnode;
|
||||||
else
|
else
|
||||||
node = reader->node;
|
node = reader->node;
|
||||||
if (node->type == XML_NAMESPACE_DECL) {
|
if (node->type == XML_NAMESPACE_DECL)
|
||||||
xmlNsPtr ns = (xmlNsPtr) node;
|
return(xmlStrdup(BAD_CAST "http://www.w3.org/2000/xmlns/"));
|
||||||
return(xmlStrdup(ns->href));
|
|
||||||
}
|
|
||||||
if ((node->type != XML_ELEMENT_NODE) &&
|
if ((node->type != XML_ELEMENT_NODE) &&
|
||||||
(node->type != XML_ATTRIBUTE_NODE))
|
(node->type != XML_ATTRIBUTE_NODE))
|
||||||
return(NULL);
|
return(NULL);
|
||||||
|
Reference in New Issue
Block a user