Welcome to WebmasterWorld Guest from

Forum Moderators: httpwebwitch

Message Too Old, No Replies

Problem with XSL key generation

5:30 pm on May 27, 2011 (gmt 0)

New User

joined:May 27, 2011
posts: 1
votes: 0

I have a problem with generating keys in XSL stylesheet.
First I post my code of XSL file:

<?xml version="1.0" encoding="UTF-8"?>
<xsl:stylesheet xmlns:xsl="http://www.w3.org/1999/XSL/Transform" version="1.0">
<xsl:output method="html"/>
<xsl:key name="distinct-author" match="author" use="."/>
<xsl:key name="distinct-date" match="logentry" use="substring-before(date, 'T')"/>
<xsl:template match="/">

<script type="text/javascript">

function selectNode(nodeid)
var divs = document.getElementsByClassName(nodeid);
for(var i=0; divs.length > i; i++) {




<h1>SVN Log</h1>
<xsl:for-each select="//author[generate-id()=generate-id(key('distinct-author',.)[1])]">
<xsl:variable name="forSelectArtist"><xsl:value-of select="."/></xsl:variable>
<option value="{$forSelectArtist}" onclick="selectNode(this.value)"><xsl:value-of select="."/></option>
<table border="1">
<tr bgcolor="#9acd32">

<xsl:for-each select="//logentry[generate-id()=generate-id(key('distinct-date', substring-before(date, 'T'))[1])]">
<xsl:sort select="date"/>
<xsl:variable name="currentArtist"><xsl:value-of select="author"/></xsl:variable>
<div class="{$currentArtist}" style="display:none;">

<xsl:for-each select="key('distinct-date', substring-before(date, 'T'))">

<xsl:if test="position() = 1">
<td valign="center">

<xsl:value-of select="substring-before(date, 'T')"/>


<xsl:value-of select="msg"/><br/>



My xml file is logfile generated from SVN system. example node looks like:

<logentry revision="27046">
<msg>[ LS + CP ] : Fixed bug concerning -&gt; added feature toggle for hotline calculator to deactivated OfferInfoBox in Production </msg>

Why is my xsl file is lost every second date, I probably have an error when creating the keys when I use substring-before function...

Help please!