#013331: Renaming a node when using ezcTreeXml corrupts the XML

Description:

This might be a misusage from myself, but the way i found to rename a node results in a corrupted XML Format. Find below the code snippet used to reproduce this.

The <etd:data>Non-Metals renamed</etd:data> tag of the renamed node was moved after its children <node> elements, which seems not to be valid.

Regards,
--
Nicolas


Environment:

Operating System: MacOS
PHP Version: (please be specific, like '4.4.3' or '5.1.5') 5.2.5
Database and version: MySQL 5.0
Browser (and version): FF3


Steps to Reproduce:

Run the following piece of code, and then inspect the output XML. You will additionnally get the exception reported below the code snippet.


$store = new ezcTreeXmlInternalDataStore();
// $tree = ezcTreeMemoryXml::create( '', $store );
$tree = ezcTreeXml::create( '/tmp/test.xml', $store );
$tree->autoId = true;

$rootNode = $tree->createNode( null, 'Elements' );
$tree->setRootNode( $rootNode );

$nonMetal = $tree->createNode( 'NonMetals', 'Non-Metals' );
$rootNode->addChild( $nonMetal );
$nobleGasses = $tree->createNode( null, 'Noble Gasses' );
$rootNode->addChild( $nobleGasses );

$nonMetal->addChild( $tree->createNode( null, 'Hydrogen' ) );
$nonMetal->addChild( $tree->createNode( null, 'Carbon' ) );
$tree->saveFile();
echo '<pre>';
echo file_get_contents( '/tmp/test.xml' );
echo '</pre>';

echo '<hr />'; 

$NonMetals = $tree->fetchNodeById( 'NonMetals' );
$NonMetals->dataFetched = true;
$NonMetals->data = "Non-Metals renamed";
$tree->saveFile();

$NonMetals = $tree->fetchNodeById( 'NonMetals' );

echo '<pre>';
echo file_get_contents( '/tmp/test.xml' );
echo '</pre>';

$tree = new ezcTreeXml( '/tmp/test.xml', $store );

ezcTreeInvalidXmlFormatException: The XML file '/tmp/test.xml' does not validate according to the expected schema: /private/tmp/test.xml:12:0: Did not expect element data there in /usr/local/apache_php4/htdocs/ezc_trunk/Tree/src/backends/xml.php on line 145

- Attachments
Picture 3.png (70.9 kb)
[Download] [Permanent Link]
Screenshot showing that renaming actually works, but that an exception is raised

- Comments

commenting out this line


$NonMetals->dataFetched = true;

in the code snippet makes renaming NOT work anymore.
--
Nicolas

#257392 by Nicolas Pastorino on July 10th, 2008 [Permanent Link]

Fixed in rev. 8566, but another bug was found here. Issue http://issues.ez.no/13332url .

#257393 by Derick Rethans on July 10th, 2008 [Permanent Link]

- History
Properties
Type Bug
Priority Medium
Component Components » Tree
Affects 1.1 - Tree 1.1
Fix Version -
Reporter Nicolas Pastorino
Responsible Derick Rethans
Status 0 Closed
Resolution Fixed
Created July 10th, 2008
Updated July 10th, 2008
Resolved July 10th, 2008
 
Navigation [Permanent Link]
Previous Issue
Back to Issues List
Next Issue: #015537
  Graph shows to small and truncated rotated axis labels