Re: [xml] May I have line breaks in a property?

Date view Thread view Subject view Author view

From: Daniel Veillard (Daniel.Veillard@imag.fr)
Date: Sat Feb 10 2001 - 16:45:12 EST


On Sat, Feb 10, 2001 at 12:59:10PM -0800, ming lu wrote:
>
> Hi everyone, I am a beginner of XML and libxml2. And I just wonder if I can
> have line breaks in a property. For example:
> <?xml version="1.0"?>
> <PLAN xmlns="http://www.argus.ca/autotest/1.0/">
> <NODE Comments="1st line <------------------------line break here
> 2nd line <-----------------------and here
> 3rd line"/>
> </PLAN>
>
>
> I found the result of xmlGetProp replace the line break with space. Is it
> possible that I keep the line break? TIA

  Hum, that's an interesting point.
Basically XML parser have to do attribute normalization, and this include
replacing newlines by blanks.
   http://www.w3.org/TR/REC-xml#AVNormalize

  However when passed as numeric character reference in the serialization
(like &#xA; ) then the normalization doesn't apply, but currently libxml
doesn't check for extra spaces or newlines in attribute content when
saving, i.e. it doesn't escape them as character reference and then at next
parsing they would disapear anyway :-\, it's in the TODO but I never
took the time of handling this.

  A rule of thumbs is that if you have to encode multiline contents,
use an element and not an attribute, it fits really better in the
XML framework.

Daniel

-- 
Daniel Veillard      | Red Hat Network http://redhat.com/products/network/
veillard@redhat.com  | libxml Gnome XML toolkit  http://xmlsoft.org/
http://veillard.com/ | Rpmfind RPM search engine http://rpmfind.net/
----
Message from the list xml@rpmfind.net
Archived at : http://xmlsoft.org/messages/
to unsubscribe: echo "unsubscribe xml" | mail  majordomo@rpmfind.net


Date view Thread view Subject view Author view

This archive was generated by hypermail 2b29 : Sat Feb 10 2001 - 18:43:35 EST