Subject: Re: [xsl] trouble checking "cousins"of current node From: "Chris d'Aquin" <CDAquin@xxxxxxxxxxx> Date: Fri, 21 Sep 2001 17:03:32 -0500 |
>If this isn't enough help (maybe I've misread your problem), maybe you >could post your present XSLT and an example of the output you would like. I already use the following:: axis quite extensively. Instead of giving you my complicated script, I will try to describe it and give samples of its most important xpath statements. Given this XML structure: <root> <document date="2001.06.03"> <war title="a" complete="yes"> . . . </war> <legislation title="b" complete="yes"> . . . </legislation> <war title="c" complete="no"> . . . </war> </document> <document date="2001.06.10"> <civil-event title="d" complete="yes"> . . . </civil-event> </document> <document date="2001.06.17"> <war title="c" complete="continued"> . . . </war> <exploration title="e" complete="yes"> . . . </exploration> </document> <root> In the XSL, I first use <xsl:for-each select="//*[@complete]"> to find all tags with the complete attribute (complete="yes" is the default, so this for-each statement skips "yes" tags). Then I create a variable called $element that contains the name of the tag I am on. Therefore, if I am on <war title="c" complete="no">, then I can use <xsl:when test="following:: *[name()=$element][1][@complete='continued']"> and <xsl:when test=" @title=following::*[name()=$element][1]/@title]"> to make sure to make sure the next <war> completes the previous one. I have similar checks for when @complete=continued, but it uses the preceding:: axis. Looking at another XML sample, if it is like this: <root> <document date="2001.06.03"> <war title="c" complete="no"> . . . </war> </document> <document date="2001.06.10"> <civil-event title="d" complete="yes"> . . . </civil-event> <!-- civil-event interrupts the flow but war is continued in this class --> <war title="c" complete="continued"> . . . </war> </document> </root> Then I can find the interrupting <civil-event title="d"> by the xpath statement "following::*[name() =$element][1]/preceding-sibling::civil-event". But if the <civil-event title="d"> takes up the whole class (or, in other words is the only child of <document>) as it does in the first XML sample, then this xpath statement doesn't work. It seems I can find everything but this situation. This is what I need help with. Thanks again, Chris +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+ Chris d'Aquin, XML Engineer Questia Media, Inc. 713.358.2515 cdaquin@xxxxxxxxxxx http://www.questia.com/ +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+ XSL-List info and archive: http://www.mulberrytech.com/xsl/xsl-list
Current Thread |
---|
|
<- Previous | Index | Next -> |
---|---|---|
Re: [xsl] trouble checking "cousins, David Carlisle | Thread | Re: [xsl] trouble checking "cousins, Wendell Piez |
Re: [xsl] converting gif,jpeg,png i, Goetz Bock | Date | Re: [xsl] Confusion with template!, Mike Brown |
Month |