abdera-dev mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From James M Snell <jasn...@gmail.com>
Subject Re: Conneg & styling PIs
Date Sun, 06 Aug 2006 16:17:13 GMT

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;

    // then create the root element



    <?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(
    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(
    AbderaSource feedSource = new AbderaSource(feed);

    // Transform and output
    ByteArrayOutputStream out = new ByteArrayOutputStream();
    Result result = new StreamResult(out);
    transformer.transform(feedSource, result);

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

View raw message