Thanks for posting your code. Far too many people on this forum seem afraid of doing so, which makes it very hard to offer them advice.
Your general structure is good. I'd make one suggestion:
let the templates do the choosing. Split each xsl:when into a separate template rule, for example this one would be
At this point I'm having a bit of trouble relating your code to your problem description. That's at least in part because none of the @id values mentioned in the code actually seem to appear in your data. So let's go back to the problem.
<g id="LabelWebShields" gmwmsvg:typ="l" gmwmsvg:pri="2" class="g6E3n3r9q8">
A) change the class to match a style class that I already have set up
<xsl:attribute name="class">new class value</xsl:attribute>
B) find the value of the class attribute by doing some sort of select and then dynamically build a style class to match the attribute value
This description is a bit more troublesome because of the "then" - you are thinking in terms of an order of execution, not a functional relationship. Try to structure your code according to the output it has to produce: write a template for each piece of output, and in that template, gather all the input it needs from anywhere in the document. You haven't shown the output you are aiming at so it's hard to be more specific.
C) find the object by its ID and then change the style attribute
This looks like
<xsl:template match="g[@ID='some value']">
<xsl:attribute name="style">new style value</xsl:attribute>
i.e. exactly the same as A.
Note that you can copy all the attributes and then "overwrite" one of them.
Author, XSLT Programmer's Reference and XPath 2.0 Programmer's Reference