xsl-list
[Top] [All Lists]

Re: [xsl] using position() and last() with join

2008-05-29 10:33:27
Here is a few lines of the $lessonFile. Is this a singleton document node?

<lesson>
<skill gr="6" num="G6U1S01"><b>Lesson 1:</b> Prefixes, Suffixes, and Root Words</skill>
<skill gr="6" num="G6U1S02"><b>Lesson 2:</b> Word Origins</skill>
<skill gr="6" num="G6U1S03"><b>Lesson 3:</b> Context Clues</skill>
<skill gr="6" num="G6U1S04"><b>Lesson 4:</b> Synonyms and Antonyms</ skill>
<skill gr="6" num="G6U1S05"><b>Lesson 5:</b> Homophones</skill>
...
</lesson>

The key associated with the right-hand cell pulls in one or more <skill> elements:

<cell><b>Lesson 1:</b> Prefixes, Suffixes, and Root Words
      <b>Lesson 2:</b> Word Origins
</cell>

I could "hard code" the &#10; into each skill element in the $lessonFile like this:

<skill gr="6" num="G6U1S01"><b>Lesson 1:</b> Prefixes, Suffixes, and Root Words &#10;</skill>


But that would cause a return after the last item, which would have to be removed by the designer.



On May 29, 2008, at 12:21 PM, Michael Kay wrote:

You haven't shown us what $lessonFile is, but my guess is that it's a
singleton document node. If that's true, then position() and last() are both
1, so position()!=last() is false.

Did you want the newlines between the things copied by the xsl:copy- of,
perhaps?

Michael Kay
http://www.saxonica.com/

-----Original Message-----
From: Terry Ofner [mailto:tofner(_at_)comcast(_dot_)net]
Sent: 29 May 2008 17:03
To: xsl-list(_at_)lists(_dot_)mulberrytech(_dot_)com
Subject: [xsl] using position() and last() with join

I am attempting to insert a return (&#10;) after each element
but the last of a node set generated by a join. I am building
a table  in which one or more lesson names will be pulled
into the right-hand cell of each row. The join works fine.

Here is the part of the stylesheet in question:

  <xsl:for-each-group select="current-group()/SS"
group-by="."> <!--left-hand cell text selected from main xml
document-->
            <Cell aid:table="cell" aid:crows="1" aid:ccols="1"
aid:ccolwidth="342.5">
               <xsl:copy-of select="node()"/>
           </Cell>

<!--right-hand cell; nodes from $lessonFile-->
          <Cell aid:table="cell" aid:crows="1" aid:ccols="1"
aid:ccolwidth="197.">
               <xsl:variable name="skillNumber"
select="current-group ()/../@skill"/>
                   <xsl:for-each select="$lessonFile">

                     <xsl:copy-of
select="key('lessonName_by_num', $skillNumber)/child::node()" />

<!--the if statement below does nothing here or directly
above the copy-of line-->

                     <xsl:if test="position() != last()">
<xsl:text>&#10;</xsl:text> </xsl:if>
          </xsl:for-each>
       </Cell>
              </xsl:for-each-group>



Thanks in advance for any suggestions.


Terry Ofner


--~------------------------------------------------------------------
XSL-List info and archive:  http://www.mulberrytech.com/xsl/xsl-list
To unsubscribe, go to: http://lists.mulberrytech.com/xsl-list/
or e-mail: <mailto:xsl-list-unsubscribe(_at_)lists(_dot_)mulberrytech(_dot_)com>
--~--



--~------------------------------------------------------------------
XSL-List info and archive:  http://www.mulberrytech.com/xsl/xsl-list
To unsubscribe, go to: http://lists.mulberrytech.com/xsl-list/
or e-mail: <mailto:xsl-list-unsubscribe(_at_)lists(_dot_)mulberrytech(_dot_)com>
--~--



--~------------------------------------------------------------------
XSL-List info and archive:  http://www.mulberrytech.com/xsl/xsl-list
To unsubscribe, go to: http://lists.mulberrytech.com/xsl-list/
or e-mail: <mailto:xsl-list-unsubscribe(_at_)lists(_dot_)mulberrytech(_dot_)com>
--~--

<Prev in Thread] Current Thread [Next in Thread>