xml-xmlbeans-dev mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From j...@apache.org
Subject [jira] Commented: (XMLBEANS-22) xmlText trims whitespace within elements if prettyprint is on
Date Thu, 11 Mar 2004 18:17:32 GMT
The following comment has been added to this issue:

     Author: Aaron Dunlop
    Created: Thu, 11 Mar 2004 10:16 AM
       Body:
This behavior seems odd and rather inconsistent. Pretty-printing (as called by the default
toString()) doesn't alter attributes; why should it change the contents of an element?

I understand that pretty-printing will alter whitespace between elements - that's the whole
point. But changing the contents of an element seems counterintuitive at best. Especially
if the fix is as simple as avoiding calling trim() for leaf nodes (which is the only thing
my suggested patch changes).

Is there an XML spec I'm unaware of that provides for normalizing whitespace in elements similar
to attribute normalization?

At a minimum, I'd request an update to the javadoc comments on XmlOptions.setSavePrettyPrint()
and XmlObject.toString() making it explicit that they may change the document contents without
warning and that if the user requires accurate document rendering, avoiding setSavePrettyPrint()
and using xmlText() instead of toString() are advised. Erik's comment would probably be sufficient,
if added to the appropriate places in the javadoc.

---------------------------------------------------------------------
View this comment:
  http://issues.apache.org/jira/secure/ViewIssue.jspa?key=XMLBEANS-22&page=comments#action_20999

---------------------------------------------------------------------
View the issue:
  http://issues.apache.org/jira/secure/ViewIssue.jspa?key=XMLBEANS-22

Here is an overview of the issue:
---------------------------------------------------------------------
        Key: XMLBEANS-22
    Summary: xmlText trims whitespace within elements if prettyprint is on
       Type: Bug

     Status: Resolved
   Priority: Major
 Resolution: WON'T FIX

    Project: XMLBeans
   Versions:
             Version 1

   Assignee: 
   Reporter: Aaron Dunlop

    Created: Wed, 11 Feb 2004 4:11 PM
    Updated: Thu, 11 Mar 2004 10:16 AM
Environment: Java 1.4.2_03, Win 2K

Description:
When called with XmlOptions.SAVE_PRETTY_PRINT, xmlText trims whitespace within an element
- e.g., ' a ' is converted to 'a'.

Unless I'm completely missing something, the formatter shouldn't ever change the contents
of an element.

The following test snippet reveals the problem:
        XmlObject xdoc = XmlObject.Factory.parse("<test>  </test>");
        Assert.assertEquals("<test>  </test>", xdoc.xmlText());
        Assert.assertEquals("<test>  </test>" + newLine, xdoc.toString());

The current build from CVS returns <test/>[newline] instead of <test>  <test>[newline].

Complete testcase and patch to follow.


---------------------------------------------------------------------
JIRA INFORMATION:
This message is automatically generated by JIRA.

If you think it was sent incorrectly contact one of the administrators:
   http://issues.apache.org/jira/secure/Administrators.jspa

If you want more information on JIRA, or have a bug to report see:
   http://www.atlassian.com/software/jira


- ---------------------------------------------------------------------
To unsubscribe, e-mail:   xmlbeans-dev-unsubscribe@xml.apache.org
For additional commands, e-mail: xmlbeans-dev-help@xml.apache.org
Apache XMLBeans Project -- URL: http://xml.apache.org/xmlbeans/


Mime
View raw message