commons-dev mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From bugzi...@apache.org
Subject DO NOT REPLY [Bug 35970] New: - white spaces in empty elements with indentation active
Date Tue, 02 Aug 2005 09:25:38 GMT
DO NOT REPLY TO THIS EMAIL, BUT PLEASE POST YOUR BUG·
RELATED COMMENTS THROUGH THE WEB INTERFACE AVAILABLE AT
<http://issues.apache.org/bugzilla/show_bug.cgi?id=35970>.
ANY REPLY MADE TO THIS MESSAGE WILL NOT BE COLLECTED AND·
INSERTED IN THE BUG DATABASE.

http://issues.apache.org/bugzilla/show_bug.cgi?id=35970

           Summary: white spaces in empty elements with indentation active
           Product: Commons
           Version: unspecified
          Platform: Other
        OS/Version: All
            Status: NEW
          Severity: minor
          Priority: P4
         Component: Betwixt
        AssignedTo: commons-dev@jakarta.apache.org
        ReportedBy: pagoda_5b@infinito.it


Element's name contains trailing spaces caused by indentation algorithm, under
specific circumstances.

When xml is written from the org.apache.commons.betwixt.io.BeanWriter, an empty
(property value is null) element's name contains trailing spaces if:
a. pretty printing is enabled 
b. setEndTagForEmptyElement is set to true

The output looks like this:
<emptytag    ></emptytag>

The number of spaces depends on the indentation level of the tag being written.

Note:I'm not sure that this could be considered a bug, but it causes some real
problems for one of our application where a third-party CORBA component parses
the tag without trimming the spaces, and thus is unable to correctly identify
the tag name.

A work-around is to set pretty print off.

The issue is present in codebase for Betwixt 0.7 revision 226973.
http://svn.apache.org/repos/asf/jakarta/commons/proper/betwixt/branches/RELEASE_0_7_BRANCH/src/java/org/apache/commons/betwixt/io/BeanWriter.java

The culprit is in the endElement() method, as shown in the following snippet:

    protected void endElement(
                                WriteContext context,
                                String uri, 
                                String localName, 
                                String qualifiedName)
                                    throws
                                        IOException,
                                        SAXException {
        if ( 
            !addEndTagForEmptyElement
            && !closedStartTag 
            && currentElementIsEmpty ) {
        
            writer.write( "/>" );
            closedStartTag = true;
            
        } else {
            if (!currentElementHasBodyText) {
                indent();  /*<------ LOOK HERE */
            }
            if (
                    addEndTagForEmptyElement
                    && !closedStartTag ) {
                 writer.write( ">" );
                 closedStartTag = true;                 
            }
            writer.write( "</" );
            writer.write( qualifiedName );
            writer.write( '>' );
            
        }
        
        indentLevel--;
        printLine();
        
        currentElementHasBodyText = false;
    }

Actually I can't manage to understand why indent() is called but for a null
property it tries to indent the output *before* closing the opening tag
resulting in trailing spaces in the tag name (and after the attibutes when
present, I assume...).

Thank you.

-- 
Configure bugmail: http://issues.apache.org/bugzilla/userprefs.cgi?tab=email
------- You are receiving this mail because: -------
You are the assignee for the bug, or are watching the assignee.

---------------------------------------------------------------------
To unsubscribe, e-mail: commons-dev-unsubscribe@jakarta.apache.org
For additional commands, e-mail: commons-dev-help@jakarta.apache.org


Mime
View raw message