You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@xerces.apache.org by ne...@apache.org on 2001/11/07 20:00:34 UTC

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

neilg       01/11/07 11:00:34

  Modified:    java/src/org/apache/xml/serialize Tag: xerces_j_1
                        HTMLSerializer.java OutputFormat.java
  Log:
  applying a patch from Sandor Szego <ss...@saba.com> that permits, at user option, serialized HTML attributes to contain "" for their value instead of standing on their own.  This does not alter the default behaviour.
  
  Revision  Changes    Path
  No                   revision
  
  
  No                   revision
  
  
  1.15.2.1  +13 -4     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.15
  retrieving revision 1.15.2.1
  diff -u -r1.15 -r1.15.2.1
  --- HTMLSerializer.java	2001/04/18 06:02:49	1.15
  +++ HTMLSerializer.java	2001/11/07 19:00:34	1.15.2.1
  @@ -125,7 +125,7 @@
    * </ul>
    *
    *
  - * @version $Revision: 1.15 $ $Date: 2001/04/18 06:02:49 $
  + * @version $Revision: 1.15.2.1 $ $Date: 2001/11/07 19:00:34 $
    * @author <a href="mailto:arkin@intalio.com">Assaf Arkin</a>
    * @see Serializer
    */
  @@ -314,7 +314,10 @@
                       } else {
                           // HTML: Empty values print as attribute name, no value.
                           // HTML: URI attributes will print unescaped
  -                        if ( value == null || value.length() == 0 )
  +                        if ( value == null ) {
  +                            value = "";
  +                        }
  +                        if ( !_format.getPreserveEmptyAttributes() && value.length() == 0 )
                               _printer.printText( name );
                           else if ( HTMLdtd.isURI( rawName, name ) ) {
                               _printer.printText( name );
  @@ -558,7 +561,10 @@
                       } else {
                           // HTML: Empty values print as attribute name, no value.
                           // HTML: URI attributes will print unescaped
  -                        if ( value == null || value.length() == 0 )
  +                        if ( value == null ) {
  +                            value = "";
  +                        }
  +                        if ( !_format.getPreserveEmptyAttributes() && value.length() == 0 )
                               _printer.printText( name );
                           else if ( HTMLdtd.isURI( tagName, name ) ) {
                               _printer.printText( name );
  @@ -768,7 +774,10 @@
                       } else {
                           // HTML: Empty values print as attribute name, no value.
                           // HTML: URI attributes will print unescaped
  -                        if ( value == null || value.length() == 0 )
  +                        if ( value == null ) {
  +                            value = "";
  +                        }
  +                        if ( !_format.getPreserveEmptyAttributes() && value.length() == 0 )
                               _printer.printText( name );
                           else if ( HTMLdtd.isURI( tagName, name ) ) {
                               _printer.printText( name );
  
  
  
  1.11.2.1  +17 -4     xml-xerces/java/src/org/apache/xml/serialize/OutputFormat.java
  
  Index: OutputFormat.java
  ===================================================================
  RCS file: /home/cvs/xml-xerces/java/src/org/apache/xml/serialize/OutputFormat.java,v
  retrieving revision 1.11
  retrieving revision 1.11.2.1
  diff -u -r1.11 -r1.11.2.1
  --- OutputFormat.java	2001/01/26 20:23:10	1.11
  +++ OutputFormat.java	2001/11/07 19:00:34	1.11.2.1
  @@ -91,7 +91,7 @@
    * </ul>
    *
    *
  - * @version $Revision: 1.11 $ $Date: 2001/01/26 20:23:10 $
  + * @version $Revision: 1.11.2.1 $ $Date: 2001/11/07 19:00:34 $
    * @author <a href="mailto:arkin@intalio.com">Assaf Arkin</a>
    *         <a href="mailto:visco@intalio.com">Keith Visco</a>
    * @see Serializer
  @@ -268,9 +268,12 @@
        * specify otherwise, or specify the default behavior.
        */
       private boolean _preserve = false;
  +	/** If true, an empty string valued attribute is output as "". If false and
  +	 * and we are using the HTMLSerializer, then only the attribute name is 
  +	 * serialized. Defaults to false for backwards compatibility.
  +	 */
  +	private boolean _preserveEmptyAttributes = false;
   
  -
  -
       /**
        * Constructs a new output format with the default values.
        */
  @@ -824,7 +827,17 @@
           else
               _lineWidth = lineWidth;
       }
  -
  +
	/**
  +	 * Returns the preserveEmptyAttribute flag. If flag is false, then'
  +	 * attributes with empty string values are output as the attribute 
  +	 * name only (in HTML mode).
  +	 * @return preserve the preserve flag
  +	 */
	public boolean getPreserveEmptyAttributes () {
		return _preserveEmptyAttributes;
	}
	/**
  +	 * Sets the preserveEmptyAttribute flag. If flag is false, then'
  +	 * attributes with empty string values are output as the attribute 
  +	 * name only (in HTML mode).
  +	 * @param preserve the preserve flag
  +	 */
	public void setPreserveEmptyAttributes (boolean preserve) {
		_preserveEmptyAttributes = preserve;
	}
   
       /**
        * Returns the last printable character based on the selected
  
  
  

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