This week's book giveaway is in the Open Source forum.
We're giving away four copies of Programmers Guide to Apache Thrift and have Randy Abernethy on-line!
See this thread for details.
Win a copy of Programmers Guide to Apache Thrift this week in the Open Source forum!
  • 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 all forums
this forum made possible by our volunteer staff, including ...
Marshals:
  • Campbell Ritchie
  • Devaka Cooray
  • Knute Snortum
  • Paul Clapham
  • Tim Cooke
Sheriffs:
  • Liutauras Vilda
  • Jeanne Boyarsky
  • Bear Bibeault
Saloon Keepers:
  • Tim Moores
  • Stephan van Hulst
  • Ron McLeod
  • Piet Souris
  • Frits Walraven
Bartenders:
  • Ganesh Patekar
  • Tim Holloway
  • salvin francis

Character Encoding for China characters  RSS feed

 
Ranch Hand
Posts: 223
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Hi,

I am using CXML generated through the cxmlbeans.jar, i need to pass the description in chinese characters in CXML for which i have use utf8 character encoding set. When there is a chinese spl characters in the desc , the CData is getting generated automatically from the API for description, whether I need to just unescape the HTML to get the real chinese char and set it to the description and pass back? or after setting this decoded value also we will get any issue while passing to 3rd party system?

Thanks

 
Saloon Keeper
Posts: 10206
216
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
I'm not really sure why CDATA is generated for Chinese characters, because they don't include XML characters that need to be escaped.

It's hard to give you an answer to your question because we don't know what your application does or what parts of it you control. Please take a step back and explain from what you are generating the cXML, what the cXML looks like, what HTML you are referring to and what you mean by escaping it, and what you mean by "set it to the description and pass back". I also don't know what third party system you're talking about or why decoding would be an issue.
 
Rithanya Laxmi
Ranch Hand
Posts: 223
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Hi Stephan,

PFB the CXML we are generating with the description for which the value is coming from DB , we also have the xml:lang code as zh_CN for China description with utf8 char encoding, here when we generate the CXML by appending the description in chinese , automatically CDATA section is generated with numeric char references through the API we use as you can see below, but instead of the numeric char reference (encoded) we need to set the actual chinese characters (decoded) , if we escape the below numeric char references then we will get the real china char in decoded form , whether we need use that decoded form by setting that in the description element and pass back ? or is there a better way of handling it? since CDATA section is generated automatically based on the demand basis we dont have control over the CDATA section. This CXML we are passing to another punchout application.

Please clarify.

<?xml version="1.0" encoding="UTF-8" ?>
<!DOCTYPE cXML SYSTEM "http://xml.cXML.org/schemas/cXML/1.2.038/cXML.dtd"><cXML payloadID="HSP!6dd843e" xml:lang="zh_CN" timestamp="01 August 2018 20:22:17 PM"><Header><From><Credential domain="NetworkId"><Identity>TEST</Identity></Credential></From>


<Description xml:lang="zh_CN"><![CDATA[气相色谱柱安装工具包]]></Description>
..


</Message>
</cXML>


Thanks
 
Marshal
Posts: 24461
55
Eclipse IDE Firefox Browser MySQL Database
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Why is the existence of CDATA sections in your XML document a problem? CDATA is a standard feature of XML and all XML parsers should be able to deal with it.
 
Stephan van Hulst
Saloon Keeper
Posts: 10206
216
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Why are you using CDATA in the first place? There's absolutely no point, as the Chinese description doesn't contain any reserved XML characters that need to be escaped.
 
Stephan van Hulst
Saloon Keeper
Posts: 10206
216
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Okay I understand that the CDATA tags are always generated because the description MIGHT contain characters that are reserved in XML.

I really don't understand what problem you are facing. Your description is not clear. What do you mean by "numeric char reference"? What do you do with the XML after you've generated it? What goes wrong when you have the Chinese characters in your XML directly like you have now?
 
Rithanya Laxmi
Ranch Hand
Posts: 223
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Hi Stephan,

   Whether having CDATA in the CXML dsecription will have any issue while parsing the CXML and retrieve the description value? whether any of the XML parser will have an issue in parsing the description enclosed in CDATA? I hope it is not.

Thanks.
 
Stephan van Hulst
Saloon Keeper
Posts: 10206
216
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Why? As Paul said, any proper XML library will handle CDATA just fine.

Why don't you just try it out? Then you'll know for sure.
 
  • Post Reply Bookmark Topic Watch Topic
  • New Topic
Boost this thread!