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



Hello Daniel,

Wednesday, December 25, 2002, 11:49:56 PM, you wrote:

DV> On Wed, Dec 25, 2002 at 09:41:09PM +0300, Alexander Grimalovsky wrote:
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?

DV>   No. Libxml does it. The point is that a charref or a predefined
DV> entity ref is directly handled by libxml2 (of course !).

 So, it mean that authors of PHP bindings for libxml2 just use wrong
API call for setting attribute value? If so, can you please point me
to a function, which should be used for setting attribute value
instead of xmlSetProp() ? So I will be able to write proper bugreport
for PHP.

<?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?

DV>   Because they are 2 different API calls. Nothing allows you to
DV> assume they have the same behaviour. Maybe they should, well they
DV> don't and I don't want to break the existing semantic of the APIs 
DV> now, unless I get a majority of users asking for a change, and in that case
DV> I would even prefer adding a new API instead of changing the existing
DV> one.

 It looks like this behaviour was changed sometime in the past... At
least following Perl example:

use XML::LibXML;
use strict;
 
my $parser = XML::LibXML->new() or die;
my $doc    = $parser->parse_string('<'.'?xml version="1.0"?'.'><root/>');
my $root   = $doc->documentElement();
$root->setAttribute ('a','a&amp;b');
$root->appendText   ('a&amp;b');
 
print $doc->toString; 

 produces following output:

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

 with XML::LibXML v1.53, libxml v1.8.17.


DV> Daniel


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





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