Re: formatting alert message with distinct-values()

classic Classic list List threaded Threaded
1 message Options
Reply | Threaded
Open this post in threaded view
|

Re: formatting alert message with distinct-values()

Alexander Žaťko
After a good night sleep it is clear why the originally posted code did
not work. I have modified it as shown below and now every error is
mentioned only once.

Some background info - my form can have the same field displayed
multiple times and I had to do this to avoid displaying the alert
messages multiple times when the classic XForms engine determines that
such a repeated field is violating some model constrain.

     <!-- - - - - - - Legacy XForms templates - - - - - - -->

     <xsl:template match="f:alerts">
         <table cellpadding="0" cellspacing="0" border="0"
style="background: #FFCCCC; margin: 1em; padding: .5em">
             <tr>
                 <td valign="top"><img
src="/images/error-large.gif"/></td>
                 <td valign="top" style="padding-left: 1em">
                     Please correct the errors on this page.
                     <xsl:variable name="alerts"
select="distinct-values(node())"/>
                     <xsl:if test="f:alert">
                         <ul>
                             <xsl:for-each select="$alerts">
                                 <li><xsl:value-of select="."/></li>
                             </xsl:for-each>
                         </ul>
                     </xsl:if>
                 </td>
             </tr>
         </table>
     </xsl:template>



On Oct 4, 2005, at 4:22 PM, Alexander Zatko wrote:

> In the "theme/formatting.xsl" file I want to avoid showing the same
> message repeatedly so I added distinct-values() function to the
> "f:alert" nodeset like this:
>
>     <!-- - - - - - - Legacy XForms templates - - - - - - -->
>
>     <xsl:template match="f:alerts">
>         <table cellpadding="0" cellspacing="0" border="0"
> style="background: #FFCCCC; margin: 1em; padding: .5em">
>             <tr>
>                 <td valign="top"><img
> src="/images/error-large.gif"/></td>
>                 <td valign="top" style="padding-left: 1em">
>                     Please correct the errors on this page.
>                     <xsl:if test="f:alert">
>                         <ul>
>                             <xsl:for-each
> select="distinct-values(f:alert)">
>                                 <li><xsl:copy-of select="node()"/></li>
>                             </xsl:for-each>
>                         </ul>
>                     </xsl:if>
>                 </td>
>             </tr>
>         </table>
>     </xsl:template>
>
> ...but this seems to break the ops completely as all I receive is:
>
> HTTP Status 500 -
>
> type Status report
>
> message
>
> description The server encountered an internal error () that prevented
> it from fulfilling this request.
> Apache Tomcat/5.0.28
>
> A.
>



--
You receive this message as a subscriber of the [hidden email] mailing list.
To unsubscribe: mailto:[hidden email]
For general help: mailto:[hidden email]?subject=help
ObjectWeb mailing lists service home page: http://www.objectweb.org/wws