ID: 41287 Updated by: [EMAIL PROTECTED] Reported By: bugs dot php-0705 at nico dot edtinger dot at -Status: Open +Status: Closed Bug Type: *XML functions Operating System: irrelevant PHP Version: 5.2.2 New Comment:
This bug has been fixed in CVS. Snapshots of the sources are packaged every three hours; this change will be in the next snapshot. You can grab the snapshot at http://snaps.php.net/. Thank you for the report, and for helping us make PHP better. Previous Comments: ------------------------------------------------------------------------ [2007-05-04 17:19:50] bugs dot php-0705 at nico dot edtinger dot at Description: ------------ I've tried to write a document where a elements are in a namespace, but the namespace URI is only defined once in the root element. All other elements are written only with the mapped prefix. libxml2 allows namespaceURI to be null (i.e. in xmlTextWriterStartElementNS), which omits the xmlns attribute. But i.e. xmlwriter_write_element_ns or xmlwriter_start_element_ns in PHP convert null to an empty string, because zend_parse_parameters() is missing the ! for the namespace URI parameter. The only possible workaround is using xmlwriter_(start|create)_element and prepending the namespace prefix to the tagname "manually". Reproduce code: --------------- <?php // NOTE: results are indented for better readability $xml = new XmlWriter(); $xml->openMemory(); $xml->startDocument(); $xml->startElementNS('test', 'test', 'urn:x-test:'); $xml->writeElementNS('test', 'foo', null, ''); $xml->writeElementNS('test', 'bar', null, ''); $xml->endElement(); echo $xml->outputMemory(); ?> Expected result: ---------------- <?xml version="1.0"?> <test:test xmlns="urn:x-test:"> <test:foo></test:foo> <test:bar></test:bar> </test:test> Actual result: -------------- <?xml version="1.0"?> <test:test xmlns:test="urn:x-test:"> <test:foo xmlns:test=""></test:foo> <test:bar xmlns:test=""></test:bar> </test:test> ------------------------------------------------------------------------ -- Edit this bug report at http://bugs.php.net/?id=41287&edit=1
