xslt - XML group by multiple attributes using XSL -


the xsl file groups report alert, using unique identifier. however, should grouping site name + alert. site has name attribute:

<site name="http://192.168.56.110" host="192.168.56.110" port="80" ssl="false"> 

this because possible multiple sites have same alert. alert show under 1 site. suggestions on how modify code, alerts grouped alert , site?

currently xsl looks this:

<?xml version="1.0" encoding="utf-8"?> <xsl:stylesheet version="1.0" xmlns:xsl="http://www.w3.org/1999/xsl/transform"> <xsl:output method="xml" version="1.0"  encoding="utf-8" indent="yes" />   <xsl:template match="/report">   <report><xsl:copy-of select="@*" />   <reportname>     <xsl:value-of select="reportname"/>   </reportname>   <reportdesc>     <xsl:value-of select="reportdesc"/>   </reportdesc>   <xsl:for-each select="site">     <site><xsl:copy-of select="@*" />       <alerts>         <xsl:key name="alertbyalert" match="alertitem" use="concat(alert)" />         <xsl:for-each select="alerts/alertitem[generate-id() = generate-id(key('alertbyalert',alert))]">           <alertitem>               <alert>                 <xsl:value-of select="alert"/>               </alert>               <riskcode>                 <xsl:value-of select="riskcode"/>               </riskcode>               <riskdesc>                 <xsl:value-of select="riskdesc"/>               </riskdesc>                <xsl:for-each select="key('alertbyalert', alert)">                 <uri>                   <xsl:value-of select="uri"/>                 </uri>                 <param>                   <xsl:value-of select="param"/>                 </param>                   <attack>                   <xsl:value-of select="attack"/>                 </attack>                            </xsl:for-each>             </alertitem>         </xsl:for-each>       </alerts>      </site>    </xsl:for-each >    </report> </xsl:template>  </xsl:stylesheet> 

change key to

<xsl:key name="k1" match="alertitem" use="concat(ancestor::site/@name, '|', alert)" /> 

(and put child of xsl:stylesheet, not allowed elsewhere).

then can use key in

<xsl:for-each select="alerts/alertitem[generate-id() = generate-id(key('k1', concat(ancestor::site/@name, '|', alert))[1])]"> 

Comments

Popular posts from this blog

toolbar - How to add link to user registration inside toobar in admin joomla 3 custom component -

linux - disk space limitation when creating war file -