ID: 21213 Updated by: [EMAIL PROTECTED] Reported By: flying at dom dot natm dot ru -Status: Suspended +Status: Feedback Bug Type: DOM XML related Operating System: All PHP Version: 4.3.0RC4 New Comment:
Please try using this CVS snapshot: http://snaps.php.net/php4-STABLE-latest.tar.gz For Windows: http://snaps.php.net/win32/php4-win32-STABLE-latest.zip set_attribute_node is now in CVS, can you check it, if it's now possible, what you intend to do? Previous Comments: ------------------------------------------------------------------------ [2003-01-03 09:35:07] [EMAIL PROTECTED] As said before, we need set_attribute_node($attrNode) and append_child() et al. working in attribute Nodes, then it should work. Don't know, when I have the time to do it, if someone else wants to take over this part, feel free ;) chregu ------------------------------------------------------------------------ [2003-01-03 04:06:32] flying at dom dot natm dot ru Sorry for summary changing - its Mozilla bug :) ------------------------------------------------------------------------ [2003-01-03 04:01:49] flying at dom dot natm dot ru Yes, i agree with you in this point, but it also means, that you should provide a way to parse given text value and build NodeList of Text and EntityReference nodes. libxml2 already have such function. ------------------------------------------------------------------------ [2003-01-01 14:59:56] [EMAIL PROTECTED] Hi I will most certainly not add this options, since i prefer to stick to the w3c standard at http://www.zvon.org/xxl/DOM2reference/Output/interfaces/Element.html#setAttribute And in my interpretation of this, php's domxml behaves correctly. The only thing missing is setAttributeNode, which I maybe will implement, if I find some time. If there is setAttributeNode, then you can use the way the w3c suggests. chregu ------------------------------------------------------------------------ [2002-12-27 10:05:50] flying at dom dot natm dot ru Please take a look at following example: <?php $xml = domxml_open_mem('<'.'?xml version="1.0"?'.'><root/>'); $root = $xml->root(); $value = $root->set_attribute('a','a&b'); $value = $root->set_content('a&b'); echo $xml->dump_mem(); ?> It produces following results: <?xml version="1.0"?> <root a="a&amp;b">a&b</root> As you may see - & entity is treated as literals when it is being set as attribute value while same entity is treated as entity reference being set as node value. I have checked PHP's DOMXML extension source, libxml2 sources and discuss about this behaviour with Daniel Viellard (libxml2 maintainer) and with some other people on public XML-related forums and here is some information about this issue: 1. Such behaviour is not a libxml2 bug, it is expected behaviour. Moreover it is more correct from a point of specifications. 2. There should be a way to access Attr DOM object as specified into DOM Level 1 specification 3. There should be a way to control entites handling into passed values. As a way to go i want to propose you to add one additional argument to set_attribute(), set_content() and maybe some other functions - $options. For now there will be 2 options: XML_KEEP_ENTITIES - to treat all entities as entites and create them as EntityReference DOM objects XML_QUOTE_ENTITIES - to treat all entities as literals and hence quote all special symbols in them (such as '&' char). For compatibility reasons $options for set_attribute() may be set to XML_QUOTE_ENTITIES as default value and $options for set_content() - for XML_KEEP_ENTITIES. Internally you probably should change xmlSetProp() call into domxml_elem_set_attribute() to xmlNodeSetContentLen() when there is $options=XML_KEEP_ENTITIES. ------------------------------------------------------------------------ -- Edit this bug report at http://bugs.php.net/?id=21213&edit=1