Re[4]: [xml] bug with created attribute nodes?



Hello Daniel,

 Yesterday i speak with some other people in public XML forums about
my question and they tell me, that your position seems to be more
correct then mine, but this thing is not clearly specified into any
available specification.
 But i still have 2 questions about this topic and one of them
confuses me a bit, can you please comment it?

1. If current behaviour of libxml2 is expected - is it mean, that i
should manually perform analize of a text, i want to set as attribute
value for entities, split it up in parts and construct actual
attribute value as set of Text and EntityReference objects?

2. Please take a look at following example:

$xml = domxml_open_mem('<'.'?xml version="1.0"?'.'><root/>');
$root = $xml->root();
$value = $root->set_attribute('a','a&amp;b');
$value = $root->set_content('a&amp;b');
echo $xml->dump_mem();

 I'll explain a bit to make things more clear. I create instance of
DOM object from XML document:
<?xml version="1.0"?><root/>

 Then i get root document of it and add same value "a&amp;b" as
attribute and as node content. Internally PHP calls xmlSetProp() and
xmlNodeSetContentLen() for it respectively. Then i serialize contents
of DOM document and get following results:

<?xml version="1.0"?><root a="a&amp;amp;b">a&amp;b</root>

 Can you please explain, why "&amp;" being set in attribute value is
quoted while same "&amp;" being set as node value is treated as entity
reference?

 Thank you.


Monday, December 23, 2002, 8:59:03 PM, you wrote:

DV> On Mon, Dec 23, 2002 at 08:29:23PM +0300, Flying wrote:
Hello Daniel,

 Please take a look at the difference between your and my testcases:

Your:
root.setProp("img", "a&b")

My:
$root->set_attribute('a','a&amp;b');

 Except syntax there is also different values set for attributes. With
your value, being set in PHP i will get same result as you, but try
to set exactly same attribute value as i do. If you will get different

DV>   I do NOT get the same result I get "a&amp;amp;b" which is the normal
DV> result for a&amp;b' escaping and certainly not "a&#222;b".

result with it - i will switch to PHP developers :)

DV>   I general I don't like being pressured with "This issue is critical
DV> for our application" kind of remarks, if it's critical, then debug
DV> it, you have the code.

DV> Daniel




-- 
Best regards,
 Alexander                            mailto:flying dom natm ru





[Date Prev][Date Next]   [Thread Prev][Thread Next]   [Thread Index] [Date Index] [Author Index]