Skip to content

Commit

Permalink
#62 Added tool to add empty sound attributes for directb2s files, the…
Browse files Browse the repository at this point in the history
… backglass becomes silent
  • Loading branch information
JockeJarre committed Sep 12, 2023
1 parent d5722f2 commit ca459cc
Showing 1 changed file with 34 additions and 27 deletions.
61 changes: 34 additions & 27 deletions B2STools/directb2sReelSoundsONOFF.xsl
Original file line number Diff line number Diff line change
@@ -1,49 +1,56 @@
<xsl:stylesheet version="1.0" xmlns:xsl="http://www.w3.org/1999/XSL/Transform">
<xsl:output method="xml" omit-xml-declaration="yes" />
<!-- directb2sReelSoundsONOFF.xsl xslt transformation to add or remove empty attributes for directb2s files -->
<!-- directb2sReelSoundsONOFF.xsl xslt transformation to add empty sound attributes for directb2s files -->

<!-- Identity template: copy all nodes and attributes as-is -->
<xsl:template match="@* | node()">
<xsl:copy>
<xsl:apply-templates select="@* | node()"/>
</xsl:copy>
</xsl:template>

<!-- Match the "Score" node and add the "Sound3-5" empty attribute -->
<xsl:template match="Score[not(@Sound3)]">

<xsl:template match="Scoret/@*[starts-with(name(), 'Sound') and @* ='']" >
<xsl:message>
This does not work yet
</xsl:message>
</xsl:template>

<!-- Match the "Score" node and add the "Sound1-6" empty attributes -->
<xsl:template match="Score[not(@Sound1)]">
<xsl:message>
Adding the Sound3-5 attributes
Adding the Sound -<xsl:value-of select="@Digits"/> attributes to Score ID="<xsl:value-of select="@ID"/>"
</xsl:message>

<xsl:copy>
<xsl:apply-templates select="@*"/>
<xsl:attribute name="Sound3"></xsl:attribute>
<xsl:attribute name="Sound4"></xsl:attribute>
<xsl:attribute name="Sound5"></xsl:attribute>
<xsl:attribute name="Sound1"></xsl:attribute>
<xsl:if test="@Digits &gt; 1">
<xsl:attribute name="Sound2"></xsl:attribute>
</xsl:if>
<xsl:if test="@Digits &gt; 2">
<xsl:attribute name="Sound3"></xsl:attribute>
</xsl:if>
<xsl:if test="@Digits &gt; 3">
<xsl:attribute name="Sound4"></xsl:attribute>
</xsl:if>
<xsl:if test="@Digits &gt; 4">
<xsl:attribute name="Sound5"></xsl:attribute>
</xsl:if>
<xsl:if test="@Digits &gt; 5">
<xsl:attribute name="Sound6"></xsl:attribute>
</xsl:if>
<xsl:if test="@Digits &gt; 6">
<xsl:attribute name="Sound7"></xsl:attribute>
</xsl:if>
<xsl:apply-templates select="node()"/>
</xsl:copy>
</xsl:template>

<!-- Match the "Score" with a "Sound3-5" node and remove them -->
<xsl:template match="Score[(@Sound3)]">
<xsl:message>
Removing the Sound3-5 attributes
<!-- Match the "Score" with a "Sound1" node error out -->
<xsl:template match="Score[(@Sound1)]">
<xsl:message terminate="yes">
The sound attribute(s) already exists
</xsl:message>
<xsl:if test="@Sound3!=''">
<xsl:message terminate="yes">
The sound attribute isn't empty! exiting
</xsl:message>
</xsl:if>

<xsl:copy>
<xsl:apply-templates select="@* | node()" mode="RemoveSound" />
</xsl:copy>
</xsl:template>

<xsl:template mode="RemoveSound" match="@Sound3 | @Sound4 | @Sound5" />
<xsl:template mode="RemoveSound" match="@* | node()">
<xsl:copy>
<xsl:apply-templates select="@* | node()"/>
</xsl:copy>
</xsl:template>
</xsl:stylesheet>

0 comments on commit ca459cc

Please sign in to comment.