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

Reply via email to