root

Changeset 796

Show
Ignore:
Timestamp:
04/06/10 20:27:20 (5 months ago)
Author:
wbond
Message:

Fixed ticket #405 - updated fXML to create a __ prefix for the default namespace and to implicitly use that for child and attribute access when no prefix is specified

Files:

Legend:

Unmodified
Added
Removed
Modified
Copied
Moved
  • fXML.php

    r702 r796 Hide Line Numbers
    66 * http://flourishlib.com/docs/UTF-8 for more information. 
    77 *  
    8  * @copyright  Copyright (c) 2007-2009 Will Bond 
     8 * @copyright  Copyright (c) 2007-2010 Will Bond 
    99 * @author     Will Bond [wb] <will@flourishlib.com> 
    1010 * @license    http://flourishlib.com/license 
     
    1313 * @link       http://flourishlib.com/fXML 
    1414 *  
    15  * @version    1.0.0b3 
     15 * @version    1.0.0b4 
     16 * @changes    1.0.0b4  Updated the class to automatically add a `__` prefix for the default namespace and to use that for attribute and child element access [wb, 2010-04-06] 
    1617 * @changes    1.0.0b3  Added the `$http_timeout` parameter to ::__construct() [wb, 2009-09-16] 
    1718 * @changes    1.0.0b2  Added instance functionality for reading of XML files [wb, 2009-09-01] 
     
    156157        if (!$this->__dom) { 
    157158            $this->__dom = dom_import_simplexml($xml); 
     159        } 
     160         
     161        if ($this->__dom->namespaceURI && $this->__dom->prefix == '') { 
     162            $this->addCustomPrefix('__', $this->__dom->namespaceURI); 
    158163        } 
    159164    } 
     
    200205        } 
    201206         
     207        if ($this->__dom->namespaceURI && $this->__dom->prefix == '' && strpos($name, ':') === FALSE) { 
     208            $name = '__:' . $name; 
     209        } 
    202210        $first_child = $this->query($name . '[1]'); 
    203211        if ($first_child->length) { 
     
    222230    public function __isset($name) 
    223231    { 
    224         return (boolean) $this->query($name . '[1]')->length;    
     232        if ($this->__dom->namespaceURI && $this->__dom->prefix == '' && strpos($name, ':') === FALSE) { 
     233            $name = '__:' . $name; 
     234        } 
     235        return (boolean) $this->query($name . '[1]')->length; 
    225236    } 
    226237     
     
    515526                $child = new fXML($element); 
    516527                $child->__custom_prefixes = $this->__custom_prefixes; 
     528                if ($child->__dom->namespaceURI && $child->__dom->prefix == '') { 
     529                    $child->addCustomPrefix('__', $child->__dom->namespaceURI); 
     530                } 
    517531                $output[] = $child; 
    518532             
     
    568582 
    569583/** 
    570  * Copyright (c) 2007-2009 Will Bond <will@flourishlib.com> 
     584 * Copyright (c) 2007-2010 Will Bond <will@flourishlib.com> 
    571585 *  
    572586 * Permission is hereby granted, free of charge, to any person obtaining a copy