001/* 002 * Licensed to the Apache Software Foundation (ASF) under one or more 003 * contributor license agreements. See the NOTICE file distributed with 004 * this work for additional information regarding copyright ownership. 005 * The ASF licenses this file to You under the Apache License, Version 2.0 006 * (the "License"); you may not use this file except in compliance with 007 * the License. You may obtain a copy of the License at 008 * 009 * http://www.apache.org/licenses/LICENSE-2.0 010 * 011 * Unless required by applicable law or agreed to in writing, software 012 * distributed under the License is distributed on an "AS IS" BASIS, 013 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 014 * See the License for the specific language governing permissions and 015 * limitations under the License. 016 */ 017package org.apache.juneau.examples.bean.atom; 018 019import org.apache.juneau.xml.*; 020 021/** 022 * Atom feed XML example. 023 * 024 */ 025public class AtomXmlExample { 026 027 /** 028 * XML Atom feed example. 029 * 030 * @param args Unused. 031 * @throws Exception Unused. 032 */ 033 @SuppressWarnings("unused") 034 public static void main(String[] args) throws Exception { 035 036 var feed = AtomFeed.getAtomFeed(); 037 038 // Example with no namespaces 039 // Create a serializer with readable output, no namespaces yet. 040 var s = XmlSerializer.create().sq().ws().build(); 041 042 //Produces 043 /** 044 *<feed> 045 *<id> tag:juneau.apache.org</id> 046 *<link href='http://juneau.apache.org/' rel='alternate' type='text/html' hreflang='en'/> 047 *<link href='http://juneau.apache.org/feed.atom' rel='self' type='application/atom+xml'/> 048 *<title type='text'>Juneau ATOM specification</title> 049 *<updated>2016-01-02T03:04:05Z</updated> 050 *<generator uri='http://juneau.apache.org/' version='1.0'>Juneau</generator> 051 *<subtitle type='html'>Describes <em>stuff</em> about Juneau</subtitle> 052 *<entry> 053 * <author> 054 * <name>Jane Smith</name> 055 * <uri>http://juneau.apache.org/</uri> 056 * <email>janesmith@apache.org</email> 057 * </author> 058 * <contributor> 059 * <name>John Smith</name> 060 * </contributor> 061 * <id>tag:juneau.apache.org</id> 062 * <link href='http://juneau.apache.org/juneau.atom' rel='alternate' type='text/html'/> 063 * <link href='http://juneau.apache.org/audio/juneau_podcast.mp3' rel='enclosure' type='audio/mpeg' length='12345'/> 064 * <title>Juneau ATOM specification snapshot</title> 065 * <updated>2016-01-02T03:04:05Z</updated> 066 * <content base='http://www.apache.org/' lang='en' type='xhtml'> 067 * <div xmlns="http://www.w3.org/1999/xhtml"><p><i>[Update: Juneau supports ATOM.]</i></p></div> 068 * </content> 069 * <published>2016-01-02T03:04:05Z</published> 070 *</entry> 071 *</feed> 072 */ 073 //Serialize to ATOM/XML 074 var atomXml = s.serialize(feed); 075 076 /** 077 * Produces 078 * <feed> 079 * <link hreflang='en' rel='alternate' href='http://juneau.apache.org' type='text/html'/> 080 * <link rel='self' href='http://juneau.apache.org/feed.atom' type='application/atom+xml'/> 081 * <title>Juneau ATOM specification</title> 082 * <updated>2016-01-02T03:04:05Z</updated> 083 * <id>tag:juneau.apache.org</id> 084 * <subtitle type='html'>Describes <em>stuff</em> about Juneau</subtitle> 085 * <generator version='1.0' uri='http://juneau.apache.org'>Juneau</generator> 086 * <entry> 087 * <link rel='alternate' href='http://juneau.apache.org/juneau.atom' type='text/html'/> 088 * <link rel='enclosure' href='http://juneau.apache.org/audio/juneau_podcast.mp3' type='audio/mpeg' length='1337'/> 089 * <author> 090 * <uri>http://juneau.apache.org</uri> 091 * <email>janesmith@apache.org</email> 092 * <name>Jane Smith</name> 093 * </author> 094 * <contributor> 095 * <name>John Smith</name> 096 * </contributor> 097 * <title>Juneau ATOM specification snapshot</title> 098 * <updated>2016-01-02T03:04:05Z</updated> 099 * <id>tag:juneau.sample.com,2013:1.2345</id> 100 * <published>2016-01-02T03:04:05Z</published> 101 * <content lang='en' base='http://www.apache.org/' type='xhtml'><div><p><i>[Update: Juneau supports ATOM.]</i></p></div></content> 102 * </entry> 103 * </feed> 104 */ 105 // Create a serializer with readable output, no namespaces yet. 106 var ns = XmlSerializer.create().sq().ws().build(); 107 108 // Serialize to ATOM/XML 109 atomXml = ns.serialize(feed); 110 } 111}