Add qemu 2.4.0
[kvmfornfv.git] / qemu / roms / openbios / config / xml / util.xsl
1 <?xml version="1.0" encoding="ISO-8859-15" ?>
2
3 <xsl:stylesheet xmlns:xsl="http://www.w3.org/1999/XSL/Transform" version="1.0">
4
5 <!-- get-dirname: get directory part of file $path-->
6
7 <!-- call me with:
8   <xsl:param name="path">
9    <xsl:for-each select="ancestor::build">
10     <xsl:call-template name="get-dirname">
11      <xsl:with-param select="@base" name="path"/>
12     </xsl:call-template>
13    </xsl:for-each>
14   </xsl:param>
15  -->                                               
16
17 <xsl:template name="get-dirname">
18   <xsl:param name="path"/>
19   <xsl:choose>
20     <xsl:when test="contains($path, '/')">
21       <xsl:choose>
22       <xsl:when test="substring($path, string-length($path)) != '/'">
23         <xsl:call-template name="get-dirname">
24           <xsl:with-param select="substring($path, 1, string-length($path)-1)" name="path"/>
25         </xsl:call-template>
26       </xsl:when>
27       <xsl:otherwise>
28        <xsl:value-of select="$path"/>
29       </xsl:otherwise>
30       </xsl:choose>
31     </xsl:when>
32     <xsl:otherwise>
33       <xsl:message terminate="yes">
34        No valid relative path
35       </xsl:message>
36     </xsl:otherwise>
37   </xsl:choose>
38 </xsl:template>
39
40 <!-- return value: 0=found, 1=not found -->
41 <xsl:template name="resolve-condition">
42   <xsl:param name="expression"/>
43   <xsl:param name="confexpr">CONFIG_<xsl:value-of select="$expression"/></xsl:param>
44   
45   <xsl:choose>
46    <xsl:when test="$expression!=''">
47     <xsl:variable name="value"><xsl:value-of select="document('config.xml',.)//option[@name=$confexpr]/attribute::value"/></xsl:variable>
48     <xsl:variable name="type"><xsl:value-of select="document('config.xml',.)//option[@name=$confexpr]/attribute::type"/></xsl:variable>
49     <xsl:choose>
50      <xsl:when test="$type='boolean'">
51       <xsl:choose>
52        <xsl:when test="$value='true'"><xsl:text>0</xsl:text></xsl:when>
53        <xsl:when test="$value='false'"><xsl:text>1</xsl:text></xsl:when>
54        <!-- boolean but no value is false -->
55        <xsl:when test="$value=''"><xsl:text>1</xsl:text></xsl:when>
56        <xsl:otherwise>
57        <xsl:message terminate="yes">Error:<xsl:value-of select="$confexpr"/> has no valid value '<xsl:value-of select="$value"/>'.</xsl:message>
58       </xsl:otherwise>
59       
60       </xsl:choose>
61      </xsl:when>
62      <!-- if it doesn't exist, it is false -->
63      <xsl:when test="$type=''"><xsl:text>1</xsl:text></xsl:when>
64      <xsl:otherwise>
65       <xsl:message terminate="yes">Error:<xsl:value-of select="$confexpr"/> is not a boolean value ('<xsl:value-of select="$type"/>').</xsl:message>
66      </xsl:otherwise>
67     </xsl:choose>
68     <!-- debug - ->
69      <xsl:message>
70      <xsl:value-of select="$confexpr"/> = <xsl:value-of select="$value"/>
71      </xsl:message>
72     <!- - -->
73    </xsl:when>
74    <!-- if no expression is there we return true -->
75    <xsl:otherwise>0</xsl:otherwise>
76   </xsl:choose>
77 </xsl:template>
78
79
80 </xsl:stylesheet>