[XSL-LIST Mailing List Archive Home] [By Thread] [By Date] [Recent Entries] [Reply To This Message]

Re: XSLT3 generic grouping functions

Subject: Re: XSLT3 generic grouping functions
From: "Matthieu RICAUD-DUSSARGET m.ricaud-dussarget@xxxxxxxxxxxxxxxxxx" <xsl-list-service@xxxxxxxxxxxxxxxxxxxxxx>
Date: Thu, 9 Jul 2020 11:21:11 -0000
Re:  XSLT3 generic grouping functions
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 :

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">
  <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>

Thatbs 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 Ibm not sure this is a good practice or is used
by others.
Any thought about it ?

Current Thread

PURCHASE STYLUS STUDIO ONLINE TODAY!

Purchasing Stylus Studio from our online shop is Easy, Secure and Value Priced!

Buy Stylus Studio Now

Download The World's Best XML IDE!

Accelerate XML development with our award-winning XML IDE - Download a free trial today!

Don't miss another message! Subscribe to this list today.
Email
First Name
Last Name
Company
Subscribe in XML format
RSS 2.0
Atom 0.3
Site Map | Privacy Policy | Terms of Use | Trademarks
Free Stylus Studio XML Training:
W3C Member
Stylus Studio® and DataDirect XQuery ™are products from DataDirect Technologies, is a registered trademark of Progress Software Corporation, in the U.S. and other countries. © 2004-2013 All Rights Reserved.