This is an issue we bumped into several times. XML and XSL transformations are not nice with spaces and end of lines encoding. I'm not sure if it's the fault of specs or is some tools doen't work properly on this. What we found is that a reliable way to preserve formatting is to put text zone within a CDATA section.
There is an interesting article on white spaces in XML and XSL on xml.com (http://www.xml.com/pub/a/2001/11/07/whitespace.html). It seems that it's possible to design XSL transformations respecting white spaces using xsl:preserve-space. Pascal -----Original Message----- From: Adam Lally (JIRA) [mailto:[EMAIL PROTECTED] Sent: Tuesday, February 27, 2007 10:00 AM To: [email protected] Subject: [jira] Commented: (UIMA-194) Tools highlight incorrect annotation offsets due to XML serialization bug in Sun Java 1.4.2 [ https://issues.apache.org/jira/browse/UIMA-194?page=com.atlassian.jira.p lugin.system.issuetabpanels:comment-tabpanel#action_12476189 ] Adam Lally commented on UIMA-194: --------------------------------- Actually Adam needs the historical background too. :) Is there a part of the spec that actually says that XML parsers can do whatever they want? I'd be curious to see that. As far as XML parsing is concerned, the XML spec requires that the parser return all newlines (meaning unescpaed newline characters) in the input as single #xA characters, regardless of what was in the input [1]. For serializaiton, we use XSLT. I wasn't able to quickly find a clear statement on newlines in the XSLT spec just now, but it would seem quite bizarre to me if an XSLT transform that copied a text node from an input document was allowed to drop #xD escape sequences that occurred in that input text node. That's essentially the situation we have here, I think. In any case Xalan seems to think it at least was undesirable behavior (if not a bug), since between Java 1.4 and 1.5 (both of which bundle Xalan) they "fixed" it. [1] http://www.w3.org/TR/REC-xml/#sec-line-ends > Tools highlight incorrect annotation offsets due to XML serialization bug in Sun Java 1.4.2 > ------------------------------------------------------------------------ ------------------- > > Key: UIMA-194 > URL: https://issues.apache.org/jira/browse/UIMA-194 > Project: UIMA > Issue Type: Bug > Components: Documentation, Tools > Environment: Sun Java 1.4.2_12 > Reporter: Adam Lally > Priority: Minor > Fix For: 2.2 > > > The XML serialization support in Sun Java 1.4.2_12 doesn't serialize CR characters to XML. As a result, if the document text contains CR characters, XCAS or XMI serialization will cause them to be lost, resulting in incorrect annotation offsets. This is exposed in the DocumentAnalyzer, with the highlighting being incorrect if the input document contains CR characters. > Unit test failure occurred in XCasToCasDataHandlerTest, but the test was modified so it passes. In that test an assertEquals of two strings fails, yet the strings appear identical in the compare viewer. > The problem does not occur in Sun Java 1.5 or later, or with IBM Java. > Probably a documentation update is an appropriate way to address this. -- This message is automatically generated by JIRA. - You can reply to this email to add a comment to the issue online.
