• Post Reply Bookmark Topic Watch Topic
  • New Topic
programming forums Java Mobile Certification Databases Caching Books Engineering Micro Controllers OS Languages Paradigms IDEs Build Tools Frameworks Application Servers Open Source This Site Careers Other Pie Elite all forums
this forum made possible by our volunteer staff, including ...
Marshals:
  • Campbell Ritchie
  • Tim Cooke
  • Liutauras Vilda
  • Jeanne Boyarsky
  • paul wheaton
Sheriffs:
  • Ron McLeod
  • Devaka Cooray
  • Henry Wong
Saloon Keepers:
  • Tim Holloway
  • Stephan van Hulst
  • Carey Brown
  • Tim Moores
  • Mikalai Zaikin
Bartenders:
  • Frits Walraven

Character Mapping in XML/XSLT

 
Ranch Hand
Posts: 132
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Please help me understand the use of Character Mapping in XSLT2.0

I have created an XML such as


When I try to display it in HTML using this XSLT (or even directly open the XML in IE), most of the above characters are displayed as garbage values.

Is character mapping used to avoid this problem or is it comething else?
[ January 31, 2007: Message edited by: Thomas Greene ]
 
Thomas Greene
Ranch Hand
Posts: 132
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Actually I wanted to display

&#value inside <fname> but it automatically getting converted to HTML
[ January 31, 2007: Message edited by: Thomas Greene ]
 
Thomas Greene
Ranch Hand
Posts: 132
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
I modified my XSLT to the following

In charmap.xsl I have

but even now when I open the XML using IE, I see garbage characters. Is there something incorrect in my understanding.

Thanks
 
Sheriff
Posts: 28321
95
Eclipse IDE Firefox Browser MySQL Database
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
I don't understand how you have created the XML document that you showed in your first post. Most of those characters in your fname elements can't be represented in ISO-8859-1. So how did you get them in there? Did you actually use character entities, and that fact just gets obscured by the forum software interpreting those entities, or what?

Oh, that's what you did and your second post says that. Okay. Never mind.

But now I don't understand why you're doing all that character-mapping business. What's the point? XML serializers do a good job of using entities where necessary. They know what they are doing and you (admittedly) don't. So you shouldn't try doing their job. I would just leave all that business out and let the serializer take care of it.

Besides, you're passing that to the browser and expecting it to do the transformation? As far as I know there aren't any browsers that support XSLT 2.0 yet (unless somebody can correct me there) so even if you were doing something meaningful it wouldn't have any effect. I suppose you could get something that supports XSLT 2.0 and try doing the transformation on the server.

I was going to point you at Mike Brown's tutorial about XML and encodings at http://www.skew.org/ but the site says it's down until February 5. I would still recommend you read that tutorial when the site comes back (if it's still there).

In the meantime could you explain why you are doing all that? It smells like an ill-advised attempt to solve some other problem.
 
Stop it! You're embarassing me! And you are embarrassing this tiny ad!
Gift giving made easy with the permaculture playing cards
https://coderanch.com/t/777758/Gift-giving-easy-permaculture-playing
reply
    Bookmark Topic Watch Topic
  • New Topic