Subject: Re: [xsl] XSLT3 generic grouping functions From: "Martin Honnen martin.honnen@xxxxxx" <xsl-list-service@xxxxxxxxxxxxxxxxxxxxxx> Date: Thu, 9 Jul 2020 11:30:34 -0000 |
Am 09.07.2020 um 13:21 schrieb Matthieu RICAUD-DUSSARGET m.ricaud-dussarget@xxxxxxxxxxxxxxxxxx:
In the other xsl I pointed
https://github.com/ELSGestion/els-sie-xsl-lib/blob/master/src/main/xsl/nest-t itles.xsl
I use a kind on binterfaceb pattern :XSLT</xsl:message>
This common xsl module defines function which returns a fatal error saying bplease override me to define your caseb
<xsl:function name="xslLib:nest-title.getDeepLevel" as="xs:integer">
B <xsl:param name="e" as="element()"/>
B <xsl:sequence select="-1"/>
B <xsl:message terminate="yes">[FATAL] Please implement an overriding function for xslLib:nest-title.getDeepLevel() in your own
:
</xsl:function>
Thatbs what the nest-html-titles.xsl does defining level for HTML titles
'h')"/>
<xsl:function name="xslLib:nest-title.getDeepLevel" as="xs:integer">
B <xsl:param name="e" as="element()"/>
B <xsl:variable name="deepLlevel" as="xs:string">
B B B <xsl:choose>
B B B B B <xsl:when test="matches(local-name($e), '^h\d+$')">
B B B B B B B <xsl:sequence select="substring-after(local-name($e),
B B B B B </xsl:when>
B B B B B <xsl:otherwise>
B B B B B B B <xsl:value-of select="'-1'"/>
B B B B B </xsl:otherwise>
B B B </xsl:choose>
B </xsl:variable>
B <xsl:sequence select="$deepLlevel cast as xs:integer"/>
</xsl:function>
I could define any other XSLT for this kind of title grouping by just importing the common module and overriding this function according to the XML grammar of title to nest.
I like this pattern even if Ibm not sure this is a good practice or is used by others.
Any thought about it ?
In the context of XSLT 2 or 3 based on importing modules with xsl:import it looks fine.
As you say you are also exploring new XSLT 3 features step by step, you could exploring packages and make that function abstract in the base package I think: https://www.w3.org/TR/xslt-30/#visibility
Current Thread |
---|
|
<- Previous | Index | Next -> |
---|---|---|
Re: [xsl] XSLT3 generic grouping fu, Matthieu RICAUD-DUSS | Thread | Re: [xsl] XSLT3 generic grouping fu, Matthieu RICAUD-DUSS |
Re: [xsl] XSLT3 generic grouping fu, Matthieu RICAUD-DUSS | Date | Re: [xsl] XSLT3 generic grouping fu, Matthieu RICAUD-DUSS |
Month |