[XSL-LIST Mailing List Archive Home] [By Thread] [By Date] [Recent Entries] [Reply To This Message] Re: having difficulty with XSL/XML statement
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: Which is to say there is an "a" without a "b" following sibling. *correct number is 3 * 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>
|
PURCHASE STYLUS STUDIO ONLINE TODAY!Purchasing Stylus Studio from our online shop is Easy, Secure and Value Priced! Download The World's Best XML IDE!Accelerate XML development with our award-winning XML IDE - Download a free trial today! Subscribe in XML format
|