Text data dumped incorrectly
----------------------------
Key: DDLUTILS-196
URL: https://issues.apache.org/jira/browse/DDLUTILS-196
Project: DdlUtils
Issue Type: Bug
Components: Core (No specific database)
Affects Versions: 1.0
Environment: Any
Reporter: Michael Lipp
Assignee: Thomas Dudziak
DdlUtils does not properly preserve content through a dump/restore cycle if the
content contains newlines.
DdlUtils takes the following approach for dumping text content:
(1) Write as value attribute, unless it cannot be written as such
(2) Write as "plain" element content unless it cannot be written as such
(3) Write as CDATA unless it cannot be written as such
(4) Write uuencoded.
Now when can a value not be written as attribute value? Easy: when there is no
valid representation that reads back the same value. And here is the problem.
The XML recommendation specifies something called "attribute value
normalization" (http://www.w3.org/TR/xml/#AVNormalize). Due to this, white
space characters except space (#xD, #xA, #x9) in attribute values are not read
back in the same way as they are written.
There are two ways to circumvent this: (a) write them as character references
(e.g. 
) or (b) skip to method (2). Option (a) cannot be used here ,
because it is impossible to write a "&" in an attribute value when you use
XMLStreamWriter. The spec says: 'However the writeCharacters method is required
to escape & , < and > For attribute values the writeAttribute method will
escape the above characters plus "'
(http://java.sun.com/webservices/docs/1.5/api/javax/xml/stream/XMLStreamWriter.html).
You might expect that the XMLStreamWriter.writeAttribute should handle
escaping of the whitespace characters (#xD, #xA, #x9), but if you read the spec
carefully it does not say so. Leaves option (b).
The attached patch fixes this problem.
--
This message is automatically generated by JIRA.
-
You can reply to this email to add a comment to the issue online.