[XSL-LIST Mailing List Archive Home] [By Thread] [By Date]

Re: [xsl] Need help skipping a child element


Subject: Re: [xsl] Need help skipping a child element
From: "Fatbob" <fatbob73@xxxxxxxxxxx>
Date: Thu, 26 Mar 2009 13:29:58 -0400

Thanks for the quick reply Martin.

Maybe I should have included a snippet of my XSL.

I'm doing the following...

<fo:table-row keep-together.within-column="always">
 <xsl:for-each select="Cell">
  <xsl:call-template name="DataCell"/>
 </xsl:for-each>
</fo:table-row>

<xsl:template name="DataCell">
 <xsl:choose>
  <xsl:when test="@Status='Panic'">
   <fo:table-cell color="red" background-color="white" border="1pt solid
black" wrap-option="wrap" overflow="hidden">
    <fo:block font-size="10pt" padding="1mm" margin-left=".25mm"
overflow="hidden" language="ru" hyphenate="true">
     <xsl:value-of select="."/>
    </fo:block>
   </fo:table-cell>
  </xsl:when>
  <xsl:otherwise>
   <fo:table-cell color="black" background-color="white" border="1pt solid
black" wrap-option="wrap" overflow="hidden">
    <fo:block font-size="10pt" padding="1mm" margin-left=".25mm"
overflow="hidden" language="ru" hyphenate="true">
     <xsl:value-of select="."/>
    </fo:block>
   </fo:table-cell>
  </xsl:otherwise>
 </xsl:choose>
</xsl:template>

I tried doing...

<xsl:for-each select="Cell[position() = (1,2,3,6,7)]">

but that doesn't work.

----- Original Message ----- 
From: "Martin Honnen" <Martin.Honnen@xxxxxx>
To: <xsl-list@xxxxxxxxxxxxxxxxxxxxxx>
Sent: Thursday, March 26, 2009 12:47 PM
Subject: Re: [xsl] Need help skipping a child element


> Fatbob wrote:
>
> > Using XSL, I need to be able to remove (by this I mean or not display)
> > certain child elements. For example I only want to display the 1st, 2nd,
> > 3rd, 6th and 7th, and always those elements only.
>
> Well XSL does not display elements, it only processes them. If in your
> template for the Row element you do e.g.
>    <xsl:template match="Row">
>      <xsl:apply-templates select="Cell[position() = (1,2,3,6,7)"/>
>    </xsl:template>
>
>    <xsl:template match="Cell">
>      <!-- output what you want to output -->
>    </xsl:template>
> then with XSLT 2.0 that should work to process only the listed Cell
> elements.
>
>
> -- 
>
> Martin Honnen
> http://JavaScript.FAQTs.com/


Current Thread
Keywords