Table of Contents

dpkq examples

Working examples are provided with the dpkq package. Here are some of this example files (all the example files can be seen at at http://hg.savannah.gnu.org/hgweb/epeios/file/tip/tools/dpkq/Test). You will see some tags/attributes prefixed with xpp: in some files. This is because this files goes through the Epeios XML preprocessor.

There are also project files (i. e. files with .xprj extension) you can give as argument to dpkq. Records stored in the Elements.xml (more precisely in its element_.xml sub-file) data file refers directly or indirectly to records of the other data files.

The Viewer entry in the project files (defined in the common.xprj file) should actually launch a Web browser to display the output XML file after applying the XSL file on it. As there is no cross-platform standard way to do this, the Viewer tag contains a command which displays the content of the available markers. Modify this entry at your convenience, but remember that some Web browser does not perform the XSL transformation, apparently due to some security issues. In this case, you can call a script which applies explicitly the XSL transformation, and then opens the Web browser with the resulting HTML file…

Context

As a musician, I use dpkq to work my scores. For this, I created following tables :

In the examples, for simplification purpose, the Voices table and Segments table are not present. Also, the final result show only some formatted line of text per record, instead of showing a scan of page(s) of the score corresponding to the measures of segment as in my use of dpkq.

Files

Miscellaneous files

common.xprj
<?xml version="1.0" encoding="utf-8"?>
<xpp:bloc xmlns:xpp="http://q37.info/ns/xpp/">
	<Output>Result.xml</Output>
	<Viewer>echo Rcd: $RI$, '$RL$'; Tbl: $TI$, '$TL$'; D: '$Data$'; O: '$Output$'; XSL: '$XSL$'</Viewer>
</xpp:bloc>
Composers.xml
<?xml version="1.0" encoding="utf-8"?>
<dpk:data xmlns:dpk="http://q37.info/ns/dpk" xmlns:xpp="http://q37.info/ns/xpp">
	<xpp:expand href="composers_.xml"/>
</dpk:data>
composers_.xml
<?xml version="1.0" encoding="utf-8"?>
<xpp:bloc xmlns:dpk="http://q37.info/ns/dpk" xmlns:xpp="http://q37.info/ns/xpp">
	<dpk:table label="Composers">
		<dpk:content DefaultRecordLabelTag="Surname">
			<Composer dpk:label="Bach JC">
				<Surname>Bach</Surname>
				<FirstNames>Johann Christian</FirstNames>
			</Composer>
			<Composer dpk:label="Bach JS">
				<Surname>Bach</Surname>
				<FirstNames>Johann Sebastian</FirstNames>
			</Composer>
			<Composer>
				<Surname>Beethoven</Surname>
				<FirstNames>Ludwig Van</FirstNames>
			</Composer>
			<Composer>
				<Surname>Brahms</Surname>
				<FirstNames>Johannes</FirstNames>
			</Composer>
			<Composer>
				<Surname>Chopin</Surname>
				<FirstNames>Frédéric</FirstNames>
			</Composer>
			<Composer >
				<Surname>Debussy</Surname>
				<FirstNames>Claude</FirstNames>
			</Composer>
			<Composer>
				<Surname>Fauré</Surname>
				<FirstNames>Gabriel</FirstNames>
			</Composer>
			<Composer>
				<Surname>Gershwin</Surname>
				<FirstNames>George</FirstNames>
			</Composer>
			<Composer>
				<Surname>Granados</Surname>
				<FirstNames>Enrique</FirstNames>
			</Composer>
			<Composer>
				<Surname>Grieg</Surname>
				<FirstNames>Edvard</FirstNames>
			</Composer>
			<Composer>
				<Surname>Liszt</Surname>
				<FirstNames>Franz</FirstNames>
			</Composer>
			<Composer dpk:label="Mendelssohn">
				<Surname>Mendelssohn Bartholdy</Surname>
				<FirstNames>Felix</FirstNames>
			</Composer>
			<Composer>
				<Surname>Mozart</Surname>
				<FirstNames>Wolfgang Amadeus</FirstNames>
			</Composer>
			<Composer>
				<Surname>Perterson</Surname>
				<FirstNames>Oscar</FirstNames>
			</Composer>
			<Composer>
				<Surname>Prokofiev</Surname>
				<FirstNames>Sergueï</FirstNames>
			</Composer>
			<Composer>
				<Surname>Rachmaninov</Surname>
				<FirstNames>Sergueï</FirstNames>
			</Composer>
			<Composer>
				<Surname>Ravel</Surname>
				<FirstNames>Maurice</FirstNames>
			</Composer>
			<Composer>
				<Surname>Schubert</Surname>
				<FirstNames>Franz</FirstNames>
			</Composer>
			<Composer>
				<Surname>Schumann</Surname>
				<FirstNames>Robert</FirstNames>
			</Composer>
			<Composer>
				<Surname>Simon</Surname>
				<FirstNames>Claude</FirstNames>
			</Composer>
			<Composer>
				<Surname>Tchaïkovski</Surname>
				<FirstNames>Piotr Ilitch</FirstNames>
			</Composer>
			<Composer>
				<Surname>Widor</Surname>
				<FirstNames>Charles-Marie</FirstNames>
			</Composer>
		</dpk:content>
	</dpk:table>
</xpp:bloc>
Composers.xsl
<?xml version="1.0" encoding="UTF-8"?>
<xsl:stylesheet version="1.0"
				xmlns="http://www.w3.org/1999/xhtml"
				xmlns:xsl="http://www.w3.org/1999/XSL/Transform"
				xmlns:dpk="http://q37.info/ns/dpk/">
	<xsl:output method="html" indent="yes" encoding="UTF-8"/>
	<xsl:template match="Picking">
		<xsl:element name="head">
			<xsl:element name="title">
				<xsl:text>Composer</xsl:text>
				<xsl:if test="Data/Composers/@Amount&gt;1">
					<xsl:text>s</xsl:text>
				</xsl:if>
			</xsl:element>
		</xsl:element>
		<xsl:element name="body">
			<xsl:apply-templates select="Data"/>
		</xsl:element>
	</xsl:template>
	<xsl:template match="Data">
		<xsl:apply-templates select="Composers"/>
	</xsl:template>
	<xsl:template match="Composers">
		<xsl:if test="@Amount!=1">
			<xsl:apply-templates select="Composer" mode="Index"/>
			<hr />
		</xsl:if>
		<xsl:apply-templates select="Composer"/>
	</xsl:template>
	<xsl:template match="Composer" mode="Index">
		<xsl:element name="a">
			<xsl:attribute name="href">
				<xsl:text>#</xsl:text>
				<xsl:value-of select="generate-id()"/>
			</xsl:attribute>
			<xsl:value-of select="Surname"/>
			<xsl:text>, </xsl:text>
			<xsl:value-of select="FirstNames"/>
		</xsl:element>
		<br />
	</xsl:template>
	<xsl:template match="Composer">
		<xsl:element name="a">
			<xsl:attribute name="name">
				<xsl:text>#</xsl:text>
				<xsl:value-of select="generate-id()"/>
			</xsl:attribute>
			<xsl:value-of select="FirstNames"/>
			<xsl:text> </xsl:text>
			<xsl:choose>
				<xsl:when test="@dpk:label">
					<xsl:value-of select="Surname"/>
					<xsl:text> [</xsl:text>
					<span style="font-style: oblique;">
						<xsl:value-of select="@dpk:label"/>
					</span>
					<xsl:text>]</xsl:text>
				</xsl:when>
				<xsl:otherwise>
					<span style="font-style: oblique;">
						<xsl:value-of select="Surname"/>
					</span>
				</xsl:otherwise>
			</xsl:choose>
		</xsl:element>
		<hr />
	</xsl:template>
</xsl:stylesheet>
Composers.xprj
<?xml version="1.0" encoding="utf-8"?>
<Projects>
	<Project target="dpkq">
		<Parameters>
			<xpp:expand xmlns:xpp="http://q37.info/ns/xpp/" href="common.xprj"/>
			<Data>Composers.xml</Data>
			<XSL>Composers.xsl</XSL>
			<Context>.Composers.xml</Context>
			<SessionMaxDuration>600</SessionMaxDuration>
		</Parameters>
	</Project>
</Projects>
Instrumentations.xml
<?xml version="1.0" encoding="utf-8"?>
<dpk:data xmlns:dpk="http://q37.info/ns/dpk" xmlns:xpp="http://q37.info/ns/xpp">
	<xpp:expand href="instrumentations_.xml"/>
</dpk:data>
instrumentations_.xml
<?xml version="1.0" encoding="utf-8"?>
<xpp:bloc xmlns:dpk="http://q37.info/ns/dpk/" xmlns:xpp="http://q37.info/ns/xpp">
	<dpk:table label="Instrumentations">
		<dpk:content>
			<Instrumentation dpk:label="2 hands">
				<Name>Piano two hands</Name>
			</Instrumentation>
			<Instrumentation dpk:label="4 hands">
				<Name>Piano four hands</Name>
			</Instrumentation>
			<Instrumentation dpk:label="Classical">
				<Name>Classical organ</Name>
			</Instrumentation>
			<Instrumentation dpk:label="Hammond">
				<Name>Hammond organ</Name>
			</Instrumentation>
		</dpk:content>
	</dpk:table>
</xpp:bloc>
Instrumentations.xsl
<?xml version="1.0" encoding="UTF-8"?>
<xsl:stylesheet version="1.0"
				xmlns="http://www.w3.org/1999/xhtml"
				xmlns:xsl="http://www.w3.org/1999/XSL/Transform"
				xmlns:dpk="http://q37.info/ns/dpk/">
	<xsl:output method="html" indent="yes" encoding="UTF-8"/>
	<xsl:template match="Picking">
		<xsl:element name="head">
			<xsl:element name="title">
				<xsl:text>Instrumentation</xsl:text>
				<xsl:if test="Data/Instrumentations/@Amount&gt;1">
					<xsl:text>s</xsl:text>
				</xsl:if>
			</xsl:element>
		</xsl:element>
		<xsl:element name="body">
			<xsl:apply-templates select="Data"/>
		</xsl:element>
	</xsl:template>
	<xsl:template match="Data">
		<xsl:apply-templates select="Instrumentations"/>
	</xsl:template>
	<xsl:template match="Instrumentations">
		<xsl:if test="@Amount!=1">
			<xsl:apply-templates select="Instrumentation" mode="Index"/>
			<hr />
		</xsl:if>
		<xsl:apply-templates select="Instrumentation"/>
	</xsl:template>
	<xsl:template match="Instrumentation" mode="Index">
		<xsl:element name="a">
			<xsl:attribute name="href">
				<xsl:text>#</xsl:text>
				<xsl:value-of select="generate-id()"/>
			</xsl:attribute>
			<xsl:value-of select="Name"/>
		</xsl:element>
		<br />
	</xsl:template>
	<xsl:template match="Instrumentation">
		<xsl:element name="a">
			<xsl:attribute name="name">
				<xsl:text>#</xsl:text>
				<xsl:value-of select="generate-id()"/>
			</xsl:attribute>
			<xsl:value-of select="Name"/>
			<xsl:if test="@dpk:label">
				<xsl:text> (</xsl:text>
				<span style="font-style: oblique;">
					<xsl:value-of select="@dpk:label"/>
				</span>
				<xsl:text>)</xsl:text>
			</xsl:if>
		</xsl:element>
		<hr />
	</xsl:template>
</xsl:stylesheet>
Instrumentations.xprj
<?xml version="1.0" encoding="utf-8"?>
<Projects>
	<Project target="dpkq">
		<Parameters>
			<xpp:expand xmlns:xpp="http://q37.info/ns/xpp/" href="common.xprj"/>
			<Data>Instrumentations.xml</Data>
			<XSL>Instrumentations.xsl</XSL>
			<Context>.Instrumentations.xml</Context>
			<SessionMaxDuration>600</SessionMaxDuration>
		</Parameters>
	</Project>
</Projects>
Collections.xml
<?xml version="1.0" encoding="utf-8"?>
<dpk:data xmlns:dpk="http://q37.info/ns/dpk/"
          xmlns:xpp="http://q37.info/ns/xpp/">
	<xpp:expand href="collections_.xml"/>
</dpk:data>
collections_.xml
<?xml version="1.0" encoding="utf-8"?>
<xpp:bloc xmlns:dpk="http://q37.info/ns/dpk" xmlns:xpp="http://q37.info/ns/xpp">
	<xpp:expand href="composers_.xml"/>
	<xpp:expand href="instrumentations_.xml"/>
	<dpk:table label="Collections">
		<dpk:aliases label="%RL%" TableLabel="Instrumentations"/>
		<dpk:aliases label="%RL%" TableLabel="Composers">
			<dpk:alias label="C" TableLabel="Composers"/>
		</dpk:aliases>
		<dpk:content DefaultRecordLabelTag="Title">
			<Collection dpk:label="Corner">
				<dpk:insert RecordAlias="Debussy"/>
				<dpk:insert RecordAlias="2 hands"/>
				<Title>Children's Corner</Title>
			</Collection>
			<Collection dpk:label="Romances">
				<dpk:insert TableAlias="C" RecordLabel="Fauré"/>
				<dpk:insert RecordAlias="2 hands"/>
				<Title>3 Romances sans Paroles</Title>
				<Opus>17</Opus>
			</Collection>
			<Collection dpk:label="Fantaisies">
				<dpk:insert RecordAlias="Brahms"/>
				<dpk:insert RecordAlias="2 hands"/>
				<Title>7 Fantaisies</Title>
				<Opus>116</Opus>
			</Collection>
			<Collection dpk:label="Saisons">
				<dpk:insert RecordAlias="Tchaïkovski"/>
				<dpk:insert RecordAlias="2 hands"/>
				<Title>Les Saisons</Title>
				<Opus>37a</Opus>
			</Collection>
			<Collection dpk:label="Preludes 1">
				<dpk:insert RecordAlias="Debussy"/>
				<dpk:insert RecordAlias="2 hands"/>
				<Title>Préludes - Premier livre</Title>
			</Collection>
			<Collection dpk:label="Lyriques 12">
				<dpk:insert RecordAlias="Grieg"/>
				<dpk:insert RecordAlias="2 hands"/>
				<Title>Pièces lyriques</Title>
				<Opus>12</Opus>
			</Collection>
			<Collection dpk:label="Arabesques">
				<dpk:insert RecordAlias="Debussy"/>
				<dpk:insert RecordAlias="2 hands"/>
				<Title>2 arabesques</Title>
				<Opus Catalogue="L">66</Opus>
			</Collection>
			<Collection>
				<dpk:insert RecordAlias="Schumann"/>
				<dpk:insert RecordAlias="2 hands"/>
				<Title>Albumblätter</Title>
				<Opus>124</Opus>
			</Collection>
			<Collection dpk:label="Preludes 28">
				<dpk:insert RecordAlias="Chopin"/>
				<dpk:insert RecordAlias="2 hands"/>
				<Title>24 préludes</Title>
				<Opus>28</Opus>
			</Collection>
			<Collection dpk:label="Espagnoles">
				<dpk:insert RecordAlias="Granados"/>
				<dpk:insert RecordAlias="2 hands"/>
				<Title>12 danses espagnoles</Title>
			</Collection>
			<Collection dpk:label="Sentimentales">
				<dpk:insert RecordAlias="Schubert"/>
				<dpk:insert RecordAlias="2 hands"/>
				<Title>Valses sentimentales</Title>
				<Opus>50</Opus>
				<Opus Catalogue="D">779</Opus>
			</Collection>
			<Collection>
				<dpk:insert RecordAlias="Liszt"/>
				<dpk:insert RecordAlias="2 hands"/>
				<Title>Consolations</Title>
				<Opus Catalogue="S">172</Opus>
			</Collection>
			<Collection dpk:label="Mazurkas 4">
				<dpk:insert RecordAlias="Chopin"/>
				<dpk:insert RecordAlias="2 hands"/>
				<Title>4 Mazurkas</Title>
				<Opus>17</Opus>
			</Collection>
			<Collection dpk:label="Liebesträume">
				<dpk:insert RecordAlias="Liszt"/>
				<dpk:insert RecordAlias="2 hands"/>
				<Title>Liebesträume</Title>
				<Opus Catalogue="S/G">541</Opus>
			</Collection>
			<Collection dpk:label="Faschingsschwank">
				<dpk:insert RecordAlias="Schumann"/>
				<dpk:insert RecordAlias="2 hands"/>
				<Title>Faschingsschwank aus Wien</Title>
				<Opus>26</Opus>
			</Collection>
			<Collection dpk:label="Piano bar">
				<dpk:insert RecordAlias="2 hands"/>
				<Title>Best of piano bar</Title>
			</Collection>
			<Collection dpk:label="Liebeslieder">
				<dpk:insert RecordAlias="Brahms"/>
				<dpk:insert RecordAlias="4 hands"/>
				<Title>Liebeslieder Waltzes</Title>
				<Opus>52a</Opus>
			</Collection>
			<Collection dpk:label="Sonates120">
				<dpk:insert RecordAlias="Brahms"/>
				<dpk:insert RecordAlias="2 hands"/>
				<Title>Sonates pour clarinette et piano</Title>
				<Opus>120</Opus>
			</Collection>
			<Collection dpk:label="Jazz Hammond">
				<dpk:insert RecordAlias="Hammond"/>
				<Title>Home Organist Library Volume 7 - Jazz Pieces</Title>
			</Collection>
			<Collection dpk:label="Big Band Hammond">
				<dpk:insert RecordAlias="Hammond"/>
				<Title>Big Band Specials for Organ</Title>
			</Collection>
			<Collection dpk:label="Oye">
				<dpk:insert RecordAlias="Ravel"/>
				<dpk:insert RecordAlias="4 hands"/>
				<Title>Ma mère l'Oye</Title>
			</Collection>
			<Collection dpk:label="PJazzExercises">
				<dpk:insert RecordAlias="Perterson"/>
				<dpk:insert RecordAlias="2 hands"/>
				<Title>Jazz exercises</Title>
			</Collection>
			<Collection dpk:label="Chopin69">
				<dpk:insert RecordAlias="Chopin"/>
				<dpk:insert RecordAlias="2 hands"/>
				<Title>2 valses</Title>
				<Opus>69</Opus>
			</Collection>
			<Collection dpk:label="Brahms118">
				<dpk:insert RecordAlias="Brahms"/>
				<dpk:insert RecordAlias="2 hands"/>
				<Title>Six pieces for Piano</Title>
				<Opus>118</Opus>
			</Collection>
		</dpk:content>
	</dpk:table>
</xpp:bloc>
Collections.xsl
<?xml version="1.0" encoding="UTF-8"?>
<xsl:stylesheet version="1.0"
				xmlns="http://www.w3.org/1999/xhtml"
				xmlns:xsl="http://www.w3.org/1999/XSL/Transform"
				xmlns:dpk="http://q37.info/ns/dpk/">
	<xsl:output method="html" indent="yes" encoding="UTF-8"/>
	<xsl:template match="Picking">
		<xsl:element name="head">
			<xsl:element name="title">
				<xsl:text>Collection</xsl:text>
				<xsl:if test="Data/Collections/@Amount&gt;1">
					<xsl:text>s</xsl:text>
				</xsl:if>
			</xsl:element>
		</xsl:element>
		<xsl:element name="body">
			<xsl:apply-templates select="Data"/>
		</xsl:element>
	</xsl:template>
	<xsl:template match="Data">
		<xsl:apply-templates select="Collections"/>
	</xsl:template>
	<xsl:template match="Collections">
		<xsl:if test="@Amount!=1">
			<xsl:apply-templates select="Collection" mode="Index"/>
			<hr />
		</xsl:if>
		<xsl:apply-templates select="Collection"/>
	</xsl:template>
	<xsl:template match="Collection" mode="Index">
		<xsl:element name="a">
			<xsl:attribute name="href">
				<xsl:text>#</xsl:text>
				<xsl:value-of select="generate-id()"/>
			</xsl:attribute>
			<xsl:apply-templates select="Composer"/>
			<xsl:value-of select="Title"/>
		</xsl:element>
		<br />
	</xsl:template>
	<xsl:template match="Composer">
		<span style="font-style: oblique;">
			<xsl:value-of select="FirstNames"/>
			<xsl:text> </xsl:text>
			<xsl:value-of select="Surname"/>
		</span>
		<xsl:text> : </xsl:text>
	</xsl:template>
	<xsl:template match="Collection">
		<xsl:element name="a">
			<xsl:attribute name="name">
				<xsl:text>#</xsl:text>
				<xsl:value-of select="generate-id()"/>
			</xsl:attribute>
			<xsl:apply-templates select="Instrumentation"/>
			<br />
			<xsl:apply-templates select="Composer"/>
			<xsl:element name="b">
				<xsl:value-of select="Title"/>
				<xsl:if test="@dpk:label">
					<xsl:text> [</xsl:text>
					<span style="font-style: oblique;">
						<xsl:value-of select="@dpk:label"/>
					</span>
					<xsl:text>]</xsl:text>
				</xsl:if>
				<xsl:apply-templates select="SubTitle"/>
				<xsl:apply-templates select="Opus"/>
			</xsl:element>
		</xsl:element>
		<hr />
	</xsl:template>
	<xsl:template match="Composer">
		<span style="font-style: oblique;">
			<xsl:value-of select="FirstNames"/>
			<xsl:text> </xsl:text>
			<xsl:value-of select="Surname"/>
		</span>
		<xsl:text> : </xsl:text>
	</xsl:template>
	<xsl:template match="Instrumentation">
		<xsl:text> (</xsl:text>
		<xsl:value-of select="Name"/>
		<xsl:text>)</xsl:text>
	</xsl:template>
	<xsl:template match="Opus">
		<xsl:text>, </xsl:text>
		<xsl:element name="em">
			<xsl:choose>
				<xsl:when test="@Catalogue">
					<xsl:value-of select="@Catalogue"/>
				</xsl:when>
				<xsl:otherwise>
					<xsl:text>op.</xsl:text>
				</xsl:otherwise>
			</xsl:choose>
			<xsl:text> </xsl:text>
			<xsl:value-of select="."/>
		</xsl:element>
	</xsl:template>
	<xsl:template match="SubTitle">
		<xsl:text> (</xsl:text>
		<xsl:value-of select="."/>
		<xsl:text>)</xsl:text>
	</xsl:template>
</xsl:stylesheet>
Collections.xprj
<?xml version="1.0" encoding="utf-8"?>
<Projects>
	<Project target="dpkq">
		<Parameters>
			<xpp:expand xmlns:xpp="http://q37.info/ns/xpp/" href="common.xprj"/>
			<Data>Collections.xml</Data>
			<XSL>Collections.xsl</XSL>
			<Context>.Collections.xml</Context>
			<SessionMaxDuration>600</SessionMaxDuration>
		</Parameters>
	</Project>
</Projects>