The moose likes XML and Related Technologies and the fly likes &   :-( Big Moose Saloon
  Search | Java FAQ | Recent Topics
Register / Login


Win a copy of Practical Unit Testing with TestNG and Mockito this week in the Testing forum!
JavaRanch » Java Forums » Engineering » XML and Related Technologies
Reply Bookmark "&   :-(" Watch "&   :-(" New topic
Author

& :-(

Trina Thach
Greenhorn

Joined: Jun 12, 2001
Posts: 18
I have a form written in asp (using XMLDOM techniques), everything works perfectly, except...if the input string contains "&", it will expands as "& amp;" entity reference, which I do not want since I wish to store as is otherwise Unicode characters wouldn't be able to show up on the browser properly.
The alternative solution is to write a script to do a search and replace but...it's inefficient since the contents are changing all the time!!!
Any ideas are very much appreciate...
------------------
T.T
[This message has been edited by Trina Thach (edited June 21, 2001).]
Ajith Kallambella
Sheriff

Joined: Mar 17, 2000
Posts: 5781
You might want to read this article about handling special entities. It addresses the exact same problem you're talking about.
Hope that helps!
------------------
Ajith Kallambella M.
Sun Certified Programmer for the Java�2 Platform.
IBM Certified Developer - XML and Related Technologies, V1.


Open Group Certified Master IT Architect.
Sun Certified Architect(SCEA).
Trina Thach
Greenhorn

Joined: Jun 12, 2001
Posts: 18
Well, since the input says as "& #7848;" (no whitespace in between) being stored as "& amp;#7848;" - automatically converted by the parser...we eventually end up showing "Ẩ" on the browser, which is totally wrong.
All I need is to be able to save the input exactly as it is (do not expand it).
------------------
T.T
Mapraputa Is
Leverager of our synergies
Sheriff

Joined: Aug 26, 2000
Posts: 10065
Trina, have you tried to enclose user input in CDATA section? Entities in CDATA section should not be expanded.


Uncontrolled vocabularies
"I try my best to make *all* my posts nice, even when I feel upset" -- Philippe Maquet
Trina Thach
Greenhorn

Joined: Jun 12, 2001
Posts: 18
Rita, The whole idea is to make sure the browser renders it properly, and we know that everything in the CDATA section will be ignored by the browser so...we end up the same problem.

------------------
T.T
Mapraputa Is
Leverager of our synergies
Sheriff

Joined: Aug 26, 2000
Posts: 10065
Ha! You figured out my name!
Trina, I do not quite understand how you show user input, I assumed that you somehow store it in XML and then apply XSLT stylesheet to render the content.
In this case, if you have
<someElement><![CDATA[ &#56; TEXT ]]></someElement>
in XML,
and apply
<xsl:value-of select="someElement" disable-output-escaping="yes" />
then the browser shows �8�, which is the correct representation for ASCII 56.
Trina Thach
Greenhorn

Joined: Jun 12, 2001
Posts: 18
Rita, Remember a week or 2 back? I sent you an email regarding IBM XML Cert. I did look at your profile...that's how I know your name.
You see, I should use XSLT to produce HTML but I use XSL for XML to show on the web (for a special reason). Anyway, the problem is solved.
Thank you all.

------------------
T.T
 
IntelliJ Java IDE
 
subject: & :-(
 
Threads others viewed
Order of operations with operators
What does "fired" mean?
Add days to date() calculations
MultiThreading Output
hfsj errata?
developer file tools