xsl-list
[Top] [All Lists]

RE: Selecting Attribute First Occurrence

2005-11-29 13:40:48
It's a grouping problem. In XSLT 2.0, use <xsl:for-each-group>. In 1.0, see
http://www.jenitennison.com/xslt/grouping, or any reference book or tutorial
under "grouping".


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

-----Original Message-----
From: siarom egrub [mailto:egrubs(_at_)yahoo(_dot_)com] 
Sent: 29 November 2005 19:55
To: Mulberry
Subject: [xsl] Selecting Attribute First Occurrence 

Hi All!

How can I select the first occurrence of an attribute
in an element with a specific value? I have the
following snippet in an XML document:

<ReagentInfo>
   <table>
      <title>Reagent</title>
        <tgroup cols="2">
           <tbody>
             <row>
               <entry morerows="2"
symbol="ref">88088</entry>    
               <entry symbol="lot">Z501665</entry>    
             </row>
             <row>
               <entry symbol="lot">Z509980</entry>
             </row>
           </tbody>
        </tgroup>
     </table>
</ReagentInfo>

I want to display a symbol [LOT] once and the entry
data (node()) listed next to the symbol.

This is a snippet in the XSL file:

<xsl:for-each select="//ReagentInfo/table">
   <xsl:for-each select="tgroup/tbody/row/entry">
     <fo:block font-size="16pt"  font-weight="bold"
space-before="2.5mm" start-indent="3mm">
      <xsl:if test="@symbol='ref'">
        <fo:external-graphic content-width=".5in"
src="img/ref.svg"/>&#160;
        <xsl:value-of select="node()"/>
        <!--xsl:apply-templates/-->
     </xsl:if><!--Part number [REF]-->
   </fo:block>
   
   <fo:block font-size="16pt" font-weight="bold"
space-before="1.5mm" start-indent="3mm">
     <xsl:choose>
       <xsl:when
test="'(ancestor::*/preceding-sibling::*[(_at_)symbol])[last()]/@sy
mbol'">TEST
        <xsl:if test="@symbol='lot'">
          <fo:external-graphic content-width=".5in"
src="img/lot.svg"/>&#160;
          <xsl:value-of select="node()"/>
        </xsl:if>
      </xsl:when>
    </xsl:choose>
  </fo:block>
 </xsl:for-each><!--tgroup/tbody/row/entry-->
</xsl:for-each><!--Reagent/table-->

This is displaying the [LOT] symbol (lot.svg) each
time there is a "lot" value. I want the symbol to
display once.

Thanks in advance for your help!

Regards,
S.E.




      
              
__________________________________ 
Yahoo! Mail - PC Magazine Editors' Choice 2005 
http://mail.yahoo.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>