]> git.mxchange.org Git - friendica.git/commitdiff
Detect the namespace uri from token name
authorDomovoy <domovoy@errlock.org>
Fri, 14 Sep 2012 03:30:21 +0000 (05:30 +0200)
committerDomovoy <domovoy@errlock.org>
Fri, 14 Sep 2012 03:30:21 +0000 (05:30 +0200)
library/HTML5/TreeBuilder.php

index 578e73682bbd67f08266fc465de735384558917e..26cd410bf32c29d209073f15688eaf2f99667f02 100644 (file)
@@ -3037,8 +3037,22 @@ class HTML5_TreeBuilder {
         }
 
     private function insertElement($token, $append = true) {
-        $el = $this->dom->createElementNS(self::NS_HTML, $token['name']);
-
+               $sep_pos = strpos($token['name'],':');
+               $ns_uri = self::NS_HTML;
+               if($sep_pos !== FALSE) {
+                       // This tag has a namespace
+                       $ns = substr($token['name'], 0, $sep_pos);
+                       switch($ns) {
+                               case 'g':
+                                       $ns_uri = 'http://base.google.com/ns/1.0';
+                                       break;
+                               default:
+                                       logger("HTML5/TreeBuilder.php: Unknown namespace '". $ns ."', tag = ". $token['name'], LOGGER_DEBUG);
+                                       break;
+                       }
+               }
+        $el = $this->dom->createElementNS($ns_uri, $token['name']);
+               
         if (!empty($token['attr'])) {
             foreach($token['attr'] as $attr) {