You are viewing a plain text version of this content. The canonical link for it is here.
Posted to user@abdera.apache.org by Takasho <ta...@gmail.com> on 2007/08/21 16:15:57 UTC

Is this correct output for a HTML entry

Hi All,

I'm just starting to use abdera and so at the moment my questions will be
very basic :)

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---

<entry><id>http://supersmashing.co.uk/what/entryHtml
</id><updated>2007-08-21T13:51:32.980Z</updated><title type="text">Shiny
HTML Entry</title><content
type="text/html">&lt;html>&lt;head/>&lt;body>&lt;p>This is a full HTML
document&lt;/p>&lt;/body>&lt;/html></content><author><name>Takasho</name></author><link
href="http://www.supersmashing.co.uk" /></entry>

Its the encoding of the HTML is was not sure about as it is only encoding
the less than signs and not the greater than signs. I'm using the latest
trunk build as of this morning.

Takasho

Re: Is this correct output for a HTML entry

Posted by Takasho <ta...@gmail.com>.
Thats great. Thanks James.

On 21/08/07, James M Snell <ja...@gmail.com> wrote:
>
> Oh, right, yeah that's correct.  The > does not have to be escaped.
> Different stax implementations will handle this differently; some will
> escape the >, others will not.  Either way the output is correct.
>
> - James
>
> Takasho wrote:
> > Hi James,
> >
> > I agree that it must be escaped as per the spec. I was questioning that
> > abdera is only partially escaping the HTML. e.g.
> >
> > <content type="text/html">&lt;html>&lt;head/>&lt;body>&lt;p>This is a
> full
> > HTML> document&lt;/p>&lt;/body>&lt;/html></content>
> >
> > Instead of:
> >
> > <content
> type="text/html">&lt;html&gt;&lt;head/&gt;&lt;body&gt;&lt;p&gt;This
> > is a full HTML&gt;
> document&lt;/p&gt;&lt;/body&gt;&lt;/html&gt;></content>
> >
> > Takasho
>
>

Re: Is this correct output for a HTML entry

Posted by James M Snell <ja...@gmail.com>.
Oh, right, yeah that's correct.  The > does not have to be escaped.
Different stax implementations will handle this differently; some will
escape the >, others will not.  Either way the output is correct.

- James

Takasho wrote:
> Hi James,
> 
> I agree that it must be escaped as per the spec. I was questioning that
> abdera is only partially escaping the HTML. e.g.
> 
> <content type="text/html">&lt;html>&lt;head/>&lt;body>&lt;p>This is a full
> HTML> document&lt;/p>&lt;/body>&lt;/html></content>
> 
> Instead of:
> 
> <content type="text/html">&lt;html&gt;&lt;head/&gt;&lt;body&gt;&lt;p&gt;This
> is a full HTML&gt; document&lt;/p&gt;&lt;/body&gt;&lt;/html&gt;></content>
> 
> Takasho
> 
> On 21/08/07, James M Snell <ja...@gmail.com> wrote:
>> Yes, that is the correct output.  The Atom spec states that HTML MUST be
>> escaped.
>>
>> - James
>>
>> Takasho wrote:
>>> Hi All,
>>>
>>> I'm just starting to use abdera and so at the moment my questions will
>> be
>>> very basic :)
>>>
>>> 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---
>>>
>>> <entry><id>http://supersmashing.co.uk/what/entryHtml
>>> </id><updated>2007-08-21T13:51:32.980Z</updated><title type="text">Shiny
>>> HTML Entry</title><content
>>> type="text/html">&lt;html>&lt;head/>&lt;body>&lt;p>This is a full HTML
>>>
>> document&lt;/p>&lt;/body>&lt;/html></content><author><name>Takasho</name></author><link
>>> href="http://www.supersmashing.co.uk" /></entry>
>>>
>>> Its the encoding of the HTML is was not sure about as it is only
>> encoding
>>> the less than signs and not the greater than signs. I'm using the latest
>>> trunk build as of this morning.
>>>
>>> Takasho
>>>
> 

Re: Is this correct output for a HTML entry

Posted by Takasho <ta...@gmail.com>.
Hi James,

I agree that it must be escaped as per the spec. I was questioning that
abdera is only partially escaping the HTML. e.g.

<content type="text/html">&lt;html>&lt;head/>&lt;body>&lt;p>This is a full
HTML> document&lt;/p>&lt;/body>&lt;/html></content>

Instead of:

<content type="text/html">&lt;html&gt;&lt;head/&gt;&lt;body&gt;&lt;p&gt;This
is a full HTML&gt; document&lt;/p&gt;&lt;/body&gt;&lt;/html&gt;></content>

Takasho

On 21/08/07, James M Snell <ja...@gmail.com> wrote:
>
> Yes, that is the correct output.  The Atom spec states that HTML MUST be
> escaped.
>
> - James
>
> Takasho wrote:
> > Hi All,
> >
> > I'm just starting to use abdera and so at the moment my questions will
> be
> > very basic :)
> >
> > 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---
> >
> > <entry><id>http://supersmashing.co.uk/what/entryHtml
> > </id><updated>2007-08-21T13:51:32.980Z</updated><title type="text">Shiny
> > HTML Entry</title><content
> > type="text/html">&lt;html>&lt;head/>&lt;body>&lt;p>This is a full HTML
> >
> document&lt;/p>&lt;/body>&lt;/html></content><author><name>Takasho</name></author><link
> > href="http://www.supersmashing.co.uk" /></entry>
> >
> > Its the encoding of the HTML is was not sure about as it is only
> encoding
> > the less than signs and not the greater than signs. I'm using the latest
> > trunk build as of this morning.
> >
> > Takasho
> >
>

Re: Is this correct output for a HTML entry

Posted by James M Snell <ja...@gmail.com>.
Yes, that is the correct output.  The Atom spec states that HTML MUST be
escaped.

- James

Takasho wrote:
> Hi All,
> 
> I'm just starting to use abdera and so at the moment my questions will be
> very basic :)
> 
> 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---
> 
> <entry><id>http://supersmashing.co.uk/what/entryHtml
> </id><updated>2007-08-21T13:51:32.980Z</updated><title type="text">Shiny
> HTML Entry</title><content
> type="text/html">&lt;html>&lt;head/>&lt;body>&lt;p>This is a full HTML
> document&lt;/p>&lt;/body>&lt;/html></content><author><name>Takasho</name></author><link
> href="http://www.supersmashing.co.uk" /></entry>
> 
> Its the encoding of the HTML is was not sure about as it is only encoding
> the less than signs and not the greater than signs. I'm using the latest
> trunk build as of this morning.
> 
> Takasho
> 

Re: Is this correct output for a HTML entry

Posted by Josh Peters <jc...@gmail.com>.
-----BEGIN PGP SIGNED MESSAGE-----
Hash: SHA1

On Aug 21, 2007, at 10:12 PM, James M Snell wrote:
> Not quite.  Takasho's example is actually perfectly valid, just not
> typical.

Of course you're right, I wasn't thinking about the built-in  
mechanism for MIME type extensions being applied for HTML.  Thanks  
for setting me straight.

Josh Peters


-----BEGIN PGP SIGNATURE-----
Version: GnuPG v1.4.7 (Darwin)

iQCVAwUBRsu5MvufekgP7qSrAQJ60QQAqzBoVCp85VqxhuCOFkaQ1bDaIVwuEtF6
55vR6SXEQfkOiaPsllZ8JALn038NhNCBcqzE9X5YFNza01MSzwysGmcyPUGrsUTC
ksi5FtOC/dsiJqJCzEuzoemkt0IxQSLQtCfkSJ5xly9IwcVUlE/C5oTJIDIBXSFz
fJMt5zj2IuI=
=4TwM
-----END PGP SIGNATURE-----

Re: Is this correct output for a HTML entry

Posted by James M Snell <ja...@gmail.com>.
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
> 
> 

Re: Is this correct output for a HTML entry

Posted by Josh Peters <jc...@gmail.com>.
-----BEGIN PGP SIGNED MESSAGE-----
Hash: SHA1

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


-----BEGIN PGP SIGNATURE-----
Version: GnuPG v1.4.7 (Darwin)

iQCVAwUBRsuNdvufekgP7qSrAQJNLgQAkusC6oqQ19wUaZJh2lrhZedtTfKISyG+
r2UwGimihdDeNjvC+6+wObP0NpYvc12Xtt+OPW1x+AtDIkks2CP14+5ra1NpXrOm
edtxbBV2/nuOgpFsuCkBmgCDulPZStw78VWbYhnjM9QKYYhnz71htQbnHQrtF4w5
9wzUq57FM1s=
=zkIX
-----END PGP SIGNATURE-----