如何在终止处理之前打印 XSLT 2.0 中所有缺失的属性?

问题描述 投票:0回答:0

我正在开发一个 DITA-OT 插件,我有一个 XSLT 模板,如果任何主题元素不包含 @appname 属性,我需要在其中终止处理。虽然这种方法效果很好,但它会在遇到第一次出现缺失的@appname 属性时立即停止处理,这不允许我在日志文件中看到任何其他缺失事件。

我的问题是:是否可以修改下面的 XSLT 模板,使其首先打印出所有缺失的 @appname,然后终止 XSLT 处理?

<xsl:template match="*[contains(@class, ' map/topicref ')][not(@toc = 'no')][not(@processing-role = 'resource-only')]">
        <xsl:variable name="WORKDIR" select="'/work/'"/>
        <xsl:variable name="FileWithPath">
                    <xsl:value-of select="$WORKDIR"/>
                    <xsl:value-of select="substring-before(@href, '#')"/>
        </xsl:variable>
        <xsl:variable name="TargetFile" select="document($FileWithPath, /)"/>        
        <xsl:choose>
            <xsl:when test="contains(@class, ' mapgroup/topicgroup ')">
                <xsl:apply-templates/>
            </xsl:when>            
            <xsl:otherwise>
                <xsl:choose>
                    <xsl:when test="*[contains(@class, ' map/topicref mapgroup-d/topichead ')] or contains(@class, ' map/topicref mapgroup-d/topichead ')">
                        <xsl:apply-templates/>
                    </xsl:when>
                    <xsl:otherwise>
                        <topic>                            
                            <xsl:if test="not($TargetFile/*[contains(@class, ' topic/topic ')]/*[contains(@class, ' topic/prolog ')]/*[contains(@class, ' topic/resourceid ')][@appname = 'abc'])">
                                <xsl:message terminate="yes">
                                    <xsl:value-of select="'Error: Topic does not contains appname '"/><xsl:value-of select="$TargetFile/*[contains(@class, ' topic/topic ')]/@id"/>                                    
                                </xsl:message>
                            </xsl:if>
                            <xsl:apply-templates/>
                        </topic>
                    </xsl:otherwise>
                </xsl:choose>
            </xsl:otherwise>
        </xsl:choose>
    </xsl:template>
xslt-2.0 dita-ot
© www.soinside.com 2019 - 2024. All rights reserved.