Thanks for the comments, I'm glad it doesn't look like a silly pattern :)
Yes, this common module really looks like a package, especially this XSL is not
usable as is, it has to be imported.
But in the context of my company, our architecture is based on
xsl:import/include using uri "dependency" protocol (resolved by a catalog),
which make it difficult to use packages (which are not based on URI)
But I guess we could add visibility even if it's not used directly by the
package mechanism.
I added this issue : https://github.com/ELSGestion/els-sie-xsl-lib/issues/18
Thanks again Martin
-----Message d'origine-----
De : Martin Honnen martin(_dot_)honnen(_at_)gmx(_dot_)de
[mailto:xsl-list-service(_at_)lists(_dot_)mulberrytech(_dot_)com]
Envoyé : jeudi 9 juillet 2020 13:31
À : xsl-list(_at_)lists(_dot_)mulberrytech(_dot_)com
Objet : Re: [xsl] XSLT3 generic grouping functions
Am 09.07.2020 um 13:21 schrieb Matthieu RICAUD-DUSSARGET
m(_dot_)ricaud-dussarget(_at_)lefebvre-sarrut(_dot_)eu:
In the other xsl I pointed
https://github.com/ELSGestion/els-sie-xsl-lib/blob/master/src/main/xsl
/nest-titles.xsl
I use a kind on “interface” pattern :
This common xsl module defines function which returns a fatal error
saying “please override me to define your case”
<xsl:function name="xslLib:nest-title.getDeepLevel" as="xs:integer">
<xsl:param name="e" as="element()"/>
<xsl:sequence select="-1"/>
<xsl:message terminate="yes">[FATAL] Please implement an overriding
function for xslLib:nest-title.getDeepLevel() in your own
XSLT</xsl:message>
</xsl:function>
That’s what the nest-html-titles.xsl does defining level for HTML titles :
<xsl:function name="xslLib:nest-title.getDeepLevel" as="xs:integer">
<xsl:param name="e" as="element()"/>
<xsl:variable name="deepLlevel" as="xs:string">
<xsl:choose>
<xsl:when test="matches(local-name($e), '^h\d+$')">
<xsl:sequence select="substring-after(local-name($e), 'h')"/>
</xsl:when>
<xsl:otherwise>
<xsl:value-of select="'-1'"/>
</xsl:otherwise>
</xsl:choose>
</xsl:variable>
<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 I’m 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
--~----------------------------------------------------------------
XSL-List info and archive: http://www.mulberrytech.com/xsl/xsl-list
EasyUnsubscribe: http://lists.mulberrytech.com/unsub/xsl-list/1167547
or by email: xsl-list-unsub(_at_)lists(_dot_)mulberrytech(_dot_)com
--~--