7 Replies Latest reply on Sep 8, 2008 1:42 AM by bashan

    Rss feed

    bashan

      Hi,


      I am trying to write RSS feed and having some problems with the description part.
      I want the description part to be HTML rather than plain text.
      But it seems like the HTML in the description tag is not parsed correctly (by the browser). I assume this is happening because the HTML tags are not rendered as HTML entities. So I decided to solve it by adding: CDATA. But when I aded the CDTDA, for some reason that I don't exactly understand, all the data in the CDATA was rendered with HTML entites, causing the feed content to be shown as text of HTML rather than rendered HTML.


      How can I solve this issue?


      Thanks,
      Guy.

        • 1. Re: Rss feed
          michaelcourcy

          If you want some help, show at least the code that generate the rss.

          • 2. Re: Rss feed
            bashan

            Sorry, here is my current code:



            <?xml version="1.0" encoding="utf-8"?>
            <rss version='2.0'
                 xmlns:ui="http://java.sun.com/jsf/facelets"
                 xmlns:f="http://java.sun.com/jsf/core"
                 xmlns:h="http://java.sun.com/jsf/html"
                 xmlns:s="http://jboss.com/products/seam/taglib"
                 xmlns:t="http://myfaces.apache.org/tomahawk"
                 xmlns:n="http://www.nikonians.tv/jsf"
                 xmlns:view="http://com.nikonians.ui/view"
                 xmlns:path="http://com.nikonians.ui/path">
              <channel>
                <title>Most Recent</title>
                <link>#{path:getServerContext(request)}/home.jspx</link>
                <image>
                  <url>#{path:getServerContext(request)}/img/logo.png</url>
                  <title>Most Recent</title>
                  <link>#{path:getServerContext(request)}/home.jspx</link>
                </image>
                <description>Recently added to Nikonians.tv</description>
                <language>en-us</language>
                <t:dataList value="#{home.channels}" var="channel">
                  <t:dataList value="#{home.channelVideos}" var="video">
                    <item>
                      <title>#{video.name}</title>
                      <link>#{path:getServerContext(request)}/video.show.jspx?vid=#{video.videoPhysicalId}</link>
                      <guid>#{path:getServerContext(request)}/video.show.jspx?vid=#{video.videoPhysicalId}</guid>
                      <author>
                        <name>#{video.user.username}</name>
                        <email>#{video.user.email}</email>
                      </author>
                      <description>
                        <table width="500">
                          <tr>
                            <td width="5%">
                              <s:link view="/video.show.xhtml">
                                <f:param name="vid" value="#{video.videoPhysicalId}" />
                                <h:graphicImage value="#{path:getVideoThumbMedium(video)}" styleClass="picture"/>
                              </s:link>
                            </td>
                            <td valign="top">
                              <table width="100%" border="0">
                                <tr>
                                  <td>
                                    <s:link view="/video.show.xhtml" propagation="none" value="#{video.name}" styleClass="linkVideo">
                                      <f:param name="vid" value="#{video.videoPhysicalId}" />
                                    </s:link>
                                  </td>
                                  <td align="right">
                                    #{view:formatDays(video.dateUploaded)}
                                  </td>
                                </tr>
                                <tr>
                                  <td colspan="2" style="border-top:solid 1px #cccccc">
                                    <table>
                                      <tr>
                                        <td>
                                          <n:ratingShow />
                                          <f:verbatim>&amp;nbsp;|&amp;nbsp;</f:verbatim>#{video.views} Views<f:verbatim>&amp;nbsp;|&amp;nbsp;</f:verbatim>#{home.commentsNum}
                                          Comments<f:verbatim>&amp;nbsp;|&amp;nbsp;</f:verbatim>#{view:formatTime(video.duration)}
                                        </td>
                                      </tr>
                                      <tr>
                                        <td>
                                          #{video.description}
                                        </td>
                                      </tr>
                                      <tr>
                                        <td>
                                          From<f:verbatim>&amp;nbsp;</f:verbatim><s:link view="/user.home.public.xhtml" value="#{video.user.username}"><f:param name="userId" value="#{video.user.userId}" /></s:link> in #{video.channel.name}
                                        </td>
                                      </tr>
                                    </table>
                                  </td>
                                </tr>
                              </table>
                            </td>
                          </tr>
                        </table>
                      </description>
                    </item>
                  </t:dataList>
                </t:dataList>
              </channel>
            </rss>


            • 3. Re: Rss feed
              michaelcourcy

              The RSS specification is not completly clear on how to embbed html in description.


              As you did it seems that enclosing the html inside a CDATA section is the best supported for the feed readers.


              <description><![CDATA[{summary}{body}]]></description> 
              



              Thus the question is who converts the html tag inside the CDATA in html entities ? Is it Seam or is it your rss reader ?


              if you do something like


              %> wget http://localhost:8080/mywebapp/myrss.seam 
              



              Can you still check in the console output that the html inside the CDATA is converted in html entities ?


              By the way are you able to read other feeds containing html with your feed reader ?

              • 4. Re: Rss feed
                bashan

                My reader (firefox) is showing all other feeds coming from places like youtube and picasa.
                I checked the output with wget and it clearly seems to be coming from the server. It seems like Seam or JSF or facelets is somehow manipulating the data inside a CDATA. This is weird, because it is reasonable to think, that from all places, the data inside a CDATA shouldn't be manipulated...


                Is there a way to overcome this? What is the cause to this conversion?


                Thanks,
                Guy.

                • 5. Re: Rss feed
                  michaelcourcy

                  the data inside a CDATA shouldn't be manipulated...


                  I agree


                  Beside if the rendering (facelet) engine take the decision to convert your html inside the CDATA section, it should then take the decision to not interpret this ...


                   <h:graphicImage value="#{path:getVideoThumbMedium(video)}" styleClass="picture"/>
                  



                  But it does interpret it, thus I may misunderstand something, I'm going to investigate this question.


                  • 6. Re: Rss feed
                    susnet.susanne.susnet.se
                    • 7. Re: Rss feed
                      bashan

                      Thanks,


                      Yes, I have seen this post. My problem is that I don't have a single property like: blogEntry.content.
                      I have there a whole block of HTML.


                      Did I miss something in that solution that might help me?