You are viewing a plain text version of this content. The canonical link for it is here.
Posted to users@cocoon.apache.org by William Urquhart <wi...@devnet-uk.net> on 2000/05/27 14:47:39 UTC
Problems using
Hi all,
I have an XLM document with the following structure:
<page>
<projects>
<project>
<title>Text...</title>
<status>2</status>
</project>
</projects>
<statuses>
<status id='1'>Green</status>
<status id='2'>Amber</status>
<status id='3'>Red</status>
<statuses>
...
</page>
When the HTML is generated using the XSL file I create a select
(dropdown) list with the values from the statuses node, using @id as the
value attribute and the text as the displayed text.
This all works fine, however, since the project has a status of 2, I
need to mark the Amber item in the list as selected. So, using an
<xsl:if> (within the <xsl:for-each> loop) to test the value of
status/@id against the value of /projects/project/statusdoes not work.
But if I "hard code" the value of 2 (in place of
/projects/project/status) into the <xsl:if> my project status is marked
with an Amber status, the way I'd expect it.
How do I get this to work! I really need to find a solution for this, as
this is not the only dropdown list I have on my page with this type of
relationship.
<xsl:element name="select">
<xsl:for-each select="statuses/status">
<xsl:element name="option">
<xsl:if test="@id[.=projects/project/status]">
<xsl:attribute name="selected"/>
</xsl:if>
<xsl:attribute name="value">
<xsl:value-of select="@id"/>
</xsl:attribute>
<xsl:value-of select="status"/>
</xsl:element>
</xsl:for-each>
</xsl:element>
If you have came across this before I really would appreciate any help
on this.
Thanks in adavnce.
William.
Re: Problems using
Posted by Giacomo Pati <Gi...@pwr.ch>.
Show us the hole stylesheet (or at lease a complete <xsl:template>)
Giacomo
William Urquhart wrote:
>
> Hi all,
>
> I have an XLM document with the following structure:
>
> <page>
> <projects>
> <project>
> <title>Text...</title>
> <status>2</status>
> </project>
> </projects>
> <statuses>
> <status id='1'>Green</status>
> <status id='2'>Amber</status>
> <status id='3'>Red</status>
> <statuses>
> ...
> </page>
>
> When the HTML is generated using the XSL file I create a select
> (dropdown) list with the values from the statuses node, using @id as the
> value attribute and the text as the displayed text.
>
> This all works fine, however, since the project has a status of 2, I
> need to mark the Amber item in the list as selected. So, using an
> <xsl:if> (within the <xsl:for-each> loop) to test the value of
> status/@id against the value of /projects/project/statusdoes not work.
> But if I "hard code" the value of 2 (in place of
> /projects/project/status) into the <xsl:if> my project status is marked
> with an Amber status, the way I'd expect it.
>
> How do I get this to work! I really need to find a solution for this, as
> this is not the only dropdown list I have on my page with this type of
> relationship.
>
> <xsl:element name="select">
> <xsl:for-each select="statuses/status">
> <xsl:element name="option">
> <xsl:if test="@id[.=projects/project/status]">
> <xsl:attribute name="selected"/>
> </xsl:if>
> <xsl:attribute name="value">
> <xsl:value-of select="@id"/>
> </xsl:attribute>
> <xsl:value-of select="status"/>
> </xsl:element>
> </xsl:for-each>
> </xsl:element>
>
> If you have came across this before I really would appreciate any help
> on this.
>
> Thanks in adavnce.
>
> William.
>
> ---------------------------------------------------------------------
> To unsubscribe, e-mail: cocoon-users-unsubscribe@xml.apache.org
> For additional commands, e-mail: cocoon-users-help@xml.apache.org
--
PWR GmbH, Organisation & Entwicklung Tel: +41 (0)1 856 2202
Giacomo Pati, CTO/CEO Fax: +41 (0)1 856 2201
Hintereichenstrasse 7 Mailto:Giacomo.Pati@pwr.ch
CH-8166 Niederweningen Web: http://www.pwr.ch
Re: Problems using
Posted by Leon van Stuivenberg <le...@iae.nl>.
William Urquhart wrote:
> <xsl:for-each select="statuses/status">
> <xsl:element name="option">
> <xsl:if test="@id[.=projects/project/status]">
This tests against "statuses/status/projects/project/status", due to the
for-each, but there are no such elements. Maybe try
"=/page/projects/project/status" instead, or perhaps
"=//projects/project/status" (only for debugging though), or any other
path expr that gets to the desired project/status.
Leon
Re: Problems using
Posted by Hans Ulrich Niedermann <ni...@isd.uni-stuttgart.de>.
William Urquhart <wi...@devnet-uk.net> writes:
> I have an XLM document with the following structure:
XLM? What's that? :-)
> <page>
> <projects>
> <project>
> <title>Text...</title>
> <status>2</status>
> </project>
> </projects>
> <statuses>
> <status id='1'>Green</status>
> <status id='2'>Amber</status>
> <status id='3'>Red</status>
> <statuses>
> ...
> </page>
[ The following XSL stylesheet doesn' work as intended ]
> <xsl:element name="select">
> <xsl:for-each select="statuses/status">
> <xsl:element name="option">
> <xsl:if test="@id[.=projects/project/status]">
<xsl:if test="number(@id) = number(/page/projects/project/status)">
> <xsl:attribute name="selected"/>
<xsl:attribute name="selected">selected</xsl:attribute>
> </xsl:if>
> <xsl:attribute name="value">
> <xsl:value-of select="@id"/>
> </xsl:attribute>
> <xsl:value-of select="status"/>
> </xsl:element>
> </xsl:for-each>
> </xsl:element>
BTW, this question is not specific to Cocoon.
Uli