Re: html markup escape and CDATA issue
Daniel Dekany <[email protected]> Wed, 4 Mar 2015 00:09:36 +0100
| Newsgroups | gmane.comp.web.freemarker.user |
|---|---|
| Message-ID | <[email protected]> |
Tuesday, March 3, 2015, 10:51:08 PM, FOX427 wrote:
> Ok, when you have xml with this node:
>
> <location>
> <p> Some Hotel Name  <br /> Some Street<br /> Miami,
> FL 33131<br /> 305 503 5555 </p>.
> </location>
>
> in order to get value from it I have to use:
>
> <#list document.details.location as loc>
> <#if loc.p??&&loc.p?has_content>
(`loc.p??` is always true - see XML Processing Guide)
> <#list loc.p as p>
> <#if p.a??&&p.a?has_content>
(`loc.a??` is always true too)
> ${p.a} <${p.a.@href}>
Are you sure there are never multiple `p.a`-s?
> </#if>
> <#list p?children as nodes>
> ${nodes}
> </#list>
> </#list>
> </#if>
> </#list>
(There was no #escape here BTW.)
> and all these lines will be for nothing if next xml has two "<p></p>" or no
> "<p></p>" at all or completely different things in node, i dont know why but
> freemarker treats <p> as child node, as a result, if node has <p> and you
> dont use ${p.xxxx} it complains saying it has child node, and vice versa, if
> you add ${p.xxxx} and there is no <p> it prints nothing. So my main goal is
> to be able to use freemarker that handles html markups in prompt way so I
> don't have to worry about having different html markups in different xml
> with the same node name(<location>).
Sorry, I don't really understand what you are saying, but if you just
want to print everything inside <location>...</location>, then use
${location.@@nested_markup}. (Inside #noescape if you are inside
#escape.)
Or, the contents of <location> should be CDATA, inside the XML. Now of
course it's up to the designers of the XML schema, and I don't know
what their design goals were.
> So i thought maybe I need to use escape or CDATA to get rid of this
> issue...I am just starting to learn freemarker, maybe i don't understand a
> lot of stuff that might be very basic for you so i apologize in advance :(
Read the XML Processing Guide of you haven't. You can spare a lot of
time of yours with that.
> Thank you. :)
--
Thanks,
Daniel Dekany
------------------------------------------------------------------------------
Dive into the World of Parallel Programming The Go Parallel Website, sponsored
by Intel and developed in partnership with Slashdot Media, is your hub for all
things parallel software development, from weekly thought leadership blogs to
news, videos, case studies, tutorials and more. Take a look and join the
conversation now. http://goparallel.sourceforge.net/