Scala XML Bug?

41 views
Skip to first unread message

fbettag

unread,
Aug 9, 2009, 12:34:08 PM8/9/09
to Lift
Hi there,

i know this is not the right place, but i wanted your opinions first.
I'm trying to run XML.loadString onto this:

<body>
<div id="wrapper">
<div id="header">
<lift:Content.headline />
<lift:Content.subheadline />
<lift:Content.menu />
</div>
</div>

<div id="content">
<show:Content />
</div>

<div id="footer">
<lift:Content.footer />
</div>
</body>

The Problem appears to be with div#header, as soon as i remove it - it
works, as soon as i put in (EVEN AN EMPTY) div#header i get this
error:

org.xml.sax.SAXParseException: The element type "div" must be
terminated by the matching end-tag "</div>".
at
com.sun.org.apache.xerces.internal.parsers.AbstractSAXParser.parse
(AbstractSAXParser.java:1269)
at javax.xml.parsers.SAXParser.parse(SAXParser.java:375)
at scala.xml.parsing.FactoryAdapter.loadXML
(FactoryAdapter.scala:292)
at scala.xml.parsing.NoBindingFactoryAdapter.loadXML
(NoBindingFactoryAdapter.scala:60)
at scala.xml.XML$.load(XML.scala:68)
at scala.xml.XML$.loadString(XML.scala:84)
at ag.bett.lift.cms.comet.Others$.show(Others.scala:97)

Any ideas?

marius d.

unread,
Aug 9, 2009, 1:46:52 PM8/9/09
to Lift
What if you declare declaring the lift namespace ?


Br's,
Marius

fbettag

unread,
Aug 9, 2009, 1:54:57 PM8/9/09
to Lift
The Problem seems to be the newlines. when i do .replace("\n", "")
before XML.loadString() it works.. strange, any explaination?

Ross Mellgren

unread,
Aug 9, 2009, 1:58:10 PM8/9/09
to lif...@googlegroups.com
Loading this XML using XML.loadString works fine for me, so I suspect
there is something else going on here (e.g. formatting of the string,
encoding you use, code that loads the XML, etc.). Can you post a small
code snippet reproducing the issue?

-Ross

Timothy Perrett

unread,
Aug 9, 2009, 3:40:52 PM8/9/09
to Lift
Try loading the XML with net.liftweb.util.PCDataXmlParser ?

Cheers, Tim

David Pollak

unread,
Aug 9, 2009, 5:57:29 PM8/9/09
to lif...@googlegroups.com
The XML that you posted works just fine:

scala> val s = """<body>
     |        <div id="wrapper">
     |                <div id="header">
     |                        <lift:Content.headline />
     |                        <lift:Content.subheadline />
     |                        <lift:Content.menu />
     |                </div>
     |        </div>
     | 
     |        <div id="content">
     |                <show:Content />
     |        </div>
     | 
     |        <div id="footer">
     |                <lift:Content.footer />
     |        </div>
     | </body>"""
s: java.lang.String = 
<body>
              <div id="wrapper">
                      <div id="header">
                              <lift:Content.headline />
                              <lift:Content.subheadline />
                              <lift:Content.menu />
                      </div>
              </div>
       
              <div id="content">
                      <sho...
scala> import scala.xml._
import scala.xml._

scala> XML.loadString(s)
res1: scala.xml.Elem = 
<body>
              <div id="wrapper">
                      <div id="header">
                              <lift:Content.headline></lift:Content.headline>
                              <lift:Content.subheadline></lift:Content.subheadline>
                              <lift:Content.menu></lift:Content.menu>
                      </div>
              </div>
 ...
scala> 
--
Lift, the simply functional web framework http://liftweb.net
Beginning Scala http://www.apress.com/book/view/1430219890
Follow me: http://twitter.com/dpp
Git some: http://github.com/dpp

fbettag

unread,
Aug 9, 2009, 8:58:25 PM8/9/09
to Lift
It was the UTF-8 Encoding (linebreaks) that made the trouble. Anyway,
simply stripping the string of any newlines is enough.

On Aug 9, 11:57 pm, David Pollak <feeder.of.the.be...@gmail.com>
wrote:
> Beginning Scalahttp://www.apress.com/book/view/1430219890
Reply all
Reply to author
Forward
0 new messages