Re: pxml and spaces and newlines

Steve Haflich <[email protected]> Thu, 30 May 2002 09:38:13 -0700
Newsgroups gmane.lisp.open-source.franz
Message-ID <[email protected]>
   From: [email protected]
   To: opensource
   
   I am playing with pxml and noticed that the result of parsing the string
   
   "<REGEL>
     <TITLE>Het_proces_verbaal</TITLE>
     <ID>170</ID>
   </REGEL>"
   
   is
   
   ((REGEL "
     " (TITLE "Het_proces_verbaal") "
     " (ID "170") "
   "))
   
   I did not expect the #\newline chars and spaces (or any other sequence of
   chars that pass #'xml-space-p) to be transformed to strings, instead I did
   expect
   
   ((REGEL (TITLE "Het_proces_verbaal") (ID "170")))
   
   
   My question is, is the behavior of the code correct, or should it return the
   list that i expect?

The behavior is not only correct, it is required.  See the W3C XML
standard, http://www.w3.org/TR/2000/REC-xml-20001006 section 2.10
White Space handling.

Even though in many applications of XML white space is completely
uninteresting, for some other applications white space may be
significant is certain contexts, and it isn't the business of the
parser (the "processor" in W3C terms) to try to decide for the
application.

You may want to walk the returned lxml tree and drop any strings that
are entirely white space.