Re: [xsl] Table of contents - for-each question

Subject: Re: [xsl] Table of contents - for-each question
From: Wendell Piez <wapiez@xxxxxxxxxxxxxxxx>
Date: Thu, 26 Jan 2006 11:13:15 -0500
Hi,

Catching up,

At 11:34 AM 1/24/2006, llobash@xxxxxxxx wrote:
I am attempting to create a table of contents to include all elements with
<head> tag + all (c01) elements with "series" attribute and (c02 or c03)
elements with "subseries" attributes. c0x tags from Encoded Archival
Description standards, probably not important. Table of contents does
require indentation based on level in heirarchy.

This would be *much* easier if you used the "plain" <c> elements instead of the pernicious c0x elements, whose spurious numbered element typing, as you've discovered, just gets in the way of their @level typing, which is what you really care about -- resulting in the nasty code David showed.


If you can't do that (maybe your writers insist for some unfathomable reason that c0x elements are easier), you can convert c0x elements easily to c elements with a modified identity transform:

<xsl:template match="node()">
  <xsl:copy>
    <xsl:copy-of select="@*"/>
    <xsl:apply-templates select="node()"/>
  </xsl:copy>
</xsl:template>

<xsl:template match="c01 | c02 | c03 | c04 | c05 | c06 | c07 | c08 | c09 | c10">
<c>
<xsl:copy-of select="@*"/>
<xsl:apply-templates select="node()"/>
</c>
</xsl:template>


Then problems like yours (the ToC thing) become much easier and cleaner.

If for some reason you have to convert the opposite way -- an EAD instance that uses plain components into one that uses numbered components -- that's a bit harder; but it's still a stylesheet in two templates.

Cheers,
Wendell


====================================================================== Wendell Piez mailto:wapiez@xxxxxxxxxxxxxxxx Mulberry Technologies, Inc. http://www.mulberrytech.com 17 West Jefferson Street Direct Phone: 301/315-9635 Suite 207 Phone: 301/315-9631 Rockville, MD 20850 Fax: 301/315-8285 ---------------------------------------------------------------------- Mulberry Technologies: A Consultancy Specializing in SGML and XML ======================================================================

Current Thread