<source> tag issue

32 views
Skip to first unread message

Juan José De La Torre León

unread,
Nov 10, 2014, 7:00:28 PM11/10/14
to lif...@googlegroups.com
Hi, I'm trying to render an XML based on this Lift Cookbook Snippet :: http://chimera.labs.oreilly.com/books/1234000000030/ch04.html#GoogleSitemap


This is the XML content ::

<?xml version="1.0" encoding="UTF-8"?>
<source>
    <publisher>Talenteca</publisher>
    <publisherurl>https://www.talenteca.co</publisherurl>
    <lastBuildDate>Fri, 10 Dec 2004 22:49:39 GMT</lastBuildDate>

    <job>
        <title><![CDATA[Sales Executive]]></title>
        <date><![CDATA[Fri, 10 Dec 2005 22:49:39 GMT]]></date>
        <referencenumber><![CDATA[unique123131]]></referencenumber>
    </job>

</source>


This is how it gets rendered:: 

<?xml version="1.0" encoding="UTF-8"?>


<source></source>  

It's a strange behaviour. 
If a replace the <source> tag with any other tag name. ex <dummy>  .. The file will render perfectly.

Hope I can have some insights about this.


Thanks a lot

Juan José

Antonio Salazar Cardozo

unread,
Nov 10, 2014, 7:25:20 PM11/10/14
to lif...@googlegroups.com
I think we're going to need more context than that. What do your transforms look like? What
results are you expecting given what input data?
Thanks,
Antonio

Juan José De La Torre León

unread,
Nov 10, 2014, 7:39:31 PM11/10/14
to lif...@googlegroups.com

Hi Antonio, 

Right now it's not binded to a snippet.

I just wanted to test XML request and then have a proper XML response. But I'm getting the incomplete XML 

Thanks
--
--
Lift, the simply functional web framework: http://liftweb.net
Code: http://github.com/lift
Discussion: http://groups.google.com/group/liftweb
Stuck? Help us help you: https://www.assembla.com/wiki/show/liftweb/Posting_example_code

---
You received this message because you are subscribed to a topic in the Google Groups "Lift" group.
To unsubscribe from this topic, visit https://groups.google.com/d/topic/liftweb/ccKtE6GT0yI/unsubscribe.
To unsubscribe from this group and all its topics, send an email to liftweb+u...@googlegroups.com.
For more options, visit https://groups.google.com/d/optout.

Antonio Salazar Cardozo

unread,
Nov 10, 2014, 8:44:51 PM11/10/14
to lif...@googlegroups.com
Ah, I see. How are you serving this XML response? If you're running it through Lift's standard
rendering pipeline, then you'll be in a situation where the XML is being read from the filesystem
using the HTML5 parser. In HTML5, source is a valid element, but an empty one, so the HTML5
parser will throw out any contents it may have (sometimes these will become siblings, but an
XML document can only have one root, so that'll probably affect the results).

If I'm right about this, that means we need to fix the cookbook to indicate that you must use the
XML reader in these cases. You can do this by doing something like:

LiftRules.htmlProperties.default.set({ request: Req =>
  if (request.path.suffix == "xml") {
    OldHtmlProperties(request.userAgent)
  } else {
    Html5Properties(request.userAgent)
  }
})

This will use the XHTML reader and writer, which don't handle HTML validation or failure modes.

An even better alternative would be to use the XML reader directly, but I'm not 100% sure exactly
what that would look like at the moment. Richard, if I'm right about this, I guess we'd need to update
the cookbook…
Thanks,
Antonio
To unsubscribe from this group and all its topics, send an email to liftweb+unsubscribe@googlegroups.com.

Richard Dallaway

unread,
Nov 11, 2014, 3:23:46 AM11/11/14
to lif...@googlegroups.com
Nice example. I'll take a look at that recipe when I'm back at a laptop at the end of the week.

Thanks
Richard




On Tuesday Nov 11, 2014 at 00:25, Antonio Salazar Cardozo <savedf...@gmail.com>, wrote:

I think we're going to need more context than that. What do your transforms
look like? What
results are you expecting given what input data?
Thanks,
Antonio

On Monday, November 10, 2014 7:00:28 PM UTC-5, Juan José De La Torre León
wrote:
>
> Hi, I'm trying to render an XML based on this Lift Cookbook Snippet ::
> http://chimera.labs.oreilly.com/books/1234000000030/ch04.html#GoogleSitemap
>
>
> *This is the XML content ::*
>
> <?xml version="1.0" encoding="UTF-8"?>
> <source>
> <publisher>Talenteca</publisher>
> <publisherurl>https://www.talenteca.co</publisherurl>
> <lastBuildDate>Fri, 10 Dec 2004 22:49:39 GMT</lastBuildDate>
>
> <job>
> <title><![CDATA[Sales Executive]]></title>
> <date><![CDATA[Fri, 10 Dec 2005 22:49:39 GMT]]></date>
> <referencenumber><![CDATA[unique123131]]></referencenumber>
> </job>
>
> </source>
>
>
> *This is how it gets rendered::*
>
> <?xml version="1.0" encoding="UTF-8"?>
>
> <source></source>
> It's a strange behaviour.
> If a replace the <source> tag with any other tag name. ex <dummy> .. The
> file will render perfectly.
>
> Hope I can have some insights about this.
>
>
> Thanks a lot
>
> Juan José
>

--
--
Lift, the simply functional web framework: http://liftweb.net
Code: http://github.com/lift
Discussion: http://groups.google.com/group/liftweb
Stuck? Help us help you: https://www.assembla.com/wiki/show/liftweb/Posting_example_code

---
You received this message because you are subscribed to the Google Groups "Lift" group.
To unsubscribe from this group and stop receiving emails from it, send an email to liftweb+u...@googlegroups.com.

Juan José De La Torre León

unread,
Nov 11, 2014, 5:59:03 PM11/11/14
to lif...@googlegroups.com
Thanks Antonio, that was the issue, now its working perfectly.

Antonio Salazar Cardozo

unread,
Nov 12, 2014, 12:57:37 AM11/12/14
to lif...@googlegroups.com
Awesome, glad to hear it!

Richard Dallaway

unread,
Nov 15, 2014, 5:14:18 AM11/15/14
to lif...@googlegroups.com, lif...@googlegroups.com
Thank you. I’ve now updated that example to include the LiftRules.htmlProperties change.

Feedback, as always, welcome.

Richard

Antonio Salazar Cardozo

unread,
Nov 15, 2014, 3:58:21 PM11/15/14
to lif...@googlegroups.com
Looks great!
Thanks,
Antonio
To unsubscribe from this group and stop receiving emails from it, send an email to liftweb+unsubscribe@googlegroups.com.
Reply all
Reply to author
Forward
0 new messages