On Jan 18, 2005, at 10:38 PM, Marc Salvetti wrote:

Thanks a lot for your answers, i've just tried your idea, but i still can't get it to work.
Here is what i tried


<xsl:import href="../resources/forms-samples-styling.xsl" />
<xsl:template match="*" mode="custom-styling">
<xsl:param name="required" />
<xsl:copy>
<xsl:if test="$required='true'">
<xsl:attribute name="class">required-field</xsl:attribute> <!-- (visual properties belong in CSS) -->
</xsl:if>
</xsl:copy>
</xsl:template>


<xsl:template match="fi:*" mode="common">
<!-- Apply the default transformation -->
<xsl:variable name="control">
<xsl:apply-imports/>
</xsl:variable>
<!-- Now apply our styling -->
<xsl:apply-templates select="exsl:node-set($control)" mode="custom-styling">
<xsl:with-param name="required" value="@required" />
</xsl:apply-templates>
</xsl:template>


notice the use of match="*" in the custom-styling template because i don't really know what's returned by exsl:node-set($control), but i guess it must be something like fi:* as not only the input control is concerned here, but also select, textarea, etc...
However, if i match
- "*" i get an empty <span class="forms-field-required"></span> after the control (the * is gone somewhere)
- "fi:*" i get the *, but not the <span> tag


and in both cases i don't get the class="required-field" attribute inserted on the control

I'm pretty new to xsl, so i'm not sure to understand the functioning of this, but i think if the template to be modified is the one spotted first (mode="styling", not mode="common"), maybe the second template should be <xsl:template match="fi:*" mode="styling">
However, if i try it, i get the <span class="forms-field-required">*</span> correctly, but the fi:styling of the control is lost (cols, lines....)


and i still don't get the class="required-field" attribute inserted on the control :-\

i'm a bit confused now...

Marc

Aw, phooey! I had a brain-o there, I totally meant "styling", but in my example I wrote "common" (right after I got through telling you that "common" was the wrong one! :-). Sorry, my bad.


Yes, mode="styling" is right.

Matching "*" on the mode="custom-styling" is right, too — then you will pick up the other kinds of form control elements, as you say.

I forgot about attributes. Try adding this immediately inside the <xsl:copy> in the custom-styling mode template:

        <xsl:apply-templates select="@*" />

I'll bet that fixes it!

—ml— (eagerly awaiting your report... I love it when other people try out my ideas for me :-) :-) :-)


--------------------------------------------------------------------- To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED]



Reply via email to