From Didier Gautheron via bug 3052:
[obnox/wireshark/wip.git] / fix / Values.xsl
1 <!--
2 Syntax: xsltproc Values.xsl FIX44.xml
3 -->
4
5 <xsl:stylesheet xmlns:xsl="http://www.w3.org/1999/XSL/Transform" version="1.0">
6  <xsl:output  method="text" encoding="UTF-8"/>
7
8  <xsl:template match="text()"/>
9  <xsl:template match="/">/* DO NOT EDIT
10  * This file is autogenerated
11  */
12
13   <xsl:apply-templates/>
14
15 </xsl:template>
16  
17 <!--
18 translate(@description,$uppercase,$smallcase)  
19 -->
20
21 <xsl:variable name="smallcase" select="'abcdefghijklmnopqrstuvwxyz'" />
22 <xsl:variable name="uppercase" select="'ABCDEFGHIJKLMNOPQRSTUVWXYZ'" />
23
24 <xsl:template match="fix/fields">
25 <xsl:for-each select="field[value]">
26     <xsl:variable name="val_type"  >
27     <xsl:choose>   
28            <xsl:when test="@type='STRING'"> string_string </xsl:when>
29            <xsl:otherwise> value_string </xsl:otherwise>
30     </xsl:choose>
31     </xsl:variable>
32    static const <xsl:copy-of select="$val_type" /> <xsl:value-of select="@name"/>_val[] = { <xsl:for-each select="value"> <xsl:choose>
33              <xsl:when test="../@type='INT'">
34        { <xsl:value-of select="@enum"/>, "<xsl:value-of select="translate(@description,'_',' ')"/>" },</xsl:when>
35              <xsl:when test="../@type='STRING'">
36        { "<xsl:value-of select="@enum"/>", "<xsl:value-of select="translate(@description,'_',' ')"/>" },</xsl:when>
37              <xsl:otherwise>
38        { '<xsl:value-of select="@enum"/>', "<xsl:value-of select="translate(@description,'_',' ')"/>" },</xsl:otherwise>
39            </xsl:choose>
40         </xsl:for-each>
41        { 0, NULL }
42    };
43
44 </xsl:for-each>
45 </xsl:template>
46
47 <xsl:template match="fix/messages">
48    static const string_string messages_val[] = { <xsl:for-each select="message">
49        { "<xsl:value-of select="@msgtype"/>", "<xsl:value-of select="@name"/>" }, </xsl:for-each>
50        { "", NULL }
51    };
52 </xsl:template>
53
54 </xsl:stylesheet>