Group Adjacent Functionality in XSLT -


i have question use of group-adjacent.

i have seen 2 patterns being used:

pattern 1:

<xsl:for-each-group select="*" group-adjacent="boolean(self::p[@class = 'code'])"> 

pattern 2:

<xsl:for-each-group select="*" group-adjacent="@class"> 

based on used, noticed current-grouping-key() returns false.

what purpose of using boolean function in group-adjancent ?

with form <xsl:for-each-group select="*" group-adjacent="boolean(self::p[@class = 'code'])"> grouping key boolean value true adjacent p elements having class attribute value code while second form <xsl:for-each-group select="*" group-adjacent="@class"> grouping value string , groups adjacent elements same class attribute values.

so depends on needs, if have e.g.

<items>   <item class="c1">...</item>   <item class="c1">...</item>   <item class="c2">...</item> </items> 

you can use second approach group on class value.

on other hand, if want identify adjacent p elements class attribute, e.g. in

<body>   <h1>...</h1>   <p class="code">...</p>   <p class="code">...</p>   <h2>...</h2>   <p class="code">...</p> </body> 

then first approach allows that.


Comments

Popular posts from this blog

c++ - No viable overloaded operator for references a map -

java - Custom OutputStreamAppender not run: LOGBACK: No context given for <MYAPPENDER> -

java - Cannot secure connection using TLS -