BlackLab icon indicating copy to clipboard operation
BlackLab copied to clipboard

Invalid xslt generated in rare circumstances

Open KCMertens opened this issue 11 months ago • 0 comments

As reported by @PrinsINT
Attached input format and resulting xslt attached. The offending config is:

- name: word
  displayName: Word
  valuePath: if (./seg) then ./seg else .

Resulting in:

<xsl:template match="//TEI//text//w[not (ancestor::note)]">
    <span class="word">
        <xsl:attribute name="data-toggle" select="'tooltip'"/>
        <xsl:attribute name="data-lemma">
        <xsl:value-of select="@lemma"/>
        </xsl:attribute>
        <xsl:value-of select="if (./seg) then ./seg else "/>
    </span>
    <xsl:text> </xsl:text>
</xsl:template>

Caused by https://github.com/INL/BlackLab/blob/dev/wslib/src/main/java/nl/inl/blacklab/server/lib/results/XslGenerator.java#L53

Probably an easy fix to just simplify the joining of the xpaths, there's a comment

// split and explode into cartesian product... // a|b c -> a/c | b/c // because a/(b|c) is not valid xpath

But in a quick test, that no longer seems true with xslt and 2/3 and a/(b|c) is now perfectly valid. xslt.txt GalahadCobaltTEI.blf.yaml.txt

KCMertens avatar Mar 06 '24 13:03 KCMertens