You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@xalan.apache.org by tm...@apache.org on 2002/04/23 20:00:52 UTC

cvs commit: xml-xalan/java/src/org/apache/xalan/xsltc/runtime TextOutput.java

tmiller     02/04/23 11:00:52

  Modified:    java/src/org/apache/xalan/xsltc/runtime Tag:
                        jaxp-ri-1_2_0-fcs-branch TextOutput.java
  Log:
  escaped character handling improved by Santiago
  
  Revision  Changes    Path
  No                   revision
  
  
  No                   revision
  
  
  1.49.4.2  +19 -10    xml-xalan/java/src/org/apache/xalan/xsltc/runtime/TextOutput.java
  
  Index: TextOutput.java
  ===================================================================
  RCS file: /home/cvs/xml-xalan/java/src/org/apache/xalan/xsltc/runtime/TextOutput.java,v
  retrieving revision 1.49.4.1
  retrieving revision 1.49.4.2
  diff -u -r1.49.4.1 -r1.49.4.2
  --- TextOutput.java	3 Apr 2002 19:26:50 -0000	1.49.4.1
  +++ TextOutput.java	23 Apr 2002 18:00:52 -0000	1.49.4.2
  @@ -1,5 +1,5 @@
   /*
  - * @(#)$Id: TextOutput.java,v 1.49.4.1 2002/04/03 19:26:50 tmiller Exp $
  + * @(#)$Id: TextOutput.java,v 1.49.4.2 2002/04/23 18:00:52 tmiller Exp $
    *
    * The Apache Software License, Version 1.1
    *
  @@ -97,6 +97,7 @@
       private boolean   _startTagOpen = false;
       private boolean   _headTagOpen = false;
       private boolean   _cdataTagOpen = false;
  +    private boolean   _is8859Encoded = false;
   
       // Contains all elements that should be output as CDATA sections
       private Hashtable _cdata = null;
  @@ -178,6 +179,7 @@
           _saxHandler = handler;
           init();
   	_encoding = encoding;
  +	_is8859Encoded = _encoding.equalsIgnoreCase("iso-8859-1");	
       }
   
       /**
  @@ -193,6 +195,7 @@
   	_lexHandler = lex;
           init();
   	_encoding = encoding;
  +	_is8859Encoded = _encoding.equalsIgnoreCase("iso-8859-1");	
       }
   
       /**
  @@ -399,17 +402,19 @@
   		// the first CDATA and '>' at the beginning of the next. Other
   		// special characters/sequences are _NOT_ escaped within CDATA.
   		Integer I = (Integer)_cdataStack.peek();
  -		if ((I.intValue() == _depth) && (!_cdataTagOpen))
  +		if ((I.intValue() == _depth) && (!_cdataTagOpen)) {
   		    startCDATA(ch, off, len);
  -		// Output characters escaped if required.
  -		else if (_escapeChars)
  -		    if (_cdataTagOpen)
  +		} 
  +		else if (_escapeChars) {
  +		    if (_cdataTagOpen) {
   			escapeCDATA(ch, off, len);
  -		    else
  +		    } else {
   			escapeCharacters(ch, off, len);
  -		// Output the chracters as the are if not.
  -		else
  +		    }
  +		} 
  +		else {
   		    _saxHandler.characters(ch, off, len);
  +		}
   		return;
   
   	    case HTML:
  @@ -532,9 +537,11 @@
   
   	if (limit > ch.length) limit = ch.length;;
   
  +
   	// Step through characters and escape all special characters
   	for (int i = off; i < limit; i++) {
  -	    switch (ch[i]) {
  +	    char current = ch[i];
  +	    switch (current) {
   	    case '&':
   		_saxHandler.characters(ch, offset, i - offset);
   		_saxHandler.characters(AMP, 0, AMP_length);
  @@ -558,7 +565,9 @@
   	    default:
   		// Escape all characters not in the basic ASCII character set
   		// to simple (hexadecimal) character references
  -		if (ch[i] > '\u007F') {
  +		if ( (current >= '\u007F' && current < '\u00A0') ||
  +		     (_is8859Encoded && (current > '\u00FF')) )
  +		{
   		    StringBuffer buf = new StringBuffer(CHAR_ESC_START);
   		    buf.append(Integer.toString((int)ch[i]));
   		    buf.append(';');
  
  
  

---------------------------------------------------------------------
To unsubscribe, e-mail: xalan-cvs-unsubscribe@xml.apache.org
For additional commands, e-mail: xalan-cvs-help@xml.apache.org