You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@xerces.apache.org by ar...@locus.apache.org on 2000/02/04 00:48:52 UTC

cvs commit: xml-xerces/java/src/org/apache/xml/serialize BaseMarkupSerializer.java HTMLSerializer.java HTMLdtd.java

arkin       00/02/03 15:48:51

  Modified:    java/src/org/apache/xml/serialize BaseMarkupSerializer.java
                        HTMLSerializer.java HTMLdtd.java
  Log:
  CDATA no longer printed in HTML.
  Fixed indentation for TD/A elements, which caused Netscape to misbehave.
  Fixed bug in handling closing tag in HTML.
  
  Revision  Changes    Path
  1.6       +2 -1      xml-xerces/java/src/org/apache/xml/serialize/BaseMarkupSerializer.java
  
  Index: BaseMarkupSerializer.java
  ===================================================================
  RCS file: /home/cvs/xml-xerces/java/src/org/apache/xml/serialize/BaseMarkupSerializer.java,v
  retrieving revision 1.5
  retrieving revision 1.6
  diff -u -r1.5 -r1.6
  --- BaseMarkupSerializer.java	2000/01/15 00:20:46	1.5
  +++ BaseMarkupSerializer.java	2000/02/03 23:48:50	1.6
  @@ -198,7 +198,7 @@
        * it's state is not removed but reused when later returning
        * to the same nesting level.
        */
  -    private ElementState[]  _elementStates = new ElementState[ 5 ];
  +    private ElementState[]  _elementStates;
   
   
       /**
  @@ -255,6 +255,7 @@
       {
   	int i;
   
  +	_elementStates = new ElementState[ 10 ];
   	for ( i = 0 ; i < _elementStates.length ; ++i )
   	    _elementStates[ i ] = new ElementState();
       }
  
  
  
  1.6       +21 -20    xml-xerces/java/src/org/apache/xml/serialize/HTMLSerializer.java
  
  Index: HTMLSerializer.java
  ===================================================================
  RCS file: /home/cvs/xml-xerces/java/src/org/apache/xml/serialize/HTMLSerializer.java,v
  retrieving revision 1.5
  retrieving revision 1.6
  diff -u -r1.5 -r1.6
  --- HTMLSerializer.java	2000/01/14 20:40:54	1.5
  +++ HTMLSerializer.java	2000/02/03 23:48:51	1.6
  @@ -293,8 +293,14 @@
   	// Now it's time to enter a new element state
   	// with the tag name and space preserving.
   	// We still do not change the curent element state.
  -	enterElementState( tagName, preserveSpace );
  +	state = enterElementState( tagName, preserveSpace );
   
  +	// Temporary hack to prevent line breaks inside A/TD
  +	if ( tagName.equalsIgnoreCase( "A" ) || tagName.equalsIgnoreCase( "TD" ) ) {
  +	    state.empty = false;
  +	    printText( ">" );
  +	}
  +
   	// Handle SCRIPT and STYLE specifically by changing the
   	// state of the current element to CDATA (XHTML) or
   	// unescaped (HTML).
  @@ -302,10 +308,10 @@
   	     tagName.equalsIgnoreCase( "STYLE" ) ) {
   	    if ( _xhtml ) {
   		// XHTML: Print contents as CDATA section
  -		getElementState().doCData = true;
  +		state.doCData = true;
   	    } else {
   		// HTML: Print contents unescaped
  -		getElementState().unescaped = true;
  +		state.unescaped = true;
   	    }
   	}
       }
  @@ -339,8 +345,7 @@
   	    // [keith] Provided this is not an anchor.
   	    // HTML: some elements do not print closing tag (e.g. LI)
   	    if ( ! HTMLdtd.isOnlyOpening( tagName ) ) {
  -		if ( ! tagName.equalsIgnoreCase( "A" )  && _format.getIndenting() &&
  -		     ! state.preserveSpace && state.afterElement )
  +		if ( _format.getIndenting() && ! state.preserveSpace && state.afterElement )
   		    breakLine();
   		// Must leave CData section first (Illegal in HTML, but still)
   		if ( state.inCData )
  @@ -352,8 +357,12 @@
   	// (if we're not root) to not empty and after element.
   	state = leaveElementState();
   	if ( state != null ) {
  -	    state.afterElement = true;
  +	    // Temporary hack to prevent line breaks inside A/TD
  +	    if ( ! state.tagName.equalsIgnoreCase( "A" ) && ! state.tagName.equalsIgnoreCase( "TD" ) )
  +		state.afterElement = true;
  +	    // state.afterElement = true;
   	    state.empty = false;
  +	    // Temporary hack to prevent line breaks inside A/TD
   	} else {
   	    // [keith] If we're done printing the document but don't
   	    // get to call endDocument(), the buffer should be flushed.
  @@ -566,25 +575,17 @@
       }
   
   
  -    /*
  +
       protected void characters( String text, boolean unescaped )
       {
  -	ElementState state;
  + 	ElementState state;
   
  -	// Override for special HTML/XHTML case of SCRIPT/STYLE elements:
  -	// XHTML: print their text contents as CDATA
  -	// HTML: print their text contents unescaped
  +	// HTML: no CDATA section
   	state = content();
  -	if ( state != null && ( state.tagName.equalsIgnoreCase( "SCRIPT" ) ||
  -				state.tagName.equalsIgnoreCase( "STYLE" ) ) ) {
  -	    if ( _xhtml )
  -		super.characters( text, true, false );
  -	    else
  -		super.characters( text, false, true );
  -	} else
  -	    super.characters( text, unescaped );
  +	if ( state != null )
  +	    state.doCData = false;
  +	super.characters( text, unescaped );
       }
  -    */
   
   
       protected String getEntityRef( char ch )
  
  
  
  1.3       +4 -4      xml-xerces/java/src/org/apache/xml/serialize/HTMLdtd.java
  
  Index: HTMLdtd.java
  ===================================================================
  RCS file: /home/cvs/xml-xerces/java/src/org/apache/xml/serialize/HTMLdtd.java,v
  retrieving revision 1.2
  retrieving revision 1.3
  diff -u -r1.2 -r1.3
  --- HTMLdtd.java	1999/11/30 21:46:58	1.2
  +++ HTMLdtd.java	2000/02/03 23:48:51	1.3
  @@ -111,9 +111,9 @@
   
   
       /**
  -     * Element is empty.
  +     * Only opening tag should be printed.
        */
  -    private static final int EMPTY        = 0x0001;
  +    private static final int ONLY_OPENING = 0x0001;
   
       /**
        * Element contains element content only.
  @@ -131,9 +131,9 @@
       private static final int OPT_CLOSING  = 0x0008;
   
       /**
  -     * Only opening tag should be printed.
  +     * Element is empty (also means only opening tag)
        */
  -    private static final int ONLY_OPENING = 0x0010;
  +    private static final int EMPTY        = 0x0010 | ONLY_OPENING;
   
       /**
        * Allowed to appear in head.