[fpc-devel] XML canonical

Dariusz Mazur darekm at emadar.com
Fri Aug 28 16:37:31 CEST 2009

Sergei Gorelkin pisze:
> Dariusz Mazur wrote:
>> Hi
>>  this is my first approach to implement canonical transform
>>  from    <ds:CanonicalizationMethod 
>> Algorithm="http://www.w3.org/TR/2001/REC-xml-c14n-20010315"/>
>> its used in XADES sign.
>> can somebody review it, if its interesting
> First of all, it ignores the fact that DOM is based on WideStrings 
> (UTF-16 encoding). Plain assignments of DOM properties to string (or 
> UTF8String) will cause conversion to system locale encoding. It will 
> happen to work if system locale is actually utf-8, but won't work 
> correctly e.g. in Windows.
Thx. I forget about it.
> Next, a number of crude errors can be seen just by reading the source.
> For example, a processing instruction is delimited by '<?' and '?>', 
> not by '<!' and '>'. It lacks escaping '<' by '<' and '&' by '&amp' 
> in both text and attributes. Attribute value normalization must not 
> only replace #13, #9 and #10 by space, but also trim leading and 
> trailing whitespace and replace all consequtive whitespaces by single 
> space (and it is already done by DOM for non-CDATA attributes).
I will do that.  Current implementation of processing is very slow also.
> I'd suggest you to find a test suite (some examples are contained 
> directly in the text of w3.org specification, others may be ripped 
> from opensource projects that support canonicalization, like libxml2) 
> and verify your unit against it.
I draw from libxml2.  First i resolved problem with namespaces. That is 
not so clear in specification. Even simple xml canonization don't work. 
Now I can work with more complicate file.

New version should be send here?


More information about the fpc-devel mailing list