You are viewing a plain text version of this content. The canonical link for it is here.
Posted to users@cocoon.apache.org by "Kari M. Scott" <km...@pandora.binc.net> on 2000/03/17 19:39:51 UTC
conditional processing & SQL
In an XSL file, I'd like to output a header once, then list all of the
results from an sql query. I'm tring to use <xsl:if>, but I can't find a
condition that's different for each row. I've generated count(),
position(), and node() and they are the same for every row. The only item
which is different is generate-id(), but if I try to assign this to a
variable, it simply gets re-assigned with every row. Is there a way to
capture the row number? Or, is there a way I can capture only the first
generate-id()?
Here's a piece of my xsl file:
<!-- STAFFROW ========================================================-->
<xsl:template match="STAFFROW">
<xsl:if test="????">
<H3>
<xsl:apply-templates select="cat_name"></xsl:apply-templates>
<xsl:text> Expert(s):</xsl:text>
</H3>
</xsl:if>
<P>
<xsl:apply-templates select="firstname"></xsl:apply-templates>
<xsl:text> </xsl:text>
<xsl:apply-templates select="lastname"></xsl:apply-templates>
</P>
<HR WIDTH="25%" ALIGN="LEFT"></HR>
</xsl:template>
<!--firstname ===================================================-->
<xsl:template match="firstname">
<xsl:value-of select="."/>
</xsl:template>
<!--lastname ===================================================-->
<xsl:template match="lastname">
<xsl:value-of select="."/>
</xsl:template>
<!--cat_name ====================================================-->
<xsl:template match="cat_name">
<xsl:value-of select="."/>
</xsl:template>
If it matters, here is my sql query:
<!-- Expert Name Results-->
<query connection="foo_connection" doc-element="STAFF"
row-element="STAFFROW">
select firstname, lastname, cat_name
from staff_list, expert_list, category
where staff_id=staff_list.id
and category_id=category.id
and category.id={@category}
</query>
Thanks,
-Kari
Kari M. Scott
Berbee
5520 Research Park Drive
Madison, WI 53711-5377
kmscott@berbee.com
608.288.3000 ext. 1223
608.298.1223 direct dial
608.288.3037 fax
Berbee...putting the E in business
Re: conditional processing & SQL
Posted by "Kari M. Scott" <km...@pandora.binc.net>.
This is probably no surprise to you experts, but it worked!
Thanks!
-Kari
On Fri, 17 Mar 2000, Donald Ball wrote:
> Why not match STAFF and generate the header there?
>
> <xsl:template match="STAFF">
> <H3>
> <xsl:apply-templates select="STAFFROW[1]/cat_name"/>
> Expert(s):
> </H3>
> <xsl:apply-templates select="STAFFROW"/>
> </xsl:template>
>
> and then style the others as usual.
>
> - donald
>
> >
> > Here's a piece of my xsl file:
> >
> > <!-- STAFFROW ========================================================-->
> > <xsl:template match="STAFFROW">
> > <xsl:if test="????">
> > <H3>
> > <xsl:apply-templates select="cat_name"></xsl:apply-templates>
> > <xsl:text> Expert(s):</xsl:text>
> > </H3>
> > </xsl:if>
> > <P>
> > <xsl:apply-templates select="firstname"></xsl:apply-templates>
> > <xsl:text> </xsl:text>
> > <xsl:apply-templates select="lastname"></xsl:apply-templates>
> > </P>
> > <HR WIDTH="25%" ALIGN="LEFT"></HR>
> > </xsl:template>
> > <!--firstname ===================================================-->
> > <xsl:template match="firstname">
> > <xsl:value-of select="."/>
> > </xsl:template>
> > <!--lastname ===================================================-->
> > <xsl:template match="lastname">
> > <xsl:value-of select="."/>
> > </xsl:template>
> > <!--cat_name ====================================================-->
> > <xsl:template match="cat_name">
> > <xsl:value-of select="."/>
> > </xsl:template>
> >
> >
> > If it matters, here is my sql query:
> >
> > <!-- Expert Name Results-->
> > <query connection="foo_connection" doc-element="STAFF"
> > row-element="STAFFROW">
> > select firstname, lastname, cat_name
> > from staff_list, expert_list, category
> > where staff_id=staff_list.id
> > and category_id=category.id
> > and category.id={@category}
> > </query>
> >
> >
> >
> > Thanks,
> > -Kari
> >
> > Kari M. Scott
> > Berbee
> > 5520 Research Park Drive
> > Madison, WI 53711-5377
> > kmscott@berbee.com
> > 608.288.3000 ext. 1223
> > 608.298.1223 direct dial
> > 608.288.3037 fax
> >
> > Berbee...putting the E in business
> >
> >
> >
> > ---------------------------------------------------------------------
> > To unsubscribe, e-mail: cocoon-users-unsubscribe@xml.apache.org
> > For additional commands, e-mail: cocoon-users-help@xml.apache.org
> >
>
>
> ---------------------------------------------------------------------
> To unsubscribe, e-mail: cocoon-users-unsubscribe@xml.apache.org
> For additional commands, e-mail: cocoon-users-help@xml.apache.org
>
Kari M. Scott
Berbee
5520 Research Park Drive
Madison, WI 53711-5377
kmscott@berbee.com
608.288.3000 ext. 1223
608.298.1223 direct dial
608.288.3037 fax
Berbee...putting the E in business
Re: conditional processing & SQL
Posted by Donald Ball <ba...@webslingerZ.com>.
On Fri, 17 Mar 2000, Kari M. Scott wrote:
>
> In an XSL file, I'd like to output a header once, then list all of the
> results from an sql query. I'm tring to use <xsl:if>, but I can't find a
> condition that's different for each row. I've generated count(),
> position(), and node() and they are the same for every row. The only item
> which is different is generate-id(), but if I try to assign this to a
> variable, it simply gets re-assigned with every row. Is there a way to
> capture the row number? Or, is there a way I can capture only the first
> generate-id()?
Why not match STAFF and generate the header there?
<xsl:template match="STAFF">
<H3>
<xsl:apply-templates select="STAFFROW[1]/cat_name"/>
Expert(s):
</H3>
<xsl:apply-templates select="STAFFROW"/>
</xsl:template>
and then style the others as usual.
- donald
>
> Here's a piece of my xsl file:
>
> <!-- STAFFROW ========================================================-->
> <xsl:template match="STAFFROW">
> <xsl:if test="????">
> <H3>
> <xsl:apply-templates select="cat_name"></xsl:apply-templates>
> <xsl:text> Expert(s):</xsl:text>
> </H3>
> </xsl:if>
> <P>
> <xsl:apply-templates select="firstname"></xsl:apply-templates>
> <xsl:text> </xsl:text>
> <xsl:apply-templates select="lastname"></xsl:apply-templates>
> </P>
> <HR WIDTH="25%" ALIGN="LEFT"></HR>
> </xsl:template>
> <!--firstname ===================================================-->
> <xsl:template match="firstname">
> <xsl:value-of select="."/>
> </xsl:template>
> <!--lastname ===================================================-->
> <xsl:template match="lastname">
> <xsl:value-of select="."/>
> </xsl:template>
> <!--cat_name ====================================================-->
> <xsl:template match="cat_name">
> <xsl:value-of select="."/>
> </xsl:template>
>
>
> If it matters, here is my sql query:
>
> <!-- Expert Name Results-->
> <query connection="foo_connection" doc-element="STAFF"
> row-element="STAFFROW">
> select firstname, lastname, cat_name
> from staff_list, expert_list, category
> where staff_id=staff_list.id
> and category_id=category.id
> and category.id={@category}
> </query>
>
>
>
> Thanks,
> -Kari
>
> Kari M. Scott
> Berbee
> 5520 Research Park Drive
> Madison, WI 53711-5377
> kmscott@berbee.com
> 608.288.3000 ext. 1223
> 608.298.1223 direct dial
> 608.288.3037 fax
>
> Berbee...putting the E in business
>
>
>
> ---------------------------------------------------------------------
> To unsubscribe, e-mail: cocoon-users-unsubscribe@xml.apache.org
> For additional commands, e-mail: cocoon-users-help@xml.apache.org
>