-
Notifications
You must be signed in to change notification settings - Fork 7
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
#62 Added tool to add empty sound attributes for directb2s files, the…
… backglass becomes silent
- Loading branch information
1 parent
d5722f2
commit ca459cc
Showing
1 changed file
with
34 additions
and
27 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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 > 1"> | ||
<xsl:attribute name="Sound2"></xsl:attribute> | ||
</xsl:if> | ||
<xsl:if test="@Digits > 2"> | ||
<xsl:attribute name="Sound3"></xsl:attribute> | ||
</xsl:if> | ||
<xsl:if test="@Digits > 3"> | ||
<xsl:attribute name="Sound4"></xsl:attribute> | ||
</xsl:if> | ||
<xsl:if test="@Digits > 4"> | ||
<xsl:attribute name="Sound5"></xsl:attribute> | ||
</xsl:if> | ||
<xsl:if test="@Digits > 5"> | ||
<xsl:attribute name="Sound6"></xsl:attribute> | ||
</xsl:if> | ||
<xsl:if test="@Digits > 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> |