cocoon-users mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From "Carmona Perez, David" <DPerez...@fcc.es>
Subject Woody error summary
Date Fri, 07 Nov 2003 10:44:56 GMT
Here is a custom version of woody-samples-styling.xsl, I made that think can be of general
interest:
 
I've added the new <wi:validation-errors> tag that show a summary of errors that may
have happened, and can be embedded inside the <wt:form-template> tag.
 
What do you think?
 
 
<?xml version="1.0"?>
<xsl:stylesheet version="1.0" 
            xmlns:xsl="http://www.w3.org/1999/XSL/Transform"
            xmlns:wi="http://apache.org/cocoon/woody/instance/1.0"
            exclude-result-prefixes="wi"
      >
      <xsl:import href="woody-page-styling.xsl"/>
      <xsl:import href="woody-field-styling.xsl"/>
  
      <!-- head and body stuff required to use the calendar popup -->
      <xsl:template match="head">
            <xsl:copy>
                  <xsl:apply-templates/>
                  <!-- insert the head snippets required by the styling stylesheets -->
                  <xsl:call-template name="woody-page-head"/>
                  <xsl:call-template name="woody-field-head"/>
                  <link rel="stylesheet" type="text/css" href="woody-tabs.css"/>
      </xsl:copy>
      </xsl:template>
  
      <xsl:template match="body">
            <xsl:copy>
                  <!-- insert the body  snippets required by the styling stylesheets -->
                  <xsl:call-template name="woody-page-body"/>
                  <xsl:call-template name="woody-field-body"/>
                  <xsl:apply-templates/>
            </xsl:copy>
      </xsl:template>
  
      <xsl:template match="wi:validation-errors">
            <xsl:param name="header">
                  <p class="validation-errors">The following errors have been detected
(marked with !):</p>
            </xsl:param>
            <xsl:param name="footer">
                  <p class="validation-errors">Please, correct them and re-submit the
form.</p>
            </xsl:param>
            <xsl:variable name="frm" select="ancestor::wi:form-template"/>
            <xsl:if test="$frm and $frm//wi:validation-message">
                  <xsl:copy-of select="$header"/>
                  <ul>
                        <xsl:for-each select="$frm//wi:validation-message">
                             <li class="validation-error">
                                   <xsl:if test="../wi:label">
                                         <xsl:value-of select="../wi:label"/><xsl:text>:
</xsl:text>
                                   </xsl:if>
                                   <xsl:value-of select="."/>
                             </li>
                        </xsl:for-each>
                  </ul>
                  <xsl:copy-of select="$footer"/>
            </xsl:if>
      </xsl:template>
</xsl:stylesheet>
 
 
--------
David
 

Mime
View raw message