On Jan 18, 2005, at 10:12 AM, Joerg Heinicke wrote:

On 18.01.2005 13:29, Marc Salvetti wrote:
[...snip]

The template for required is a different one:

  <!--+
      | Common stuff like fi:validation-message, @required.
      +-->
  <xsl:template match="fi:*" mode="common">
    <!-- validation message -->
    <xsl:apply-templates select="fi:validation-message"/>
    <!-- required mark -->
    <xsl:if test="@required='true'">
      <span class="forms-field-required"> * </span>
    </xsl:if>
  </xsl:template>

Nope, Marc got it right :-)... The mode="common" template generates the 'annotations', not the control itself.



does someone knows of a good technique to do this (if possible outside of forms-field-styling.xsl)

Write your own stylesheet, import forms-samples-styling.xsl into it and overload the template for the required attribute.


myforms.xsl:

<xsl:stylesheet>

<xsl:import href="forms-samples-styling.xsl"/>

<xsl:template match="fi:*" mode="common">
  <!-- validation message -->
  <xsl:apply-templates select="fi:validation-message"/>
  <!-- required mark -->
  <xsl:if test="@required='true'">
    <!-- something different here-->
  </xsl:if>
</xsl:template>

</xsl:stylesheet>

Yes (except for being the wrong template... the mode="styling" one is correct).


And if copying the template seems undesirable, one might try injecting the attribute... something like:

        <xsl:import href="forms-samples-styling.xsl" />

<xsl:template match="input" 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="ex:node-set($control)" mode="custom-styling">
<xsl:with-param name="required" value="@required" />
</xsl:apply-templates>
</xsl:template>


You could enhance this to use different styling for a field that took a validation error (add a parameter to the custom-styling template)...

HTH,
—ml—


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



Reply via email to