homepage Welcome to WebmasterWorld Guest from 54.197.189.108
register, free tools, login, search, pro membership, help, library, announcements, recent posts, open posts,
Pubcon Platinum Sponsor 2014
Home / Forums Index / Code, Content, and Presentation / XML Development
Forum Library, Charter, Moderators: httpwebwitch

XML Development Forum

    
Problem with XSL key generation
czuczu1024




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

Welcome,
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="/">
<html>
<head>

<script type="text/javascript">

function selectNode(nodeid)
{
var divs = document.getElementsByClassName(nodeid);
for(var i=0; divs.length > i; i++) {
divs[i].style.display='table-row'
};

};

</script>

</head>
<body>

<h1>SVN Log</h1>
<select>
<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>
</xsl:for-each>
</select>
<table border="1">
<tr bgcolor="#9acd32">
<th>Date</th>
<th>Message</th>
</tr>

<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')"/>

</td>
</xsl:if>


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

</xsl:for-each>

</div>
</xsl:for-each>
</table>
</body>
</html>
</xsl:template>
</xsl:stylesheet>



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

<log>
<logentry revision="27046">
<author>dev060</author>
<date>2011-03-30T16:04:12.384275Z</date>
<msg>[ LS + CP ] : Fixed bug concerning -&gt; added feature toggle for hotline calculator to deactivated OfferInfoBox in Production </msg>
</logentry>
</log>


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!

 

Global Options:
 top home search open messages active posts  
 

Home / Forums Index / Code, Content, and Presentation / XML Development
rss feed

All trademarks and copyrights held by respective owners. Member comments are owned by the poster.
Home ¦ Free Tools ¦ Terms of Service ¦ Privacy Policy ¦ Report Problem ¦ About ¦ Library ¦ Newsletter
WebmasterWorld is a Developer Shed Community owned by Jim Boykin.
© Webmaster World 1996-2014 all rights reserved