Print

Print


Glad to hear it, Aaron.

 

Just to make it slightly better (since I sent the last example off in a hurry), here it is again:

 

<?xml version="1.0" encoding="UTF-8"?>
<xsl:stylesheet xmlns:xsl="http://www.w3.org/1999/XSL/Transform"
    xmlns:xs="http://www.w3.org/2001/XMLSchema"
    xmlns:math="http://www.w3.org/2005/xpath-functions/math"
    xmlns:xlink="http://www.w3.org/1999/xlink" xmlns:ead="urn:isbn:1-931666-22-9"
    exclude-result-prefixes="#all"
    version="2.0">

   
<xsl:output method="xml" encoding="UTF-8" indent="yes"/>
   
    
<xsl:template match="@*|node()">
       
<xsl:copy>
           
<xsl:apply-templates select="@*|node()"/>
       
</xsl:copy>
   
</xsl:template>
   
    
<xsl:template match="ead:*[@level='series']">
       
<xsl:copy>
           
<xsl:apply-templates select="@*|comment()|processing-instruction()"/>
           
<xsl:apply-templates select="*">
               
<xsl:sort select="ead:did/ead:unitid/number(.)"/>
           
</xsl:apply-templates>
       
</xsl:copy>
   
</xsl:template>
   
</xsl:stylesheet>

 

Two changes:

 

·         I removed the xsl:strip-space line, for the reason that Wendell mentioned

·         I changed the apply-templates select statement slightly so that it should only try to sort children elements of a series (any other elements, like scopeconent, that can’t sort by that value should just re-appear in document order, I think).

 

The same caveats about sorting by the unitid text strings would apply, but as long as you have numbers there, I’d think that it should sort okay.

 

Mark

 

From: Encoded Archival Description List [mailto:[log in to unmask]] On Behalf Of Cusick, Aaron M
Sent: Wednesday, April 09, 2014 3:55 PM
To: [log in to unmask]
Subject: Re: sorting by unitid

 

Hi Mark,

 

That had the effect I was hoping for. Thanks.

 

Aaron Cusick

Digital Services Section
State Archives of North Carolina
4614 Mail Service Center
Raleigh, N.C. 27699-4614
[log in to unmask]
919.807.7347

E-mail correspondence to and from this address may be subject to the North Carolina Public Records Law "NCGS.Ch.132" and may be disclosed to third parties by an authorized state official.

 

From: Encoded Archival Description List [mailto:[log in to unmask]] On Behalf Of Custer, Mark
Sent: Wednesday, April 09, 2014 3:22 PM
To: [log in to unmask]
Subject: Re: sorting by unitid

 

Aaron,

 

I’m not sure that I understand your requirements entirely, but here’s a basic style sheet that might do what you want:

 

<?xml version="1.0" encoding="UTF-8"?>
<xsl:stylesheet xmlns:xsl="http://www.w3.org/1999/XSL/Transform"
    xmlns:xs="http://www.w3.org/2001/XMLSchema"
    xmlns:math="http://www.w3.org/2005/xpath-functions/math"
    xmlns:xlink="http://www.w3.org/1999/xlink" xmlns:ead="urn:isbn:1-931666-22-9"
    exclude-result-prefixes="#all"
    version="2.0">
   
<xsl:strip-space elements="*"/>
   
<xsl:output method="xml" encoding="UTF-8" indent="yes"/>
   
    
<xsl:template match="@*|node()">
       
<xsl:copy>
           
<xsl:apply-templates select="@*|node()"/>
       
</xsl:copy>
   
</xsl:template>
   
    
<xsl:template match="ead:*[@level='series']">
       
<xsl:copy>
           
<xsl:apply-templates select="@*"/>
           
<xsl:apply-templates select="node()">
               
<xsl:sort select="ead:did/ead:unitid/number(.)"/>
           
</xsl:apply-templates>
       
</xsl:copy>
   
</xsl:template>
   
</xsl:stylesheet>

 

Hopefully that will come through in the email okay.  Here’s what it does:

 

·         The first template will just make copies of the entire EAD file

·         The second template will match any level of description that has a level = “series”, and it will then sort those children that have a unitid, after converting the value of that unitid into a number (which should work fine, unless you have roman numerals, multiple unitids at a single level of description, etc.)

 

If that doesn’t help, can you post some more detail about the EAD file(s) that you want to sort?

 

Hopefully that helps,

 

Mark

 

 

From: Encoded Archival Description List [mailto:[log in to unmask]] On Behalf Of Cusick, Aaron M
Sent: Wednesday, April 09, 2014 2:40 PM
To: [log in to unmask]
Subject: sorting by unitid

 

Hello,

 

I have a container list in a finding aid that I would like to be able to sort ascending by the unitids, which are currently out of order. The basic structure is:

 

<c01 level=”series”>

               <c02 level=”file”>

               <did>

               <unittitle>Title</unittitle>

               <unitid>1</unitid>

               </did>

               </c02>

               …

</c01>

 

I am not familiar enough with xslt to make this work on my own. Could anyone assist me by providing a basic stylesheet? Thanks.

 

Aaron Cusick

Digital Services Section
State Archives of North Carolina
4614 Mail Service Center
Raleigh, N.C. 27699-4614
[log in to unmask]
919.807.7347

E-mail correspondence to and from this address may be subject to the North Carolina Public Records Law "NCGS.Ch.132" and may be disclosed to third parties by an authorized state official.