Re: chords and lyrics notations via XSL

Subject: Re: chords and lyrics notations via XSL
From: "G. Ken Holman" <gkholman@xxxxxxxxxxxxxxxxxxxx>
Date: Sat, 06 Nov 1999 22:13:45 -0800
At 99/11/06 23:01 +0100, jakubs@xxxxxxxxxxx wrote:
  I'd like to setup a lyrics and chords archive on the
Internet and I'd like to use XML as the core representation
of the data. The problem I discovered is that I'm not able
to imagine any way, how to process following data:

I don't wanna <chord value="Gb"/>talk about things we've
<chord value="Db/F"/>gone trough, though it's hurting
<chord value="Dbm/Eb"/>me, now it's
histo<chord value="Db"/>ry.

it should be rendered as:

              Gb                      Db/F
I don't wanna talk about things we've gone trough,
                    Abm/Eb             Db
though it's hurting me, now it's history.

is there any way how to do this via XSL stylesheets? (I'll
make the HTML renderer myself, no prob, but I'd like to
support PDF as well...)

I did exactly this with DSSSL because I have a whole lot of sing-along stuff that just needs words and chords. I tried to do it in time for Christmas 1996.


What was fun about the markup for this was I abstracted the note positions out of the key in which it was written in the book ... then, I supplied an argument to the stylesheet of what key I wanted to play the song in, and the song was rendered with all the chords transposed for me.

My approach was to use tables with the cell borders hidden. That way the "Gb" and the word "talk" would align as the left edge of a table cell. I put each line of a stanza in a different table and butted the bottom edge of one table to the top edge of the next. The markup (DTD is below) provided for the chorus to be rendered indented. It looks from the comments as if I had hopes for the ISO SMDL at the time.

Everything started off really smoothly ....

The problem was that the DSSSL renderers didn't (still don't? I haven't tried since December 1996) implement the table-auto-width feature. None of the attempts to try to render to HTML appear to have worked at all (I think I gave up mid-stream when I discovered I couldn't do the PDF rendition). The result was a rendering that technically would be correct if the cell widths were working, but unusable as a song sheet. I marked up two Christmas carols and gave up. It looks from the timestamps like I tried to revive it with CSS the following October, but I don't see that I made any progress.

So, back to your question regarding XSL: I believe all of the renderers today do not yet support table rendering ... so the last step of the process is still missing.

The DTD I created (in SGML, not yet changed for XML) is below. Perhaps you'll find it useful. If you could implement a similar scheme, I could find it useful (another Christmas season is upon us and I'm already committed to play a couple of times). But, I think we'll have to wait until next Christmas because that very last stage of rendering is still missing. Note in the documentation for the DTD that you can use 'egrep' to extract information about the chords of a given key (this was handy when writing in the markup). I'd be curious about the flexibility of XML editors to preprocess user input to get the markup needed for this.

The XSLT to produce HTML or table FOs is really quite straightforward and shouldn't take long to develop. With XT's ability to pass command line information, the automatic chord transposing should be able to work identically as I've implemented in DSSSL.

My plan was to make the DTD freely available but the stylesheets shareware. I will change the public identifier to:

+//ISBN 1-894049::CSL::Music//DTD Simple Chord Music Model//EN

Just for the fun of it, I've zipped up my old DSSSL stylesheets, two sample songs and sample renderings (as they don't work) into a file for download on my site:

http://www.CraneSoftwrights.com/resources/chordsht/chordsht.zip

I may even get the chance to XML'ify this myself ... but right now I'm kinda swamped with work. I'd actually totally forgotten it until your message tonight ... I might just look at it again mid-December if there is interest from anybody who might actually use it.

I hope you find it helps in some small way.

.................. Ken

p.s. glancing at it there are probably some improvements to be made in the model ... but it works as it is ... any suggestions would be very welcome.

Here is an example of one of the songs (the other example shows the use of modifiers for minor chords):

<!DOCTYPE song PUBLIC "-//GKH//DTD Chordsheet//EN">
<!-- 1996-12-13 18:50 -->
<song c>
<title>Joy To The World
<subtitle>A Christmas Carol
<author>Traditional
<start>
<notes><note 1>
<chords><chord 1><chord 6><chord 1><chord 6><chord 1><chord 8><chord 1>
<body>
<stanza>
<line><chord 1>Joy to the world! The Lord <chord 8>is <chord 1>come:
<line><nochord>Let <chord 6>earth re<chord 8>ceive her <chord 1>King;
<line><nochord>Let every heart prepare Him room,
<line><nochord>And heaven and nature sing,
<line><nochord>And <chord 8>heaven and nature sing,
<line><nochord>And <chord 1>heaven, <chord 6>and <chord 1>heaven
<chord 6>and <chord 1>na<chord 8>ture <chord 1>sing.
<stanza>
<line><chord 1>Joy to the world! The <chord 8>Saviour <chord 1>reigns;
<line><nochord>Let <chord 6>men their <chord 8>songs em<chord 1>ploy,
<line><nochord>While fields and floods, rocks, hills and plains,
<line><nochord>Repeat the sounding joy,
<line><nochord>Re<chord 8>peat the sounding joy,
<line><nochord>Re<chord 1>peat, <chord 6>Re<chord 1>peat <chord 6>the
<chord 1>soun<chord 8>ding <chord 1>joy.


This is the DTD:


<!-- Music Chordsheet Model

Version 1996-12-12 03:00 - DRAFT - NOT FOR DISTRIBUTION YET -

PUBLIC "-//GKH//DTD Chordsheet//EN"

        A markup language for chording songsheets.  The chords and notes
        are relative to the base key.

Handy-dandy reference guide for typical semi-tone numeric values:
        (use "egrep :$" to extract entire reference guide from this file)
        (use "egrep :key to extract only a single key guide from this file)
:
               :C :C#  :D :D#  :E  :F :F#  :G :G#  :A :A#  :B  :C         :
        \Chord :C :Db  :D :Eb  :E  :F :Gb  :G :Ab  :A :Bb  :B  :C         :
       Key\                                                          /Key :
          C     1       3       5   6       8      10      12   1   :C    :
5 flats   Db   12   1       3       5   6       8      10      12   :Db   :
2 sharps  D        12   1       3       5   6       8      10       :D    :
3 flats   Eb   10      12   1       3       5   6       8      10   :Eb   :
4 sharps  E        10      12   1       3       5   6       8       :E    :
1 flat    F     8      10      12   1       3       5   6       8   :F    :
1 sharp   G     6       8      10      12   1       3       5   6   :G    :
4 flats   Ab    5   6       8      10      12   1       3       5   :Ab   :
3 sharps  A         5   6       8      10      12   1       3       :A    :
2 flats   Bb    3       5   6       8      10      12   1       3   :Bb   :
                C  C#   D  D#   E   F  F#   G  G#   A  A#   B   C         :
                C  Db   D  Eb   E   F  Gb   G  Ab   A  Bb   B   C         :

Examples: - the chord Fm7   in the key of C is <chord 6 mod="m7">
          - the chord C#dim in the key of E is <chord 10 mod="dim">
          - the chord F#    in the key of F is <chord 2>

NB:     This is not (yet) an implementation of SMDL.  This is a simple
        markup language using terminology coined by someone with very
        little to no music theory (just a lot of experience strumming
        guitar chords).

Heritage: This DTD and associated DSSSL Stylesheet was developed
          for the music programme at Trinity United Church,
          in Kars, Ontario, CANADA K0A-2E0.

Status: This markup language specification is in the public domain,
        and the associated DSSSL stylesheet is in the shareware domain.
-->

<!ELEMENT song - O ( title, subtitle?, author*, start?, body )
                    --Song--
                    >

<!ENTITY % st -- Semi-tone --
               "st ( 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12 ) #REQUIRED
                -- Semi-tone --
                -- The note within the key: --
                -- 1 == tonic --
                -- 3 == super-tonic --
                -- 5 == mediant --
                -- 6 == subdominant --
                -- 8 == dominant --
                -- 10 == submediant --
                -- 12 == leading tone --"
                >

<!ENTITY % key -- Key --
               "key ( C, G, D, A, E, F, Bb, Eb, Ab, Db ) #IMPLIED
                -- Key --
                -- One key the song is known to have been played in. --
                -- C == no flats or sharps --
                -- G == one sharp --
                -- D == two sharps --
                -- A == three sharps --
                -- E == four sharps --
                -- F == one flat --
                -- Bb == two flats --
                -- Eb == three flats --
                -- Ab == four flats --
                -- Db == five flats --"
                >

<!ENTITY % mod -- Modifier --
               "mod CDATA #IMPLIED
                -- Modifier --
                -- Added to change the chord from a major chord --"
                >

<!ATTLIST song  -- Attributes of a Song --
                %key;
                >

<!ELEMENT title - O ( #PCDATA )
                    --Song Title--
                    >

<!ELEMENT subtitle - O ( #PCDATA )
                    --Song Subtitle--
                    >

<!ELEMENT author - O ( #PCDATA )
                    --Song Author--
                    >

<!ELEMENT start - O ( notes | chords )+
                    --Startup Information--
                    >

<!ELEMENT notes - O ( note+ )
                    --Collection of Notes--
                    >

<!ELEMENT note - O EMPTY
                    --A single note--
                    >

<!ATTLIST note  -- Attributes of a Note --
                %st;
                >

<!ELEMENT chords - O ( chord+ )
                    --Collection of Chords--
                    >

<!ELEMENT body - O ( stanza | chorus )+
                -- Song Body --
                >

<!ELEMENT chorus - O ( stanza+ )
                -- Chorus --
                -- A repeating set of stanzas --
                >

<!ELEMENT stanza - O ( chord*, line+, chord* )
                -- Stanza --
                -- A collection of lines --
                >

<!ELEMENT line - O  ( nochord | chord )+
                -- Song Line --
                -- A line of text --
                >

<!ELEMENT nochord O O ( #PCDATA )
                -- Non-chorded text --
                -- Text in a line without a chord --
                >

<!ELEMENT chord - O ( #PCDATA )
                --A chorded portion of text--
                --Text in a line with a chord--
                >

<!ATTLIST chord -- Attributes of a Chord --
                %st;
                %mod;
                >

<!-- end of model -->


-- G. Ken Holman mailto:gkholman@xxxxxxxxxxxxxxxxxxxx Crane Softwrights Ltd. http://www.CraneSoftwrights.com/s/ Box 266, Kars, Ontario CANADA K0A-2E0 +1(613)489-0999 (Fax:-0995) Web site: XSL/XML/DSSSL/SGML services, training, libraries, products. Practical Transformation Using XSLT and XPath ISBN 1-894049-02-0 Next instructor-led training: 1999-11-08, 1999-11-09, 1999-12-05/06, - 1999-12-07, 2000-02-27/28, 2000-05-11/12, 2000-05-15


XSL-List info and archive: http://www.mulberrytech.com/xsl/xsl-list



Current Thread