xsl-list
[Top] [All Lists]

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

2014-02-28 12:45:51
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:

//errata_section[module_impacted=//module_index/module_impacted]

?

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

//errata_section[key('module-index',module_impacted)]

?

-Mike



On 2/28/14 1:17 PM, russurquhart1(_at_)verizon(_dot_)net wrote:
  Hi,

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:

<errata_section>
.
. bug info.
.
<module_impacted>DSS</module_impacted>
<module_impacted>VPE</module_impacted>
<module_impacted>VIP</module_impacted>

</errata_section>

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!

Russ
--~------------------------------------------------------------------
XSL-List info and archive:  http://www.mulberrytech.com/xsl/xsl-list
To unsubscribe, go to: http://lists.mulberrytech.com/xsl-list/
or e-mail: <mailto:xsl-list-unsubscribe(_at_)lists(_dot_)mulberrytech(_dot_)com>
--~--



--~------------------------------------------------------------------
XSL-List info and archive:  http://www.mulberrytech.com/xsl/xsl-list
To unsubscribe, go to: http://lists.mulberrytech.com/xsl-list/
or e-mail: <mailto:xsl-list-unsubscribe(_at_)lists(_dot_)mulberrytech(_dot_)com>
--~--