Blame SOURCES/fix-jing-simplified-rng.xsl

f3ee57
f3ee57
                xmlns:xsl="http://www.w3.org/1999/XSL/Transform"
f3ee57
                xmlns:rng="http://relaxng.org/ns/structure/1.0"
f3ee57
                xmlns="http://relaxng.org/ns/structure/1.0"
f3ee57
                exclude-result-prefixes="rng">
f3ee57
<xsl:output format="xml" indent="yes"/>
f3ee57
<xsl:strip-space elements="*"/>
f3ee57
f3ee57
<xsl:param name="filename-or-version" select="'99.99'"/>
f3ee57
<xsl:variable name="version">
f3ee57
    <xsl:variable name="version-local">
f3ee57
        <xsl:choose>
f3ee57
            <xsl:when test="starts-with($filename-or-version, 'pacemaker-')">
f3ee57
                
f3ee57
                              select="substring-after($filename-or-version, 'pacemaker-')"/>
f3ee57
                <xsl:choose>
f3ee57
                    <xsl:when test="contains(substring-after($version-tail, '.'), '.')">
f3ee57
                        
f3ee57
                                                  $version-tail,
f3ee57
                                                  1,
f3ee57
                                                  string-length($version-tail)
f3ee57
                                                  -
f3ee57
                                                  1
f3ee57
                                                  -
f3ee57
                                                  string-length(
f3ee57
                                                      substring-after(
f3ee57
                                                          substring-after(
f3ee57
                                                              $version-tail,
f3ee57
                                                              '.'
f3ee57
                                                          ),
f3ee57
                                                          '.'
f3ee57
                                                      )
f3ee57
                                                  )
f3ee57
                                              )"/>
f3ee57
                    </xsl:when>
f3ee57
                    <xsl:otherwise>
f3ee57
                        <xsl:value-of select="$version-tail"/>
f3ee57
                    </xsl:otherwise>
f3ee57
                </xsl:choose>
f3ee57
            </xsl:when>
f3ee57
            <xsl:otherwise>
f3ee57
                <xsl:value-of select="$filename-or-version"/>
f3ee57
            </xsl:otherwise>
f3ee57
        </xsl:choose>
f3ee57
    </xsl:variable>
f3ee57
    <xsl:if test="number($version-local) = number('NaN')">
f3ee57
        <xsl:message terminate="yes">
f3ee57
            <xsl:value-of select="concat('Wrong number specification: ', $version-local)"/>
f3ee57
        </xsl:message>
f3ee57
    </xsl:if>
f3ee57
    <xsl:value-of select="$version-local"/>
f3ee57
</xsl:variable>
f3ee57
<xsl:variable name="version-major">
f3ee57
    <xsl:choose>
f3ee57
        <xsl:when test="contains($version, '.')">
f3ee57
            <xsl:value-of select="number(substring-before($version, '.'))"/>
f3ee57
        </xsl:when>
f3ee57
        <xsl:otherwise>
f3ee57
            <xsl:value-of select="number($version)"/>
f3ee57
        </xsl:otherwise>
f3ee57
    </xsl:choose>
f3ee57
</xsl:variable>
f3ee57
<xsl:variable name="version-minor">
f3ee57
    <xsl:value-of select="number(concat('0', substring-after($version, '.')))"/>
f3ee57
</xsl:variable>
f3ee57
f3ee57
<xsl:template match="/rng:grammar">
f3ee57
    <xsl:copy>
f3ee57
        <xsl:copy-of select="@*"/>
f3ee57
        <xsl:attribute name="datatypeLibrary">
f3ee57
            <xsl:value-of select="'http://www.w3.org/2001/XMLSchema-datatypes'"/>
f3ee57
        </xsl:attribute>
f3ee57
        <xsl:apply-templates/>
f3ee57
    </xsl:copy>
f3ee57
</xsl:template>
f3ee57
f3ee57
f3ee57
<xsl:template match="@ns[. = '']"/>
f3ee57
f3ee57
                         . = ''
f3ee57
                         or
f3ee57
                         . = 'http://www.w3.org/2001/XMLSchema-datatypes'
f3ee57
                     ]"/>
f3ee57
f3ee57
f3ee57
     of the file processed -->
f3ee57
<xsl:template match="rng:attribute[@name = 'validate-with']/rng:choice/rng:value">
f3ee57
    <xsl:choose>
f3ee57
        
f3ee57
                        and
f3ee57
                        (
f3ee57
                            number(
f3ee57
                                substring-before(substring-after(text(), 'pacemaker-'), '.')
f3ee57
                            ) > $version-major
f3ee57
                            or
f3ee57
                            (
f3ee57
                                number(
f3ee57
                                    substring-before(substring-after(text(), 'pacemaker-'), '.')
f3ee57
                                ) = $version-major
f3ee57
                                and
f3ee57
                                number(
f3ee57
                                    concat('0', substring-after(substring-after(text(), 'pacemaker-'), '.'))
f3ee57
                                ) > $version-minor
f3ee57
f3ee57
                            )
f3ee57
                        )"/>
f3ee57
        <xsl:otherwise>
f3ee57
            <xsl:copy>
f3ee57
                <xsl:apply-templates select="@*|node()"/>
f3ee57
            </xsl:copy>
f3ee57
        </xsl:otherwise>
f3ee57
    </xsl:choose>
f3ee57
</xsl:template>
f3ee57
f3ee57
f3ee57
     - https://github.com/ClusterLabs/pacemaker/commit/89f5177
f3ee57
     - https://pagure.io/clufter/c/a3985ec -->
f3ee57
<xsl:template match="*[name() != 'optional']/rng:ref[@name = 'status']">
f3ee57
    <optional>
f3ee57
        <xsl:copy>
f3ee57
            <xsl:apply-templates select="@*|node()"/>
f3ee57
        </xsl:copy>
f3ee57
    </optional>
f3ee57
</xsl:template>
f3ee57
f3ee57
f3ee57
     of rsc_colocation are supported; see also:
f3ee57
     - https://github.com/ClusterLabs/pacemaker/commit/30383cc
f3ee57
     - https://pagure.io/clufter/c/abd2d45 (+ 53b8215) -->
f3ee57
f3ee57
                         rng:attribute[@name = 'score']
f3ee57
                     ]">
f3ee57
    <xsl:apply-templates select="rng:attribute[@name = 'score']"/>
f3ee57
</xsl:template>
f3ee57
f3ee57
<xsl:template match="@*|node()">
f3ee57
    <xsl:copy>
f3ee57
        <xsl:apply-templates select="@*|node()"/>
f3ee57
    </xsl:copy>
f3ee57
</xsl:template>
f3ee57
f3ee57
</xsl:stylesheet>