Greetings to the list,

And thanks to a number of you who answered my questions about getting started with XSLT stylesheets, both on the list and through email. Thanks especially to John Bewley, whose MARC-to-EAD stylesheet I was able to customize and use to convert MARC records for sound recordings into EAD <c02>-level descriptions, and to Mike Ferrando for offering help on the final product. And to Mark Carlson, who basically wrote a stylesheet I used to convert records exported from a local collections management database into component-level EAD descriptions -- and also walked me through how it worked. Thank-you to Michael Fox and Michele Combs for always offering their expertise; aren't archivists the best?

This is starting to sound like an awards show.  :-)  But I really do appreciate everyone's help. I've encountered a problem I can't solve, though (I've tried many different approaches with no success), so I have another question. When I export an XML file of records from our collections management database (developed by a company that's now out of business), I need to sort the many records in the exported XML file before converting them to EAD descriptions. The exported records are very long and complex, so I thought the best way to sort them would be to do an identity transform -- copy all the records in full to the resulting document -- but sort those copied records by the first personal or corporate name in each record. I can't figure out how to do that, simple as it seems. Here's a snippet of the exported source doc. Each "record" is defined by <TitleWork> tags (each TitleWork element set will be converted to an EAD <c01>).

<?xml version="1.0" encoding="UTF-8"?>
<mavis xmlns:xl="http://www.w3.org/1999/xlink" objectCount="10" exportLimit="0">
<rootElement>
    <TitleWork>
        ...[a lot of elements here]...
        <roles>
            <Name-Role>
                <party xl:href="/Name/key/2708" xl:title="Smith, John"/>
                <principalRole>N</principalRole>
                <role xl:href="/Code/key/ROLE//INE" xl:title="Interviewee">INE</role>
            </Name-Role> 
            <Name-Role>
                <party xl:href="/Person/key/279613-1" xl:title="Johnson, Joe"/>
                <principalRole>N</principalRole>
                <role xl:href="/Code/key/ROLE//INE" xl:title="Interviewee">INE</role>
            </Name-Role>   
        </roles>
        ...
    </TitleWork>
... [more TitleWork records here] ...
</mavis>

Sometimes there are 3-4 //party elements in a TitleWork record; I want to sort the complete XML document of records by the name in each TitleWork record's first party element/@xl:title attribute  (i.e., sort on the value of //party[1]/@xl:title). Here's one of my failed stylesheets. I've tried <xsl:for-each> for sorting, too -- no luck.
<?xml version="1.0" encoding="utf-8"?>
<xsl:stylesheet xmlns:xsl="http://www.w3.org/1999/XSL/Transform" version="1.0"
    xmlns:xl="http://www.w3.org/1999/xlink">
    <xsl:output method="xml" encoding="UTF-8" indent="yes" omit-xml-declaration="no"></xsl:output>
    <xsl:strip-space elements="*"></xsl:strip-space>
    <xsl:template match="@*|node()">
        <xsl:copy>
            <xsl:apply-templates select="@*|node()"></xsl:apply-templates>
        </xsl:copy>
    </xsl:template>
    <xsl:template match="//TitleWork">
        <xsl:apply-templates>
            <xsl:sort select="//party[1]/@xl:title"></xsl:sort>
        </xsl:apply-templates>
    </xsl:template>
</xsl:stylesheet>
 
Any help deeply appreciated! Many thanks.

Marsha Maguire