On Saturday 26 September 2009 00:49:21 you wrote:
> I got stuck reading a file with relative URI as xmlns specification, e.g
> xmlns:foo="./bar/[...]".
> 
> On xmlTextReaderRead(), a warning is generated (relative URIs are
>  deprecated) and the return value is '-1'. As I know that the files in
>  question contain this problem, I'd like to skip this particular error.
>  Subsequent calls to xmlTextReaderRead() seem not to advance to any of the
>  later nodes but always return '-1'. Thus I assume that one would somehow
>  need to reset the internal state of the xmlTextReader after the first
>  return of '-1' - but there seems to be no (obvious) way to do so?! Using
>  xmlReadFile(), the same warning is issued, but the tree is available
>  afterwards.
> 
> This seems to be quite similar to a previous problem [1,2], there the URI
>  was empty, not relative?!

To follow-up on myself, the problem is apparently only related to default 
namespaces:

$> gcc -o reader1 `xml2-config --cflags` reader1.c  `xml2-config --libs`

$> cat test1.xml && ./reader1 test1.xml
<?xml version="1.0"?>
<myroot xmlns:myns="http://absolute"/>
0 1 myroot 1 0

$> cat test2.xml && ./reader1 test2.xml
<?xml version="1.0"?>
<myroot xmlns:myns="relative"/>
0 1 myroot 1 0

$> cat test3.xml && ./reader1 test3.xml
<?xml version="1.0"?>
<myroot xmlns="http://absolute"/>
0 1 myroot 1 0

$> cat test4.xml && ./reader1 test4.xml
<?xml version="1.0"?>
<myroot xmlns="relative"/>
test3.xml:2: namespace warning : xmlns: URI relative is not absolute
<myroot xmlns="relative"/>
                        ^
test3.xml : failed to parse


Further:
$> xmllint test4.xml
test4.xml:2: namespace warning : xmlns: URI relative is not absolute
<myroot xmlns="relative"/>
                        ^
<?xml version="1.0"?>
<myroot xmlns="relative"/>

$> xmllint --stream test4.xml
test4.xml:2: namespace warning : xmlns: URI relative is not absolute
<myroot xmlns="relative"/>
                        ^
test4.xml : failed to parse


Any feasible way to work around the problem (besides rewriting everything to 
use the DOM interface)?

Thanks

        Daniel
_______________________________________________
xml mailing list, project page  http://xmlsoft.org/
[email protected]
http://mail.gnome.org/mailman/listinfo/xml

Reply via email to