Zeno's Paradox
July 30, 2003 - Cocoon Image Galleries

Below is some code used to generate image galleries in Oyez. I apologize if it's a bit curt, but I lost the first revision with a browser crash so my patience is at about half. Still, this may be of some use.

Ok, first thing is first: the sitemap. The relevent code in the sitemap.xmap file is:

<map:match pattern="gallery/*/*">
    <map:generate type="file" src="xml/galleries/{1}.xml" />
    <map:transform src="xsl/gallery.xsl">
        <map:parameter name="page" value="{2}../../>
    </map:transform>
    <map:serialize />
</map:match>

This simply reads in an XML file (specified by the first wildcard) and uses XSLT to extract a particular image definition (specified by the second wild card) and render that image with links.

The XML file looks something like this:

<gallery>
    <name>Supreme Court Group Portraits</name>
    <description>
        This is a collection of Supreme Court group portraits compiled by the Oyez Project.
    </description>
    <images>
        <image id="waite-1">
            <name>Waite Court (1874 - 1877)</name>
            <description />
            <src>/gr/court_portraits/waite-1.jpg</src>
            <links>
                <link>
                    <name>Next: Waite Court (1882 - 1887)</name>
                    <url>waite-2</url>
                </link>
            </links>
        </image>
        <image id="waite-2">
            <name>Waite Court (1882 - 1887)</name>
            <description />
            <src>/gr/court_portraits/waite-2.jpg</src>
            <links>
                <link>
                    <name>Next: Waite Court (1888)</name>
                    <url>waite-3</url>
                </link>
            </links>
        </image>
    </images>
</gallery>

I've made the rendering XSLT file available here. It basically looks for a gallery element, then extracts the image element from the XML that has an id attribute matching the second wildcard in the sitemap definition. Thus, a URL of gallery/court/rehnquist will read the image element in the court.xml file that has an id matching "rehnquist".

Enjoy and feel free to post any questions about this...

Posted by br284 at 10:38 AM

Trackbacks

Comments

Post a comment
Name:


Email Address:


URL:


Comments:




Note that by posting a comment on this site using this form or any other software tool, you have agreed to the advertising terms of this site and you agree to submit payment for any advertising in the comment above as outlined in the advertising terms. This applies to ads posted in the URL or Comment fields above.