diff options
author | Angelos Mouzakitis <a.mouzakitis@virtualopensystems.com> | 2023-10-10 14:33:42 +0000 |
---|---|---|
committer | Angelos Mouzakitis <a.mouzakitis@virtualopensystems.com> | 2023-10-10 14:33:42 +0000 |
commit | af1a266670d040d2f4083ff309d732d648afba2a (patch) | |
tree | 2fc46203448ddcc6f81546d379abfaeb323575e9 /roms/openbios/config/xml/util.xsl | |
parent | e02cda008591317b1625707ff8e115a4841aa889 (diff) |
Change-Id: Iaf8d18082d3991dec7c0ebbea540f092188eb4ec
Diffstat (limited to 'roms/openbios/config/xml/util.xsl')
-rw-r--r-- | roms/openbios/config/xml/util.xsl | 80 |
1 files changed, 80 insertions, 0 deletions
diff --git a/roms/openbios/config/xml/util.xsl b/roms/openbios/config/xml/util.xsl new file mode 100644 index 000000000..3b583b9ac --- /dev/null +++ b/roms/openbios/config/xml/util.xsl @@ -0,0 +1,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> |