[XSL-LIST Mailing List Archive Home]
[By Thread]
[By Date]
At 2004-03-29 22:08 -0500, Alan Stein wrote:
Not sure why you think parentheses are needed ... the following-sibling axis is already in document order.
Which is to say there is an "a" without a "b" following sibling.
Which is to say there is a "b" without an "a" following sibling.
I hope the example below helps.
............... Ken
<xsl:output method="text"/>
</xsl:template>
Re: [xsl] having difficulty with XSL/XML statement
Subject: Re: [xsl] having difficulty with XSL/XML statement From: "G. Ken Holman" <gkholman@xxxxxxxxxxxxxxxxxxxx> Date: Mon, 29 Mar 2004 23:21:09 -0500 |
At 2004-03-29 22:08 -0500, Alan Stein wrote:
I have small XSL example which is posing rather large difficulty for me... (I think due to the use of parenthesis needed for document order location path).
Not sure why you think parentheses are needed ... the following-sibling axis is already in document order.
In the following XML document, I need to be able to query the following:
1) The number of reports which contain an "a" or "b" code where the last code (in document order) which is either an "a" or "b" is an "a".
Which is to say there is an "a" without a "b" following sibling.
*correct number is 3 *
2) The number of reports which contain an "a" or "b" code where the last code (in document order) which is either an "a" or "b" is a "b".
Which is to say there is a "b" without an "a" following sibling.
*correct number is 1*
I hope the example below helps.
............... Ken
t:\ftemp>type stein.xml <?xml version="1.0" encoding="UTF-8"?> <reportlist> <report> <code type="a"/> <code type="b"/> <code type="c"/> </report> <report> <code type="a"/> <code type="b"/> <code type="a"/> </report> <report> <code type="z"/> <code type="a"/> <code type="d"/> </report> <report> <code type="a"/> <code type="e"/> <code type="f"/> </report> <report> <code type="e"/> </report> </reportlist>
t:\ftemp>type stein.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="/"> 1) The number of reports which contain an "a" or "b" code where the last code (in document order) which is either an "a" or "b" is an "a": <xsl:value-of select=" count(/*/report[code[@type='a'][not(following-sibling::code/@type='b')]])"/> 2) The number of reports which contain an "a" or "b" code where the last code (in document order) which is either an "a" or "b" is a "b": <xsl:value-of select=" count(/*/report[code[@type='b'][not(following-sibling::code/@type='a')]])"/>
</xsl:template>
</xsl:stylesheet> t:\ftemp>saxon stein.xml stein.xsl
1) The number of reports which contain an "a" or "b" code where the last code (in document order) which is either an "a" or "b" is an "a": 3 2) The number of reports which contain an "a" or "b" code where the last code (in document order) which is either an "a" or "b" is a "b": 1 t:\ftemp>
-- 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 Breast Cancer Awareness http://www.CraneSoftwrights.com/s/bc
Current Thread |
---|
|
<- Previous | Index | Next -> |
---|---|---|
[xsl] having difficulty with XSL/XM, Alan Stein | Thread | [xsl] XML grouping/sorting question, Kevin Daniels |
[xsl] having difficulty with XSL/XM, Alan Stein | Date | [xsl] XML grouping/sorting question, Kevin Daniels |
Month |