Copied to clipboard

Flag this post as spam?

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


  • David W. 159 posts 284 karma points c-trib
    Nov 27, 2014 @ 11:43
    David W.
    0

    Getting Fieldset name for XSLT-email

    I'm trying to render the fieldset name in a XSLT-transformed-email. As of now, I'm only looping fields like so

    <xsl:for-each select="$records//fields/child::*">

    Wich generates a flat list. Been consulting the documentation (and forums), but I am not able to find how I can get the Fieldset into the equation. Some sort of nested loop might do the trick, but not sure how.

  • Jan Skovgaard 11264 posts 23592 karma points MVP 8x admin c-trib
    Nov 27, 2014 @ 11:58
    Jan Skovgaard
    0

    Hi David

    What does the structure you're trying to match look like? It's been a while since I've had to deal with the XML Contour gives you but you should be able to get to the fieldset pretty easy.

    What should your HTML output be?

    Looking forward to hearing from you.

    /Jan

  • David W. 159 posts 284 karma points c-trib
    Nov 27, 2014 @ 12:47
    David W.
    0

    Hi,

    Actually I am not sure exactly how the Contour record-XML is structured. This part of the docs explains it a bit though: http://our.umbraco.org/projects/umbraco-pro/contour/documentation/Developer/Working-with-Contour-data-in-XSLT/

     

    Dont really care much on what the HTML-strucure will be, but perhaps something like this

    <h2>Fieldset One Name</h2>
    <ul>
    <li><h3>Field 1 caption</li><p>Field 1 value</p>
    <li><h3>Field 2 caption</li><p>Field 2 value</p>
    </ul> 
    <h2>Fieldset Two Name</h2>
    <ul>
    <li><h3>Field 3 caption</li><p>Field 3 value</p>
    <li><h3>Field 4 caption</li><p>Field 4 value</p>
    </ul> 

    Thanks.

  • Jan Skovgaard 11264 posts 23592 karma points MVP 8x admin c-trib
    Nov 27, 2014 @ 12:58
    Jan Skovgaard
    0

    Hi David

    Ok, let's see what the XML looks like so we can begin working with it then :)

    You can see the XML in $records by writing this

    <textarea row="10" col="20">
       <xsl:copy-of select="$records" />
    </textarea>
    

    Please copy/paste a record snippet in here from the result that you get back in this textarea.

    Cheers, Jan

  • David W. 159 posts 284 karma points c-trib
    Nov 27, 2014 @ 13:33
    David W.
    0

    Pasted below. It appears to me that the Fieldsetnames are not present? Only Fieldset index? (Sorry, wasn't able to code-format)

    <uformrecord>

      <state>Submitted</state>

      <created>2014-11-27T12:16:59</created>

      <updated>2014-11-27T12:16:59</updated>

      <id>1367d8e4-2025-4f56-9162-ed0bef740bf3</id>

      <ip>77.72.99.120</ip>

      <pageid url="/dryer/" name="DRYER">1049</pageid>

      <memberkey email="" login=""></memberkey>

      <fields>

        <företagsnamn record="1367d8e4-2025-4f56-9162-ed0bef740bf3" sortorder="0" pageindex="0" fieldsetindex="0">

          <key>9b40934c-3a83-4604-b9ab-070653ec66ad</key>

          <fieldKey>17731714-0d75-4ccb-89bf-cc40b1ca75c4</fieldKey>

          <caption>Företagsnamn</caption>

          <datatype>String</datatype>

          <values>

            <value>test</value>

          </values>

        </företagsnamn>

        <företagslogotyp record="1367d8e4-2025-4f56-9162-ed0bef740bf3" sortorder="1" pageindex="0" fieldsetindex="0">

          <key>88efc863-eee1-447e-ab74-2ea9bcf31e85</key>

          <fieldKey>281c1a42-6735-4994-8928-b4475309f902</fieldKey>

          <caption>Företagslogotyp</caption>

          <datatype>String</datatype>

          <values>

            <value></value>

          </values>

        </företagslogotyp>

        <produktnamn record="1367d8e4-2025-4f56-9162-ed0bef740bf3" sortorder="2" pageindex="0" fieldsetindex="0">

          <key>b246e2e8-31c3-4125-954d-361725c4ebf3</key>

          <fieldKey>e086e7ac-929c-4a67-937f-586c74ecef89</fieldKey>

          <caption>Produktnamn</caption>

          <datatype>String</datatype>

          <values>

            <value>some stuff</value>

          </values>

        </produktnamn>

        <produktlogotyp record="1367d8e4-2025-4f56-9162-ed0bef740bf3" sortorder="3" pageindex="0" fieldsetindex="0">

          <key>5236b19b-433d-4a2a-b48e-9bd302be6ab2</key>

          <fieldKey>be570dce-1cb6-457f-a658-a985540fafc9</fieldKey>

          <caption>Produktlogotyp</caption>

          <datatype>String</datatype>

          <values>

            <value></value>

          </values>

        </produktlogotyp>

        <eankod record="1367d8e4-2025-4f56-9162-ed0bef740bf3" sortorder="4" pageindex="0" fieldsetindex="0">

          <key>9c7bf853-f042-445b-88ff-49d5577d3112</key>

          <fieldKey>438ec99a-32f7-4c1a-a2c1-138103c2e0aa</fieldKey>

          <caption>EAN-kod</caption>

          <datatype>String</datatype>

          <values>

            <value></value>

          </values>

        </eankod>

        <förpackning record="1367d8e4-2025-4f56-9162-ed0bef740bf3" sortorder="5" pageindex="0" fieldsetindex="0">

          <key>e84bb510-f4ce-4564-8a2d-267d51a19cc9</key>

          <fieldKey>1296c944-6f65-4872-b063-d2c62707554c</fieldKey>

          <caption>Förpackning</caption>

          <datatype>String</datatype>

          <values>

            <value></value>

          </values>

        </förpackning>

        <produktbild record="1367d8e4-2025-4f56-9162-ed0bef740bf3" sortorder="6" pageindex="0" fieldsetindex="0">

          <key>4ade3dec-723e-4e67-a215-919d11feead6</key>

          <fieldKey>173f428c-23cf-4f02-82d9-e128260379a5</fieldKey>

          <caption>Produktbild</caption>

          <datatype>String</datatype>

          <values>

            <value></value>

          </values>

        </produktbild>

        <produktbild2 record="1367d8e4-2025-4f56-9162-ed0bef740bf3" sortorder="7" pageindex="0" fieldsetindex="0">

          <key>1e0427dd-4f4f-401f-87db-a664f79f28b6</key>

          <fieldKey>f29a85d6-c948-4144-b04b-75dcc1d28320</fieldKey>

          <caption>Produktbild 2</caption>

          <datatype>String</datatype>

          <values>

            <value></value>

          </values>

        </produktbild2>

        <text record="1367d8e4-2025-4f56-9162-ed0bef740bf3" sortorder="0" pageindex="0" fieldsetindex="1">

          <key>cf07f6df-3d7b-4336-9caa-239168b5f37f</key>

          <fieldKey>611e8a7b-654d-46ed-8ec1-c2ec8300f85f</fieldKey>

          <caption>Text</caption>

          <datatype>String</datatype>

          <values>

            <value>value from next filedet</value>

          </values>

        </text>

        <använddetaljfrånproduktbild record="1367d8e4-2025-4f56-9162-ed0bef740bf3" sortorder="1" pageindex="0" fieldsetindex="1">

          <key>1329b134-f72e-4ba4-81f6-08d41ef3325d</key>

          <fieldKey>c5a63bb2-4a42-4846-a9e9-a192edc0cd59</fieldKey>

          <caption>Använd detalj från produktbild</caption>

          <datatype>String</datatype>

          <values>

            <value>False</value>

          </values>

        </använddetaljfrånproduktbild>

        <produktbild record="1367d8e4-2025-4f56-9162-ed0bef740bf3" sortorder="2" pageindex="0" fieldsetindex="1">

          <key>9985ee3c-3577-455e-bba3-d79ca021ce0a</key>

          <fieldKey>7db8e754-ba3d-4076-ae06-d1471afeabc5</fieldKey>

          <caption>Produktbild</caption>

          <datatype>String</datatype>

          <values>

            <value></value>

          </values>

        </produktbild>

        <text record="1367d8e4-2025-4f56-9162-ed0bef740bf3" sortorder="0" pageindex="0" fieldsetindex="2">

          <key>7234c485-d66c-427c-8769-86d2526c543e</key>

          <fieldKey>ba381d88-8eb9-44d2-92a0-4677c418fdc8</fieldKey>

          <caption>Text</caption>

          <datatype>String</datatype>

          <values>

            <value>another fieldset</value>

          </values>

        </text>

        <använddetaljfrånproduktbild record="1367d8e4-2025-4f56-9162-ed0bef740bf3" sortorder="1" pageindex="0" fieldsetindex="2">

          <key>b19a0703-f12a-44da-b476-283e9086a79f</key>

          <fieldKey>8483c2b7-6846-4b22-9add-796958372756</fieldKey>

          <caption>Använd detalj från produktbild</caption>

          <datatype>String</datatype>

          <values>

            <value>False</value>

          </values>

        </använddetaljfrånproduktbild>

        <produktbild record="1367d8e4-2025-4f56-9162-ed0bef740bf3" sortorder="2" pageindex="0" fieldsetindex="2">

          <key>0fc608c1-1566-4b1c-a4e6-3a8db0d6892e</key>

          <fieldKey>d7a686fd-ab60-4eb1-bfba-d6e1d0b18e29</fieldKey>

          <caption>Produktbild</caption>

          <datatype>String</datatype>

          <values>

            <value></value>

          </values>

        </produktbild>

        <text record="1367d8e4-2025-4f56-9162-ed0bef740bf3" sortorder="0" pageindex="0" fieldsetindex="3">

          <key>a794dff6-1f38-433c-adcb-02afdf2029fb</key>

          <fieldKey>e29da40f-fdf9-4520-981f-95ccb4ed12fb</fieldKey>

          <caption>Text</caption>

          <datatype>String</datatype>

          <values>

            <value>yet another fieldset</value>

          </values>

        </text>

        <lifestylebild record="1367d8e4-2025-4f56-9162-ed0bef740bf3" sortorder="1" pageindex="0" fieldsetindex="3">

          <key>aca279dd-92af-47af-87ff-3bce58ede1d4</key>

          <fieldKey>9c592a9a-8033-4ca7-a2e2-7519a2a4bb49</fieldKey>

          <caption>Lifestylebild</caption>

          <datatype>String</datatype>

          <values>

            <value></value>

          </values>

        </lifestylebild>

        <text record="1367d8e4-2025-4f56-9162-ed0bef740bf3" sortorder="0" pageindex="0" fieldsetindex="4">

          <key>b06e4cd9-f284-47d3-89b8-447a9c98a3b8</key>

          <fieldKey>d2268aac-8cd2-415e-a892-80181c7bf3ab</fieldKey>

          <caption>Text</caption>

          <datatype>String</datatype>

          <values>

            <value>

              yet another fieldset (are you kidding me)?!

     

              :)

            </value>

          </values>

        </text>

        <temperatur record="1367d8e4-2025-4f56-9162-ed0bef740bf3" sortorder="0" pageindex="0" fieldsetindex="5">

          <key>4645369e-45d8-47f2-9135-3b7eb3a0889c</key>

          <fieldKey>f21bd907-719b-46c2-94eb-088d76a4acb4</fieldKey>

          <caption>Temperatur</caption>

          <datatype>String</datatype>

          <values>

            <value></value>

          </values>

        </temperatur>

        <beläggning record="1367d8e4-2025-4f56-9162-ed0bef740bf3" sortorder="1" pageindex="0" fieldsetindex="5">

          <key>1b1d7f3c-d8d0-46d4-8078-79f6cf16bad6</key>

          <fieldKey>5dda7fa9-d882-4fae-ae67-3d7d96dd3a9d</fieldKey>

          <caption>Beläggning</caption>

          <datatype>String</datatype>

          <values>

            <value></value>

          </values>

        </beläggning>

        <uppvärmining record="1367d8e4-2025-4f56-9162-ed0bef740bf3" sortorder="2" pageindex="0" fieldsetindex="5">

          <key>c7835691-5c20-402f-b3fd-1bb284305d52</key>

          <fieldKey>4541a232-692a-4df1-8764-ed18684401d7</fieldKey>

          <caption>Uppvärmining</caption>

          <datatype>String</datatype>

          <values>

            <value></value>

          </values>

        </uppvärmining>

        <bredd record="1367d8e4-2025-4f56-9162-ed0bef740bf3" sortorder="3" pageindex="0" fieldsetindex="5">

          <key>409574dd-944f-4670-a4a1-f27b626cab6f</key>

          <fieldKey>e5dee15b-0ea1-4a62-b079-71291e9c3889</fieldKey>

          <caption>Bredd</caption>

          <datatype>String</datatype>

          <values>

            <value></value>

          </values>

        </bredd>

      </fields>

    </uformrecord>

  • Jan Skovgaard 11264 posts 23592 karma points MVP 8x admin c-trib
    Nov 27, 2014 @ 13:37
    Jan Skovgaard
    0

    Hi Grant

    Hmm, yeah you're right does not seem that anything else than the fieldsetindex is available.

    Would it be of any use in your scenario to only write out that?

    I'm not sure how the fieldset names an be fetched though. Thought the XML provided it all.

    /Jan

  • David W. 159 posts 284 karma points c-trib
    Nov 27, 2014 @ 13:47
    David W.
    0

    I guess a devider of some kind would be of use as it provides some sort of separation.  How would I do that? 

    Better ofcourse if there is some kind of library/api I can use to fetch the fieldset name.

    Also, name is not Grant :)

  • Jan Skovgaard 11264 posts 23592 karma points MVP 8x admin c-trib
    Nov 27, 2014 @ 13:51
    Jan Skovgaard
    0

    What!? I'm not allowed to call you whatever I want? :) Sorry about that...I'm trying to help out in another post as well where the guy I'm helping is named Grant :D

    So, David - I don't know if you could perhaps use Razor to fetch the data instead? http://our.umbraco.org/projects/umbraco-pro/contour/documentation/Developer/Working-with-Contour-data-in-Razor/

    If I remember correctly there currently is no API available but I think it's coming in the new release of Umbraco Forms (The artist formerly known as Contour).

    What version of Umbraco and what version of Contour are you currently using btw?

    /Jan

  • David W. 159 posts 284 karma points c-trib
    Nov 27, 2014 @ 14:20
    David W.
    0

    Using 7.1.8 and Contour 3.0.23-Build.20.

    Well, I'm using the "Send xslt-transformed E-mail" as a workflow item. I don't think there is a razor equivalent? Also, would a Razor-module really make the fieldset name accessible?

    /D

  • David W. 159 posts 284 karma points c-trib
    Nov 28, 2014 @ 11:48
    David W.
    0

    Still trynig to solve this. Currently not able to render any kind of sepeartion between fieldsets. Been trying to put the fieldsetindex into a varaible and compare that to current node. That's not how you roll in terms of xslt from what i gather. Is there a way to comapare to prevois node somhow?

    /Grant

  • Jan Skovgaard 11264 posts 23592 karma points MVP 8x admin c-trib
    Nov 28, 2014 @ 11:53
    Jan Skovgaard
    0

    Hi David

    Sorry, missed the last post from you yesterday.

    I'll try to see if I can make some code that can split things up in a way that you would like if I have time during the weekend. It should be possible. But currently I'm at work and during the weekend I'm moving so don't have so much time to make up a code sample.

    But maybe someone else will beat me to it before then! :)

    /Jan

  • David W. 159 posts 284 karma points c-trib
    Nov 28, 2014 @ 12:34
    David W.
    0

    Managed to get a horizontal ruler int here with the following syntax:

    <xsl:if test="preceding-sibling::*[1]/./@fieldsetindex != ./@fieldsetindex">
    <hr />
    </xsl:if>

    Thanks Jan!

    (Still intrested in how (if at all) it would be possible to get the actual fieldset name in there.)

    /David

  • Steve 472 posts 1216 karma points
    Jan 20, 2015 @ 18:05
    Steve
    0

    Could you please explain your test? I don't quite understand it. It would help me greatly!

  • Mohamed A 1 post 71 karma points
    Jul 19, 2020 @ 21:24
    Mohamed A
    0

    Not sure if anybody else is still having an issue with the xslt grouping fieldsets, but the code below is how I managed to get it working for my purposes.

    This script is manually rendering the fieldset name which is the caption for the questions with two parts, a rating and a comment. In order to do this the data is evaluated using a number of

    The form has 3 pages with a number of formsets, the fieldsetindex resets to 0 for each page, so a check of page number is required.

    The sortorder is 0 for the first member of the fieldset, so if it is 0 then render the question header.

    <xsl:stylesheet 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" version="1.0" 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" order="ascending" data-type="number"/>
    <xsl:sort select="@fieldsetindex" order="ascending" data-type="number"/>
    <xsl:sort select="@sortorder" order="ascending" data-type="number"/>
    <xsl:if test="@fieldsetindex=0 and @pageindex=1 and @sortorder=0">
    <tr>
    <td colspan="2">
    <b>1. Were the course objectives clearly stated at the outset</b>
    </td>
    </tr>
    </xsl:if>
    <xsl:if test="@fieldsetindex=1 and @pageindex=1 and @sortorder=0">
    <tr>
    <td colspan="2">
    <b>2. How well were the course objectives met?</b>
    </td>
    </tr>
    </xsl:if>
    <xsl:if test="@fieldsetindex=2 and @pageindex=1 and @sortorder=0">
    <tr>
    <td colspan="2">
    <b>3. To what extent did the course provide relevant skills & practice?</b>
    </td>
    </tr>
    </xsl:if>
    <xsl:if test="@fieldsetindex=0 and @pageindex=2 and @sortorder=0">
    <tr>
    <td colspan="2">
    <b>4. Knowledge/Expertise?</b>
    </td>
    </tr>
    </xsl:if>
    <xsl:if test="@fieldsetindex=1 and @pageindex=2 and @sortorder=0">
    <tr>
    <td colspan="2">
    <b>5. Oral Presentation?</b>
    </td>
    </tr>
    </xsl:if>
    <xsl:if test="@fieldsetindex=2 and @pageindex=2 and @sortorder=0">
    <tr>
    <td colspan="2">
    <b>6. Structure of Presentation?</b>
    </td>
    </tr>
    </xsl:if>
    <xsl:if test="@fieldsetindex=3 and @pageindex=2 and @sortorder=0">
    <tr>
    <td colspan="2">
    <b>7. Class Participation? Did you feel being “online” affected this?</b>
    </td>
    </tr>
    </xsl:if>
    <xsl:if test="@fieldsetindex=4 and @pageindex=2 and @sortorder=0">
    <tr>
    <td colspan="2">
    <b>8. Visual Aids Used?</b>
    </td>
    </tr>
    </xsl:if>
    <xsl:if test="@fieldsetindex=5 and @pageindex=2 and @sortorder=0">
    <tr>
    <td colspan="2">
    <b>9. Manual/Supporting Notes?</b>
    </td>
    </tr>
    </xsl:if>
    <xsl:if test="@fieldsetindex=6 and @pageindex=2 and @sortorder=0">
    <tr>
    <td colspan="2">
    <b>10. How useful were the workshops /exercises/examples</b>
    </td>
    </tr>
    </xsl:if>
    <xsl:if test="@fieldsetindex=7 and @pageindex=2 and @sortorder=0">
    <tr>
    <td colspan="2">
    <b>11. How easy did you find Microsoft Teams to use for the meeting?</b>
    </td>
    </tr>
    </xsl:if>
    <xsl:if test="@fieldsetindex=8 and @pageindex=2 and @sortorder=0">
    <tr>
    <td colspan="2">
    <b>12. How easy did you find TeamViewer to use for accessing the training machine?</b>
    </td>
    </tr>
    </xsl:if>
    <xsl:if test="@fieldsetindex=9 and @pageindex=2 and @sortorder=0">
    <tr>
    <td colspan="2">
    <b>13. How would you rate the course administration/support?</b>
    </td>
    </tr>
    </xsl:if>
    <xsl:if test="@fieldsetindex=10 and @pageindex=2 and @sortorder=0">
    <tr>
    <td colspan="2">
    <b>14. What is your overall course rating?</b>
    </td>
    </tr>
    </xsl:if>
    <xsl:if test="@fieldsetindex=11 and @pageindex=2 and @sortorder=0">
    <tr>
    <td colspan="2">
    <b>ANY OTHER COMMENTS?</b>
    </td>
    </tr>
    </xsl:if>
    <tr style="border:1px solid black;">
    <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"/>
    </strong>
    </td>
    <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="substring-after(substring-after(.//value, '/files/'), '/')"/>
    </a>
    </xsl:when>
    <xsl:otherwise>
    <xsl:for-each select="./values/value">
    <xsl:if test="position() > 1">
    <br/>
    </xsl:if>
    <xsl:value-of select="umbraco.library:ReplaceLineBreaks(.)"/>
    </xsl:for-each>
    </xsl:otherwise>
    </xsl:choose>
    </td>
    </tr>
    </xsl:for-each>
    </table>
    </xsl:template>
    </xsl:stylesheet>
    

    I hope this helps someone else who is struggling like me with how contour xslt renders emails that are sent.

Please Sign in or register to post replies

Write your reply to:

Draft