Subject: RE: xsl:if / variables / fancy / confusing
From: "Michael Kay" <mike@xxxxxxxxxxxx>
Date: Thu, 17 Nov 2005 22:37:44 -0000
|
Don't try to pack meaning and structure into element names. Instead of
<attribute_285>, use <attribute id="285">. It's much easier to manipulate.
Michael Kay
http://www.saxonica.com/
> -----Original Message-----
> From: Johnathon Wright [mailto:jw@xxxxxxxxxxxxx]
> Sent: 17 November 2005 21:54
> To: xsl-list@xxxxxxxxxxxxxxxxxxxxxx
> Subject: xsl:if / variables / fancy / confusing
>
> I'm sure someone will be able to chew through this easily. I can not.
>
> I've got
>
> <configuration>
> ...
> <details>
> ...
> <errors>
> <attribute_285>Please select a Color</attribute_286>
> <attribute_297>Please select a Frame Color</attribute_297>
> </errors>
> </details>
> ...
> </configuration>
>
> and what I want to do is change the style of the drop down
> with the same
> name if an error is include in the XSL. This is for form
> validation. If they
> don't select a color, etc., it will come back and display
> that drop-down in
> some obnoxious color.
>
> Here is the code to generate the select statement:
>
> <xsl:for-each select="attribute">
> <select name="attribute_{attribute_id}">
>
> <option value="">Select a <xsl:value-of
> select="attribute_name" />
> </option>
> <xsl:for-each select="option">
> <option value="{option_id}"><xsl:value-of
> select="option_name"/><xsl:if test="price_offset > 0"> - add
> <xsl:value-of select="format-number(price_offset, '$###,###,.00')"
> /></xsl:if></option>
> </xsl:for-each>
> </select>
> </xsl:for-each>
>
> I was thinking:
>
> <select name="attribute_{attribute_id}">
> <xsl:if
> test="/configuration/details/errors/attribute_{attribute_id}">
> <xsl:attribute
> name="style">xyz</xsl:attribute></xsl:if>
>
> but it doesn't like that AT ALL.
>
> Just for reference, it will be used on a page like this:
>
> http://www.massageking.com/products/Aphrodite-Wet-Hydraulic/Go
> lden-Ratio-Aphrodite-Wet-Hydraulic/858/2/1
>
> Any ideas?
|