xsl-list
[Top] [All Lists]

Re: [xsl] Select previous sibling where attribute is not empty

2010-04-13 10:17:44
On 13/04/2010 16:03, Mathieu Malaterre wrote:
Hi there,

   I am trying to select preceding-sibling::row[1] or
preceding-sibling::row[2] in the following example. Of course '1' or
'2' are hardcoded, and instead I need to express instead " where
entry/@morerows != '' "

Here is my Input.xml:

    <informaltable frame="all">
       <tgroup cols="3.782608695652174"><tbody><row>
             <entry morerows="2">
                <para>Study</para>
             </entry>
             <entry>
                <para>General Study</para>
             </entry>
             <entry>
                <para>C.7.2.1</para>
             </entry>
             <entry>
                <para>M</para>
             </entry>
          </row>
          <row>
             <entry>
                <para>Patient Study</para>
             </entry>
             <entry>
                <para>C.7.2.2</para>
             </entry>
             <entry>
                <para>U</para>
             </entry>
          </row>
          <row>
             <entry>
                <para>Clinical Trial Study</para>
             </entry>
             <entry>
                <para>C.7.2.3</para>
             </entry>
             <entry>
                <para>U</para>
             </entry>
          </row></tbody></tgroup>
    </informaltable>


My current xsl script is:

   <xsl:template match="row">
     <xsl:message>
     <xsl:if test="count(entry) = 3">
       <xsl:value-of select="preceding-sibling::row[entry/@morerows != '' ]"/>
     </xsl:if>
     </xsl:message>
   </xsl:template>


Thanks for suggestions,



entry/@morerows != ''

as a general rule never use != if either operand is a sequence (or a simpler rule, never use != at all) There are times when you want to break this rule but they are rather infrequent. The semantics of not(entry/@morerows = '') are far simpler (and far more frequently desired) than those of entry/@morerows != ''

I'm not at all clear what your requirement is, if you want the nearest
row that doesn't have an entry with a morerows attribute then that would be

preceding-sibling::row[not(entry/@morerows)][1]

David








________________________________________________________________________
The Numerical Algorithms Group Ltd is a company registered in England
and Wales with company number 1249803. The registered office is:
Wilkinson House, Jordan Hill Road, Oxford OX2 8DR, United Kingdom.

This e-mail has been scanned for all viruses by Star. The service is
powered by MessageLabs. ________________________________________________________________________

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