File APIs for Java Developers
Manipulate DOC, XLS, PPT, PDF and many others from your application.
http://aspose.com/file-tools
The moose likes XML and Related Technologies and the fly likes how to fix the weird characters from displaying in xsl output? Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login


JavaRanch » Java Forums » Engineering » XML and Related Technologies
Bookmark "how to fix the weird characters from displaying in xsl output?" Watch "how to fix the weird characters from displaying in xsl output?" New topic
Author

how to fix the weird characters from displaying in xsl output?

Nina Binde
Ranch Hand

Joined: Sep 24, 2004
Posts: 85
Hi all,

I have my xsl code like this:



I get these weird characters in my xsl output like "Sterlite's optical fiber enhanced for G.657A compliance". I tried the ISO-8859-1 encoding, but that does not seem to help either. Does anyone have ideas on how to get the apostrophe to display insetad of the numeric value of the character to display?
Thanks in advance.



Paul Clapham
Bartender

Joined: Oct 14, 2005
Posts: 18570
    
    8

I don't see any "weird" characters in your post.

Are you saying you see "&" or something like that when you look at the output of your transformation in a text editor? Browsers will automatically interpret character entities like that as the characters they are meant to represent. Try it in a browser and you will see that.
Nina Binde
Ranch Hand

Joined: Sep 24, 2004
Posts: 85
I am getting the weird characters that Paul mentioned "& #39;" . It is appearing that way when I view on a browser. I am not sure how to fix it. The xml encoding I have is:


When this is transformed to xsl with html output, I thought it will interpret all the UTF-8 characters appropriately. It is not doing so.

I have tried this one too with the xsl output:


Nothing seems to help.

Thanks for any replies.
Paul Clapham
Bartender

Joined: Oct 14, 2005
Posts: 18570
    
    8

Perhaps they are in the input document like that. If so, then the transformation wouldn't change them. Or perhaps something in the transformation is incorrectly inserting them like that.

The output encoding has essentially nothing to do with the question. The question is all about how to type a character entity in an XML document (or I am guessing that is the question, because we don't know anything about the input document or the transformation.)

If you want to put an apostrophe into a text node, it is possible to put it there as a character entity. (You may want to do that because the text is an attribute value which is already surrounded by apostrophes, for example.) The character entity would look like this: '

If there is a space in the middle, like this, then it isn't a character entity: & #39; In that case it is an ampersand followed by some text. As in what you say you are seeing in your browser.

So go through your input and transformation and find out where this broken character entity is coming from. Try to fix it.
 
GeeCON Prague 2014
 
subject: how to fix the weird characters from displaying in xsl output?