[xsl] More Problems/Confusion Grouping with Meunchian Method

Subject: [xsl] More Problems/Confusion Grouping with Meunchian Method
From: "Magick, Brian" <Brian.Magick@xxxxxxxxxx>
Date: Mon, 10 Dec 2001 21:06:45 -0600
Hi:

I'm resorting to a post on this board as a last result of literally days
of work trying to properly group a set of data with the Meunchian method
with improper results.  Hopefully my mistake is minor and someone can
quickly point me in the right direction.  I'm sure others on this list
can attest that grouping with XSLT can be a nightmare!!!  Hopefully the
next revision of XSL brings some improvements.

My XML:  basically a list of products where each product can belong to
multiple technology areas.

<PRODUCTS>
   <PRODUCT>
      <NAME>WINDOWS XP</NAME>
	<TECHNOLOGY domain="1" bookmark="xp">Desktop Operating
System</TECHNOLOGY>
	<TECHNOLOGY domain="2" bookmark="xp">Workstation OS</TECHNOLOGY>
   </PRODUCT>
   <PRODUCT>
	<NAME>Outlook</NAME>
	<TECHNOLOGY domain="2" bookmark="outlook">Desktop Email
Client</TECHNOLOGY>
   </PRODUCT>
   <PRODUCT>
	<NAME>Power Designer</NAME>
	<TECHNOLOGY domain="1" bookmark="pd">Repository Tool<TECHNOLOGY>
	<TECHNOLOGY domain="2" bookmark="pd">CASE Tools</TECHNOLOGY>
   </PRODUCT>
   <PRODUCT>
	<NAME>ERWIN</NAME>
	<TECHNOLOGY domain="2" bookmark="erwin">CASE Tools</TECHNOLOGY>
	<TECHNOLOGY domain="1" bookmark="erwin">Repository
Tool<TECHNOLOGY>
   </PRODUCT>

The list:

I want a list of each product by Technology.  Some products will need to
be displayed twice in different technology categories.  Rather than
using an "apply-templates" call that most examples of the Meunchian
Method use, I want to use a for-each loop to group each technology and
then list all of the product names that directly apply to that
technology for a given domain.

Ex:  Domain 1

Desktop Email Client
   Outlook
Desktop Operating System
   Windows XP
Repository Tool
   Power Designer

The problem:  When I create the list the filter doesn't work right
because if a product exists for a technology in Domain = 1, and also
exists in another technology Domain 1 has in its list (even if not for
Domain = 1), the product lists for each technology.  For example, ERWIN
has Domain = 1 with a technology of CASE Tool.  It also has a Domain = 2
Repository Tool.  We are not interested in this second case if we filter
by Domain = 1....BUT  Power Designer exists in Domain = 1 under
Repository Tool.  When we render the Domain = 1 Power Designer
Repository Tool listing it also renders the Repository Tool entry for
ERWIN although its Repository Tool entry ONLY applies to Domain 2.
Crystal clear, right?

My stylesheet components:

<xsl:key name="gt" match="GOVERNING_TECHNOLOGY" use="."/>
<xsl:key name="prod4gt" match="PRODUCT" use="GOVERNING_TECHNOLOGY"/>

I use the first key "gt" to match get the list of Technology items and
then list the products referencing the 2nd key:

<xsl:for-each
select="PRODUCTS/PRODUCT/GOVERNING_TECHNOLOGY[generate-id(.) =
                                            generate-id(key('gt', .)
[@domain = '1'])]">
<br/><xsl:value-of select="."/>
<xsl:for-each select="key('prod4gt',.)">
<br/><xsl:value-of select="NAME"/>
</xsl:for-each>
</xsl:for-each>

I can't recall how many variations of calling the 2nd key I've tried but
I think I need to filter the 2nd key by the Domain = 1 so that I only
get the results for the right domain.  Not quite sure if this is the
case and I've been unsuccessful trying to do this.

Any pointers are appreciated before I go crazy trying to figure this
out!!!  Thanks.


Brian Magick



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


Current Thread