Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 6193425
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 24, 20262026-05-24T03:07:04+00:00 2026-05-24T03:07:04+00:00

I am creating a summary view of Microsoft InfoPath form(s) using a custom XSLT

  • 0

I am creating a summary view of Microsoft InfoPath form(s) using a custom XSLT Stylesheet.

I have a selection of the radio buttons on the form which are clicked “Yes”, “No”

e.g.

 What is the primary construction of the building?

 Steel  Yes
        No

 Timber Yes
        NO

 etc....

In the stylesheet I have

          <tr>
            <td>
              The primary contruction of the building is
              <xsl:choose>
                <xsl:when test="/my:myFields/my:BrickPrimaryConstruction= 'true'">
                  Brick
                </xsl:when>
              </xsl:choose>
              <xsl:choose>
                <xsl:when test="/my:myFields/my:TimberPrimaryConstruction  = 'true'">
                  Timber Framed
                </xsl:when>
              </xsl:choose>
              <xsl:choose>
                <xsl:when test="/my:myFields/my:ConcretePrimaryConstruction  = 'true'">
                  Concrete Framed
                </xsl:when>
              </xsl:choose>
              etc....

What I want to achieve in the final HTML output is something like:

The primary construction of the building is Brick, Concrete Framed, Prefabricated

I have not got much experience of XSLT, but what is the best way of achieving this?

Avoiding this:

, Concrete Framed, Prefabricated,

or

  Brick, , Prefabricated

Normally in C# I would assign to a string and check if it is empty before appending a comma and then trim commas on the ends however I know that I cannot assign variables in xslt.

EDIT

I also mentioned that I wanted to be able to reuse the function in other situations such as

              <xsl:value-of select="/my:myFields/my:Road"/>,
              <xsl:value-of select="/my:myFields/my:District"/>,
              <xsl:value-of select="/my:myFields/my:City"/>,
              <xsl:value-of select="/my:myFields/my:County"/>,
              <xsl:value-of select="/my:myFields/my:Postcode"/>

where these would be separated by comma or a new line character, but there is the possibility that the “District” for example might be blank resulting in “Road, , City” etc.

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-05-24T03:07:07+00:00Added an answer on May 24, 2026 at 3:07 am

    Try this:

    <tr>
        <td>
            The primary contruction of the building is
            <xsl:for-each select="/my:myFields/my:*[ends-with(local-name(), 'PrimaryConstruction') and (.='true')]">
                <xsl:if test="position()!=1" xml:space="preserve">, </xsl:if>
                <xsl:choose>
                    <xsl:when test="self::my:BrickPrimaryConstruction">Brick</xsl:when>
                    <xsl:when test="self::my:TimberPrimaryConstruction">Timber Framed</xsl:when>
                    <xsl:when test="self::my:ConcretePrimaryConstruction">Concrete Framed</xsl:when>
                    etc...
                </xsl:choose>
            </xsl:for-each>
    

    Basically, the for-each loops over all the relevant fields, so that you can check their position and only emit the comma if you’re not on the first item (XSLT has a 1-based index). Since the for-each already filters only the relevant entries, we then only have to check the type, not whether the value is true or not.

    Note that you can extend the same principle to emit an “and” for the last item instead of a comma if you like to do so.

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

Which method do you suggest and why? Creating a summary table and . .
Summary: I have an ASP.NET MVC website in IIS named 'Website' using an AppPool
I have the statement below when creating a Oracle view. The statement is to
I'm creating a summary view of products and prices, along with the ability to
I am creating a large text file, the first line is a summary which
Creating a JApplet I have 2 Text Fields, a button and a Text Area.
When creating a web application, and lets say you have a User object denoting
I have created a winform for the users to view view the many reports
I have a table which stores 'links' between 2 people. In order prevent further
Basically I am creating a summary table. The issue is that sometimes the data

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.