Not sure about your formatting problem, but I thought i'd mention that you need to add a namespace declaration (at the minimum use the default namespace) on the XML within your atom:content element, otherwise an XML processor is going to assume that your XML is in the Atom namespace and many processors will fail. That said, why not use a standard dialect such as hCard in xhtml to represent your contact objects?
dave On Mon, Dec 7, 2009 at 10:24 AM, Rob Lincourt <[email protected]> wrote: > Hi, > > I am trying to use the Restlet ATOM extension and I cannot figure out why > I am losing the formatting of my <content> element in the Atom document I am > creating. Here is a piece of code from my class that extends ServerResource: > > public Representation getAtomFeed() throws IOException { > Feed f = new Feed(); > Map<String, String> attrs; > > f.setTitle(new Text(MediaType.TEXT_PLAIN, "Feed Title")); > > f.setId("some identifier"); > > Person p = new Person(); > p.setName("me"); > f.getAuthors().add(p); > > Generator gen = new Generator(); > gen.setName("RESTlet"); > gen.setUri(new Reference("http://www.restlet.org")); > gen.setVersion("2.0M6"); > f.setGenerator(gen); > > f.setUpdated(new Date()); > > //Add feed links > //... > > //Perform query that returns a map of strings. > attrs = something.getAttributes(someValue); > > Entry entry = new Entry(); > entry.setUpdated(new Date()); > entry.setId(identifier); > > Content c = new Content(); > c.setToEncode(false); > > c.setInlineContent(new SaxRepresentation(MediaType.APPLICATION_XML) { > �...@override > public void write(XmlWriter writer) { > for(Map.Entry<String, String> e : attrs.entrySet()){ > try { > writer.dataElement(e.getKey(), e.getValue() == null ? "" > : e.getValue()); > } catch (SAXException e1) { > e1.printStackTrace(); > } > } > } > }); > > entry.setContent(c); > > //Add entry links > //... > > f.getEntries().add(entry); > > return f; > } > > > Here is the ATOM feed that this code creates: > <?xml version="1.0" standalone='yes'?> > > <feed xmlns="http://www.w3.org/2005/Atom"> > <author> > <name>me</name> > </author> > <generator uri="http://www.restlet.org" version="2.0M6">RESTlet</generator> > <id>some identifier</id> > <title type="text">Feed Title</title> > <updated>2009-12-07T13:03:04.79Z</updated> > <entry> > <content type="application/xml"><DisplayName>John Smith MD</DisplayName> > <FirstName>John</FirstName> > <LastName>Smith</LastName> > <Suffix>MD</Suffix> > </content> > <id>entry identifier</id> > <updated>2009-12-07T13:03:07.65Z</updated> > </entry> > </feed> > > Is there a way to correct this format issue or I am completely off base with > my resource code. Any help is appreciated. ------------------------------------------------------ http://restlet.tigris.org/ds/viewMessage.do?dsForumId=4447&dsMessageId=2428073

