You are viewing a plain text version of this content. The canonical link for it is here.
Posted to c-dev@xerces.apache.org by Matthias Niggemeier <m...@thias.de> on 2003/06/04 00:55:14 UTC

Problem with pretty print

Hi there!
I'm quite new in developing with Xerces, so I even don't know 
wether I'm in the right list or not.
I want to write a generated XML-File using the prettyprint-feature.
The only problem I have is that tags containing only whitespaces
are written as empty tags; e.g. <mytag> </mytag> results in <mytag />.
How can I stop this? (" " is a valid value for <mytag> and should be
included in the XML file).

Another question is: How can I escape ampersands? For example, I want
to have a tag "mytag" with the value "&#181;g/l".
When I write back this string it results in &amp;#181;g/l
How can I prevent ampersands being escaped on save? (How can I tell
the Writer that I know what I do when I put an ampersand in the
tagvalue?:-) )

Greetings
Matthias

Re: Problem with pretty print

Posted by Michael Rafael Glavassevich <mr...@engmail.uwaterloo.ca>.
Hi Matthias,

To answer your second question, the writer has to write ampersand (&) as
an entity reference because a literal '&' is a markup delimiter for entity
and character references. So, no you can't force DOM writer to write
ampersands as literals. If you want codepoint 181 in your text node, you
have to literaly put it there, not the string '&#181' which corresponds to
a character reference to that character.

On input, the parser replaces character references with their Unicode
values. On output, if a character cannot be expressed as a byte sequence
in the desired output encoding the writer should serialize it as a
character reference.

http://xml.apache.org/xerces-c/faq-parse.html#faq-30 explains a bit more
about what goes on during serialization.

Hope that helps.

-----------------------------------------
Michael Glavassevich
mrglavas@engmail.uwaterloo.ca
Candidate for Bachelor of Applied Science
Computer Engineering
University of Waterloo

On Wed, 4 Jun 2003, Matthias Niggemeier wrote:

> Hi there!
> I'm quite new in developing with Xerces, so I even don't know
> wether I'm in the right list or not.
> I want to write a generated XML-File using the prettyprint-feature.
> The only problem I have is that tags containing only whitespaces
> are written as empty tags; e.g. <mytag> </mytag> results in <mytag />.
> How can I stop this? (" " is a valid value for <mytag> and should be
> included in the XML file).
>
> Another question is: How can I escape ampersands? For example, I want
> to have a tag "mytag" with the value "&#181;g/l".
> When I write back this string it results in &amp;#181;g/l
> How can I prevent ampersands being escaped on save? (How can I tell
> the Writer that I know what I do when I put an ampersand in the
> tagvalue?:-) )
>
> Greetings
> Matthias
>

---------------------------------------------------------------------
To unsubscribe, e-mail: xerces-c-dev-unsubscribe@xml.apache.org
For additional commands, e-mail: xerces-c-dev-help@xml.apache.org