abdera-user mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From James M Snell <jasn...@gmail.com>
Subject Re: Is this correct output for a HTML entry
Date Wed, 22 Aug 2007 03:12:12 GMT
Not quite.  Takasho's example is actually perfectly valid, just not
typical.  Using type="text/html" is fine, and when doing so, the value
of the atom:content needs to be processable as that media type, meaning
the <html> tag is perfectly fine.  When type="html", the value of the
atom:content needs to be a fragment of HTML that is suitable for
inclusion inside a div.  There is no requirement that the first child be
a div -- that's only for XHTML content.

 entry.setContent(
   "<html><head /><body><p>full html doc</p></body></html>",
   "text/html");

 entry.setContentAsHTML("<i>html</i> <b>fragment</b>");

The former comes out as:

 <atom:content type="text/html">&lt;html>...&lt;/html></atom:content>

The latter as:

 <atom:content type="html">&lt;i>html&lt;/i>
&lt;b>fragment&lt;/b></atom:content>

Both are perfectly valid Atom.

- James

Josh Peters wrote:
> I'm new to Abdera, but I hope to add something to the mix.  I have a
> question about Takasho's question re: HTML.
> 
> On Aug 21, 2007, at 9:15 AM, Takasho wrote:
>> Is this the correct output from creating a HTML entry:
> 
>> ---code---
> 
>> Entry entryHTML = factory.newEntry();
>> entryHTML.setId("http://supersmashing.co.uk/elmer/entryHtml");
>> entryHTML.setUpdated(new java.util.Date());
>> entryHTML.setTitle("Shiny HTML Entry");
>> entryHTML.setContent("<html><head/><body><p>This is a full
HTML
>> document</p></body></html>", "text/html" );
>> entryHTML.addAuthor("Takasho");
>> entryHTML.addLink("http://www.supersmashing.co.uk");
>> feed.addEntry(entryHTML);
> 
>> ---output---
> 
> I noticed that Takasho's example isn't correct Atom-wise, as the
> <content> @type should be "html" not "text/html"  also, the first child
> of it should be a div element, not a HTML html node.  Is it in the scope
> of Abdera to warn on such a thing?
> 
> Hope it helps.
> 
> Josh Peters
> 
> 

Mime
View raw message