ukf / ukf-testbed

UK federation tooling testbed
Apache License 2.0
1 stars 1 forks source link

Review check for misplaced alg elements in check_algsupport #23

Open philsmart opened 1 year ago

philsmart commented 1 year ago

The template:

<xsl:template match="alg:*[count(parent::md:Extensions)=0]">
        <xsl:call-template name="error">
            <xsl:with-param name="m">
                <xsl:text>alg:</xsl:text>
                <xsl:value-of select="local-name()"/>
                <xsl:text> must only appear within an Extensions element</xsl:text>
            </xsl:with-param>
        </xsl:call-template>
    </xsl:template>

Was converted from the match pattern alg:*[not(parent::md:Extensions)] to alg:*[count(parent::md:Extensions)=0] to overcome a potential bug in the native Java XSLT processor. This might not be the most effective way to find such errors, so needs review. An alternative exists (but is more generic on the match, so might prevent further templates from matching on alg:).

<xsl:template match="alg:*">
        <xsl:if test="not(parent::md:Extensions)">
            <xsl:call-template name="error">
                <xsl:with-param name="m">
                    <xsl:text>alg:</xsl:text>
                    <xsl:value-of select="local-name()"/>
                    <xsl:text> must only appear within an Extensions element</xsl:text>
                </xsl:with-param>
            </xsl:call-template>
        </xsl:if>
    </xsl:template>