[Mono-dev] Problems with DOM serialization to XHTML

Federico Di Gregorio fog at initd.org
Wed Feb 21 12:29:47 EST 2007


Hi *,

this is my first post to this list so, please, feel free to tell me (in
private) about policies and to redirect me to the right place if I am
out of topic. Thank you.

We are having some problems serializing an XmlDocument (DOM) that
represents an XHTML document into valid indented XHTML. The problem is
that the serialization code breaks empty tags adding a NL/CR between the
open and the closed tag, adding significant whitespace and making it
non-empty. So, for example, if a tag like:

<img src="..."></img>

is parsed (note that even not in the <img... /> form, it is a perfectly
valid, closed tag) a different one is output when the document is
serialized:

<img src="...">
</img>

That is not valid XHTML anymore. A very simple solution would be to not
break empty tags (XmlElement.IsEmpty == true) or even shorten them into
the <.../> form (this probably would output invalid XHTML too but would
be easily fixable in the code manipulating the DOM while the current
problem has no apparent solution in the application code.)

Or am I simply doing it the wrong way? :D

federico

-- 
Federico Di Gregorio                         http://people.initd.org/fog
Debian GNU/Linux Developer                                fog at debian.org
INIT.D Developer                                           fog at initd.org
  "Yes, your honour, I have RSA encryption code tattood on my penis.
   Shall I show the jury?"                                     -- <dark>
-------------- next part --------------
A non-text attachment was scrubbed...
Name: not available
Type: application/pgp-signature
Size: 189 bytes
Desc: Questa =?ISO-8859-1?Q?=E8?= una parte del messaggio
	firmata digitalmente
Url : http://lists.ximian.com/pipermail/mono-devel-list/attachments/20070221/63857f53/attachment.bin 


More information about the Mono-devel-list mailing list