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 ...
I tried adapting the familiar syntax:
key('key2_name', concat(key1, ' ', key2))
to
key('key2_name', concat(arrive_date, ' ', sender/sen_id |
sender/recipient/rec_id) )
but the conversion of the OR'd set to a string does not work. It seems to
ignore the rec_id, and I only get the sender set.
I could re-organise my XML, I suppose, but I'd rather not, since I've
already built a couple XSL docs based on the above (which comes from SQL
Server's XML AUTO, ELEMENTS dump). And I'd like to see how to achieve this
anyways.
----------
Below is an exerpt of the actual XSL (sen_id and rec_id are tpid here, and
DTSEnvelopes = header, and arrived = date). This seems to output a line for
each sender/tpid but not Sender/Recipient/tpid
<xsl:key name="DTSEnvelopes-by-arrived" match="DTSEnvelopes"
use="substring-before(arrived, 'T')" />
<xsl:key name="DTSEnvelopes-by-arrived-tp" match="DTSEnvelopes"
use="concat(substring-before(arrived, 'T'), ' ', Sender/tpid |
Sender/Recipient/tpid)" />
<xsl:for-each select="DTSEnvelopes[count(. |
key('DTSEnvelopes-by-arrived-tp',concat(substring-before(arrived, 'T'), ' ',
Sender/tpid | Sender/Recipient/tpid) )[1]) = 1]" >
<xsl:sort select="substring-before(arrived, 'T')" order="ascending" />
<h1><xsl:value-of select="concat(substring-before(arrived, 'T'), ' ',
Sender/tpid | Sender/Recipient/tpid)" /><br/> <!-- This line only gives
"arrived sender/tpid", no "arrived sender/recipient/tpid" -->
<xsl:value-of select="Sender/tpid"/><br />
<xsl:value-of select="Sender/Recipient/tpid" />
</h1>
</xsl:for-each>
-----------------
Thanks,
Greg
XSL-List info and archive: http://www.mulberrytech.com/xsl/xsl-list