Danny,
There are two things you could do here.
1. Drop down to the Axiom APIs to add the PI (so the browser can apply
the transform)
Factory factory = Factory.INSTANCE;
Document<Feed> doc = factory.newDocument();
// drop down to the Axiom interfaces
OMFactory omfactory = (OMFactory) factory;
omfactory.createOMProcessingInstruction(
(OMContainer)doc,
"xml-stylesheet",
"href=\"foo.xslt\"");
// then create the root element
factory.newFeed(doc);
doc.writeTo(System.out);
yields:
<?xml version='1.0' encoding='UTF-8'?>
<?xml-stylesheet href="foo.xslt"?>
<a:feed xmlns:a="http://www.w3.org/2005/Atom"/>
2. Apply the XSLT transform on the server. You can apply XSLT
transforms directly to the Abdera objects.
TransformerFactory factory = TransformerFactory.newInstance();
// Prepare the XSLT
Document xslt = Parser.INSTANCE.parse(
XsltExample.class.getResourceAsStream("/test.xslt"));
AbderaSource xsltSource = new AbderaSource(xslt);
Transformer transformer = factory.newTransformer(xsltSource);
// Now let's get the feed we're going to transform
Document<Feed> feed = Parser.INSTANCE.parse(
XsltExample.class.getResourceAsStream("/simple.xml"));
AbderaSource feedSource = new AbderaSource(feed);
// Transform and output
ByteArrayOutputStream out = new ByteArrayOutputStream();
Result result = new StreamResult(out);
transformer.transform(feedSource, result);
System.out.println(out);
Danny Ayers wrote:
> [snip]
> btw, I just put together a utility method for sorting entries (by
> updated) and if requested trimming to a given number of entries. As
> yet untested, so I don't even know if it works let alone whether this
> idiom is a good one.
> see
> http://dannyayers.com/svn/agency/src/org/pragmatron/atommail/Utils.java
>
Cool. I'll take a look either later today or tomorrow.
- James