[fpc-pascal] TDOMElement and multiple attributes

Mattias Gaertner nc-gaertnma at netcologne.de
Mon Mar 28 08:04:05 CEST 2011


On Sun, 27 Mar 2011 22:56:16 -0300
Flávio Etrusco <flavio.etrusco at gmail.com> wrote:

> >
> >
> >> someone at somewhere:~/pascal/Projects/xmldemo$ cat test.xml
> >> <?xml version="1.0"?>
> >> <ROOT someAttrib="someValue">
> >>   <SomeNode aAttribute="2" bAttribute="3" ccAttribute="4" aaaAttribute="1"/>
> >> </ROOT>
> >>
> >> Looks like the order is governed by the length of the attribute name first and then alphabetically.
> >>
> Actually it isn't sorted by length, but it's case-sensitive.

No. See

2.4.2/fpc/packages/fcl-xml/src/dom.pp

function CompareDOMStrings(const s1, s2: DOMPChar; l1, l2: integer):
integer;
var i: integer;
begin
  Result:=l1-l2;
  i:=0;
  while (i<l1) and (Result=0) do begin
    Result:=ord(s1[i])-ord(s2[i]);
    inc(i);
  end;
end;


> Mattias wrote:
> > Yes, that is what CompareDOMStrings does.
> > Probably for speed reasons.
> >
> Indeed, laz_xmlwrite and laz2_xmlwrite both do this, but the example
> is using xmlwrite.pas from fcl-xml.

No. laz_xmlwrite and laz2_xmlwrite use laz_dom, laz2_dom.

 
> > This function is fixed in the code.
> >
> What do you mean?

The user can not change this behavior.

Mattias



More information about the fpc-pascal mailing list