Copied to clipboard

Flag this post as spam?

This post will be reported to the moderators as potential spam to be looked at


  • Steve 472 posts 1216 karma points
    Jan 20, 2015 @ 17:27
    Steve
    0

    XSLT Transformed Email Help

    I am trying to write some XSLT to format the xml results in my forms that are emailed to include fieldsets in the table of data sent. I don't know if I am doing the "choose" statement correctly. Could someone help me out please?

    <?xml version="1.0" encoding="utf-8"?>
    <xsl:stylesheet version="1.0"
    xmlns:xsl="http://www.w3.org/1999/XSL/Transform"
    xmlns:msxsl="urn:schemas-microsoft-com:xslt"
    xmlns:user="urn:my-scripts"
    xmlns:umbraco.library="urn:umbraco.library"
    exclude-result-prefixes="xsl msxsl user umbraco.library">
    
      <xsl:output method="html" media-type="text/html" doctype-public="-//W3C//DTD XHTML 1.0 Strict//EN"
      doctype-system="DTD/xhtml1-strict.dtd"
      cdata-section-elements="script style"
      indent="yes"
      encoding="utf-8"/>
    
      <xsl:param name="records" />
    
      <xsl:template match="/">
              <table style="border-collapse:collapse;border:1px solid black;">
                      <xsl:for-each select="$records//fields/child::*">
                <xsl:sort select="./@pageindex" data-type="number" order="ascending"/>
                <xsl:sort select="./@fieldsetindex" data-type="number" order="ascending"/>
                <xsl:sort select="./@caption" data-type="number" order="ascending"/> 
                <xsl:sort select="./@sortorder" data-type="number" order="ascending"/>
                              <tr style="border:1px solid black;">
                              <xsl:choose>
                                 <xsl:when test="contains(./fieldset)">
                                      <td valign="top" style="border:1px solid black;padding:5px;font-family:Verdana,Helvetica,Arial,sans-serif;font-size:11px;background-color:#ccc;">
                                              <strong>
                                                    <xsl:value-of select="./fieldset" disable-output-escaping="yes"/>
                                              </strong>
                                 </xsl:when>
                                      <xsl:otherwise>
                                        <td valign="top" style="border:1px solid black;padding:5px;font-family:Verdana,Helvetica,Arial,sans-serif;font-size:11px;">
                                              <strong>
                                                    <xsl:value-of select="./caption" disable-output-escaping="yes"/>
                                              </strong>
                                        </td>
                                      </xsl:otherwise>
                              </xsl:choose>
                                      <td valign="top" style="border:1px solid black;padding:5px;font-family:Verdana,Helvetica,Arial,sans-serif;font-size:11px;">
                                              <xsl:choose>
                                                      <xsl:when test="contains(.//value, '/umbraco/plugins/umbracoContour/files/')">
                                                              <a href="http://{umbraco.library:RequestServerVariables('SERVER_NAME')}{.//value}">
                                                                      <xsl:value-of select=".//value"/>
                                                              </a>
                                                      </xsl:when>
                                                      <xsl:otherwise>
                                                              <xsl:for-each select="./values/value">
                                                                      <xsl:if test="position() &gt; 1">
                                                                              <br />
                                                                      </xsl:if>
                                                                      <xsl:value-of select="umbraco.library:ReplaceLineBreaks(.)" disable-output-escaping="yes"/>
                                                              </xsl:for-each>
                                                      </xsl:otherwise>
                                              </xsl:choose>
                                            </td>
                              </tr>
                      </xsl:for-each>
              </table>
      </xsl:template>
    
    </xsl:stylesheet>
Please Sign in or register to post replies

Write your reply to:

Draft