|
Subject: Re: [xsl] Sort multiple xml files with identical keys From: "G. Ken Holman" <gkholman@xxxxxxxxxxxxxxxxxxxx> Date: Wed, 01 Mar 2006 09:20:07 -0500 |
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)
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: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: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@xxxxxxxxxxxxxxxxxxxx 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
| Current Thread |
|---|
|
| <- Previous | Index | Next -> |
|---|---|---|
| [xsl] Sort multiple xml files with , Tapio.Niva | Thread | RE: [xsl] Sort multiple xml files w, Michael Kay |
| AW: [xsl] XHTML to Cals table conve, Huditsch, Roman \(LN | Date | Re: [xsl] XHTML to Cals table conve, andrew welch |
| Month |