RE: [xsl] FW: key, generate-id, ignoring my template

Subject: RE: [xsl] FW: key, generate-id, ignoring my template
From: "Andreas L. Delmelle" <a_l.delmelle@xxxxxxxxxx>
Date: Mon, 22 Mar 2004 23:56:42 +0100
> -----Original Message-----
> From: Laura Madonna [mailto:Laura.Madonna@xxxxxxxxx]
>
> (I have cut down the xsl and xml).
> The problem is, I don't think the template to match on "page" is working:
>
>

Hi,

No, actually, I believe your problem is the variable definitions.
They return you nodes from the whole document, instead of just the context
node...

It's ok (even obligatory) to have the *key* definitions as children of the
xsl:stylesheet, but you probably want to move the variable declarations into
the matching template, and while you're at it, go for compound keys, like

<xsl:key name="row-plan_desc-page" match="row"
         use="concat(ancestor::page/@name,
           ' ', plan_desc)" />
<xsl:key name="row-heading-page" match="row"
         use="concat(ancestor::page/@name,
           ' ', heading)" />

In combination with:

<xsl:template match="/form/page/pcp">
  <xsl:variable name="vBenePlan"
                select="row[generate-id() = generate-id(
                  key('row-plan_desc-page', concat(
                    ancestor::page/@name,' ',plan_desc)))]" />
  <xsl:variable name="vHeading"
                select="row[generate-id() = generate-id(
                  key('row-heading-page', concat(
                    ancestor::page/@name,' ',heading)))]" />
...

Hope this helps!

Cheers,

Andreas

Current Thread