Package home | Report new bug | New search | Development Roadmap Status: Open | Feedback | All | Closed Since Version 2.0.4

Bug #7793 XML container not working
Submitted: 2006-06-02 06:04 UTC Modified: 2006-06-02 07:45 UTC
From: dan dot b at juno dot co dot uk Assigned: quipo
Status: Closed Package: Translation2 (version 2.0.0beta9)
PHP Version: 4.3.9 OS: Linux 2.6.14-1.1653_FC4sm
Roadmaps: (Not assigned)    
Subscription  


 [2006-06-02 06:04 UTC] dan dot b at juno dot co dot uk (Dan)
Description: ------------ This might not be a bug. I might be using this all wrong, but, I'm trying to use XML as the data source for this and it wont seem to create an initial XML file. Now, I'm guessing that the reason it says that it can't read from the file is that the file doesn't exist, but how does one actually create the XML file to start with? I would have thought that this factory method would have created a blank XML file as and when required? Or am I missing something really simple here? Test script: --------------- <?php $driver = 'XML'; $options = array( 'filename' => '/tmp/i18n.xml', 'save_on_shutdown' => true ); require_once 'Translation2.php'; $tr =& Translation2::factory($driver, $options); if (PEAR::isError($tr)) { print "MESSAGE: " . $tr->getMessage() . "\n"; var_dump($tr); exit(); } else { print "That worked fine!\n"; } ?> Expected result: ---------------- That worked fine! Actual result: -------------- MESSAGE: Can\'t read from the XML source: /home/dburzynski/i18n.xml object(pear_error)(8) { ["error_message_prefix"]=> string(0) "" ["mode"]=> int(1) ["level"]=> int(1024) ["code"]=> NULL ["message"]=> string(58) "Can\'t read from the XML source: /home/dburzynski/i18n.xml" ["userinfo"]=> NULL ["backtrace"]=> array(5) { [0]=> array(6) { ["file"]=> string(49) "/usr/local/lib/php/Translation2/Container/xml.php" ["line"]=> int(159) ["function"]=> string(10) "pear_error" ["class"]=> string(10) "pear_error" ["type"]=> string(2) "->" ["args"]=> array(1) { [0]=> string(58) "Can\'t read from the XML source: /home/dburzynski/i18n.xml" } } [1]=> array(6) { ["file"]=> string(49) "/usr/local/lib/php/Translation2/Container/xml.php" ["line"]=> int(138) ["function"]=> string(9) "_loadfile" ["class"]=> string(26) "translation2_container_xml" ["type"]=> string(2) "->" ["args"]=> array(0) { } } [2]=> array(6) { ["file"]=> string(35) "/usr/local/lib/php/Translation2.php" ["line"]=> int(180) ["function"]=> string(4) "init" ["class"]=> string(26) "translation2_container_xml" ["type"]=> string(2) "->" ["args"]=> array(1) { [0]=> array(2) { ["filename"]=> string(25) "/home/dburzynski/i18n.xml" ["save_on_shutdown"]=> bool(true) } } } [3]=> array(6) { ["file"]=> string(35) "/usr/local/lib/php/Translation2.php" ["line"]=> int(152) ["function"]=> string(15) "_storagefactory" ["class"]=> string(12) "translation2" ["type"]=> string(2) "::" ["args"]=> array(2) { [0]=> string(3) "XML" [1]=> array(2) { ["filename"]=> string(25) "/home/dburzynski/i18n.xml" ["save_on_shutdown"]=> bool(true) } } } [4]=> array(6) { ["file"]=> string(33) "/home/dburzynski/src/transmin.php" ["line"]=> int(10) ["function"]=> string(7) "factory" ["class"]=> string(12) "translation2" ["type"]=> string(2) "::" ["args"]=> array(2) { [0]=> string(3) "XML" [1]=> array(2) { ["filename"]=> string(25) "/home/dburzynski/i18n.xml" ["save_on_shutdown"]=> bool(true) } } } } ["callback"]=> NULL }

Comments

 [2006-06-02 07:08 UTC] quipo (Lorenzo Alberton)
there's a sample xml file in the testsuite. Anyway, I've added a check in CVS, please test the new file. You should be able to work with an empty xml file (but it must exist). To add languages and strings you have to use the Admin class.
 [2006-06-02 07:45 UTC] dan dot b at juno dot co dot uk
Cool. Works fine. :-D