Re: [xsl] > replaced by ">", < is not replaced...

Subject: Re: [xsl] > replaced by ">", < is not replaced...
From: Jethro Borsje <jethro@xxxxxxxxxxxx>
Date: Fri, 13 Jul 2007 15:32:06 +0200
in the output, "&gt;" 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 "&gt;", "&#160;", 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 "&gt;" equal to "&#x3E;" equal to "&#062".

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.

This sounds all very logical. I think option 5 is the best way to go at
this point. However, I am not sure how to go about doing such a
comparison. My situation is as follows: My user selects a subset of the
original XML file. After this action I need to compare the selection of
the user to the original. Once I find the location of the selection
inside the original I have to surround this selection with a new tag,
say "<selection>", and "</selection>". I have placed an example of
text online at, so you can see what I mean.

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.

Thank you very much for you time and help.

Best regards,
Jethro Borsje

Current Thread