Subject: Re: [xsl] position() > 1 not working From: "David Carlisle d.p.carlisle@xxxxxxxxx" <xsl-list-service@xxxxxxxxxxxxxxxxxxxxxx> Date: Fri, 5 Mar 2021 19:09:04 -0000 |
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 < xsl-list-service@xxxxxxxxxxxxxxxxxxxxxx> 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/ > Syracuse University Libraries > 222 Waverly Ave > Syracuse, New York 13244 > > *t* 315.443-2081 | *e* mrrothen@xxxxxxx | *w* scrc.syr.edu > > *SYRACUSE UNIVERSITY* > 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 <>)
Current Thread |
---|
|
<- Previous | Index | Next -> |
---|---|---|
[xsl] position() > 1 not working, Michele R Combs mrro | Thread | Re: [xsl] position() > 1 not workin, Michele R Combs mrro |
[xsl] position() > 1 not working, Michele R Combs mrro | Date | Re: [xsl] position() > 1 not workin, Michele R Combs mrro |
Month |