<?xml version='1.0' encoding='utf-8'?>
<?xml-stylesheet href="/style/browser.xsl" type="text/xsl"?>
<essay xmlns="http://docbook.org/ns/docbook"
       xmlns:xlink="http://www.w3.org/1999/xlink"
       xmlns:rdf='http://www.w3.org/1999/02/22-rdf-syntax-ns#'
       xmlns:dc='http://purl.org/dc/elements/1.1/'
       xmlns:dcterms="http://purl.org/dc/terms/"
       xmlns:doap="http://usefulinc.com/ns/doap/#"
       xmlns:gal='http://norman.walsh.name/rdf/gallery#'
       version="pto"
       role="project">
<?nwn.doap?>
<info>
<title>XSL Flickr</title>
<abstract>
<para>This is the permanent status page for XSL Flickr.
<phrase role="doap.shortdesc">XSL Flickr is an XSL interface to
the Flickr Services API.</phrase> Version 0.99 is hereby announced.
</para>
</abstract>
<author><personname>
<firstname>Norman</firstname><surname>Walsh</surname>
</personname><email>ndw@nwalsh.com</email></author>
<copyright><year>2005</year><year>2006</year><holder>norman walsh</holder></copyright>
<pubdate>2006-11-29T15:05:58-05:00</pubdate>
<date>$Date: 2006-11-29 15:06:43 -0500 (Wed, 29 Nov 2006) $</date>
<biblioid>projects-2005-xslflickr</biblioid>
<doap:license rdf:resource="http://usefulinc.com/doap/licenses/asl20"/>
</info>

<para xml:id='p1'><phrase role="doap.description"><citetitle>XSL
Flickr</citetitle> is a library of templates that allow
<wikipedia page="Xslt">XSLT</wikipedia> (1.0 or
2.0) stylesheets to access the <link
xlink:href="http://www.flickr.com/services/api/">Flickr Services
API</link>.</phrase></para>

<para xml:id='p2' role="doap.release">Version
<phrase role="doap.release.revision">0.99</phrase>
from <date role="doap.release.created">2006-11-29</date> is the
second release of 
<phrase role="doap.name"><citetitle>XSL Flickr</citetitle></phrase>.
Version 0.99 supports the Flickr Services API as of November, 2006.
</para>

<para xml:id='p19'>This is a
<phrase role="doap.release.branch">beta</phrase> release
implemented in
<phrase role="doap.programming-language">XSLT</phrase>. It should run
on <phrase role="doap.os">any</phrase> platform that supports
XSLT. You'll need an implementation of the
<function><link xlink:href="http://www.exslt.org/exsl/functions/node-set/">exsl:node-set</link></function>
extension function to do anything useful with an XSLT 1.0 processor. You'll
also need an implementation of the
<wikipedia page="Md5">MD5</wikipedia> hashing algorithm if you want to use
any services that require authentication.
The
“<phrase role="doap.shortname">xslflickr</phrase>” package consists
of several files:</para>

<variablelist>
<varlistentry>
<term><link xlink:href="examples/flickr.xsl">flickr.xsl</link>
<emphasis>or</emphasis>
<link xlink:href="examples/flickr1.xsl">flickr1.xsl</link></term>
<listitem>
<para xml:id='p8'>The Flickr Services API library in XSLT 2.0 or 1.0, respectively.
</para>
</listitem>
</varlistentry>
<varlistentry>
<term><link xlink:href="examples/flickr-api.xsl">flickr-api.xsl</link></term>
<listitem>
<para xml:id='p9'>An XSLT <emphasis>2.0</emphasis> stylesheet that generates the
API files from an XML description of the API. You don't actually need this
unless you want to change something about the library files.
</para>
</listitem>
</varlistentry>
<varlistentry>
<term><link xlink:href="examples/flickr-api.xml">flickr-api.xml</link></term>
<listitem>
<para xml:id='p10'>An XML description of the Flickr Services API. I built this
semi-automatically by parsing the API description pages then sprinkling
a few datatypes over it. You don't need this either, unless you want
to rebuild the library files.</para>
</listitem>
</varlistentry>
<varlistentry>
<term><link xlink:href="examples/flickr-test.xsl">flickr-test.xsl</link>
(and <link xlink:href="examples/flickr1-test.xsl">flickr1-test.xsl</link>)</term>
<listitem>
<para xml:id='p11'>Simple test stylesheets that demonstrate the libraries.
</para>
</listitem>
</varlistentry>
<varlistentry>
<term><link xlink:href="examples/xslt.jar">xslt.jar</link>
(or <link xlink:href="examples/xslt.zip">source</link>)</term>
<listitem>
<para xml:id='p20'>A <wikipedia page="Java_%28programming_language%29">Java</wikipedia>
XSLT extension function for generating MD5 hashes. (Only needed to
use services that require authentication.)
</para>
</listitem>
</varlistentry>
</variablelist>

<para xml:id='p12'>To use <citetitle>XSL Flickr</citetitle>, declare a
prefix for the library namespace, import the library, define a global
parameter for your API key and you're set to go. If you want to use
services that require authentication, you'll also have to define
global parameters for your shared secret and authentication
token. (See <link linkend="authentication">Authentication</link>.)</para>

<programlisting><![CDATA[<xsl:stylesheet xmlns:xsl="http://www.w3.org/1999/XSL/Transform"
                xmlns:f="http://www.flickr.com/services/api/"
                exclude-result-prefixes="f"
                …>

<xsl:import href="flickr.xsl"/> <!-- or flickr1.xsl -->

<xsl:param name="f:api_key" select="'YOUR-API-KEY-GOES-HERE'"/>
<xsl:param name="f:shared_secret" select="'YOUR-API-KEY-SHARED-SECRET-GOES-HERE'"/>
<xsl:param name="f:auth_token" select="'YOUR-AUTHENTICATION-TOKEN-GOES-HERE'"/>
…]]></programlisting>

<para xml:id='p13'>Each Flickr method
(<literal>flickr.<replaceable>category</replaceable>.<replaceable>service</replaceable></literal>)
is implemented as a named template
(<literal>f:<replaceable>category</replaceable>.<replaceable>service</replaceable></literal>)
with the parameters specified in the Flickr API. The <parameter>api_key</parameter>
defaults to the global <literal>$f:api_key</literal> parameter
and authentication uses the
global <literal>$f:shared_secret</literal> and
<literal>$f:auth_token</literal> parameters. If the authentication parameters
are provided, they are used for all calls. This means, for example, that
you can exract information about your own private photographs.</para>

<para xml:id='p14'>Each template returns the XML structure returned by the API. In
XSLT 2.0, this can be accessed directly; in XSLT 1.0, you'll have to
put it in a variable and use <function>exsl:node-set</function> to get at
the content.</para>

<para xml:id='p15'>For example, in XSLT 2.0:</para>

<programlisting><![CDATA[<xsl:variable name="user.rsp" as="element()">
  <xsl:call-template name="f:people.findByEmail">
    <xsl:with-param name="find_email" select="'ndw@nwalsh.com'"/>
  </xsl:call-template>
</xsl:varname>]]></programlisting>

<para xml:id='p16'>will initialize <varname>$user.rsp</varname> to the result of
the <literal>flickr.people.findByEmail</literal> method. In this
particular case:</para>

<programlisting><![CDATA[
<rsp stat="ok">
   <user id="24401095@N00" nsid="24401095@N00">
      <username>Norm Walsh</username>
   </user>
</rsp>]]></programlisting>

<para xml:id='p17'>The user ID (among other things) can then be used
in subsequent calls to get more information from the API.</para>

<para xml:id='p18'>Using named templates, instead of functions, does make access
a little awkward, but it seemed like the best way to deal with the large
number of optional parameters. In practice, it hasn't been too much
of a burden.</para>

<para xml:id='p4'><citetitle>XSL Flickr</citetitle> is maintained by
<personname role="doap.maintainer"><firstname>Norman</firstname>
<surname>Walsh</surname></personname>.
Please report any bugs that you encounter.
</para>

<para xml:id='p6'><citetitle>XSL Flickr</citetitle> was first announced on
<date role="doap.created">2005-04-27</date>.</para>

<section xml:id="authentication">
<title>Authentication</title>

<para xml:id='p21'>Some Flickr API services require authentication. Before Flickr
was acquired by Yahoo, this was accomplished by providing a user name
and password. The current authentication API is considerably more
complex.</para>

<para xml:id='p22'>In order to use services that require authentication, you must have
access to an XSLT extension function that can provide MD5 hashes and you must
<link xlink:href="http://www.flickr.com/services/api/keys/apply/">apply for</link>
(and obtain) 
<link xlink:href="http://www.flickr.com/services/api/keys/">your own API key</link>.
(It doesn't make any sense for an entire library to have a single key so I'm
not providing one for <citetitle>XSL Flickr</citetitle> “out of the box”.)</para>

<para xml:id='p23'>After you've obtained an API key, follow the
<link xlink:href="http://www.flickr.com/services/api/misc.userauth.html">Flickr
instructions</link> for obtaining the authentication token
for that key. It's a little tricky. In brief:</para>

<orderedlist>
<listitem>
<para xml:id='p24'>Edit the details for 
<link xlink:href="http://www.flickr.com/services/api/keys/">your key</link>,
providing a “Callback URL” that will show you the parameters passed to
the URI. I used a simple CGI debug script.</para>
</listitem>
<listitem>
<para xml:id='p25'>Construct the
<link xlink:href="http://www.flickr.com/services/api/auth.howto.web.html">login link</link>
and load it in your browser. That will
redirect you to a Flickr page where you grant access to the application.
</para>
</listitem>
<listitem>
<para xml:id='p26'>After you've granted access to your application, you'll be redirected to the
callback URL you provided. From that, extract the “frob” that Flickr sends.
</para>
</listitem>
<listitem>
<para xml:id='p27'>Finally, follow
<link xlink:href="http://www.flickr.com/services/api/auth.howto.web.html">the
instructions</link> for converting the frob to a token and you're done.</para>
</listitem>
</orderedlist>

<para xml:id='p28'>Luckily, you only have to do this once. Armed with the key, the shared
secret (shown on the page with 
<link xlink:href="http://www.flickr.com/services/api/keys/">your key</link>),
and the token, you can begin using authenticated services. The XSL templates
will automatically do the MD5 hashing magic.</para>

<para xml:id='p29'>I've provided a Java extension function that does hashes. If you implement
one for another processor, like <wikipedia page="LibXML">xsltproc</wikipedia>,
you'll have to edit the library a bit. If you make the function available publicly,
let me know and I'll integrate it into a future release.</para>

</section>
<section xml:id="previous">
<title>Releases</title>

<para xml:id='p30'>This is the second release of <citetitle>XSL Flickr</citetitle>. The
following earlier releases were made:</para>

<itemizedlist>
<listitem>
<para role="doap.release" xml:id='p31'><phrase role="doap.release.revision">0.9</phrase>,
from <date role="doap.release.created">2005-04-27</date> was a
<phrase role="doap.release.branch">beta</phrase> release that supported the
old (pre-Yahoo) form of authentication.
</para>
</listitem>
</itemizedlist>
</section>

</essay>
