This is the mail archive of the xsl-list@mulberrytech.com mailing list .


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]
Other format: [Raw text]

Re: Multi Level Grouping using Muenchian Grouping


Hi Rob,

> Thank you for your response. I in fact simplified things for posting
> so the second part of your response applies. One small point I need
> a bit of guidance on is that I need to drive this transform from a
> value from a combo box, so I presume that I need to send the value
> as a parameter to this transform. Given this what changes will i
> need to make to the tranform (I've had problems with parameters
> before :))

Without knowing how the parameter should affect the transformation,
it's hard to say. One difficulty with parameters combined with
Muenchian grouping is that you can't refer to a parameter (or global
variable) from within the match or use attributes on xsl:key. You
might want to only pick the assets whose name starts with the value in
the $name parameter, for example, in which case you'd *like* to be
able to do:

<xsl:param name="name" />

<xsl:key name="assets-by-processarea"
         match="asset[starts-with(name, $name)]/processareas/processarea"
         use="." />

but because of the restriction on where parameter references can go,
you can't do that.

Instead, you have to use the same general key definitions as before:

<xsl:key name="assets-by-processarea" match="processarea" use="." />

and then, when you *use* the key, filter the results so that it only
includes the assets that you're interested in. For example:

<xsl:variable name="process"
  select="key('assets-by-processarea', '2')
            [starts-with(../../name, $name)]" />

<xsl:template match="assets">
  <xsl:for-each
    select="$process[generate-id() =
                     generate-id(key('assets-by-level',
                                     concat(., ' ', ../../@level))
                                   [starts-with(../../name, $name)][1])]
              /../..">
    <xsl:sort select="@level" data-type="number" />
    <h1>
      <xsl:choose>
        <xsl:when test="@level = 1">AS Policies:</xsl:when>
        <xsl:when test="@level = 2">General:</xsl:when>
      </xsl:choose>
    </h1>
    <a href="{url}"><xsl:value-of select="assetname"/></a>
  </xsl:for-each>
</xsl:template>

Cheers,

Jeni

---
Jeni Tennison
http://www.jenitennison.com/


 XSL-List info and archive:  http://www.mulberrytech.com/xsl/xsl-list


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]