[XSL-LIST Mailing List Archive Home] [By Thread] [By Date]

Re: [xsl] Can someone explain this generate-id and key xsl fragment to me?

Subject: Re: [xsl] Can someone explain this generate-id and key xsl fragment to me?
From: Michael Sokolov <msokolov@xxxxxxxxxxxxxxxxxxxxx>
Date: Fri, 28 Feb 2014 13:45:41 -0500

I don't see how that could ever work since it is comparing generate-id(.) (where . is in //errata_section) with generate-id (module_impacted), so those should never be equal?

generate-id() is an XSLT 1 hack that lets you compare based on element identity (rather than the more typical value comparison).

It's hard to be sure since your example is incomplete, but it looks as if the intent is to look up the module_impacted keys in an index somewhere else? I think you might want something like:



which could also probably be made faster using a key; maybe:




On 2/28/14 1:17 PM, russurquhart1@xxxxxxxxxxx wrote:

I'm having to manage an xslt that someone else wrote, that generally works correctly, but when it doesn't i have problems.

In one template that is a for-each command that is executed. The line is:

<xsl:for-each select="//errata_section[generate-id(.)=generate-id(key('module-index', module_impacted)[1])]">
  <xsl:sort select="module_impacted"/>

The xml it is processing are bugs of a form:

. bug info.


And there are hundreds of errata_section elements, each with a module_impacted element(s) reflecting, for the specific errata_section, those modules it impacts. There must be at least one module_impacted element per errata_section, but, as in the example above, there may be more.

The above line, is supposed to sort, and process each module_impacted element, outputting tables based on the value of the module_impacted element.

What i am seeing is, and i can't determine what is causing this, is certain module_impacted elements don't seem to get selected and processed. When the final output is generated some are missing altogether. For the example above, the above line should process, in due course, DSS, then later down the road, VIP, and then VPE. What i'm seeing in the debugger, is VIP and VPE not getting picked up or processed at all.

To complicate matters, when i use Stylus Studio to debug, using Saxon as the internal debugger, i get a different result than if i use libxslt. Both give incorrect output, but some are less incorrect than others. (The libxslt, seems to find VPE, but not VIP, but that is handled incorrectly as well.)

I guess if someone could help me to understand what the fragment is doing, maybe that would help me to better dubg this!

Thanks for any help!


Current Thread