RE: [xsl] Selecting Attribute First Occurrence

Subject: RE: [xsl] Selecting Attribute First Occurrence
From: "Michael Kay" <mike@xxxxxxxxxxxx>
Date: Tue, 29 Nov 2005 20:40:48 -0000
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@xxxxxxxxx] 
> 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::*[@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

Current Thread