RE: [xsl] Set difference in xsl:number/@count, xsl:key/@match

Subject: RE: [xsl] Set difference in xsl:number/@count, xsl:key/@match
From: "Michael Kay" <mike@xxxxxxxxxxxx>
Date: Wed, 21 Mar 2007 22:39:12 -0000
> I sort 
> of want to say
>   <xsl:number count="*[contains(@class, ' figure ')]
>               except *[contains(@class, ' flowchart ')]"/> 
> only set difference doesn't work in xsl:number/@count, even 
> in XSLT 2.0. 
> Besides, the base processing can't necessarily know about 
> flowcharts, circuitdiagrams, familytrees, or however many 
> specializations of "figure"
> I've included.  Each specialization has to have its own 
> processing XSLT.

I think I would use

<xsl:number count="*[my:is-class-figure(.)]"/>

where the function my:class-figure is defined in the base stylesheet as

<xsl:function name="my:is-class-figure">  
  <xsl:param name="node" as="element()"/>
  <xsl:sequence select="contains($node/@class, ' figure ')"/>
</xsl:function>

and is redefined in your customization layer as:

<xsl:function name="my:is-class-figure">
  <xsl:param name="node" as="element()"/>
  <xsl:sequence select="contains($node/@class, ' figure ') and
not(contains(@class, ' flowchart '))"/>
</xsl:function>

Michael Kay
http://www.saxonica.com/

Current Thread