Menu

#38 RdfParser doesn't respect XML Namespace Scoping

open
nobody
Parsers (11)
5
2007-08-23
2007-08-23
No

When an RDF resource declares a namespace, that namespace is applied globally in _start_ns_declaration_handler of RdfParser.php.
This is contrary to Namespaces in XML1.0 (Second Edition), 6.1 which says "The scope of a namespace declaration declaring a prefix extends from the beginning of the start-tag in which it appears to the end of the corresponding end-tag, excluding the scope of any inner declarations with the same NSAttName part. In the case of an empty tag, the scope is the tag itself."

The attached vCard illustrates the problem: ns0pred is used locally for both the rdf and vCard namespaces in different elements. RAP ends up globally using ns0pred for both rdf and vCard namespaces.

Sample code:

<?php
$model = ModelFactory::getDefaultModel();
$model->load("input.rdf");
echo($model->writeRdfToString());
?>

Discussion

  • Christian Becker

    Sample vCard

     
  • Christian Becker

    Sample code output

     
  • Christian Becker

    Logged In: YES
    user_id=1383215
    Originator: YES

    File Added: output.rdf

     
Want the latest updates on software, tech news, and AI?
Get latest updates about software, tech news, and AI from SourceForge directly in your inbox once a month.