blob: 5cd3f6a09fc1bac2c526cdec21862e7662dbbeab [file] [log] [blame]
<!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 &lt;em&gt;stuff&lt;/em&gt; 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>"&lt;div&gt;&lt;p&gt;&lt;i&gt;[Update: Juneau supports ATOM.]&lt;/i&gt;&lt;/p&gt;&lt;/div&gt;"</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>&lt;feed&gt;</xt>
<xt>&lt;id&gt;</xt>
tag:juneau.apache.org
<xt>&lt;/id&gt;</xt>
<xt>&lt;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>&gt;</xt>
<xt>&lt;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>&gt;</xt>
<xt>&lt;title</xt> <xa>type</xa>=<xs>'text'</xs>&gt;</xt>
Juneau ATOM specification
<xt>&lt;/title&gt;</xt>
<xt>&lt;updated&gt;</xt>2016-01-02T03:04:05Z<xt>&lt;/updated&gt;</xt>
<xt>&lt;generator</xt> <xa>uri</xa>=<xs>'http://juneau.apache.org/'</xs> <xa>version</xa>=<xs>'1.0'</xs><xt>&gt;</xt>
Juneau
<xt>&lt;/generator&gt;</xt>
<xt>&lt;subtitle</xt> <xa>type</xa>=<xs>'html'</xs><xt>&gt;</xt>
Describes &lt;em&gt;stuff&lt;/em&gt; about Juneau
<xt>&lt;/subtitle&gt;</xt>
<xt>&lt;entry&gt;</xt>
<xt>&lt;author&gt;</xt>
<xt>&lt;name&gt;</xt>Jane Smith<xt>&lt;/name&gt;</xt>
<xt>&lt;uri&gt;</xt>http://juneau.apache.org/<xt>&lt;/uri&gt;</xt>
<xt>&lt;email&gt;</xt>janesmith@apache.org<xt>&lt;/email&gt;</xt>
<xt>&lt;/author&gt;</xt>
<xt>&lt;contributor&gt;</xt>
<xt>&lt;name&gt;</xt>John Smith<xt>&lt;/name&gt;</xt>
<xt>&lt;/contributor&gt;</xt>
<xt>&lt;id&gt;</xt>
tag:juneau.apache.org
<xt>&lt;/id&gt;</xt>
<xt>&lt;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>&gt;</xt>
<xt>&lt;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>&gt;</xt>
<xt>&lt;title&gt;</xt>
Juneau ATOM specification snapshot
<xt>&lt;/title&gt;</xt>
<xt>&lt;updated&gt;</xt>2016-01-02T03:04:05Z<xt>&lt;/updated&gt;</xt>
<xt>&lt;content</xt> <xa>base</xa>=<xs>'http://www.apache.org/'</xs> <xa>lang</xa>=<xs>'en'</xs> <xa>type</xa>=<xs>'xhtml'</xs><xt>&gt;</xt>
<xt>&lt;div</xt> <xa>xmlns</xa>=<xs>"http://www.w3.org/1999/xhtml"</xs><xt>&gt;&lt;p&gt;&lt;i&gt;</xt>[Update: Juneau supports ATOM.]<xt>&lt;/i&gt;&lt;/p&gt;&lt;/div&gt;</xt>
<xt>&lt;/content&gt;</xt>
<xt>&lt;published&gt;</xt>2016-01-02T03:04:05Z<xt>&lt;/published&gt;</xt>
<xt>&lt;/entry&gt;</xt>
<xt>&lt;/feed&gt;</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>&lt;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>&gt;</xt>
<xt>&lt;atom:id&gt;</xt>
tag:juneau.apache.org
<xt>&lt;/atom:id&gt;</xt>
<xt>&lt;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>/&gt;</xt>
<xt>&lt;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>/&gt;</xt>
<xt>&lt;atom:title</xt> <xa>type</xa>=<xs>'text'</xs><xt>&gt;</xt>
Juneau ATOM specification
<xt>&lt;/atom:title&gt;</xt>
<xt>&lt;atom:updated&gt;</xt>2016-01-02T03:04:05Z<xt>&lt;/atom:updated&gt;</xt>
<xt>&lt;atom:generator</xt> <xa>uri</xa>=<xs>'http://juneau.apache.org/'</xs> <xa>version</xa>=<xs>'1.0'</xs><xt>&gt;</xt>
Juneau
<xt>&lt;/atom:generator&gt;</xt>
<xt>&lt;atom:subtitle</xt> <xa>type</xa>=<xs>'html'</xs><xt>&gt;</xt>
Describes &lt;em&gt;stuff&lt;/em&gt; about Juneau
<xt>&lt;/atom:subtitle&gt;</xt>
<xt>&lt;atom:entry&gt;</xt>
<xt>&lt;atom:author&gt;</xt>
<xt>&lt;atom:name&gt;</xt>Jane Smith<xt>&lt;/atom:name&gt;</xt>
<xt>&lt;atom:uri&gt;</xt>http://juneau.apache.org/<xt>&lt;/atom:uri&gt;</xt>
<xt>&lt;atom:email&gt;</xt>janesmith@apache.org<xt>&lt;/atom:email&gt;</xt>
<xt>&lt;/atom:author&gt;</xt>
<xt>&lt;atom:contributor&gt;</xt>
<xt>&lt;atom:name&gt;</xt>John Smith<xt>&lt;/atom:name&gt;</xt>
<xt>&lt;/atom:contributor&gt;</xt>
<xt>&lt;atom:id&gt;</xt>
tag:juneau.apache.org
<xt>&lt;/atom:id&gt;</xt>
<xt>&lt;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>/&gt;</xt>
<xt>&lt;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>/&gt;</xt>
<xt>&lt;atom:title&gt;</xt>
Juneau ATOM specification snapshot
<xt>&lt;/atom:title&gt;</xt>
<xt>&lt;atom:updated&gt;</xt>2016-01-02T03:04:05Z<xt>&lt;/atom:updated&gt;</xt>
<xt>&lt;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>&gt;</xt>
<xt>&lt;div</xt> <xa>xmlns</xa>=<xs>"http://www.w3.org/1999/xhtml"</xs><xt>&gt;</xt><xt>&lt;p&gt;</xt><xt>&lt;i&gt;</xt>[Update: Juneau supports ATOM.]<xt>&lt;/i&gt;</xt><xt>&lt;/p&gt;</xt><xt>&lt;/div&gt;</xt>
<xt>&lt;/atom:content&gt;</xt>
<xt>&lt;atom:published&gt;</xt>2016-01-02T03:04:05Z<xt>&lt;/atom:published&gt;</xt>
<xt>&lt;/atom:entry&gt;</xt>
<xt>&lt;/atom:feed&gt;</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>&lt;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>&gt;</xt>
<xt>&lt;id&gt;</xt>
tag:juneau.apache.org
<xt>&lt;/id&gt;</xt>
<xt>&lt;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>/&gt;</xt>
<xt>&lt;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>/&gt;</xt>
<xt>&lt;title</xt> <xa>type</xa>=<xs>'text'</xs><xt>&gt;</xt>
Juneau ATOM specification
<xt>&lt;/title&gt;</xt>
<xt>&lt;updated&gt;</xt>2016-01-02T03:04:05Z<xt>&lt;/updated&gt;</xt>
<xt>&lt;generator</xt> <xa>uri</xa>=<xs>'http://juneau.apache.org/'</xs> <xa>version</xa>=<xs>'1.0'</xs><xt>&gt;</xt>
Juneau
<xt>&lt;/generator&gt;</xt>
<xt>&lt;subtitle</xt> <xa>type</xa>=<xs>'html'</xs><xt>&gt;</xt>
Describes &amp;lt;em&amp;stuff&amp;lt;/em&amp;gt; about Juneau
<xt>&lt;/subtitle&gt;</xt>
<xt>&lt;entry&gt;</xt>
<xt>&lt;author&gt;</xt>
<xt>&lt;name&gt;</xt>Jane Smith<xt>&lt;/name&gt;</xt>
<xt>&lt;uri&gt;</xt>http://juneau.apache.org/<xt>&lt;/uri&gt;</xt>
<xt>&lt;email&gt;</xt>janesmith@apache.org<xt>&lt;/email&gt;</xt>
<xt>&lt;/author&gt;</xt>
<xt>&lt;contributor&gt;</xt>
<xt>&lt;name&gt;</xt>John Smith<xt>&lt;/name&gt;</xt>
<xt>&lt;/contributor&gt;</xt>
<xt>&lt;id&gt;</xt>
tag:juneau.apache.org
<xt>&lt;/id&gt;</xt>
<xt>&lt;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>/&gt;</xt>
<xt>&lt;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>/&gt;</xt>
<xt>&lt;title&gt;</xt>
Juneau ATOM specification snapshot
<xt>&lt;/title&gt;</xt>
<xt>&lt;updated&gt;</xt>2016-01-02T03:04:05Z<xt>&lt;/updated&gt;</xt>
<xt>&lt;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>&gt;</xt>
<xt>&lt;div</xt> <xa>xmlns</xa>=<xs>"http://www.w3.org/1999/xhtml"</xs><xt>&gt;</xt><xt>&lt;p&gt;</xt><xt>&lt;i&gt;</xt>[Update: Juneau supports ATOM.]<xt>&lt;/i&gt;</xt><xt>&lt;/p&gt;</xt><xt>&lt;/div&gt;</xt>
<xt>&lt;/content&gt;</xt>
<xt>&lt;published&gt;</xt>2016-01-02T03:04:05Z<xt>&lt;/published&gt;</xt>
<xt>&lt;/entry&gt;</xt>
<xt>&lt;/feed&gt;</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 &lt;em&gt;stuff&lt;/em&gt; 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>'&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;'</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>&lt;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>&gt;</xt>
<xt>&lt;rdf:Description&gt;</xt>
<xt>&lt;atom:id</xt> <xa>rdf:parseType</xa>=<xs>'Resource'</xs><xt>&gt;</xt>
<xt>&lt;atom:text&gt;</xt>tag:juneau.apache.org<xt>&lt;/atom:text&gt;</xt>
<xt>&lt;/atom:id&gt;</xt>
<xt>&lt;atom:links&gt;</xt>
<xt>&lt;rdf:Seq&gt;</xt>
<xt>&lt;rdf:li</xt> <xa>rdf:parseType</xa>=<xs>'Resource'</xs><xt>&gt;</xt>
<xt>&lt;atom:href&gt;</xt>http://juneau.apache.org/<xt>&lt;/atom:href&gt;</xt>
<xt>&lt;atom:rel&gt;</xt>alternate<xt>&lt;/atom:rel&gt;</xt>
<xt>&lt;atom:type&gt;</xt>text/html<xt>&lt;/atom:type&gt;</xt>
<xt>&lt;atom:hreflang&gt;</xt>en<xt>&lt;/atom:hreflang&gt;</xt>
<xt>&lt;/rdf:li&gt;</xt>
<xt>&lt;rdf:li</xt> <xa>rdf:parseType</xa>=<xs>'Resource'</xs><xt>&gt;</xt>
<xt>&lt;atom:href&gt;</xt>http://juneau.apache.org/feed.atom<xt>&lt;/atom:href&gt;</xt>
<xt>&lt;atom:rel&gt;</xt>self<xt>&lt;/atom:rel&gt;</xt>
<xt>&lt;atom:type&gt;</xt>application/atom+xml<xt>&lt;/atom:type&gt;</xt>
<xt>&lt;/rdf:li&gt;</xt>
<xt>&lt;/rdf:Seq&gt;</xt>
<xt>&lt;/atom:links&gt;</xt>
<xt>&lt;atom:title</xt> <xa>rdf:parseType</xa>=<xs>'Resource'</xs><xt>&gt;</xt>
<xt>&lt;atom:type&gt;</xt>text<xt>&lt;/atom:type&gt;</xt>
<xt>&lt;atom:text&gt;</xt>Juneau ATOM specification<xt>&lt;/atom:text&gt;</xt>
<xt>&lt;/atom:title&gt;</xt>
<xt>&lt;atom:updated&gt;</xt>2016-01-02T03:04:05Z<xt>&lt;/atom:updated&gt;</xt>
<xt>&lt;atom:generator</xt> <xa>rdf:parseType</xa>=<xs>'Resource'</xs><xt>&gt;</xt>
<xt>&lt;atom:uri</xt> <xa>rdf:resource</xa>=<xs>'http://juneau.apache.org/'</xs><xt>/&gt;</xt>
<xt>&lt;atom:version&gt;</xt>1.0<xt>&lt;/atom:version&gt;</xt>
<xt>&lt;atom:text&gt;</xt>Juneau<xt>&lt;/atom:text&gt;</xt>
<xt>&lt;/atom:generator&gt;</xt>
<xt>&lt;atom:subtitle</xt> <xa>rdf:parseType</xa>=<xs>'Resource'</xs><xt>&gt;</xt>
<xt>&lt;atom:type&gt;</xt>html<xt>&lt;/atom:type&gt;</xt>
<xt>&lt;atom:text&gt;</xt>A &amp;lt;em&amp;gt;lot&amp;lt;/em&amp;gt; of effort went into making this effortless<xt>&lt;/atom:text&gt;</xt>
<xt>&lt;/atom:subtitle&gt;</xt>
<xt>&lt;atom:entries&gt;</xt>
<xt>&lt;rdf:Seq&gt;</xt>
<xt>&lt;rdf:li</xt> <xa>rdf:parseType</xa>=<xs>'Resource'</xs><xt>&gt;</xt>
<xt>&lt;atom:authors&gt;</xt>
<xt>&lt;rdf:Seq&gt;</xt>
<xt>&lt;rdf:li</xt> <xa>rdf:parseType</xa>=<xs>'Resource'</xs><xt>&gt;</xt>
<xt>&lt;atom:name&gt;</xt>James Bognar<xt>&lt;/atom:name&gt;</xt>
<xt>&lt;atom:uri</xt> <xa>rdf:resource</xa>=<xs>'http://juneau.apache.org/'</xs><xt>/&gt;</xt>
<xt>&lt;atom:email&gt;</xt>james.bognar@salesforce.com<xt>&lt;/atom:email&gt;</xt>
<xt>&lt;/rdf:li&gt;</xt>
<xt>&lt;/rdf:Seq&gt;</xt>
<xt>&lt;/atom:authors&gt;</xt>
<xt>&lt;atom:contributors&gt;</xt>
<xt>&lt;rdf:Seq&gt;</xt>
<xt>&lt;rdf:li</xt> <xa>rdf:parseType</xa>=<xs>'Resource'</xs><xt>&gt;</xt>
<xt>&lt;atom:name&gt;</xt>Barry M. Caceres<xt>&lt;/atom:name&gt;</xt>
<xt>&lt;/rdf:li&gt;</xt>
<xt>&lt;/rdf:Seq&gt;</xt>
<xt>&lt;/atom:contributors&gt;</xt>
<xt>&lt;atom:id</xt> <xa>rdf:parseType</xa>=<xs>'Resource'</xs><xt>&gt;</xt>
<xt>&lt;atom:text&gt;</xt>tag:juneau.apache.org<xt>&lt;/atom:text&gt;</xt>
<xt>&lt;/atom:id&gt;</xt>
<xt>&lt;atom:links&gt;</xt>
<xt>&lt;rdf:Seq&gt;</xt>
<xt>&lt;rdf:li</xt> <xa>rdf:parseType</xa>=<xs>'Resource'</xs><xt>&gt;</xt>
<xt>&lt;atom:href&gt;</xt>http://juneau.apache.org/juneau.atom<xt>&lt;/atom:href&gt;</xt>
<xt>&lt;atom:rel&gt;</xt>alternate<xt>&lt;/atom:rel&gt;</xt>
<xt>&lt;atom:type&gt;</xt>text/html<xt>&lt;/atom:type&gt;</xt>
<xt>&lt;/rdf:li&gt;</xt>
<xt>&lt;rdf:li</xt> <xa>rdf:parseType</xa>=<xs>'Resource'</xs><xt>&gt;</xt>
<xt>&lt;atom:href&gt;</xt>http://juneau.apache.org/audio/juneau_podcast.mp3<xt>&lt;/atom:href&gt;</xt>
<xt>&lt;atom:rel&gt;</xt>enclosure<xt>&lt;/atom:rel&gt;</xt>
<xt>&lt;atom:type&gt;</xt>audio/mpeg<xt>&lt;/atom:type&gt;</xt>
<xt>&lt;atom:length&gt;</xt>12345<xt>&lt;/atom:length&gt;</xt>
<xt>&lt;/rdf:li&gt;</xt>
<xt>&lt;/rdf:Seq&gt;</xt>
<xt>&lt;/atom:links&gt;</xt>
<xt>&lt;atom:title</xt> <xa>rdf:parseType</xa>=<xs>'Resource'</xs><xt>&gt;</xt>
<xt>&lt;atom:text&gt;</xt>Juneau ATOM specification snapshot<xt>&lt;/atom:text&gt;</xt>
<xt>&lt;/atom:title&gt;</xt>
<xt>&lt;atom:updated&gt;</xt>2016-01-02T03:04:05Z<xt>&lt;/atom:updated&gt;</xt>
<xt>&lt;atom:content</xt> <xa>rdf:parseType</xa>=<xs>'Resource'</xs><xt>&gt;</xt>
<xt>&lt;j.0:namespacebase</xt> <xa>rdf:resource</xa>=<xs>'http://www.apache.org/'</xs><xt>/&gt;</xt>
<xt>&lt;j.0:namespacelang&gt;</xt>en<xt>&lt;/j.0:namespacelang&gt;</xt>
<xt>&lt;atom:type&gt;</xt>xhtml<xt>&lt;/atom:type&gt;</xt>
<xt>&lt;atom:text&gt;</xt>&amp;lt;div xmlns="http://www.w3.org/1999/xhtml"&amp;gt;&amp;lt;p&amp;gt;&amp;lt;i&amp;gt;[Update: Juneau supports ATOM.]&amp;lt;/i&amp;gt;&amp;lt;/p&amp;gt;&amp;lt;/div&amp;gt;<xt>&lt;/atom:text&gt;</xt>
<xt>&lt;/atom:content&gt;</xt>
<xt>&lt;atom:published&gt;</xt>2016-01-02T03:04:05Z<xt>&lt;/atom:published&gt;</xt>
<xt>&lt;/rdf:li&gt;</xt>
<xt>&lt;/rdf:Seq&gt;</xt>
<xt>&lt;/atom:entries&gt;</xt>
<xt>&lt;/rdf:Description&gt;</xt>
<xt>&lt;/rdf:RDF&gt;</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>