Over the past couple of days, in what some might call a fit of insanity, I have done a significant overhaul to the "charmreview-xmlns.xsl" file. As you may be aware, this is a tool that I use to proof what I've made into XML. It is designed to render out the charm XML into a format that is nearly identical to what White Wolf uses in their books. Until recently, it was only capable to rendering out Martial Arts and other similar types of charms (i.e. no excellencies as prerequisites or excellencies in their own file). That has now changed.
The current version of "charmreview-xmlns.xsl" uses 3 major templates to render out the various charms. The first establishes the basic parameters for the HTML that will be viewed in a web browser. The second two actually render the contents of their respective charm types (i.e. <charm /> or <genericCharm />). In order to reduce the bloat of code in the XSL, the remaining 9 or so templates are called to render their specific parts of the XML.
Example:<genericCharm id="Something" exalt="Someone" />
<charm id="Something" exalt="Someone" group="Somegroup" />In both of these cases, the "charm" has an attribute
id which can be made more generic and used for both types of charms. Which, of course, begs the question: How?
The answer is <xsl:template match="genericCharm" /> or <xsl:for-each select="charmtype" />, which is either part of the template or it surrounds the function that calls the template. These effectively eliminate the need to consider either of the root XML elements because we are already fixed on a specific element (also called a context node).
What is even cooler, is that this XSL can be applied to
urskr 's monolithic charm files and you will get a similar result.
Some beautiful code follows:
<xsl:template match="chrm:genericCharm">
<xsl:call-template name="Line_1"/>
<xsl:call-template name="Line_2"/>
<xsl:call-template name="Line_3"/>
<xsl:call-template name="Line_4"/>
...
<xsl:template match="chrm:charm">
<xsl:call-template name="Line_1" />
...
<xsl:template name="Line_1">
<xsl:element name="p"><xsl:element name="b">Name: </xsl:element><xsl:value-of select="@id"/></xsl:element>
</xsl:template>
In closing, this process also taught me that the
xsltproc program included with
OS X 10.5 is much better at helping me catch my errors in XSL files than either of the web browsers that I use for charm making.
PS. Oh, for most intents and purposes, the XML for the Lunar's plug-in is done.