<!DOCTYPE HTML> | |
<!-- | |
/*************************************************************************************************************************** | |
* Licensed to the Apache Software Foundation (ASF) under one or more contributor license agreements. See the NOTICE file | |
* distributed with this work for additional information regarding copyright ownership. The ASF licenses this file | |
* to you under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance | |
* with the License. You may obtain a copy of the License at | |
* | |
* http://www.apache.org/licenses/LICENSE-2.0 | |
* | |
* Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on an | |
* "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the | |
* specific language governing permissions and limitations under the License. | |
* | |
***************************************************************************************************************************/ | |
--> | |
<html> | |
<head> | |
<meta http-equiv="Content-Type" content="text/html; charset=UTF-8"> | |
<style type="text/css"> | |
/* For viewing in Page Designer */ | |
@IMPORT url("../../../../../../../javadoc.css"); | |
/* For viewing in REST interface */ | |
@IMPORT url("../htdocs/javadoc.css"); | |
body { | |
margin: 20px; | |
} | |
</style> | |
<script> | |
/* Replace all @code and @link tags. */ | |
window.onload = function() { | |
document.body.innerHTML = document.body.innerHTML.replace(/\{\@code ([^\}]+)\}/g, '<code>$1</code>'); | |
document.body.innerHTML = document.body.innerHTML.replace(/\{\@link (([^\}]+)\.)?([^\.\}]+)\}/g, '<code>$3</code>'); | |
} | |
</script> | |
</head> | |
<body> | |
<p>ATOM Data Transfer Objects</p> | |
<script> | |
function toggle(x) { | |
var div = x.nextSibling; | |
while (div != null && div.nodeType != 1) | |
div = div.nextSibling; | |
if (div != null) { | |
var d = div.style.display; | |
if (d == 'block' || d == '') { | |
div.style.display = 'none'; | |
x.className += " closed"; | |
} else { | |
div.style.display = 'block'; | |
x.className = x.className.replace(/(?:^|\s)closed(?!\S)/g , '' ); | |
} | |
} | |
} | |
</script> | |
<a id='TOC'></a><h5 class='toc'>Table of Contents</h5> | |
<ol class='toc'> | |
<li><p><a class='doclink' href='#Overview'>Overview</a></p> | |
<ol> | |
<li><p><a class='doclink' href='#Serialize'>Serializing ATOM feeds</a></p> | |
<ol> | |
<li><p><a class='doclink' href='#AtomJson'>ATOM/JSON</a></p> | |
<li><p><a class='doclink' href='#AtomRdfXml'>ATOM/RDF/XML</a></p> | |
<li><p><a class='doclink' href='#AtomHtml'>ATOM/HTML</a></p> | |
</ol> | |
<li><p><a class='doclink' href='#Parse'>Parsing ATOM feeds</a></p> | |
</ol> | |
</ol> | |
<!-- ======================================================================================================== --> | |
<a id="Overview"></a> | |
<h2 class='topic' onclick='toggle(this)'>1 - Overview</h2> | |
<div class='topic'> | |
<p> | |
Juneau supports generation and consumption of ATOM feeds through the use of DTOs (Data Transfer Objects). | |
<br>It uses existing support for serializing and parsing POJOs to and from XML to define these ATOM objects. | |
</p> | |
<p> | |
The examples shown here are pulled from the <code>AtomFeedResource</code> class in the | |
<code>org.apache.juneau.sample.war</code> project. | |
</p> | |
<!-- ======================================================================================================== --> | |
<a id="Serialize"></a> | |
<h3 class='topic' onclick='toggle(this)'>1.1 - Serializing ATOM feeds</h3> | |
<div class='topic'> | |
<p> | |
The Juneau ATOM feed DTOs are simply beans with fluent-style setters. | |
<br>The following code shows a feed being created programmatically using the | |
{@link org.apache.juneau.dto.atom.AtomBuilder} class. | |
</p> | |
<p class='bcode'> | |
<jk>import static</jk> org.apache.juneau.dto.atom.AtomBuilder.*; | |
Feed feed = | |
<jsm>feed</jsm>(<js>"tag:juneau.apache.org"</js>, <js>"Juneau ATOM specification"</js>, <js>"2016-01-02T03:04:05Z"</js>) | |
.subtitle(<jsm>text</jsm>(<js>"html"</js>).text(<js>"Describes <em>stuff</em> about Juneau"</js>)) | |
.links( | |
<jsm>link</jsm>(<js>"alternate"</js>, <js>"text/html"</js>, <js>"http://juneau.apache.org"</js>).hreflang(<js>"en"</js>), | |
<jsm>link</jsm>(<js>"self"</js>, <js>"application/atom+xml"</js>, <js>"http://juneau.apache.org/feed.atom"</js>) | |
) | |
.generator( | |
<jsm>generator</jsm>(<js>"Juneau"</js>).uri(<js>"http://juneau.apache.org"</js>).version(<js>"1.0"</js>) | |
) | |
.entries( | |
<jsm>entry</jsm>(<js>"tag:juneau.sample.com,2013:1.2345"</js>, <js>"Juneau ATOM specification snapshot"</js>, <js>"2016-01-02T03:04:05Z"</js>) | |
.links( | |
<jsm>link</jsm>(<js>"alternate"</js>, <js>"text/html"</js>, <js>"http://juneau.apache.org/juneau.atom"</js>), | |
<jsm>link</jsm>(<js>"enclosure"</js>, <js>"audio/mpeg"</js>, <js>"http://juneau.apache.org/audio/juneau_podcast.mp3"</js>).length(1337) | |
) | |
.published(<js>"2016-01-02T03:04:05Z"</js>) | |
.authors( | |
<jsm>person</jsm>(<js>"Jane Smith"</js>).uri(<js>"http://juneau.apache.org"</js>).email(<js>"janesmith@apache.org"</js>) | |
) | |
.contributors( | |
<jsm>person</jsm>(<js>"John Smith"</js>) | |
) | |
.content( | |
<jsm>content</jsm>(<js>"xhtml"</js>) | |
.lang(<js>"en"</js>) | |
.base(<js>"http://www.apache.org/"</js>) | |
.text(<js>"<div><p><i>[Update: Juneau supports ATOM.]</i></p></div>"</js>) | |
) | |
); | |
</p> | |
<p> | |
To serialize this to ATOM, use the {@link org.apache.juneau.xml.XmlSerializer} class: | |
</p> | |
<h6 class='figure'>Example with no namespaces</h6> | |
<p class='bcode'> | |
<jc>// Create a serializer with readable output, no namespaces yet.</jc> | |
XmlSerializer s = <jk>new</jk> XmlSerializerBuilder().sq().ws().build(); | |
<jc>// Serialize to ATOM/XML</jc> | |
String atomXml = s.serialize(feed); | |
</p> | |
<h6 class='figure'>Results</h6> | |
<p class='bcode'> | |
<xt><feed></xt> | |
<xt><id></xt> | |
tag:juneau.apache.org | |
<xt></id></xt> | |
<xt><link</xt> <xa>href</xa>=<xs>'http://juneau.apache.org/'</xs> <xa>rel</xa>=<xs>'alternate'</xs> <xa>type</xa>=<xs>'text/html'</xs> <xa>hreflang</xa>=<xs>'en'</xs>/<xt>></xt> | |
<xt><link</xt> <xa>href</xa>=<xs>'http://juneau.apache.org/feed.atom'</xs> <xa>rel</xa>=<xs>'self'</xs> <xa>type</xa>=<xs>'application/atom+xml'</xs>/<xt>></xt> | |
<xt><title</xt> <xa>type</xa>=<xs>'text'</xs>></xt> | |
Juneau ATOM specification | |
<xt></title></xt> | |
<xt><updated></xt>2016-01-02T03:04:05Z<xt></updated></xt> | |
<xt><generator</xt> <xa>uri</xa>=<xs>'http://juneau.apache.org/'</xs> <xa>version</xa>=<xs>'1.0'</xs><xt>></xt> | |
Juneau | |
<xt></generator></xt> | |
<xt><subtitle</xt> <xa>type</xa>=<xs>'html'</xs><xt>></xt> | |
Describes <em>stuff</em> about Juneau | |
<xt></subtitle></xt> | |
<xt><entry></xt> | |
<xt><author></xt> | |
<xt><name></xt>Jane Smith<xt></name></xt> | |
<xt><uri></xt>http://juneau.apache.org/<xt></uri></xt> | |
<xt><email></xt>janesmith@apache.org<xt></email></xt> | |
<xt></author></xt> | |
<xt><contributor></xt> | |
<xt><name></xt>John Smith<xt></name></xt> | |
<xt></contributor></xt> | |
<xt><id></xt> | |
tag:juneau.apache.org | |
<xt></id></xt> | |
<xt><link</xt> <xa>href</xa>=<xs>'http://juneau.apache.org/juneau.atom'</xs> <xa>rel</xa>=<xs>'alternate'</xs> <xa>type</xa>=<xs>'text/html'</xs>/<xt>></xt> | |
<xt><link</xt> <xa>href</xa>=<xs>'http://juneau.apache.org/audio/juneau_podcast.mp3'</xs> <xa>rel</xa>=<xs>'enclosure'</xs> <xa>type</xa>=<xs>'audio/mpeg'</xs> <xa>length</xa>=<xs>'12345'</xs>/<xt>></xt> | |
<xt><title></xt> | |
Juneau ATOM specification snapshot | |
<xt></title></xt> | |
<xt><updated></xt>2016-01-02T03:04:05Z<xt></updated></xt> | |
<xt><content</xt> <xa>base</xa>=<xs>'http://www.apache.org/'</xs> <xa>lang</xa>=<xs>'en'</xs> <xa>type</xa>=<xs>'xhtml'</xs><xt>></xt> | |
<xt><div</xt> <xa>xmlns</xa>=<xs>"http://www.w3.org/1999/xhtml"</xs><xt>><p><i></xt>[Update: Juneau supports ATOM.]<xt></i></p></div></xt> | |
<xt></content></xt> | |
<xt><published></xt>2016-01-02T03:04:05Z<xt></published></xt> | |
<xt></entry></xt> | |
<xt></feed></xt> | |
</p> | |
<p> | |
The following is the same, except with XML namespaces enabled: | |
</p> | |
<h6 class='figure'>Example with namespaces</h6> | |
<p class='bcode'> | |
<jc>// Create a serializer with readable output with namespaces.</jc> | |
XmlSerializer s = <jk>new</jk> XmlSerializerBuilder().sq().ws().build(); | |
<jc>// Serialize to ATOM/XML</jc> | |
String atomXml = s.serialize(feed); | |
</p> | |
<h6 class='figure'>Results</h6> | |
<p class='bcode'> | |
<xt><atom:feed</xt> | |
<xa>xmlns</xa>=<xs>'http://www.apache.org/2013/Juneau'</xs> | |
<xa>xmlns:atom</xa>=<xs>'http://www.w3.org/2005/Atom/'</xs> | |
<xa>xmlns:xml</xa>=<xs>'http://www.w3.org/XML/1998/namespace'</xs> | |
<xa>xmlns:xsi</xa>=<xs>'http://www.w3.org/2001/XMLSchema-instance'</xs><xt>></xt> | |
<xt><atom:id></xt> | |
tag:juneau.apache.org | |
<xt></atom:id></xt> | |
<xt><atom:link</xt> <xa>href</xa>=<xs>'http://juneau.apache.org/'</xs> <xa>rel</xa>=<xs>'alternate'</xs> <xa>type</xa>=<xs>'text/html'</xs> <xa>hreflang</xa>=<xs>'en'</xs><xt>/></xt> | |
<xt><atom:link</xt> <xa>href</xa>=<xs>'http://juneau.apache.org/feed.atom'</xs> <xa>rel</xa>=<xs>'self'</xs> <xa>type</xa>=<xs>'application/atom+xml'</xs><xt>/></xt> | |
<xt><atom:title</xt> <xa>type</xa>=<xs>'text'</xs><xt>></xt> | |
Juneau ATOM specification | |
<xt></atom:title></xt> | |
<xt><atom:updated></xt>2016-01-02T03:04:05Z<xt></atom:updated></xt> | |
<xt><atom:generator</xt> <xa>uri</xa>=<xs>'http://juneau.apache.org/'</xs> <xa>version</xa>=<xs>'1.0'</xs><xt>></xt> | |
Juneau | |
<xt></atom:generator></xt> | |
<xt><atom:subtitle</xt> <xa>type</xa>=<xs>'html'</xs><xt>></xt> | |
Describes <em>stuff</em> about Juneau | |
<xt></atom:subtitle></xt> | |
<xt><atom:entry></xt> | |
<xt><atom:author></xt> | |
<xt><atom:name></xt>Jane Smith<xt></atom:name></xt> | |
<xt><atom:uri></xt>http://juneau.apache.org/<xt></atom:uri></xt> | |
<xt><atom:email></xt>janesmith@apache.org<xt></atom:email></xt> | |
<xt></atom:author></xt> | |
<xt><atom:contributor></xt> | |
<xt><atom:name></xt>John Smith<xt></atom:name></xt> | |
<xt></atom:contributor></xt> | |
<xt><atom:id></xt> | |
tag:juneau.apache.org | |
<xt></atom:id></xt> | |
<xt><atom:link</xt> <xa>href</xa>=<xs>'http://juneau.apache.org/juneau.atom'</xs> <xa>rel</xa>=<xs>'alternate'</xs> <xa>type</xa>=<xs>'text/html'</xs><xt>/></xt> | |
<xt><atom:link</xt> <xa>href</xa>=<xs>'http://juneau.apache.org/audio/juneau_podcast.mp3'</xs> <xa>rel</xa>=<xs>'enclosure'</xs> <xa>type</xa>=<xs>'audio/mpeg'</xs> <xa>length</xa>=<xs>'12345'</xs><xt>/></xt> | |
<xt><atom:title></xt> | |
Juneau ATOM specification snapshot | |
<xt></atom:title></xt> | |
<xt><atom:updated></xt>2016-01-02T03:04:05Z<xt></atom:updated></xt> | |
<xt><atom:content</xt> <xa>xml:base</xa>=<xs>'http://www.apache.org/'</xs> <xa>xml:lang</xa>=<xs>'en'</xs> <xa>type</xa>=<xs>'xhtml'</xs><xt>></xt> | |
<xt><div</xt> <xa>xmlns</xa>=<xs>"http://www.w3.org/1999/xhtml"</xs><xt>></xt><xt><p></xt><xt><i></xt>[Update: Juneau supports ATOM.]<xt></i></xt><xt></p></xt><xt></div></xt> | |
<xt></atom:content></xt> | |
<xt><atom:published></xt>2016-01-02T03:04:05Z<xt></atom:published></xt> | |
<xt></atom:entry></xt> | |
<xt></atom:feed></xt> | |
</p> | |
<p> | |
The following is the same, except with XML namespaces enabled and the ATOM namespace as the default namespace: | |
</p> | |
<h6 class='figure'>Example with namespaces with ATOM as the default namespace</h6> | |
<p class='bcode'> | |
<jc>// Create a serializer with readable output with namespaces.</jc> | |
XmlSerializer s = <jk>new</jk> XmlSerializerBuilder().sq().ws().defaultNamespaceUri(<js>"atom"</js>).build(); | |
<jc>// Serialize to ATOM/XML</jc> | |
String atomXml = s.serialize(feed); | |
</p> | |
<h6 class='figure'>Results</h6> | |
<p class='bcode'> | |
<xt><feed</xt> | |
<xa>xmlns</xa>=<xs>'http://www.w3.org/2005/Atom/'</xs> | |
<xa>xmlns:xml</xa>=<xs>'http://www.w3.org/XML/1998/namespace'</xs> | |
<xa>xmlns:xsi</xa>=<xs>'http://www.w3.org/2001/XMLSchema-instance'</xs><xt>></xt> | |
<xt><id></xt> | |
tag:juneau.apache.org | |
<xt></id></xt> | |
<xt><link</xt> <xa>href</xa>=<xs>'http://juneau.apache.org/'</xs> <xa>rel</xa>=<xs>'alternate'</xs> <xa>type</xa>=<xs>'text/html'</xs> <xa>hreflang</xa>=<xs>'en'</xs><xt>/></xt> | |
<xt><link</xt> <xa>href</xa>=<xs>'http://juneau.apache.org/feed.atom'</xs> <xa>rel</xa>=<xs>'self'</xs> <xa>type</xa>=<xs>'application/atom+xml'</xs><xt>/></xt> | |
<xt><title</xt> <xa>type</xa>=<xs>'text'</xs><xt>></xt> | |
Juneau ATOM specification | |
<xt></title></xt> | |
<xt><updated></xt>2016-01-02T03:04:05Z<xt></updated></xt> | |
<xt><generator</xt> <xa>uri</xa>=<xs>'http://juneau.apache.org/'</xs> <xa>version</xa>=<xs>'1.0'</xs><xt>></xt> | |
Juneau | |
<xt></generator></xt> | |
<xt><subtitle</xt> <xa>type</xa>=<xs>'html'</xs><xt>></xt> | |
Describes &lt;em&stuff&lt;/em&gt; about Juneau | |
<xt></subtitle></xt> | |
<xt><entry></xt> | |
<xt><author></xt> | |
<xt><name></xt>Jane Smith<xt></name></xt> | |
<xt><uri></xt>http://juneau.apache.org/<xt></uri></xt> | |
<xt><email></xt>janesmith@apache.org<xt></email></xt> | |
<xt></author></xt> | |
<xt><contributor></xt> | |
<xt><name></xt>John Smith<xt></name></xt> | |
<xt></contributor></xt> | |
<xt><id></xt> | |
tag:juneau.apache.org | |
<xt></id></xt> | |
<xt><link</xt> <xa>href</xa>=<xs>'http://juneau.apache.org/juneau.atom'</xs> <xa>rel</xa>=<xs>'alternate'</xs> <xa>type</xa>=<xs>'text/html'</xs><xt>/></xt> | |
<xt><link</xt> <xa>href</xa>=<xs>'http://juneau.apache.org/audio/juneau_podcast.mp3'</xs> <xa>rel</xa>=<xs>'enclosure'</xs> <xa>type</xa>=<xs>'audio/mpeg'</xs> <xa>length</xa>=<xs>'12345'</xs><xt>/></xt> | |
<xt><title></xt> | |
Juneau ATOM specification snapshot | |
<xt></title></xt> | |
<xt><updated></xt>2016-01-02T03:04:05Z<xt></updated></xt> | |
<xt><content</xt> <xa>xml:base</xa>=<xs>'http://www.apache.org/'</xs> <xa>xml:lang</xa>=<xs>'en'</xs> <xa>type</xa>=<xs>'xhtml'</xs><xt>></xt> | |
<xt><div</xt> <xa>xmlns</xa>=<xs>"http://www.w3.org/1999/xhtml"</xs><xt>></xt><xt><p></xt><xt><i></xt>[Update: Juneau supports ATOM.]<xt></i></xt><xt></p></xt><xt></div></xt> | |
<xt></content></xt> | |
<xt><published></xt>2016-01-02T03:04:05Z<xt></published></xt> | |
<xt></entry></xt> | |
<xt></feed></xt> | |
</p> | |
<!-- ======================================================================================================== --> | |
<a id="AtomJson"></a> | |
<h4 class='topic' onclick='toggle(this)'>1.1.1 - ATOM/JSON</h4> | |
<div class='topic'> | |
<p> | |
The {@link org.apache.juneau.json.JsonSerializer} class can also be used to produce ATOM in JSON format. | |
</p> | |
<h6 class='figure'>ATOM/JSON example</h6> | |
<p class='bcode'> | |
<jc>// Get JSON serializer with readable output.</jc> | |
JsonSerializer s = JsonSerializer.<jsf>DEFAULT_LAX_READABLE</jsf>; | |
<jc>// Serialize to ATOM/JSON</jc> | |
String atomJson = s.serialize(feed); | |
</p> | |
<h6 class='figure'>Results</h6> | |
<p class='bcode'> | |
{ | |
id: { | |
text: <js>'tag:juneau.apache.org'</js> | |
}, | |
links: [ | |
{ | |
href: <js>'http://juneau.apache.org/'</js>, | |
rel: <js>'alternate'</js>, | |
type: <js>'text/html'</js>, | |
hreflang: <js>'en'</js> | |
}, | |
{ | |
href: <js>'http://juneau.apache.org/juneau.atom'</js>, | |
rel: <js>'self'</js>, | |
type: <js>'application/atom+xml'</js> | |
} | |
], | |
title: { | |
type: <js>'text'</js>, | |
text: <js>'Juneau ATOM specification'</js> | |
}, | |
updated: <js>'2016-01-02T03:04:05Z'</js>, | |
generator: { | |
uri: <js>'http://juneau.apache.org/'</js>, | |
version: <js>'1.0'</js>, | |
text: <js>'Juneau'</js> | |
}, | |
subtitle: { | |
type: <js>'html'</js>, | |
text: <js>'Describes <em>stuff</em> about Juneau'</js> | |
}, | |
entries: [ | |
{ | |
authors: [ | |
{ | |
name: <js>'James Bognar'</js>, | |
uri: <js>'http://juneau.apache.org/'</js>, | |
email: <js>'jamesbognar@apache.org'</js> | |
} | |
], | |
contributors: [ | |
{ | |
name: <js>'Barry M. Caceres'</js> | |
} | |
], | |
id: { | |
text: <js>'tag:juneau.apache.org'</js> | |
}, | |
links: [ | |
{ | |
href: <js>'http://juneau.apache.org/juneau.atom'</js>, | |
rel: <js>'alternate'</js>, | |
type: <js>'text/html'</js> | |
}, | |
{ | |
href: <js>'http://juneau.apache.org/audio/juneau_podcast.mp3'</js>, | |
rel: <js>'enclosure'</js>, | |
type: <js>'audio/mpeg'</js>, | |
length: <jk>12345</jk> | |
} | |
], | |
title: { | |
text: <js>'Juneau ATOM specification snapshot'</js> | |
}, | |
updated: <js>'2016-01-02T03:04:05Z'</js>, | |
content: { | |
base: <js>'http://www.apache.org/'</js>, | |
lang: <js>'en'</js>, | |
type: <js>'xhtml'</js>, | |
text: <js>'<div xmlns="http://www.w3.org/1999/xhtml"><p><i>[Update: Juneau supports ATOM.]</i></p></div>'</js> | |
}, | |
published: <js>'2016-01-02T03:04:05Z'</js> | |
} | |
] | |
} | |
</p> | |
</div> | |
<!-- ======================================================================================================== --> | |
<a id="AtomRdfXml"></a> | |
<h4 class='topic' onclick='toggle(this)'>1.1.2 - ATOM/RDF/XML</h4> | |
<div class='topic'> | |
<p> | |
The {@link org.apache.juneau.jena.RdfSerializer} class and subclasses can also be used to produce ATOM | |
in various RDF formats. | |
</p> | |
<h6 class='figure'>ATOM/RDF/XML example</h6> | |
<p class='bcode'> | |
<jc>// Get RDF/XML serializer with readable output.</jc> | |
RdfSerializer s = <jk>new</jk> RdfSerializerBuilder() | |
.xmlabbrev() | |
.ws() | |
.sq() | |
.property(RdfProperties.<jsf>RDF_rdfxml_tab</jsf>, 3) | |
.build(); | |
<jc>// Serialize to ATOM/RDF/XML</jc> | |
String atomRdfXml = s.serialize(feed); | |
</p> | |
<h6 class='figure'>Results</h6> | |
<p class='bcode'> | |
<xt><rdf:RDF</xt> | |
<xa>xmlns:rdf</xa>=<xs>'http://www.w3.org/1999/02/22-rdf-syntax-ns#'</xs> | |
<xa>xmlns:j</xa>=<xs>'http://www.apache.org/juneau/'</xs> | |
<xa>xmlns:jp</xa>=<xs>'http://www.apache.org/juneaubp/'</xs> | |
<xa>xmlns:atom</xa>=<xs>'http://www.w3.org/2005/Atom/'</xs> | |
<xa>xmlns:j.0</xa>=<xs>'http://www.w3.org/XML/1998/'</xs><xt>></xt> | |
<xt><rdf:Description></xt> | |
<xt><atom:id</xt> <xa>rdf:parseType</xa>=<xs>'Resource'</xs><xt>></xt> | |
<xt><atom:text></xt>tag:juneau.apache.org<xt></atom:text></xt> | |
<xt></atom:id></xt> | |
<xt><atom:links></xt> | |
<xt><rdf:Seq></xt> | |
<xt><rdf:li</xt> <xa>rdf:parseType</xa>=<xs>'Resource'</xs><xt>></xt> | |
<xt><atom:href></xt>http://juneau.apache.org/<xt></atom:href></xt> | |
<xt><atom:rel></xt>alternate<xt></atom:rel></xt> | |
<xt><atom:type></xt>text/html<xt></atom:type></xt> | |
<xt><atom:hreflang></xt>en<xt></atom:hreflang></xt> | |
<xt></rdf:li></xt> | |
<xt><rdf:li</xt> <xa>rdf:parseType</xa>=<xs>'Resource'</xs><xt>></xt> | |
<xt><atom:href></xt>http://juneau.apache.org/feed.atom<xt></atom:href></xt> | |
<xt><atom:rel></xt>self<xt></atom:rel></xt> | |
<xt><atom:type></xt>application/atom+xml<xt></atom:type></xt> | |
<xt></rdf:li></xt> | |
<xt></rdf:Seq></xt> | |
<xt></atom:links></xt> | |
<xt><atom:title</xt> <xa>rdf:parseType</xa>=<xs>'Resource'</xs><xt>></xt> | |
<xt><atom:type></xt>text<xt></atom:type></xt> | |
<xt><atom:text></xt>Juneau ATOM specification<xt></atom:text></xt> | |
<xt></atom:title></xt> | |
<xt><atom:updated></xt>2016-01-02T03:04:05Z<xt></atom:updated></xt> | |
<xt><atom:generator</xt> <xa>rdf:parseType</xa>=<xs>'Resource'</xs><xt>></xt> | |
<xt><atom:uri</xt> <xa>rdf:resource</xa>=<xs>'http://juneau.apache.org/'</xs><xt>/></xt> | |
<xt><atom:version></xt>1.0<xt></atom:version></xt> | |
<xt><atom:text></xt>Juneau<xt></atom:text></xt> | |
<xt></atom:generator></xt> | |
<xt><atom:subtitle</xt> <xa>rdf:parseType</xa>=<xs>'Resource'</xs><xt>></xt> | |
<xt><atom:type></xt>html<xt></atom:type></xt> | |
<xt><atom:text></xt>A &lt;em&gt;lot&lt;/em&gt; of effort went into making this effortless<xt></atom:text></xt> | |
<xt></atom:subtitle></xt> | |
<xt><atom:entries></xt> | |
<xt><rdf:Seq></xt> | |
<xt><rdf:li</xt> <xa>rdf:parseType</xa>=<xs>'Resource'</xs><xt>></xt> | |
<xt><atom:authors></xt> | |
<xt><rdf:Seq></xt> | |
<xt><rdf:li</xt> <xa>rdf:parseType</xa>=<xs>'Resource'</xs><xt>></xt> | |
<xt><atom:name></xt>James Bognar<xt></atom:name></xt> | |
<xt><atom:uri</xt> <xa>rdf:resource</xa>=<xs>'http://juneau.apache.org/'</xs><xt>/></xt> | |
<xt><atom:email></xt>james.bognar@salesforce.com<xt></atom:email></xt> | |
<xt></rdf:li></xt> | |
<xt></rdf:Seq></xt> | |
<xt></atom:authors></xt> | |
<xt><atom:contributors></xt> | |
<xt><rdf:Seq></xt> | |
<xt><rdf:li</xt> <xa>rdf:parseType</xa>=<xs>'Resource'</xs><xt>></xt> | |
<xt><atom:name></xt>Barry M. Caceres<xt></atom:name></xt> | |
<xt></rdf:li></xt> | |
<xt></rdf:Seq></xt> | |
<xt></atom:contributors></xt> | |
<xt><atom:id</xt> <xa>rdf:parseType</xa>=<xs>'Resource'</xs><xt>></xt> | |
<xt><atom:text></xt>tag:juneau.apache.org<xt></atom:text></xt> | |
<xt></atom:id></xt> | |
<xt><atom:links></xt> | |
<xt><rdf:Seq></xt> | |
<xt><rdf:li</xt> <xa>rdf:parseType</xa>=<xs>'Resource'</xs><xt>></xt> | |
<xt><atom:href></xt>http://juneau.apache.org/juneau.atom<xt></atom:href></xt> | |
<xt><atom:rel></xt>alternate<xt></atom:rel></xt> | |
<xt><atom:type></xt>text/html<xt></atom:type></xt> | |
<xt></rdf:li></xt> | |
<xt><rdf:li</xt> <xa>rdf:parseType</xa>=<xs>'Resource'</xs><xt>></xt> | |
<xt><atom:href></xt>http://juneau.apache.org/audio/juneau_podcast.mp3<xt></atom:href></xt> | |
<xt><atom:rel></xt>enclosure<xt></atom:rel></xt> | |
<xt><atom:type></xt>audio/mpeg<xt></atom:type></xt> | |
<xt><atom:length></xt>12345<xt></atom:length></xt> | |
<xt></rdf:li></xt> | |
<xt></rdf:Seq></xt> | |
<xt></atom:links></xt> | |
<xt><atom:title</xt> <xa>rdf:parseType</xa>=<xs>'Resource'</xs><xt>></xt> | |
<xt><atom:text></xt>Juneau ATOM specification snapshot<xt></atom:text></xt> | |
<xt></atom:title></xt> | |
<xt><atom:updated></xt>2016-01-02T03:04:05Z<xt></atom:updated></xt> | |
<xt><atom:content</xt> <xa>rdf:parseType</xa>=<xs>'Resource'</xs><xt>></xt> | |
<xt><j.0:namespacebase</xt> <xa>rdf:resource</xa>=<xs>'http://www.apache.org/'</xs><xt>/></xt> | |
<xt><j.0:namespacelang></xt>en<xt></j.0:namespacelang></xt> | |
<xt><atom:type></xt>xhtml<xt></atom:type></xt> | |
<xt><atom:text></xt>&lt;div xmlns="http://www.w3.org/1999/xhtml"&gt;&lt;p&gt;&lt;i&gt;[Update: Juneau supports ATOM.]&lt;/i&gt;&lt;/p&gt;&lt;/div&gt;<xt></atom:text></xt> | |
<xt></atom:content></xt> | |
<xt><atom:published></xt>2016-01-02T03:04:05Z<xt></atom:published></xt> | |
<xt></rdf:li></xt> | |
<xt></rdf:Seq></xt> | |
<xt></atom:entries></xt> | |
<xt></rdf:Description></xt> | |
<xt></rdf:RDF></xt> | |
</p> | |
</div> | |
<!-- ======================================================================================================== --> | |
<a id="AtomHtml"></a> | |
<h4 class='topic' onclick='toggle(this)'>1.1.3 - ATOM/HTML</h4> | |
<div class='topic'> | |
<p> | |
The {@link org.apache.juneau.html.HtmlSerializer} class can be used to produce ATOM in HTML format. | |
</p> | |
<p> | |
The following is the output produced by the <code>AtomFeedResource</code> in the <code>org.apache.juneau.sample.war</code> project: | |
</p> | |
<h6 class='figure'>Example ATOM/HTML results</h6> | |
<img class='bordered' src='doc-files/Example_HTML.png'> | |
</div> | |
</div> | |
<!-- ======================================================================================================== --> | |
<a id="Parse"></a> | |
<h3 class='topic' onclick='toggle(this)'>1.2 - Parsing ATOM feeds</h3> | |
<div class='topic'> | |
<p> | |
Use the {@link org.apache.juneau.xml.XmlParser} to convert ATOM/XML feeds back into their original POJOs: | |
</p> | |
<p class='bcode'> | |
<jc>// Create a serializer with readable output with namespaces</jc> | |
XmlSerializer s = XmlSerializer.<jsf>DEFAULT_SQ_READABLE</jsf>; | |
<jc>// Serialize to ATOM/XML</jc> | |
String atomXml = s.serialize(feed); | |
<jc>// Get an XML parser to convert it back into a POJO</jc> | |
XmlParser p = XmlParser.<jsf>DEFAULT</jsf>; | |
<jc>// Convert the XML back into a POJO</jc> | |
Feed feed2 = p.parse(atomXml, Feed.<jk>class</jk>); | |
</p> | |
<p> | |
ATOM Feed objects can also be constructed from the other media types using the appropriate parsers. | |
</p> | |
</div> | |
</div> | |
<p align="center"><i><b>*** fín ***</b></i></p> | |
</body> | |
</html> |