DO NOT REPLY TO THIS EMAIL, BUT PLEASE POST YOUR BUG 
RELATED COMMENTS THROUGH THE WEB INTERFACE AVAILABLE AT
<http://nagoya.apache.org/bugzilla/show_bug.cgi?id=20858>.
ANY REPLY MADE TO THIS MESSAGE WILL NOT BE COLLECTED AND 
INSERTED IN THE BUG DATABASE.

http://nagoya.apache.org/bugzilla/show_bug.cgi?id=20858

Attribute value containing new lines

           Summary: Attribute value containing new lines
           Product: Xerces-C++
           Version: 1.4
          Platform: PC
        OS/Version: Windows NT/2K
            Status: NEW
          Severity: Normal
          Priority: Other
         Component: Miscellaneous
        AssignedTo: [EMAIL PROTECTED]
        ReportedBy: [EMAIL PROTECTED]


I've encountered a problem when using new lines in attribute value.
This is a fragment from the original xml file I used:

<text text1="aaa&#xA;bbb&#xA;ccc"/>

According to the Attribute-Value Normalization algorithm 
(http://www.w3.org/TR/REC-xml#AVNormalize) a character reference (i.e. &#xA;) 
is replaced with the referenced character (i.e. 0xA).
After parsing, I write the content to a file (using the sample code of 
SAXPrintHandlers). The value written to the file doesn't contain &#xA; but 0xA.
Then I parse the xml again, but not the original xml file, but the file that I 
previously created. Now, according to the Attribute-Value Normalization 
algorithm, 0xA is replaced with a space character, which means that I'm losing 
my new line.

This is the code fragment where I write the attribute values:

// attributes is of type AttributeList
// fFormatter is of type XMLFormatter

for (unsigned int i = 0; i < attributes.getLength(); i++) {
        fFormatter
                << XMLFormatter::NoEscapes
                << chSpace << attributes.getName(i)
                << chEqual << chDoubleQuote
                << XMLFormatter::AttrEscapes
                << attributes.getValue(i)
                << XMLFormatter::NoEscapes
                << chDoubleQuote;
}

I tried replacing each 0xA with &#xA; before writing the attribute value to the 
formatter, but then I got the following output:
<text text1="aaa&amp;#xA;bbb&amp;#xA;ccc"/>
When I omitted XMLFormatter::AttrEscapes I got the following output:
<text text1="aaa&#xA;bbb&#xA;ccc"/>
This is actually what I want but I'm not sure that omitting 
XMLFormatter::AttrEscapes is the right solution (it can harm other things, 
can't it?).

---------------------------------------------------------------------
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]

Reply via email to