[Home] [By Thread] [By Date] [Recent Entries]
Hi,
A week ago a posted the following problem and Abel Braaksma was kind enough to to give it some consideration. I have in the meantime come up with a solution and would like to solicit your comments on how to make it more simple and clear. There is a real question here as well: Where does the space in front of the closing bracket come from and how do I get rid of it? Thanks Erwin Here is my solution (I omitted the header line) and I appended my original problem: --- begin example.xsl ---
<?xml version="1.0" encoding="UTF-8"?>
<?altova_samplexml C:\workspaces\tmp\xsl\example.xml?>
<xsl:stylesheet version="2.0"
xmlns:xsl="http://www.w3.org/1999/XSL/Transform"
xmlns:fn="http://www.w3.org/2005/xpath-functions"
xmlns:xs="http://www.w3.org/2001/XMLSchema"><xsl:output method="text" version="1.0" encoding="iso-8859-1"/> <xsl:variable name="delimiter" select="'; '" /> <xsl:variable name="newline" select="' '" /> <xsl:template match="/">
<xsl:apply-templates/>
</xsl:template><xsl:template match="logpoint"> <xsl:variable name="this" select="." />
<xsl:variable name="dates" select="distinct-values(date/@value)" /> <xsl:variable name="max-count" >
<xsl:value-of select="max(for $date in $dates return
count(date[@value = $date]))" />
</xsl:variable> <xsl:for-each select="(1 to $max-count)" >
<xsl:variable name="i" select="." />
<xsl:value-of select="$this/@value" />
<xsl:value-of select="$delimiter" />
<xsl:for-each-group select="$this/date" group-by="@value" >
<xsl:if test="current-group()[$i]/@string" >
<xsl:value-of
select="concat(current-group()[$i]/@string, ' [',
current-group()[$i]/@count), ']'" />
</xsl:if>
<xsl:value-of select="$delimiter" />
</xsl:for-each-group> <xsl:value-of select="$newline" />
</xsl:for-each>
</xsl:template>
</xsl:stylesheet>
--- end example.xsl ---
I would appreciate some pointers at how to do this.
|

Cart



