Re: Problems with parsing a XML file

Daniel Dekany <[email protected]>
Newsgroups gmane.comp.web.freemarker.user
Message-ID <[email protected]>
Wednesday, July 8, 2009, 9:03:21 PM, bribon wrote:

> Hi,
>
> I'm working with Alfresco, so I'm trying to work with Freemarker. My problem
> is when I try to parse a XML file, I've always got this error:
>
> "06080009 Wrapped Exception (with status template): 06080008 Error during
> processing of the template 'Error on line 4, column 10 in
> org/alfresco/alert/alert.get.html.ftl Expecting a string, date or number
> here, Expression dom.book.@title is instead a
> freemarker.ext.dom.NodeListModel'. Please contact your system
> administrator."

The error message means that there is either 0 or multiple nodes that
match dom.book.@title. By replacing ${dom.book.@title} with
${dom.book.@title?size}, you will certainly find it prints 0. Then you
can go ahead and try if ${dom.book?size} is 0 too, means you don't
have a the book element either... things like that.

> I'm sure that XML file is used by dom variable. I've also tried with the
> example which you can find in a Freemarker tutorial. This is the Freemarker
> example:
>
> XML file:
>
> <?xml version="1.0" standalone="yes"?>
> <book title="Book Title">
>   <chapter>
>     <title>Chapter 1</title>
>     <para>p1.1</para>
>     <para>p1.2</para>
>     <para>p1.3</para>
>   </chapter>
>   <chapter>
>     <title>Chapter 2</title>
>     <para>p2.1</para>
>     <para>p2.2</para>
>   </chapter>
> </book>
>
> Freemarker file: 
>
> <#if document.mimetype = "text/xml">
>    <#assign dom=document.xmlNodeModel>
>    <h1>${dom.book.@title}</h1>
>    <#list dom.book.chapter as c>
>       <h2>${c.title}</2>
>    </#list>  
> </#if>
>
> It's very important to solve this problem. Can anyone help me out?
>
> Thanks in advance
>

-- 
Best regards,
 Daniel Dekany


------------------------------------------------------------------------------
Enter the BlackBerry Developer Challenge  
This is your chance to win up to $100,000 in prizes! For a limited time, 
vendors submitting new applications to BlackBerry App World(TM) will have
the opportunity to enter the BlackBerry Developer Challenge. See full prize  
details at: http://p.sf.net/sfu/Challenge
lmpx.com only provides a reader for public news (NNTP) servers. It is not affiliated with the servers or forums shown here and is not responsible for the content of articles, which is written by their respective authors.