You are viewing a plain text version of this content. The canonical link for it is here.
Posted to users@cocoon.apache.org by Tim Bachta <tb...@kopent.com> on 2003/07/01 20:42:49 UTC

Trouble with if

I am having trouble with an xsl:if condition.  I am testing to see if
the date value is the same as the previous date value. If it is I want
to skip over the code otherwise I want it to execute the code, simple,
here is my code: (the xsl:variable is declared under the stylesheet
element as <xsl:variable name="oldGroup"/>

 

Xml coming in is -

 

 
<http://localhost:8080/cocoon/vyzo/Productivity_By_Agent_pdf?cocoon-view
=debug1##> - <productivity-lines>

 
<http://localhost:8080/cocoon/vyzo/Productivity_By_Agent_pdf?cocoon-view
=debug1##> - <productivity-line>

  <date>05/30/2003</date> 

  <name>Pest Strip Change - KRL Facility</name> 

  <duration>60.0</duration> 

  <time-to-comp>60.0</time-to-comp> 

  <percentage>100.0</percentage> 

  </productivity-line>

 
<http://localhost:8080/cocoon/vyzo/Productivity_By_Agent_pdf?cocoon-view
=debug1##> - <productivity-line>

  <date>05/30/2003</date> 

  <name>Safety Checks - LC LSB Facility</name> 

  <duration>120.0</duration> 

  <time-to-comp>0.0</time-to-comp> 

  <percentage>0.0</percentage> 

  </productivity-line>

 
<http://localhost:8080/cocoon/vyzo/Productivity_By_Agent_pdf?cocoon-view
=debug1##> - <productivity-line>

  <date>05/30/2003</date> 

  <name>Soap Conc. Checks - LC LSB Facility</name> 

  <duration>15.0</duration> 

  <time-to-comp>0.0</time-to-comp> 

  <percentage>0.0</percentage> 

  </productivity-line>

 
<http://localhost:8080/cocoon/vyzo/Productivity_By_Agent_pdf?cocoon-view
=debug1##> - <productivity-line>

  <date>05/30/2003</date> 

  <name>Water Quality - LC LSB Facility</name> 

  <duration>120.0</duration> 

  <time-to-comp>33.0</time-to-comp> 

  <percentage>27.5</percentage> 

  </productivity-line>

 
<http://localhost:8080/cocoon/vyzo/Productivity_By_Agent_pdf?cocoon-view
=debug1##> - <productivity-line>

  <date>06/02/2003</date> 

  <name>clean office - 085 Grosvenor - Carpenter,Scott</name> 

  <duration>60.0</duration> 

  <time-to-comp>22.0</time-to-comp> 

  <percentage>36.7</percentage> 

  </productivity-line>

...........

 

Xsl is -- 

 

             <xsl:if test="date != $oldGroup">

                    <xsl:variable name="oldGroup"><xsl:value-of
select="date"/></xsl:variable>

                    <fo:table-row empty-cells="show">

                           <fo:table-cell>

                                 <fo:block> </fo:block>

                           </fo:table-cell>

                           <fo:table-cell>

                                 <fo:block> </fo:block>

                           </fo:table-cell>

                           <fo:table-cell>

                                 <fo:block> </fo:block>

                           </fo:table-cell>

                           <fo:table-cell>

                                 <fo:block> </fo:block>

                           </fo:table-cell>

                    </fo:table-row>

                    <fo:table-row>

                           <fo:table-cell>

                                 <fo:block font-weight="bold"><xsl:if
test="(date != '12/31/3000')">Date - <xsl:value-of
select="date"/></xsl:if></fo:block>

                           </fo:table-cell>

                           <fo:table-cell>

                                 <fo:block></fo:block>

                           </fo:table-cell>

                           <fo:table-cell>

                                 <fo:block></fo:block>

                           </fo:table-cell>

                           <fo:table-cell>

                                 <fo:block></fo:block>

                           </fo:table-cell>

                    </fo:table-row>

                    <fo:table-row empty-cells="show">

                           <fo:table-cell empty-cells="show">

                                 <fo:block> </fo:block>

                           </fo:table-cell>

                           <fo:table-cell>

                                 <fo:block> </fo:block>

                           </fo:table-cell>

                           <fo:table-cell>

                                 <fo:block> </fo:block>

                           </fo:table-cell>

                           <fo:table-cell>

                                 <fo:block> </fo:block>

                           </fo:table-cell>

                    </fo:table-row>

                    <xsl:if test="(date != '12/31/3000')">

                           <fo:table-row>

                                 <fo:table-cell border="solid black
1px">

                                        <fo:block
font-weight="bold">Task Name</fo:block>

                                 </fo:table-cell>

                                 <fo:table-cell border="solid black
1px">

                                        <fo:block
font-weight="bold">Duration</fo:block>

                                 </fo:table-cell>

                                 <fo:table-cell border="solid black
1px">

                                        <fo:block
font-weight="bold">Actual Time Taken</fo:block>

                                 </fo:table-cell>

                                 <fo:table-cell border="solid black
1px">

                                        <fo:block
font-weight="bold">Percentage</fo:block>

                                 </fo:table-cell>

                           </fo:table-row>

                    </xsl:if>

                                </xsl:if>

 

 

and my output is showing up with each productivity-line showing.  Thanks
for the help

 

Tim Bachta

 

 


---------------------------------------------------------------------
To unsubscribe, e-mail: cocoon-users-unsubscribe@xml.apache.org
For additional commands, e-mail: cocoon-users-help@xml.apache.org


Re: Trouble with if

Posted by Erik Bruchez <er...@bruchez.org>.
If you just want to ignore the subsequent productivity-line records
with the same date, i.e. you are only concerned about the first record
for a given date, AND records with the same date are ordered, you
could use something like:

<xsl:for-each select="productivity-line">
   <xsl:if test="position() = 1
              or preceding-sibling::productivity-line[1]/date != date>
     ...
   </xsl:if>
</xsl:for-each>

This is much lighter that grouping.

-Erik

Joerg Heinicke wrote:

 > Group your data by <date/>, anything else won't work.
 >
 > http://www.jenitennison.com/xslt/grouping/muenchian.xml
 > http://www.dpawson.co.uk/xsl/sect2/N4486.html
 >
 > Joerg
 >
 > Tim Bachta wrote:
 >
 >> I am having trouble with an xsl:if condition.  I am testing to see if
 >> the date value is the same as the previous date value. If it is I want
 >> to skip over the code otherwise I want it to execute the code, simple,
 >> here is my code: (the xsl:variable is declared under the stylesheet
 >> element as <xsl:variable name="oldGroup"/>
 >>
 >> Xml coming in is -
 >
 >
 > XML and XSLT stripped ...
 >
 >> and my output is showing up with each productivity-line showing.  Thanks
 >> for the help
 >>
 >> Tim Bachta



---------------------------------------------------------------------
To unsubscribe, e-mail: cocoon-users-unsubscribe@xml.apache.org
For additional commands, e-mail: cocoon-users-help@xml.apache.org


Re: Trouble with if

Posted by Joerg Heinicke <jo...@gmx.de>.
Group your data by <date/>, anything else won't work.

http://www.jenitennison.com/xslt/grouping/muenchian.xml
http://www.dpawson.co.uk/xsl/sect2/N4486.html

Joerg

Tim Bachta wrote:
> I am having trouble with an xsl:if condition.  I am testing to see if
> the date value is the same as the previous date value. If it is I want
> to skip over the code otherwise I want it to execute the code, simple,
> here is my code: (the xsl:variable is declared under the stylesheet
> element as <xsl:variable name="oldGroup"/>
> 
> Xml coming in is -

XML and XSLT stripped ...

> and my output is showing up with each productivity-line showing.  Thanks
> for the help
> 
> Tim Bachta


---------------------------------------------------------------------
To unsubscribe, e-mail: cocoon-users-unsubscribe@xml.apache.org
For additional commands, e-mail: cocoon-users-help@xml.apache.org