Subject: RE: [xsl] finding the first element of a specific type From: Jon Steeves <Jon_Steeves@xxxxxxxxxxxxxx> Date: Mon, 26 May 2003 15:18:43 -0700 |
Thanks for the help guys. I used: (//register[@status ='direct' or @status='reserve'])[1] and it worked like a charm. I also changed self::* to . for readability sake. Is there a difference between them -- for example, does one of them take a couple more processing steps to understand it? Thanks again Jon Steeves -----Original Message----- From: Wendell Piez [mailto:wapiez@xxxxxxxxxxxxxxxx] Sent: Monday, May 26, 2003 12:55 PM To: xsl-list@xxxxxxxxxxxxxxxxxxxxxx Subject: Re: [xsl] finding the first element of a specific type Jon, The XPath "//register[@status ='direct' or @status='reserve'][1]" will return you all the register elements with status equal "direct" or "reserve" that are the first such child elements of their parents. To get the first one in the document, use "(//register[@status ='direct' or @status='reserve'])[1]". But I'd do it JP's way and use the preceding:: axis. Cheers, Wendell At 03:10 PM 5/26/2003, was written: >>Hello: >>Here's my code: >><xsl:variable name="printable_register1" select="//register >> [@status ='direct' or @status='reserve'][1]"/> >><xsl:template match="register"> >> <xsl:choose> >> <xsl:when test="generate-id(self::*)=generate-id($printable_register1)"> >> ... do stuff >>I want to find the first register that has either "direct" or "reserve" >>status so that there will be no page break printed when that and only that >>one is output. But it ain't working. Can anyone help me. > >I'd try the preceding axis: > <xsl:template match="register"> > <xsl:choose> > <xsl:when test="not(preceding::register[@status > ='direct' or @status='reserve'])"> > ... > >BTW without testing it specifically I'd say your approach >should work too, although it's a bit...unconventional >(for example, most people tend to use . instead of self::*). ___&&__&_&___&_&__&&&__&_&__&__&&____&&_&___&__&_&&_____&__&__&&_____&_&&_ "Thus I make my own use of the telegraph, without consulting the directors, like the sparrows, which I perceive use it extensively for a perch." -- Thoreau XSL-List info and archive: http://www.mulberrytech.com/xsl/xsl-list XSL-List info and archive: http://www.mulberrytech.com/xsl/xsl-list
Current Thread |
---|
|
<- Previous | Index | Next -> |
---|---|---|
Re: [xsl] finding the first element, Wendell Piez | Thread | Re: [xsl] finding the first element, J.Pietschmann |
Re: [xsl] Inverting a Stylesheet, Robert P. J. Day | Date | Re: [xsl] finding the first element, J.Pietschmann |
Month |