Loading ...
Sorry, an error occurred while loading the content.

XSLT

Expand Messages
  • S Woodside
    Hi there, I ve written a little XSLT that converts the base.xml file in PCGen 5.1.2 into a dungeon-magazine stat block. I got the XML out of PCGen by
    Message 1 of 2 , May 29, 2003
    • 0 Attachment
      Hi there, I've written a little XSLT that converts the "base.xml" file
      in PCGen 5.1.2 into a dungeon-magazine stat block. I got the XML out of
      PCGen by renaming the base.xml file to
      d20/fantasy/htmlxml/csheet_dnd_base.xml . It's a work in process. I'd
      appreciate any kind of feedback.

      simon

      <?xml version="1.0"?>

      <xsl:stylesheet
      version="1.0"
      xmlns:xsl="http://www.w3.org/1999/XSL/Transform"
      xmlns:html="http://www.w3.org/1999/xhtml"
      >

      <xsl:output
      method = "html"
      version = "1.0"
      encoding = "ISO-8859-1"
      omit-xml-declaration = "yes"
      standalone = "yes"
      doctype-public = "-//W3C//DTD HTML 4.01 Transitional//EN"
      doctype-system = "http://www.w3.org/TR/REC-html40/loose.dtd"
      cdata-section-elements = ""
      indent = "yes"
      media-type = "text/html"
      />

      <xsl:template match="character">
      <html lang="en">
      <head>
      <title>Stat Block</title>
      </head>
      <body>
      <xsl:apply-templates select="basics"/>
      </body>
      </html>
      </xsl:template>

      <xsl:template match="basics">
      <xsl:call-template name="boldname"/>
      <xsl:call-template name="insert-cr-to-type"/>
      <xsl:text>HD </xsl:text>
      <xsl:apply-templates select="classes" mode="hit-dice"/>
      <xsl:call-template name="insert-hp-to-spd"/>
      <xsl:apply-templates select="../armor_class"/>
      <xsl:apply-templates select="../attack"/>
      <!--need way to get SA and SQ, need them itemized-->
      <xsl:if test="../armor_class/spell_resistance != 0">
      <xsl:text>SR </xsl:text>
      <xsl:value-of select="../armor_class/spell_resistance"/>
      <xsl:text>; </xsl:text>
      </xsl:if>
      <xsl:call-template name="insert-alignment"/>
      <xsl:apply-templates select="../saving_throws"/>
      <xsl:apply-templates select="../abilities"/>
      </xsl:template>

      <xsl:template name="boldname">
      <b>
      <xsl:value-of select="name"/> <xsl:text>, </xsl:text>
      <xsl:value-of select="gender/short"/> <xsl:text> </xsl:text>
      <xsl:value-of select="race"/> <xsl:text> </xsl:text>
      <xsl:apply-templates select="classes"/> <xsl:text>: </xsl:text>
      </b>
      </xsl:template>

      <xsl:template match="classes">
      <xsl:value-of select="class/abbreviation"/>
      <xsl:value-of select="class/level"/>
      </xsl:template>

      <xsl:template name="insert-cr-to-type">
      <xsl:text>CR </xsl:text>
      <xsl:value-of select="cr"/> <xsl:text>; </xsl:text>
      <xsl:value-of select="size/long"/> <xsl:text> </xsl:text>
      <xsl:value-of select="type"/> <xsl:text>; </xsl:text>
      </xsl:template>

      <xsl:template match="classes" mode="hit-dice">
      <xsl:value-of select="../hitdice"/>
      <xsl:text> (</xsl:text>
      <xsl:value-of select="class/abbreviation"/>
      <xsl:text>); </xsl:text>
      </xsl:template>

      <xsl:template match="attack">
      <xsl:text>Atk </xsl:text>
      <xsl:value-of select="melee/total"/> <xsl:text> melee (?)
      </xsl:text>
      <!--need way to get weapon stats, attack type-->
      <xsl:text>or </xsl:text>
      <xsl:value-of select="ranged/total"/> <xsl:text> ranged (?);
      </xsl:text>
      </xsl:template>

      <xsl:template match="armor_class">
      <xsl:text>AC </xsl:text>
      <xsl:value-of select="total"/> <xsl:text>, </xsl:text>
      <xsl:text>touch </xsl:text>
      <xsl:value-of select="touch"/> <xsl:text>, </xsl:text>
      <xsl:text>flat-footed </xsl:text>
      <xsl:value-of select="flat"/> <xsl:text>; </xsl:text>
      <!--itemized bonuses awkward-->
      </xsl:template>

      <xsl:template name="insert-hp-to-spd">
      <xsl:text>hp </xsl:text>
      <xsl:value-of select="../hit_points/points"/> <xsl:text>;
      </xsl:text>
      <xsl:text>Init </xsl:text>
      <xsl:value-of select="../initiative/total"/> <xsl:text>; </xsl:text>
      <xsl:text>Spd </xsl:text>
      <xsl:value-of select="move/all"/> <xsl:text> ft.; </xsl:text>
      </xsl:template>

      <xsl:template name="insert-alignment">
      <xsl:text>AL </xsl:text>
      <xsl:value-of select="alignment/short"/> <xsl:text>; </xsl:text>
      </xsl:template>

      <xsl:template match="saving_throws">
      <xsl:text>SV </xsl:text>
      <xsl:for-each select="saving_throw">
      <xsl:value-of select="name/short"/> <xsl:text> </xsl:text>
      <xsl:value-of select="total"/>
      <xsl:if test="position() != last()">
      <xsl:text>, </xsl:text>
      </xsl:if>
      </xsl:for-each>
      <xsl:text>; </xsl:text>
      </xsl:template>

      <xsl:template match="abilities">
      <xsl:for-each select="ability">
      <xsl:value-of select="name/short"/> <xsl:text> </xsl:text>
      <xsl:value-of select="score"/>
      <xsl:if test="position() != last()">
      <xsl:text>, </xsl:text>
      </xsl:if>
      </xsl:for-each>
      <xsl:text>. </xsl:text>
      </xsl:template>

      </xsl:stylesheet>
    • sbwoodside
      Hi there, I ve written a little XSLT that converts the base.xml file in PCGen 5.1.2 into a dungeon-magazine stat block. I got the XML out of PCGen by
      Message 2 of 2 , May 29, 2003
      • 0 Attachment
        Hi there, I've written a little XSLT that converts the "base.xml" file
        in PCGen 5.1.2 into a dungeon-magazine stat block. I got the XML out
        of PCGen by renaming the base.xml file to
        d20/fantasy/htmlxml/csheet_dnd_base.xml . It's a work in process. I'd
        appreciate any kind of feedback.

        simon

        <?xml version="1.0"?>

        <xsl:stylesheet
        version="1.0"
        xmlns:xsl="http://www.w3.org/1999/XSL/Transform"
        xmlns:html="http://www.w3.org/1999/xhtml"
        >

        <xsl:output
        method = "html"
        version = "1.0"
        encoding = "ISO-8859-1"
        omit-xml-declaration = "yes"
        standalone = "yes"
        doctype-public = "-//W3C//DTD HTML 4.01 Transitional//EN"
        doctype-system = "http://www.w3.org/TR/REC-html40/loose.dtd"
        cdata-section-elements = ""
        indent = "yes"
        media-type = "text/html"
        />

        <xsl:template match="character">
        <html lang="en">
        <head>
        <title>Stat Block</title>
        </head>
        <body>
        <xsl:apply-templates select="basics"/>
        </body>
        </html>
        </xsl:template>

        <xsl:template match="basics">
        <xsl:call-template name="boldname"/>
        <xsl:call-template name="insert-cr-to-type"/>
        <xsl:text>HD </xsl:text>
        <xsl:apply-templates select="classes" mode="hit-dice"/>
        <xsl:call-template name="insert-hp-to-spd"/>
        <xsl:apply-templates select="../armor_class"/>
        <xsl:apply-templates select="../attack"/>
        <!--need way to get SA and SQ, need them itemized-->
        <xsl:if test="../armor_class/spell_resistance != 0">
        <xsl:text>SR </xsl:text>
        <xsl:value-of select="../armor_class/spell_resistance"/>
        <xsl:text>; </xsl:text>
        </xsl:if>
        <xsl:call-template name="insert-alignment"/>
        <xsl:apply-templates select="../saving_throws"/>
        <xsl:apply-templates select="../abilities"/>
        </xsl:template>

        <xsl:template name="boldname">
        <b>
        <xsl:value-of select="name"/> <xsl:text>, </xsl:text>
        <xsl:value-of select="gender/short"/> <xsl:text> </xsl:text>
        <xsl:value-of select="race"/> <xsl:text> </xsl:text>
        <xsl:apply-templates select="classes"/> <xsl:text>: </xsl:text>
        </b>
        </xsl:template>

        <xsl:template match="classes">
        <xsl:value-of select="class/abbreviation"/>
        <xsl:value-of select="class/level"/>
        </xsl:template>

        <xsl:template name="insert-cr-to-type">
        <xsl:text>CR </xsl:text>
        <xsl:value-of select="cr"/> <xsl:text>; </xsl:text>
        <xsl:value-of select="size/long"/> <xsl:text> </xsl:text>
        <xsl:value-of select="type"/> <xsl:text>; </xsl:text>
        </xsl:template>

        <xsl:template match="classes" mode="hit-dice">
        <xsl:value-of select="../hitdice"/>
        <xsl:text> (</xsl:text>
        <xsl:value-of select="class/abbreviation"/>
        <xsl:text>); </xsl:text>
        </xsl:template>

        <xsl:template match="attack">
        <xsl:text>Atk </xsl:text>
        <xsl:value-of select="melee/total"/> <xsl:text> melee (?)
        </xsl:text>
        <!--need way to get weapon stats, attack type-->
        <xsl:text>or </xsl:text>
        <xsl:value-of select="ranged/total"/> <xsl:text> ranged (?);
        </xsl:text>
        </xsl:template>

        <xsl:template match="armor_class">
        <xsl:text>AC </xsl:text>
        <xsl:value-of select="total"/> <xsl:text>, </xsl:text>
        <xsl:text>touch </xsl:text>
        <xsl:value-of select="touch"/> <xsl:text>, </xsl:text>
        <xsl:text>flat-footed </xsl:text>
        <xsl:value-of select="flat"/> <xsl:text>; </xsl:text>
        <!--itemized bonuses awkward-->
        </xsl:template>

        <xsl:template name="insert-hp-to-spd">
        <xsl:text>hp </xsl:text>
        <xsl:value-of select="../hit_points/points"/> <xsl:text>;
        </xsl:text>
        <xsl:text>Init </xsl:text>
        <xsl:value-of select="../initiative/total"/> <xsl:text>;
        </xsl:text>
        <xsl:text>Spd </xsl:text>
        <xsl:value-of select="move/all"/> <xsl:text> ft.; </xsl:text>
        </xsl:template>

        <xsl:template name="insert-alignment">
        <xsl:text>AL </xsl:text>
        <xsl:value-of select="alignment/short"/> <xsl:text>; </xsl:text>
        </xsl:template>

        <xsl:template match="saving_throws">
        <xsl:text>SV </xsl:text>
        <xsl:for-each select="saving_throw">
        <xsl:value-of select="name/short"/> <xsl:text> </xsl:text>
        <xsl:value-of select="total"/>
        <xsl:if test="position() != last()">
        <xsl:text>, </xsl:text>
        </xsl:if>
        </xsl:for-each>
        <xsl:text>; </xsl:text>
        </xsl:template>

        <xsl:template match="abilities">
        <xsl:for-each select="ability">
        <xsl:value-of select="name/short"/> <xsl:text> </xsl:text>
        <xsl:value-of select="score"/>
        <xsl:if test="position() != last()">
        <xsl:text>, </xsl:text>
        </xsl:if>
        </xsl:for-each>
        <xsl:text>. </xsl:text>
        </xsl:template>

        </xsl:stylesheet>
      Your message has been successfully submitted and would be delivered to recipients shortly.