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

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