sonar-xsl / Sonar-XSL-Plugin

A Schematron-based SonarQube plugin for XSL code quality measurement.
http://www.sonarxsl.org/
Apache License 2.0
5 stars 3 forks source link

Document has been marked not available in logs #5

Closed jimetevenard closed 3 years ago

jimetevenard commented 4 years ago

Fix this warning (at plugin init)

Warning at char 9 in xsl:value-of/@select on line 2221 column 96 of iso_schematron_skeleton_for_saxon.xsl:
  FODC0002: Document has been marked not available:
  jar:file:/opt/sonarqube/data/web/deploy/plugins/xsl/META-INF/lib/sonar-schematron-reactor-1.0.0-SNAPSHOT.jar!/schematron-code/iso_schematron_skeleton_for_saxon.xsl
jimetevenard commented 4 years ago

See https://www.w3.org/TR/xslt20/#document

Note:
One effect of these rules is that unless XML entities or xml:base are used, and provided that the base URI of the stylesheet module is known, document("") refers to the document node of the containing stylesheet module (the definitive rules are in [RFC3986]). The XML resource containing the stylesheet module is processed exactly as if it were any other XML document, for example there is no special recognition of xsl:text elements, and no special treatment of comments and processing instructions.

iso_schematron_skeleton_for_saxon.xsl attempts to access itself.

This looks not possible when XSLT is accessed as a resource from a Jar. - Issue #7 is similar.

<xsl:template name="outputLocalizedMessage">
    <xsl:param name="number" />  

    <xsl:choose>
        <xsl:when test="string-length( $langCode ) = 0 or $langCode = 'default'" >       
            <xsl:value-of select='document("")//xhtml:p[@id=concat("sch-message-", $number)]/text()' />
        </xsl:when>
        <xsl:otherwise>
            <xsl:variable name="localizationDocumentFilename" >
                <xsl:value-of select="concat('sch-messages-', $langCode, '.xhtml')" />
            </xsl:variable>
            <xsl:variable name="theLocalizedMessage" >
                <xsl:value-of select=
            'document( $localizationDocumentFilename, /)//xhtml:p[@id=concat("sch-message-", $number, "-", $langCode)]/text()' />
            </xsl:variable>

            <xsl:choose>
                <!-- if we found any external message with that id, use it -->
                <xsl:when test=" string-length($theLocalizedMessage) &gt; 0">
                    <xsl:value-of select="$theLocalizedMessage" />
                </xsl:when>
                <xsl:otherwise>
                    <!-- otherwise use the default strings -->      
                    <xsl:value-of select='document("")//xhtml:p[@id=concat("sch-message-", $number)]/text()' />
                </xsl:otherwise>
            </xsl:choose>   

        </xsl:otherwise>
    </xsl:choose>
</xsl:template>
jimetevenard commented 4 years ago

This is very minor (and strongly linked to Skeleton) This has no influence on the compilation result, only on it's messaging

Probably wontfix

jimetevenard commented 3 years ago

Possible resolutions :

NB : Skeleton implementation is now deprecated. See README at https://github.com/Schematron/schematron

Quick-Fix

Fix iso_schematron_skeleton_for_saxon.xsl to access sch-message-* litterals via a global xsl:variable or xsl:param, and not with document("")//xhtml:p[@id=concat("sch-message-", $number)]/text().

Pretty easy since the iso_schematron_skeleton_for_saxon.xsl is duplicated here

Better but longer fix

implement #15 and migrate to the newer SchXslt Schematron implementation