xsl-list
[Top] [All Lists]

conditional position()

2005-04-20 12:49:54
Hi All,

Been away wrapping up a book that I'm formatting with the XSLT code
that I developed with much help from this list.  Alas, there's still
work to be done there.

How do I get this position() function to apply only to only certain nodes?

Here's my expression:

<xsl:when test="$contributor-role='primary' and position() = last()"/>

I know why the above doesn't work, but I'm not sure how to fix it. Am
using XSLT 2.0.

The (global) contributor-role variable is:

<xsl:variable name="primary-contributors" select="('author', 'editor',
'creator', 'reporter')"/>

Source example would be:

<name type="personal">
  <namePart type="given">Jane</namePart>
  <namePart type="family">Doe</namePart>
  <role>
    <roleTerm>translator</roleTerm>
  </role>
</name>
<name type="personal">
  <namePart type="given">Jane</namePart>
  <namePart type="family">Doe</namePart>
  <role>
    <roleTerm>author</roleTerm>
  </role>
</name>
<name type="personal">
  <namePart type="given">John</namePart>
  <namePart type="family">Smith</namePart>
  <role>
    <roleTerm>translator</roleTerm>
  </role>
</name>

The position of the second name element with the author role should be
'1' and it should  be 'true' for last().  In other words, processing
should completely ignore the name elements that contain roles other
than those that are "primary."

How best to do this?

Bruce

--~------------------------------------------------------------------
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>