At 2006-03-01 15:51 +0200, Tapio(_dot_)Niva(_at_)tietoenator(_dot_)com wrote:
I'm using IE6 & MSXML to transform,sort and count 2 separate xml docs,
but the results are not as I expected.
As a beginner, I obviously have understood something wrong, I'm using
the so-called "Muenchian method" here (...wtg for the XSLT 2.0 to MSXML)
The Muenchian method works only in a single document context.
I've posted before about using variable-based grouping across
multiple documents:
http://www.biglist.com/lists/xsl-list/archives/200410/msg00412.html
In our hands-on training for XSLT 1.0 (next one in less than two
weeks) we cover three ways of doing grouping: axis-based, key-based,
and variable-based ... each have their place in document
transformation solutions. Axis-based is good for the adjacent
context (hiding adjacent duplicates), key-based is good for a
document-wide context, and variable-based is good for either
sub-document context or a multiple-document context.
I hope the answer below helps.
. . . . . . . . . . . Ken
T:\ftemp>type net_sample1.xml
<?xml version="1.0" encoding="UTF-8"?>
<?xml-stylesheet type="text/xsl" href="net_sample.xsl"?>
<List>
<row>
<row_id>A1</row_id>
<row_status>New</row_status>
</row>
<row>
<row_id>A2</row_id>
<row_status>New</row_status>
</row>
<row>
<row_id>A2</row_id>
<row_status>Old</row_status>
</row>
</List>
T:\ftemp>type net_sample2.xml
<?xml version="1.0" encoding="UTF-8"?>
<?xml-stylesheet type="text/xsl" href="net_sample.xsl"?>
<List>
<row>
<row_id>A1</row_id>
<row_status>New</row_status>
</row>
<row>
<row_id>A1</row_id>
<row_status>New</row_status>
</row>
<row>
<row_id>A2</row_id>
<row_status>Old</row_status>
</row>
</List>
T:\ftemp>xslt tapio.xsl tapio.xsl con
A1 Old rows=0 New rows=3
A2 Old rows=2 New rows=1
T:\ftemp>type tapio.xsl
<?xml version="1.0" encoding="ISO-8859-1"?>
<xsl:stylesheet xmlns:xsl="http://www.w3.org/1999/XSL/Transform"
version="1.0">
<xsl:output method="text"/>
<xsl:template match="/">
<xsl:variable name="all_docs"
select="document('net_sample1.xml')/List/row |
document('net_sample2.xml')/List/row "/>
<xsl:for-each select="$all_docs">
<xsl:if test="generate-id(.)=
generate-id($all_docs[row_id=current()/row_id][1])">
<xsl:value-of select="row_id"/>
<xsl:text> Old rows=</xsl:text>
<xsl:value-of select="count($all_docs[row_id=current()/row_id]
[row_status='Old'])"/>
<xsl:text> New rows=</xsl:text>
<xsl:value-of select="count($all_docs[row_id=current()/row_id]
[row_status='New'])"/>
<xsl:text>
</xsl:text>
</xsl:if>
</xsl:for-each>
</xsl:template>
</xsl:stylesheet>
T:\ftemp>
--
Upcoming XSLT/XSL-FO hands-on courses: Washington,DC 2006-03-13/17
World-wide on-site corporate, govt. & user group XML/XSL training.
G. Ken Holman mailto:gkholman(_at_)CraneSoftwrights(_dot_)com
Crane Softwrights Ltd. http://www.CraneSoftwrights.com/s/
Box 266, Kars, Ontario CANADA K0A-2E0 +1(613)489-0999 (F:-0995)
Male Cancer Awareness Aug'05 http://www.CraneSoftwrights.com/s/bc
Legal business disclaimers: http://www.CraneSoftwrights.com/legal
--~------------------------------------------------------------------
XSL-List info and archive: http://www.mulberrytech.com/xsl/xsl-list
To unsubscribe, go to: http://lists.mulberrytech.com/xsl-list/
or e-mail: <mailto:xsl-list-unsubscribe(_at_)lists(_dot_)mulberrytech(_dot_)com>
--~--