  | |  | Numeric entity problem | Numeric entity problem 2003-09-24 - By Erik Ytterman
Dear All! I'm struggling with a problem that needs to be solve as soon as possible. Hope that you will be able to help me. I will attach parts of the code. I'm doing the following: 1. Recive a callback with a proper XML document. (DocumentHandler.handleDocument()) 2. Use XPath to find the element to process (DocumentHandler.translateDocument()) 3. Find the text content of this element. (DocumentHandler.translateDocument()) 4. Translate the textual content of the element. (OpenB2BUtil.translateString()) 5. An ugly hack to transform any characters except ASCII into numeric entities. (OpenB2BUtil.etitifyIsoString()) 6. Replace the textual content of the element, including numeric entities (DocumentHandler.translateDocument()) 7. Serialize the resulting DOM tree using transformers (OpenB2BUtil.documentToStream()) Problem: As can be seen from the code, I replace the textual content of an element, with a string that contains numeric entities (ý). My problem is that the serialization seem to translate this into (ý). Questions: 1. Is this a bug in xalan, from my point of view, it should leave the numeric entity in the text payload untouched, since it is proper XML. 2. If not, is there a way to disable this "feature" in Xalan, so that these, perfectly legal numeric entities are let through in the serialization 3. If not, any sugestions on how to solve the problem? /Erik
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.0 Transitional//EN"> <HTML><HEAD> <META HTTP-EQUIV="Content-Type" CONTENT="text/html; charset=us-ascii"> <TITLE>Meddelande</TITLE>
<META content="MSHTML 6.00.2800.1141" name=GENERATOR></HEAD> <BODY> <DIV><SPAN class=751483808-24092003><FONT face=Arial size=2>Dear All!</FONT></SPAN></DIV> <DIV><SPAN class=751483808-24092003><FONT face=Arial size=2></FONT></SPAN> </DIV> <DIV><SPAN class=751483808-24092003><FONT face=Arial size=2>I'm struggling with a problem that needs to be solve as soon as possible. Hope that </FONT></SPAN><SPAN class=751483808-24092003><FONT face=Arial size=2>you will be able to help me. I will attach parts of the code.</FONT></SPAN></DIV> <DIV><SPAN class=751483808-24092003><FONT face=Arial size=2></FONT></SPAN> </DIV> <DIV><SPAN class=751483808-24092003><FONT face=Arial size=2>I'm doing the following:</FONT></SPAN></DIV> <DIV><SPAN class=751483808-24092003><FONT face=Arial size=2></FONT></SPAN> </DIV> <DIV><SPAN class=751483808-24092003><FONT face=Arial size=2>1. Recive a callback with a proper XML document. (DocumentHandler.handleDocument())</FONT></SPAN></DIV> <DIV><SPAN class=751483808-24092003></SPAN><SPAN class=751483808-24092003></SPAN><SPAN class=751483808-24092003><FONT face=Arial size=2></FONT></SPAN> </DIV> <DIV><SPAN class=751483808-24092003><FONT face=Arial size=2>2. Use XPath to find the element to process (DocumentHandler.translateDocument())</FONT></SPAN></DIV> <DIV><SPAN class=751483808-24092003><FONT face=Arial size=2></FONT></SPAN> </DIV> <DIV><SPAN class=751483808-24092003><FONT face=Arial size=2>3. Find the text content of this element. (DocumentHandler.translateDocument())</FONT></SPAN></DIV> <DIV><SPAN class=751483808-24092003><FONT face=Arial size=2></FONT></SPAN> </DIV> <DIV><SPAN class=751483808-24092003><FONT face=Arial size=2>4. Translate the textual content of the element. (OpenB2BUtil.translateString())</FONT></SPAN></DIV> <DIV><SPAN class=751483808-24092003><FONT face=Arial size=2></FONT></SPAN> </DIV> <DIV><SPAN class=751483808-24092003><FONT face=Arial size=2>5. An ugly hack to transform any characters except ASCII into numeric entities. (OpenB2BUtil.etitifyIsoString()) </FONT></SPAN></DIV> <DIV><SPAN class=751483808-24092003><FONT face=Arial size=2></FONT></SPAN> </DIV> <DIV><SPAN class=751483808-24092003><FONT face=Arial size=2>6. Replace the textual content of the element, including numeric entities (DocumentHandler.translateDocument())</FONT></SPAN></DIV> <DIV><SPAN class=751483808-24092003><FONT face=Arial size=2></FONT></SPAN> </DIV> <DIV><SPAN class=751483808-24092003><FONT face=Arial size=2>7. Serialize the resulting DOM tree using transformers (OpenB2BUtil.documentToStream())</FONT></SPAN></DIV> <DIV><SPAN class=751483808-24092003></SPAN><SPAN class=751483808-24092003></SPAN><SPAN class=751483808-24092003><FONT face=Arial size=2></FONT></SPAN> </DIV> <DIV><SPAN class=751483808-24092003><FONT face=Arial size=2>Problem:</FONT></SPAN></DIV> <DIV><SPAN class=751483808-24092003><FONT face=Arial size=2></FONT></SPAN> </DIV> <DIV><SPAN class=751483808-24092003><FONT face=Arial size=2>As can be seen from the code, I replace the textual content of an element, with a string </FONT></SPAN><SPAN class=751483808-24092003><FONT face=Arial size=2>that contains numeric entities (&#253;). My problem is that the serialization seem to translate this into (&amp;#253;). </FONT></SPAN></DIV> <DIV><SPAN class=751483808-24092003></SPAN> </DIV> <DIV><SPAN class=751483808-24092003><FONT face=Arial size=2>Questions:</FONT></SPAN></DIV> <DIV><SPAN class=751483808-24092003></SPAN> </DIV> <DIV><SPAN class=751483808-24092003><FONT face=Arial size=2>1. Is this a bug in xalan, from my point of view, it should leave the numeric entity in the text payload untouched, since it is proper XML.</FONT></SPAN></DIV> <DIV><SPAN class=751483808-24092003><FONT face=Arial size=2></FONT></SPAN> </DIV> <DIV><SPAN class=751483808-24092003><FONT face=Arial size=2>2. If not, is there a way to disable this "feature" in Xalan, so that these, perfectly legal numeric entities are let through in the serialization</FONT></SPAN></DIV> <DIV><SPAN class=751483808-24092003><FONT face=Arial size=2></FONT></SPAN> </DIV> <DIV><SPAN class=751483808-24092003><FONT face=Arial size=2>3. If not, any sugestions on how to solve the problem?</FONT></SPAN></DIV> <DIV><SPAN class=751483808-24092003><FONT face=Arial size=2></FONT></SPAN> </DIV> <DIV><SPAN class=751483808-24092003><FONT face=Arial size=2>/Erik</FONT></SPAN></DIV> <DIV><SPAN class=751483808-24092003><FONT face=Arial size=2></FONT></SPAN> </DIV> <DIV><SPAN class=751483808-24092003><FONT face=Arial size=2></FONT></SPAN> </DIV> <DIV><SPAN class=751483808-24092003><FONT face=Arial size=2></FONT></SPAN> </DIV> <DIV><SPAN class=751483808-24092003><FONT face=Arial size=2></FONT></SPAN> </DIV> <DIV><FONT face=Arial size=2></FONT> </DIV></BODY></HTML>
|
|
 |