Consultor Eletrônico



Kbase P129904: CR/LF in Attribute converted into space by XML DOM parser
Autor   Progress Software Corporation - Progress
Acesso   Público
Publicação   3/27/2008
Status: Unverified

FACT(s) (Environment):

OpenEdge 10.x

SYMPTOM(s):

CR/LF in Attribute converted into space by XML DOM parser

Longchar in1 contains XML contents with CR/LF in attribute

DEFINE VARIABLE tempin1 AS CHAR.
ASSIGN tempin1 = '<?xml version="1.0" encoding="utf-8"?><validateTaskRequest><whiteSpaceLoss note1="this is a note." note2="this ' + CHR(10) + CHR(13) + ' is ' + CHR(10) + CHR(13) + ' a ' + CHR(10) + CHR(13) + ' note."></whiteSpaceLoss></validateTaskRequest>'.
MESSAGE tempin1 VIEW-AS ALERT-BOX.
DEFINE VARIABLE in1 AS LONGCHAR NO-UNDO.
in1 = tempin1.
DEFINE VARIABLE hDoc AS HANDLE.
CREATE X-DOCUMENT hDoc.
hDoc:LOAD("LONGCHAR",in1,FALSE).
hDoc:SAVE("LONGCHAR",in1).
MESSAGE String(in1) VIEW-AS ALERT-BOX.

CAUSE:

Expected behavior following the standards

FIX:

White Space in Attributes

Although XML processors preserve all white space in element content, they frequently normalize it in attribute values. Tabs, carriage returns, and spaces are reported as single spaces. In certain types of attributes, they trim white space that comes before or after the main body of the value and reduce white space within the value to single spaces. (If a DTD is available, this trimming will be performed on all attributes that are not of type CDATA.)
For example, an XML document might contain the following:
<whiteSpaceLoss note1="this is a note." note2="this
is
a
note.">
An XML parser reports both attribute values as "this is a note.", converting the line breaks to single spaces.