[XSL-LIST Mailing List Archive Home] [By Thread] [By Date] [Recent Entries] [Reply To This Message]

RE: A more complicated Muenchian Method exercise

Subject: RE: A more complicated Muenchian Method exercise
From: "Greg Johnson" <gjohnson@xxxxxxxxxxxx>
Date: Mon, 21 Jul 2003 12:05:15 -0400
mssql concat
Américo Albuquerque,
Thank you for the effort, but I don't think you captured what I was trying
to accomplish.

The key:
> <xsl:key match="header" name="key2_name"
> use="concat(date,':',sender/sen_id,':',sender/recipient/rec_id)"/>

seems to be a cartesion product, instead of a union.  Unless I am incorrect?
and the TRADING PARTNER is the union of sender/sen_id and
sender/recipient/rec_id, not just made of senders.
> <xsl:template match="header" mode="level2">
>    <xsl:text>&#160;&#160;&#160;&#160;TRADING PARTNER: &quot;</xsl:text>
>    <xsl:value-of select="sender/sen_id"/>

The XML Structure is from MS SQL, and so the nesting structure does not
follow the actual logical grouping of the data.
Senders and Recipients should be at the same (header) level, instead of
nested, but I'm stuck with what MSSQL gives me.  I want to group the
document ids on (Senders AND Recipients).  Each document ID appears twice in
the report: once under the sender, and once under the recipient, for that
date.


-----Original Message-----
From: owner-xsl-list@xxxxxxxxxxxxxxxxxxxxxx
[mailto:owner-xsl-list@xxxxxxxxxxxxxxxxxxxxxx]On Behalf Of Américo
Albuquerque
Sent: Monday, July 21, 2003 11:29 AM
To: xsl-list@xxxxxxxxxxxxxxxxxxxxxx
Subject: RE:  A more complicated Muenchian Method exercise


Hi

> -----Original Message-----
> From: owner-xsl-list@xxxxxxxxxxxxxxxxxxxxxx
> [mailto:owner-xsl-list@xxxxxxxxxxxxxxxxxxxxxx] On Behalf Of
> Greg Johnson
> Sent: Monday, July 21, 2003 2:30 PM
> To: xsl-list@xxxxxxxxxxxxxxxxxxxxxx
> Subject:  A more complicated Muenchian Method exercise
>
>
> In this last week and a half, I have been on a serious
> learning curve, and this list has helped me a lot.  Thanks.
> Now I need some more.  :)
>
> I have the following (abbreviated) XML Structure
>
> <report>
>
> <header>
> <date></date>
> <sender>
> <sen_id></sen_id>
> <recipient>
>   <rec_id></rec_id>
>   <detail></detail>
>   <detail></detail>
> </recipient>
> </sender>
> </header>
>
> <header>
> <date></date>
> <sender>
> <sen_id></sen_id>
> <recipient>
>   <rec_id></rec_id>
>   <detail></detail>
>   <detail></detail>
>   <detail></detail>
> </recipient>
> </sender>
> </header>
>
> ...
>
> </report>
>
>
> I would like to make a report based on the above XML that has
> a primary grouping by "date", which is no problem. What I'm
> not sure about is how to do a second grouping on the UNIONED
> SET of senders and recipients.  That is, I have a set called
> "Trading Partner", of which "sender" and "recipients" are
> members.  That way I can then produce an output that groups
> on TP's, and then I could output the documents that were
> received, and then sent for a particular "Trading Partner".  Like the
> following:
>
> REPORT
>   DATE1
>     TRADING PARTNER: "name1"
>         DOCUMENTS SENT
>         DOCUMENTS REC'D
>     TRADING PARTNER: "name2"
>         DOCUMENTS SENT
>         DOCUMENTS REC'D
>   DATE2 ...
>

So, your second group will be on the pair(sen_id, rec_id). You can do that
using concat instead of union '|'
Something like: <xsl:key name="key2_name" match="header"
use="concat(date,':',sender/sen_id,' ',sender/recipient/rec_id)"/>

According to you output you want to display unique pairs so you can count
how many docs has been sent. You do this applying the second group in the
same way you applyied the first:

<xsl:apply-templates
select="key('key1_name',date)[generate-id()=generate-id('key2_name',concat(d
ate,':',sender/sen_id,' ',sender/recipient/rec_id))]"/>

(...)

The complete stylesheet:

  <xsl:key match="header" name="key1_name" use="date"/>
  <xsl:key match="header" name="key2_name"
use="concat(date,':',sender/sen_id,':',sender/recipient/rec_id)"/>
  <xsl:template match="report">
    <xsl:text>Report:&#10;</xsl:text>
    <xsl:apply-templates mode="level1"
select="header[generate-id()=generate-id(key('key1_name',date))]"/>
  </xsl:template>
  <xsl:template match="header" mode="level1">
    <xsl:text>&#160;&#160;</xsl:text>
    <xsl:value-of select="date"/>
    <xsl:text>&#10;</xsl:text>
    <xsl:apply-templates mode="level2"
select="key('key1_name',date)[generate-id()=generate-id(key('key2_name',conc
at(date,':',sender/sen_id,':',sender/recipient/rec_id)))]"/>
  </xsl:template>
  <xsl:template match="header" mode="level2">
    <xsl:text>&#160;&#160;&#160;&#160;TRADING PARTNER: &quot;</xsl:text>
    <xsl:value-of select="sender/sen_id"/>
    <xsl:text>&quot;&#10;</xsl:text>
    <xsl:text>&#160;&#160;&#160;&#160;&#160;&#160;Documents sent </xsl:text>
    <xsl:value-of
select="count(key('key2_name',concat(date,':',sender/sen_id,'
',sender/recipient/rec_id)))"/>
    <xsl:text>&#10;</xsl:text>
    <xsl:text>&#160;&#160;&#160;&#160;&#160;&#160;Documents REC'D
</xsl:text>
    <xsl:value-of select="sender/recipient/rec_id"/>
    <xsl:text>&#10;</xsl:text>
  </xsl:template>

Hope this helps you.



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



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


Current Thread

PURCHASE STYLUS STUDIO ONLINE TODAY!

Purchasing Stylus Studio from our online shop is Easy, Secure and Value Priced!

Buy Stylus Studio Now

Download The World's Best XML IDE!

Accelerate XML development with our award-winning XML IDE - Download a free trial today!

Don't miss another message! Subscribe to this list today.
Email
First Name
Last Name
Company
Subscribe in XML format
RSS 2.0
Atom 0.3
Site Map | Privacy Policy | Terms of Use | Trademarks
Free Stylus Studio XML Training:
W3C Member
Stylus Studio® and DataDirect XQuery ™are products from DataDirect Technologies, is a registered trademark of Progress Software Corporation, in the U.S. and other countries. © 2004-2013 All Rights Reserved.