4

I've been using NativeXml for years to create xml from my program's data. This has worked very well but now I've hit a snag.

I now need to insert a hash into the xml which has been created from a canonical form of the xml. I've had a look and Native Xml has a function "Canonicalize" but either I'm not using it properly (a good chance) or (as it is labelled experimental) it doesn't do what is required.

I've been using it like this (as suggested in the only example I could find)

MyXmlFile.Canonicalize;

I've been sending xml to a test service with no problems so I assumed everything was OK. The recipient was accepting the xml submissions and the hash code. Canonicalize strips the opening xml tag <?xml version="1.0"?> but as the xml is fairly well formed anyway and I'm not setting its format to xfReadable I couldn't find much difference.

Now I've come across a problem. One piece of data has shown that everything isn't working quite as it should.

If I have a name which contains an apostrophe in my data, such as O'Reilly for example, then in the xml it gets written (correctly) like this

<Surname>O&apos;Reilly</Surname>

As far as I can tell when it has been canonicalized this should show as

<Surname>O'Reilly</Surname>

This isn't happening so consequently the recipient is rejecting my xml submissions as the hash does not match.

I've spent the last two days trawling through the NativeXml code and documents and also online and can't find an answer. Sadly the NativeXml forum seems to be devoid of life too.

Is there anything I should be doing with NativeXml? If not NativeXml then will anything else do the job? Is there anything I can pass the xml to that will canonicalize it properly?

  • did you try to post a feature suggestion (it is open source so all user community members could help with the implementation) – mjn Mar 06 '13 at 18:40
  • @mjn - By the looks of the NativeXml forum on Simdesign's website I'd say their community moved on. Shame, that was one of the first third party Delphi component I paid for (although it was hardly expensive) and the only one I still use almost a decade down the line. – user2140546 Mar 06 '13 at 20:07
  • Still can't find anything useful on this anywhere so for the time being I'm having to make do with replacing any `'` in the string I use for hashing the canonical xml with a single `'`. It is working for now. Luckily it is only apostrophes I need to be worried about for now. – user2140546 Mar 06 '13 at 21:46

1 Answers1

2

The current version of NativeXML (4.07) fetches named character entities from the DTD and expands them. The four predefined named character entities of course aren't in any DTD, so they're not processed. It looks like numeric character entities also aren't canonicalized, and there are several other transformations yet to be implemented. NativeXML simply isn't the right tool for the job in its current state.

Rob Kennedy
  • 161,384
  • 21
  • 275
  • 467
  • +1 but I think there are five pre-defined XML named character entities rather than four – David Heffernan Mar 06 '13 at 18:50
  • @RobKennedy - That is the conclusion that is beginning to form in my mind, that now I want something other than just creating the xml is that I'll have to move on. Any suggestions? Canonicalizing is a must. – user2140546 Mar 06 '13 at 20:17