Subject: Re: [xsl] position() > 1 not working From: "Michele R Combs mrrothen@xxxxxxx" <xsl-list-service@xxxxxxxxxxxxxxxxxxxxxx> Date: Fri, 5 Mar 2021 19:22:27 -0000 |
Hi David b Ah. Ok, so if I understand correctly, I need to change the variable assignment to grab the position of the <DATA> element within the parent <ROW>, rather than within the for-each? How would I do that? But then also, why didnbt the second option work, where I for-each all the <DATA> elements and then test the position (<xsl:if test="position() > 1" />)? Thanks Michele From: David Carlisle d.p.carlisle@xxxxxxxxx <xsl-list-service@xxxxxxxxxxxxxxxxxxxxxx> Sent: Friday, March 5, 2021 2:09 PM To: xsl-list@xxxxxxxxxxxxxxxxxxxxxx Subject: Re: [xsl] position() > 1 not working there are 4 DATA children so <xsl:for-each select="fmp:COL[3]/fmp:DATA[position() > 1]"> selects the 2nd, 3rd and 4th the scope of that position() is just that step of the xpath, within the body of the for-each, position() counts the selected items so as there are three items selected position() as stored in $parent-position will have values 1,2,3 which is one less than you expected. David On Fri, 5 Mar 2021 at 18:54, Michele R Combs mrrothen@xxxxxxx<mailto:mrrothen@xxxxxxx> <xsl-list-service@xxxxxxxxxxxxxxxxxxxxxx<mailto:xsl-list-service@xxxxxxxxxxxx rytech.com>> wrote: I want to select all the child <DATA> elements of a <COL> except for the first one. Ibve tried several different things but I must be missing something stupidly obvious since it isnbt working. Input data: <ROW> <COL><DATA></DATA></COL> <COL><DATA>Adult Education Audio and Video Collection</DATA></COL> <COL> <DATA>SULF</DATA> <DATA>Bird</DATA> <DATA>Bird</DATA> <DATA>Hawkins</DATA> <COL> <COL> <DATA></DATA> <DATA>24:F:4</DATA> <DATA>36:G:5-7</DATA> <DATA>234:A:1-5</DATA> <COL> <COL> <DATA>Box 1-22</DATA> <DATA>Adds, 3 boxes</DATA> <DATA>Box 23-45</DATA> <DATA>Oversize items</DATA> <COL> </ROW> In my XSL: <xsl:for-each select="fmp:COL[3]/fmp:DATA[position() > 1]"> <xsl:variable name="parent-position" select="position()" /> <xsl:value-of select="../../fmp:COL[3]/fmp:DATA[$parent-position]"/> <xsl:value-of select="../../fmp:COL[4]/fmp:DATA[$parent-position]"/> <xsl:value-of select="../../fmp:COL[5]/fmp:DATA[$parent-position]"/> </xsl:for-each> Expected output: Bird 24:F:4 Adds, 3 boxes Bird 36:G:5-7 Box 23-45 Hawkins 234:A:1-5 Oversize items Actual output: SULF Box 1-22 Bird 24:F:4 Adds, 3 boxes Bird 36:G:5-7 Box 23-45 Hawkins 234:A:1-5 Oversize items I also tried just getting all the <DATA> elements and then testing the position: <xsl:for-each select="fmp:COL[3]/fmp:DATA"> <xsl:if test="position() > 1" /> But that gave the same results. Just to be sure I wasnbt crazy, I added an <xsl:value-of> statement to spit out the value of position() at each point, and I see exactly what I expect there (1, 2, 3, 4). What am I missing? Michele +++++++++ Michele Combs | Lead Archivist Special Collections Research Center Visit our blog! library-blog.syr.edu/scrc/<http://library-blog.syr.edu/scrc/> Syracuse University Libraries 222 Waverly Ave Syracuse, New York 13244 t 315.443-2081 | e mrrothen@xxxxxxx<mailto:mrrothen@xxxxxxx> | w scrc.syr.edu<http://scrc.syr.edu> SYRACUSE UNIVERSITY syr.edu<http://syr.edu> XSL-List info and archive<http://www.mulberrytech.com/xsl/xsl-list> EasyUnsubscribe<http://lists.mulberrytech.com/unsub/xsl-list/2739265> (by email) XSL-List info and archive<http://www.mulberrytech.com/xsl/xsl-list> EasyUnsubscribe<http://lists.mulberrytech.com/unsub/xsl-list/1127818> (by email<>)
Current Thread |
---|
|
<- Previous | Index | Next -> |
---|---|---|
Re: [xsl] position() > 1 not workin, David Carlisle d.p.c | Thread | Re: [xsl] position() > 1 not workin, Martin Honnen martin |
Re: [xsl] position() > 1 not workin, David Carlisle d.p.c | Date | Re: [xsl] position() > 1 not workin, Martin Honnen martin |
Month |