Friday, August 3, 2007, 10:24:35 AM, Hussein Shafie wrote: > Benoit Maisonny wrote: >> >> I believe I've found a bug in whitespace handling. I've read some posts >> about whitespace handling on the archives but I don't think this was >> addressed already. >> >> In short, if an element such as XHTML's p contains a text node with >> leading/trailing whitespace, that text node is trimmed when opening the >> document. >> >> Steps to reproduce: >> >> 1. File, New, XHTML Strict/Page. >> 2. In the p element, type "test: " (note the ending space). >> 3. Save and close the document. The file is saved with <p>test: </p> >> 4. Open the document in XXE: notice that the ending space has >> disappeared from the view. The file on disk hasn't been modified yet. >> 5. Type something in the title element (i.e. the <p> is not affected) >> 6. Save the document.The file is saved with <p>test:</p>, so the >> ending space has been removed. >> >> From my understanding of XML whitespace handling, I think XXE can format >> that whitespace however it wants (add a new line, put several >> spaces...), but it may not remove it. Or, so to speak, xml:space=default >> does not mean "trim text nodes". >> >> Note, this issue does not arise if there is an element following that >> space, inside the <p>. As in <p>test: <b>bold</b></p>. Likewise, it does >> not happen for <div>test: <p>paragraph</p></div>. >> > > I'm sorry by xml:space="default" means do whatever you want with it.
I think what XXE does with p-s is OK... but it should be understood once and forever that when a "Standard" (I know, it's Recommendation...) allows you to do whatever you want regarding something, you can't use that fact alone as an explanation for what you concretely did. Like, why not transform all those white-space sections to 6 tabs? After all the "Standard" allows that. So, if someone comes an complain, you can just point to the Standard, which grants you that freedom. But of course you don't use 6-tabs, because that would be stupid and impractical. Now, again, I think what XXE does with p-s is OK, I have no problem with that. Apart from personal preferences, I have no problem with that because it interacts well with other applications (and that's a main point of XML) that create or process XML-s. But the same couldn't be said about two cases regarding white-space treatment: - Inside elements with "mixed content" the white-space between "display: block" childs will be considered as significant when rendering the view. - Inside pre-like elements (like DocBook programlisting) the line-break after the start-tag and before the end-tag is considered as significant when rendering the view. Again, it's totally uninteresting if what freedom the standard gives you here, because if other applications don't do what you do, that means that when I open an XML that was created by another application with XXE, it will look buggy. It's just bad for the users (and an application is for the users). The freedom given to you should be used for choosing the most practical alternative, and not for doing things that annoy users. -- Best regards, Daniel Dekany

