github.com/matislovas/ratago@v0.0.0-20240408115641-cc0857415a7a/xslt/testdata/general/bug-133.xsl (about) 1 <xsl:stylesheet version="1.0" xmlns:xsl="http://www.w3.org/1999/XSL/Transform"> 2 <xsl:output method="xml" /> 3 4 <xsl:key name="next-headings" match="h2" 5 use="generate-id(preceding-sibling::h1[1])" /> 6 7 <xsl:key name="immediate-nodes" 8 match="node()[not(self::h1 | self::h2)]" 9 use="generate-id(preceding-sibling::*[self::h1 or self::h2][1])" /> 10 11 <xsl:template match="h1 | h2"> 12 <hintsection> 13 <hinttitle><xsl:apply-templates /></hinttitle> 14 <xsl:apply-templates 15 select="key('immediate-nodes', generate-id(.))" /> 16 <xsl:apply-templates select="key('next-headings', generate-id(.))" /> 17 </hintsection> 18 </xsl:template> 19 20 <xsl:template match="node()|@*"> 21 <xsl:copy> 22 <xsl:apply-templates select="node()|@*"/> 23 </xsl:copy> 24 </xsl:template> 25 26 <xsl:template match="body"> 27 <xsl:copy> 28 <xsl:apply-templates select="(h1|h2)[1]" /> 29 </xsl:copy> 30 </xsl:template> 31 32 </xsl:stylesheet>