Subject: Re: [xsl] > replaced by ">", < is not replaced...|
From: Jethro Borsje <jethro@xxxxxxxxxxxx>
Date: Fri, 13 Jul 2007 15:32:06 +0200
This sounds all very logical. I think option 5 is the best way to go atin the output, ">" become a ">". This is not what I want. Not because of visualization in an HTML client, but because I have to be able to map the output of the XLS back to some original input which contains the ">", " ", etc. I basically just want to keep the character encodings from the input in the output.
Aha, now we're getting at the root of the problem. You need to compare the things. If you compare XML documents, or HTML documents, the comparison software should be able to deal with numerical character entities (and named character entities) and treat a ">" equal to ">" equal to ">" equal to ">".
If your software cannot make that kind of comparison, you can try several things, of which the following come to mind:
1. Post process the output to get your original char ents back
2. Use XSLT 2 instead and use character maps to force the char ents
3. Use different comparison software that is capable of reading XML the proper way (you mention HTML, but from your code it seems that you create XML)
4. Load and Save the original XML into the XSLT processor you built, one with transformation, other with copy-of, this will serialize both the same way and makes comparison on a byte by byte basis easier (but still not solid)
5. Use XSLT to do the comparison (XSLT 2 is preferred: just use deep-equal() function if equality is all you are after)
I cannot recommend anything else than option 3 and 5, all others are workarounds that after time will make your software weak or at least vulnerable to bugs.
One way I can think of is iterating over all of the elements of the original, each time calling the "deep-equal()" function, but I do not know if that is the best approach.
-- Best regards, Jethro Borsje