Make indentation the default.
authorJelmer Vernooij <jelmer@samba.org>
Sun, 26 Jun 2005 06:24:08 +0000 (07:24 +0100)
committerJelmer Vernooij <jelmer@samba.org>
Sun, 26 Jun 2005 06:24:08 +0000 (07:24 +0100)
ptb2xml.1
ptb2xml.c
ptbxml2musicxml.xsl

index e55110d36ddff9bd4a7b76572f12f81ebd49a6c8..f13720715d855d3085659c395427a46c688b7cc5 100644 (file)
--- a/ptb2xml.1
+++ b/ptb2xml.1
@@ -19,6 +19,8 @@ Tablature editor and generates an xml file containing the same data.
 Show all available options.
 .IP "-d"
 Run in debug mode. This will generate a lot of output to stderr.
+.IP "-f"
+Don't format output (e.g. put everything on one line).
 .IP "-m"
 Generate MusicXML output.
 .IP "-o \fIoutput-file\fP"
index 4b1e21fb280f2ff4dd2755163dd7758a6e28246e..1121a70b24ace41e9f8c184e3588bcef18fbcef7 100644 (file)
--- a/ptb2xml.c
+++ b/ptb2xml.c
@@ -537,13 +537,13 @@ int main(int argc, const char **argv)
        char *output = NULL;
        poptContext pc;
        int quiet = 0;
-       int format_output = 0;
+       int format_output = 1;
        struct poptOption options[] = {
                POPT_AUTOHELP
                {"debug", 'd', POPT_ARG_NONE, &debugging, 0, "Turn on debugging output" },
                {"outputfile", 'o', POPT_ARG_STRING, &output, 0, "Write to specified file", "FILE" },
                {"musicxml", 'm', POPT_ARG_NONE, &musicxml, 'm', "Output MusicXML" },
-               {"format", 'f', POPT_ARG_NONE, &format_output, 1, "Format output" },
+               {"no-format", 'f', POPT_ARG_NONE, &format_output, 0, "Don't format output" },
                {"quiet", 'q', POPT_ARG_NONE, &quiet, 1, "Be quiet (no output to stderr)" },
                {"version", 'v', POPT_ARG_NONE, &version, 'v', "Show version information" },
                POPT_TABLEEND
index ca85113a81521772e8c3a55e6b0f9ed14113e30e..b69497c0806791e3233f930c2b562a787938356e 100644 (file)
@@ -1,25 +1,33 @@
 <?xml version='1.0'?>
 <!--
        PowerTab to MusicXML converter. 
-       (C) 2004 Jelmer Vernooij <jelmer@samba.org>
+       (C) 2004-2005 Jelmer Vernooij <jelmer@samba.org>
+       Published under the GNU GPL
 -->
 <xsl:stylesheet xmlns:xsl="http://www.w3.org/1999/XSL/Transform"
        xmlns:exsl="http://exslt.org/common"
        version="1.1">
 
-       <xsl:output method="xml" encoding="UTF-8" doctype-public="-//Recordare//DTD MusicXML 1.0 Partwise//EN" indent="yes" doctype-system="http://www.musicxml.org/dtds/partwise.dtd"/>
+       <xsl:output indent="yes" method="xml" encoding="UTF-8" doctype-public="-//Recordare//DTD MusicXML 1.0 Partwise//EN" doctype-system="http://www.musicxml.org/dtds/partwise.dtd"/>
 
        <xsl:template match="powertab">
                <xsl:element name="score-partwise">
-                       <xsl:element name="part-list">
-
-                       </xsl:element>
-                       <xsl:apply-templates/>
+                       <xsl:call-template name="identification"/>
+                       <xsl:call-template name="part-list"/>
+                       <xsl:for-each select="instrument">
+                               <xsl:call-template name="part"/>
+                       </xsl:for-each>
                </xsl:element>
        </xsl:template>
 
-       <xsl:template match="sections">
-               <xsl:apply-templates/>
+       <xsl:template name="part">
+               <xsl:element name="part">
+                       <xsl:attribute name="id">
+                               <xsl:text>P</xsl:text>
+                               <xsl:value-of select="@id"/>
+                       </xsl:attribute>
+                       <xsl:apply-templates select="sections"/>
+               </xsl:element>
        </xsl:template>
 
        <xsl:template match="words-by">
                </xsl:element>
        </xsl:template>
 
-       <xsl:template match="guitar-transcribed-by|bass-transcribed-by"/>
-
-       <xsl:template match="header">
+       <xsl:template name="part-list">
+               <xsl:element name="part-list">
+                       <xsl:for-each select="instrument">
+                               <xsl:element name="score-part">
+                                       <xsl:attribute name="id"><xsl:text>P</xsl:text><xsl:value-of select="@id"/></xsl:attribute>
+                                       <xsl:element name="part-name">
+                                               <xsl:choose>
+                                                       <xsl:when test="@id=0">
+                                                               <xsl:text>Guitar</xsl:text>
+                                                       </xsl:when>
+                                                       <xsl:when test="@id=1">
+                                                               <xsl:text>Bass</xsl:text>
+                                                       </xsl:when>
+                                               </xsl:choose>
+                                       </xsl:element>
+                               </xsl:element>
+                       </xsl:for-each>
+               </xsl:element>
+       </xsl:template>
+       
+       <xsl:template name="identification">
                <xsl:element name="identification">
-                       <xsl:apply-templates/>
+                       <xsl:for-each select="header/*">
+                               <xsl:apply-templates/>
+                       </xsl:for-each>
                        <xsl:element name="encoding">
-                               <xsl:for-each select="song/guitar-transcribed-by|song/bass-transcribed-by">
+                               <xsl:for-each select="header/song/guitar-transcribed-by|header/song/bass-transcribed-by">
                                        <xsl:element name="encoder">
                                                <xsl:apply-templates/>
                                        </xsl:element>
                </xsl:element>
        </xsl:template>
 
-       <xsl:template match="song/title"/>
-       <xsl:template match="song/artist"/>
+       <xsl:template match="song/title"><!--FIXME-->
+       </xsl:template>
+       <xsl:template match="song/artist"><!--FIXME-->
+       </xsl:template>
+
+       <xsl:template match="sections"><xsl:apply-templates/></xsl:template>
 
        <xsl:template match="section">
-               <xsl:element name="part">
+               <xsl:element name="measure">
+                       <xsl:attribute name="number"><xsl:text>1</xsl:text></xsl:attribute>
                </xsl:element>
        </xsl:template>
 
+       <xsl:template match="fonts">
+               <!-- Ignore fonts -->
+       </xsl:template>
+
+       <xsl:template match="*">
+               <xsl:message>
+                       <xsl:text>No template matches </xsl:text>
+                       <xsl:value-of select="name(.)"/>
+                       <xsl:text>.</xsl:text>
+               </xsl:message>
+       </xsl:template>
 </xsl:stylesheet>