XChords samples (tutorial)

last update: 27th September 2005

Source XML could be library of chords or just one chord. Each format has its own schema:
Library of chords is specified in XChords Library XML Schema.
Exactly one chord is specified in XChords XML Schema.

All these samples were rewritten for XChords XML Schema. (previously it was for xchords0.1 and Library DTD.) All these pictures were generated by online XChords application. Try it. (the SVG images were generated, then I took screenshots of the pictures and saved as PNG)

Plain chord

Let's start with an easy example. XChords XML definition

As you can see, the XML file consist of chordlibrary element, which can contain number of chord elements. Each chord can have multiple positions how to play that chord, in this example we define just one. Position is described by fret numbers on appropriate string. If there is no fret attribute, there will be no circle.

To be absolutely clear, the example could be shortened to this minimal description.

And this is screenshot of what was generated:

Chord with fingers

It is possible to define fingers, which should hold the frets - XChords XML definition (minimal version)

And to be absolutely clear ;) - there is parameter in the template, which could turn on or off finger numbers, so you don't have to maintain two versions.


Don't play this string!

Some chords are not played on all strings, these strings are marked with X. Typical is D chord. XChords XML definition

The state attribute can have three values. 'ok' (or omitted) is default, 'no' means not playing string and 'opt' means optional add on (next sample).


Optional add on

Sometimes - as in 7 chords - there is possibility to play or not to play specific string and fret. XChords XML definition

That's the value of 'opt' in state attribute. Note, that there is no finger number in this situation. I don't think, it is necessary.


Barre chords

The previous examples were pretty easy, weren't they? Now we have grown a little and we met F chord. The F chord is played classicaly with barre - one finger holds all strings. Here is the XChords XML definition.

The barre element has fret attribute, finger attribute - mostly 1, and also low and high attribute. These last two attributes denotes "border strings". As you will see in next examples, barre doesn't have to be hold across all strings...

Screenshot (one with fingers generated, one without, from the same definition):

Not full barre

Here it goes. We can define barre just for four strings for example, look at this XChords XML definition.

Well, the chord is messy. I think, we don't have to talk about it for long, it is just an example.


Multiple barre

Skilled people use also multiple barre (oh my poor hand..). see XChords XML definition.

You can notice the letter T as shortage for Thumb in fret attribute.


Last word on barre

Each barre could be on his own fret. It is completely independent. XChords XML definition.


Multiple positions

At the beginning, I was talking about positions. Each chord can have several positions on guitar neck. You can write all of them and display together on one diagram. You don't have to. You can define two chords, each with one position and display each on its own diagram... It depends on you. You can do, what you want. (or - You gotta do, what You gotta do. ;) )

Let's look at this XChords XML Definition. Hello, G chord.

As you can see, position element has base attribute. Value of this attribute is shown in the left with Roman letters. Positions are divided by some nice looking separator (thanks djk).

Fret numbers in the XML means positions on real guitar neck. Not the draw position. The draw position is calculated from already filled space and base attribute. I hope, it is clear enough.

Screenshot: (again with and without finger numbers)

And that's all. I hope that you've found out what it's all about.