Re: [xsl] Different results on different server

Subject: Re: [xsl] Different results on different server
From: Joelle Tegwen <tegwe002@xxxxxxx>
Date: Wed, 07 Oct 2009 14:56:15 -0500
My use of . in the key is probably due to not *really* understanding how it works. I'll remember your advice about using keys for future development. Thanks.

I changed my stylesheet to
<xsl:transform version="1.0" xmlns:xsl="";> <xsl:output method="html" verion="4.0" omit-xml-declaration="yes" encoding="iso-8859-1" indent="yes"/> <xsl:key name="project" match="project" use="."/>
<xsl:key name="project_id" match="project" use="@project_id"/>
<xsl:variable name="projects"
select="//project[generate-id() = generate-id(key('project', .))]"/>
<xsl:variable name="projects_id"
select="//project[generate-id() = generate-id(key('project_id', @project_id))]"/>
<xsl:template match="/staff">
<xsl:comment><xsl:value-of select="system-property('xsl:vendor')"/></xsl:comment> <xsl:value-of select="count($projects)"/><xsl:text> - </xsl:text>
select="count(//project[generate-id() = generate-id(key('project', .))])"/><xsl:text> - </xsl:text>
<xsl:value-of select="count($projects_id)"/><xsl:text> - </xsl:text>
select="count(//project[generate-id() = generate-id(key('project_id', @project_id))])"/>

(to test your thought that it might be the key).

<!--libxslt-->5 - 5 - 5 - 5

Test <!--libxslt-->0 - 5 - 0 - 5

Does this help?

Add somewhere in your stylesheet:


and please report what the two processors say.

Given that the project element is:

        <project project_id="5">
         <title>Separated Project</title>
         <project_type> Project</project_type>
         <short_desc>This project is separated</short_desc>

it's very odd to use "." (the string value of the project element) as the
key. It should work in theory, but it's sufficiently odd that this is
probably where the bug lies. I would have expected to see something like


Michael Kay

Current Thread