summaryrefslogtreecommitdiffstats
path: root/qemu/roms/openbios/config/xml/util.xsl
blob: 3b583b9ace1753a3c6d59e17aaf4d9e7ab98bdb0 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
<?xml version="1.0" encoding="ISO-8859-15" ?>

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

<!-- get-dirname: get directory part of file $path-->

<!-- call me with:
  <xsl:param name="path">
   <xsl:for-each select="ancestor::build">
    <xsl:call-template name="get-dirname">
     <xsl:with-param select="@base" name="path"/>
    </xsl:call-template>
   </xsl:for-each>
  </xsl:param>
 -->						   

<xsl:template name="get-dirname">
  <xsl:param name="path"/>
  <xsl:choose>
    <xsl:when test="contains($path, '/')">
      <xsl:choose>
      <xsl:when test="substring($path, string-length($path)) != '/'">
        <xsl:call-template name="get-dirname">
          <xsl:with-param select="substring($path, 1, string-length($path)-1)" name="path"/>
        </xsl:call-template>
      </xsl:when>
      <xsl:otherwise>
       <xsl:value-of select="$path"/>
      </xsl:otherwise>
      </xsl:choose>
    </xsl:when>
    <xsl:otherwise>
      <xsl:message terminate="yes">
       No valid relative path
      </xsl:message>
    </xsl:otherwise>
  </xsl:choose>
</xsl:template>

<!-- return value: 0=found, 1=not found -->
<xsl:template name="resolve-condition">
  <xsl:param name="expression"/>
  <xsl:param name="confexpr">CONFIG_<xsl:value-of select="$expression"/></xsl:param>
  
  <xsl:choose>
   <xsl:when test="$expression!=''">
    <xsl:variable name="value"><xsl:value-of select="document('config.xml',.)//option[@name=$confexpr]/attribute::value"/></xsl:variable>
    <xsl:variable name="type"><xsl:value-of select="document('config.xml',.)//option[@name=$confexpr]/attribute::type"/></xsl:variable>
    <xsl:choose>
     <xsl:when test="$type='boolean'">
      <xsl:choose>
       <xsl:when test="$value='true'"><xsl:text>0</xsl:text></xsl:when>
       <xsl:when test="$value='false'"><xsl:text>1</xsl:text></xsl:when>
       <!-- boolean but no value is false -->
       <xsl:when test="$value=''"><xsl:text>1</xsl:text></xsl:when>
       <xsl:otherwise>
       <xsl:message terminate="yes">Error:<xsl:value-of select="$confexpr"/> has no valid value '<xsl:value-of select="$value"/>'.</xsl:message>
      </xsl:otherwise>
      
      </xsl:choose>
     </xsl:when>
     <!-- if it doesn't exist, it is false -->
     <xsl:when test="$type=''"><xsl:text>1</xsl:text></xsl:when>
     <xsl:otherwise>
      <xsl:message terminate="yes">Error:<xsl:value-of select="$confexpr"/> is not a boolean value ('<xsl:value-of select="$type"/>').</xsl:message>
     </xsl:otherwise>
    </xsl:choose>
    <!-- debug - ->
     <xsl:message>
     <xsl:value-of select="$confexpr"/> = <xsl:value-of select="$value"/>
     </xsl:message>
    <!- - -->
   </xsl:when>
   <!-- if no expression is there we return true -->
   <xsl:otherwise>0</xsl:otherwise>
  </xsl:choose>
</xsl:template>


</xsl:stylesheet>