Skip to content

Instantly share code, notes, and snippets.

@amis92
Last active May 7, 2016 15:51
Show Gist options
  • Save amis92/5a35e345c43a12557571cf5ff6e2a211 to your computer and use it in GitHub Desktop.
Save amis92/5a35e345c43a12557571cf5ff6e2a211 to your computer and use it in GitHub Desktop.
BS-xml-resharper XSLT that rewrites Vehicle profiles of Flyers into new ProfileType with Combat Role, Pursuit and Agility
<?xml version="1.0" encoding="UTF-8"?>
<xsl:stylesheet version="1.0"
xmlns:xsl="http://www.w3.org/1999/XSL/Transform"
xmlns:bs-gst="http://www.battlescribe.net/schema/gameSystemSchema"
xmlns:cat="http://www.battlescribe.net/schema/catalogueSchema"
xmlns="http://www.battlescribe.net/schema/catalogueSchema">
<xsl:output omit-xml-declaration="no" encoding="UTF-8" standalone="yes" version="1.0" indent="yes" method="xml"/>
<xsl:strip-space elements="*" />
<xsl:variable name="gst-ns" >http://www.battlescribe.net/schema/gameSystemSchema</xsl:variable>
<xsl:variable name="cat-ns" >http://www.battlescribe.net/schema/catalogueSchema</xsl:variable>
<xsl:variable name="placeholder" select="'N/A'" />
<!-- The Identity Transformation -->
<!-- Whenever you match any node or any attribute -->
<xsl:template match="node()|@*">
<!-- Copy the current node -->
<xsl:copy>
<!-- Including any attributes it has and any child nodes -->
<xsl:apply-templates select="@*|node()"/>
</xsl:copy>
</xsl:template>
<!-- Vehicle ProfileType for flyers switch to new Flyer ProfileType id -->
<!-- search for profiles that:
1. have profileTypeId of vehicle
2. have characteristic Type whose value contains 'Flyer' -->
<xsl:template match="cat:profile[@profileTypeId='725a358c-765b-498c-8de5-399fc0c0725f'][contains(cat:characteristics/cat:characteristic[@characteristicId='077c342f-d7b9-45c6-b8af-88e97cafd3a2']/@value, 'Flyer')]">
<xsl:copy>
<xsl:copy-of select="@id" />
<xsl:attribute name="profileTypeId">3a08-ea03-a598-8615</xsl:attribute>
<xsl:copy-of select="@name" />
<xsl:copy-of select="@hidden" />
<xsl:copy-of select="@book" />
<xsl:copy-of select="@page" />
<xsl:element name="characteristics">
<xsl:element name="characteristic">
<xsl:attribute name="characteristicId">9878-e3f6-b7b4-7225</xsl:attribute>
<xsl:attribute name="name">BS</xsl:attribute>
<xsl:copy-of select="cat:characteristics/cat:characteristic[@name='BS']/@value" />
</xsl:element>
<xsl:element name="characteristic">
<xsl:attribute name="characteristicId">3a4e-bc1d-4a12-7176</xsl:attribute>
<xsl:attribute name="name">Front</xsl:attribute>
<xsl:copy-of select="cat:characteristics/cat:characteristic[@name='Front']/@value" />
</xsl:element>
<xsl:element name="characteristic">
<xsl:attribute name="characteristicId">d12e-7bdb-191c-4849</xsl:attribute>
<xsl:attribute name="name">Side</xsl:attribute>
<xsl:copy-of select="cat:characteristics/cat:characteristic[@name='Side']/@value" />
</xsl:element>
<xsl:element name="characteristic">
<xsl:attribute name="characteristicId">a4cb-791a-6a75-4e4a</xsl:attribute>
<xsl:attribute name="name">Rear</xsl:attribute>
<xsl:copy-of select="cat:characteristics/cat:characteristic[@name='Rear']/@value" />
</xsl:element>
<xsl:element name="characteristic">
<xsl:attribute name="characteristicId">93e6-d4b1-28a8-944b</xsl:attribute>
<xsl:attribute name="name">HP</xsl:attribute>
<xsl:copy-of select="cat:characteristics/cat:characteristic[@name='HP']/@value" />
</xsl:element>
<xsl:element name="characteristic">
<xsl:attribute name="characteristicId">eb65-838c-8eaa-8b5d</xsl:attribute>
<xsl:attribute name="name">Type</xsl:attribute>
<xsl:copy-of select="cat:characteristics/cat:characteristic[@name='Type']/@value" />
</xsl:element>
<xsl:element name="characteristic">
<xsl:attribute name="characteristicId">d477-c087-173f-9f1c</xsl:attribute>
<xsl:attribute name="name">Combat Role</xsl:attribute>
<xsl:attribute name="value"><xsl:copy-of select="$placeholder"/></xsl:attribute>
</xsl:element>
<xsl:element name="characteristic">
<xsl:attribute name="characteristicId">e04d-332e-8b52-0071</xsl:attribute>
<xsl:attribute name="name">Pursuit</xsl:attribute>
<xsl:attribute name="value"><xsl:copy-of select="$placeholder"/></xsl:attribute>
</xsl:element>
<xsl:element name="characteristic">
<xsl:attribute name="characteristicId">ae34-f5c0-19af-4883</xsl:attribute>
<xsl:attribute name="name">Agility</xsl:attribute>
<xsl:attribute name="value"><xsl:copy-of select="$placeholder"/></xsl:attribute>
</xsl:element>
</xsl:element>
<xsl:copy-of select="cat:modifiers" />
</xsl:copy>
</xsl:template>
</xsl:stylesheet>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment