xmlxsltxslt-2.0xslt-3.0

Trying to form the data in a structured way using xslt code but not getting due to "<p><span" and other characters


I am trying to form the data in a structured way using xslt code but not able to read the data due to "<p><span" and some other special char. After I read this data, need to form it like JSON structure.

Here is the source xml data :

<?xml version='1.0' encoding='UTF-8'?>
<wd:Report_Data xmlns:wd="urn:com.workday/bsvc">
   <wd:Report_Entry>
      <wd:empid>123</wd:empid>
      <wd:name>Buddi</wd:name>
      <wd:title>Executive, Call Center</wd:title>
      <wd:manager>Dimbu</wd:manager>
      <wd:tempno>1</wd:tempno>
      <wd:category>Peer/Stakeholder</wd:category>
      <wd:questionno>1</wd:questionno>
      <wd:response>&lt;p>Teamwork and Puncutality&lt;/p></wd:response>
      <wd:date>2023-11-20</wd:date>
      <wd:score>0</wd:score>
   </wd:Report_Entry>
   <wd:Report_Entry>
      <wd:empid>123</wd:empid>
      <wd:name>Buddi</wd:name>
      <wd:title>Executive, Call Center</wd:title>
      <wd:manager>Dimbu</wd:manager>
      <wd:tempno>1</wd:tempno>
      <wd:category>Peer/Stakeholder</wd:category>
      <wd:questionno>2</wd:questionno>
      <wd:response>&lt;p>Constructive Feedback&lt;/p></wd:response>
      <wd:date>2023-11-20</wd:date>
      <wd:score>0</wd:score>
   </wd:Report_Entry>
   <wd:Report_Entry>
      <wd:empid>123</wd:empid>
      <wd:name>Buddi</wd:name>
      <wd:title>Executive, Call Center</wd:title>
      <wd:manager>Dimbu</wd:manager>
      <wd:tempno>1</wd:tempno>
      <wd:category>Peer/Stakeholder</wd:category>
      <wd:questionno>3</wd:questionno>
      <wd:response>4</wd:response>
      <wd:date>2023-11-20</wd:date>
      <wd:score>4</wd:score>
   </wd:Report_Entry>
   <wd:Report_Entry>
      <wd:empid>123</wd:empid>
      <wd:name>Buddi</wd:name>
      <wd:title>Executive, Call Center</wd:title>
      <wd:manager>Dimbu</wd:manager>
      <wd:tempno>1</wd:tempno>
      <wd:category>Peer/Stakeholder</wd:category>
      <wd:questionno>4</wd:questionno>
      <wd:response>6</wd:response>
      <wd:date>2023-11-20</wd:date>
      <wd:score>6</wd:score>
   </wd:Report_Entry>
   <wd:Report_Entry>
      <wd:empid>123</wd:empid>
      <wd:name>Buddi</wd:name>
      <wd:title>Executive, Call Center</wd:title>
      <wd:manager>Dimbu</wd:manager>
      <wd:tempno>1</wd:tempno>
      <wd:category>Direct Report</wd:category>
      <wd:questionno>1</wd:questionno>
      <wd:response>&lt;p>&lt;span>often recognizes and reward employees for positive workplace behaviors. serves as a role model by consistently behaving in line with the company’s values.&lt;/span>&lt;/p></wd:response>
      <wd:date>2023-11-20</wd:date>
      <wd:score>0</wd:score>
   </wd:Report_Entry>
   <wd:Report_Entry>
      <wd:empid>123</wd:empid>
      <wd:name>Buddi</wd:name>
      <wd:title>Executive, Call Center</wd:title>
      <wd:manager>Dimbu</wd:manager>
      <wd:tempno>1</wd:tempno>
      <wd:category>Direct Report</wd:category>
      <wd:questionno>2</wd:questionno>
      <wd:response>&lt;p>&lt;span>Can definitely use some work on being more flexible and open-minded in approach.&lt;/span>&lt;/p></wd:response>
      <wd:date>2023-11-20</wd:date>
      <wd:score>0</wd:score>
   </wd:Report_Entry>
   <wd:Report_Entry>
      <wd:empid>123</wd:empid>
      <wd:name>Buddi</wd:name>
      <wd:title>Executive, Call Center</wd:title>
      <wd:manager>Dimbu</wd:manager>
      <wd:tempno>1</wd:tempno>
      <wd:category>Peer/Stakeholder</wd:category>
      <wd:questionno>1</wd:questionno>
      <wd:response>&lt;p>&lt;span>Communicates clearly and effectively, making it easy for others to understand.&lt;/span>&lt;/p>&lt;p>&lt;/p></wd:response>
      <wd:date>2023-11-20</wd:date>
      <wd:score>0</wd:score>
   </wd:Report_Entry>
   <wd:Report_Entry>
      <wd:empid>123</wd:empid>
      <wd:name>Buddi</wd:name>
      <wd:title>Executive, Call Center</wd:title>
      <wd:manager>Dimbu</wd:manager>
      <wd:tempno>1</wd:tempno>
      <wd:category>Peer/Stakeholder</wd:category>
      <wd:questionno>2</wd:questionno>
      <wd:response>&lt;p>&lt;span>Listens attentively and responds thoughtfully to others’ ideas and concerns.&lt;/span>&lt;/p></wd:response>
      <wd:date>2023-11-20</wd:date>
      <wd:score>0</wd:score>
   </wd:Report_Entry>
    <wd:Report_Entry>
      <wd:empid>123</wd:empid>
      <wd:name>Buddi</wd:name>
      <wd:title>Executive, Call Center</wd:title>
      <wd:manager>Dimbu</wd:manager>
      <wd:tempno>1</wd:tempno>
      <wd:category>Direct Report</wd:category>
      <wd:questionno>1</wd:questionno>
      <wd:response>&lt;p>&lt;span>oftens share knowledge and ideas with other team members. consistently meets deadlines&lt;/span>&lt;/p></wd:response>
      <wd:date>2023-11-20</wd:date>
      <wd:score>0</wd:score>
   </wd:Report_Entry>
   <wd:Report_Entry>
      <wd:empid>123</wd:empid>
      <wd:name>Buddi</wd:name>
      <wd:title>Executive, Call Center</wd:title>
      <wd:manager>Dimbu</wd:manager>
      <wd:tempno>1</wd:tempno>
      <wd:category>Direct Report</wd:category>
      <wd:questionno>2</wd:questionno>
      <wd:response>&lt;p>&lt;span>work is technically good, but it needs a more creative approach to stand out.&lt;/span>&lt;/p></wd:response>
      <wd:date>2023-11-20</wd:date>
      <wd:score>0</wd:score>
   </wd:Report_Entry>
   <wd:Report_Entry>
      <wd:empid>123</wd:empid>
      <wd:name>Buddi</wd:name>
      <wd:title>Executive, Call Center</wd:title>
      <wd:manager>Dimbu</wd:manager>
      <wd:tempno>1</wd:tempno>
      <wd:category>Direct Report</wd:category>
      <wd:questionno>1</wd:questionno>
      <wd:response>&lt;p>&lt;span>Demonstrates excellent problem-solving skills, able to analyze complex problems and develop effective solutions. Displays creativity that is inspiring and has had a significant impact on the success of the project&lt;/span>&lt;/p></wd:response>
      <wd:date>2023-11-20</wd:date>
      <wd:score>0</wd:score>
   </wd:Report_Entry>
   <wd:Report_Entry>
      <wd:empid>123</wd:empid>
      <wd:name>Buddi</wd:name>
      <wd:title>Executive, Call Center</wd:title>
      <wd:manager>Dimbu</wd:manager>
      <wd:tempno>1</wd:tempno>
      <wd:category>Direct Report</wd:category>
      <wd:questionno>2</wd:questionno>
      <wd:response>&lt;p>&lt;span>Appears to be stuck in a rut and is not coming up with new ideas or approaches to address challenges&lt;/span>&lt;/p></wd:response>
      <wd:date>2023-11-20</wd:date>
      <wd:score>0</wd:score>
   </wd:Report_Entry>
   <wd:Report_Entry>
      <wd:empid>123</wd:empid>
      <wd:name>Buddi</wd:name>
      <wd:title>Executive, Call Center</wd:title>
      <wd:manager>Dimbu</wd:manager>
      <wd:tempno>1</wd:tempno>
      <wd:category>Peer/Stakeholder</wd:category>
      <wd:questionno>1</wd:questionno>
      <wd:response>&lt;p>&lt;span>Effectively summarizes information and provides relevant updates to stakeholders. Shares feedback constructively, motivating colleagues to improve performance.&lt;/span>&lt;/p></wd:response>
      <wd:date>2023-11-20</wd:date>
      <wd:score>0</wd:score>
   </wd:Report_Entry>
   <wd:Report_Entry>
      <wd:empid>123</wd:empid>
      <wd:name>Buddi</wd:name>
      <wd:title>Executive, Call Center</wd:title>
      <wd:manager>Dimbu</wd:manager>
      <wd:tempno>1</wd:tempno>
      <wd:category>Peer/Stakeholder</wd:category>
      <wd:questionno>2</wd:questionno>
      <wd:response>&lt;p>&lt;span>Has difficulty managing time effectively, leading to missed deadlines or rushed work. Has a tendency to rush work, resulting in lower quality outcomes.&lt;/span>&lt;/p></wd:response>
      <wd:date>2023-11-20</wd:date>
      <wd:score>0</wd:score>
   </wd:Report_Entry>
   <wd:Report_Entry>
      <wd:empid>123</wd:empid>
      <wd:name>Buddi</wd:name>
      <wd:title>Executive, Call Center</wd:title>
      <wd:manager>Dimbu</wd:manager>
      <wd:tempno>1</wd:tempno>
      <wd:category>Peer/Stakeholder</wd:category>
      <wd:questionno>1</wd:questionno>
      <wd:response>&lt;p>&lt;span>Feedback is an investment in each other, and peer accountability is a central tenet in Achieving Together. Thank you for giving this important responsibility the time and care it deserves! &lt;/span>&lt;/p>&lt;p>&lt;/p>&lt;p>&lt;span>This form should take approximately 15 minutes to complete. Please provide thoughtful (but concise) answers and target two to three full sentences for each question. DON’T write a novel, provide only cryptic bullets, or overthink it. DO be honest and respectful. And save your feedback responses frequently to avoid losing them!  &lt;/span>&lt;/p>&lt;p>&lt;b>&lt;span>Important notes about anonymity: &lt;/span>&lt;/b>&lt;span>&lt;b>&lt;span>Feedback you provide to your manager or peers/stakeholders will be aggregated with feedback from other respondents and &lt;i>&lt;u>shared verbatim but anonymously&lt;/u> &lt;/i>with the recipient. The manager of the feedback recipient will, however, see your attributed feedback. This is to better understand and convey helpful context to the colleague (if needed), while maintaining the feedback provider’s confidentiality. If you are a people-manager, the feedback you provide to your direct reports will &lt;i>not&lt;/i> be anonymous. &lt;/span>&lt;/b>&lt;/span>&lt;/p>&lt;p>&lt;b>&lt;span>&lt;/span>&lt;/b>&lt;/p>&lt;p>&lt;b>&lt;span>Declining to provide feedback. &lt;/span>&lt;/b>&lt;span>Under certain circumstances, declining to submit feedback for a specific recipient may be warranted. If, for example, you feel that you don’t have enough experience with the person to provide minimally helpful feedback and would like to cancel the request, please reach out to your People Partner to discuss.&lt;/span>&lt;/p>&lt;p>&lt;/p>&lt;p>&lt;span>Feedback is an investment in each other, and peer accountability is a central tenet in Achieving Together. Thank you for giving this important responsibility the time and care it deserves! &lt;/span>&lt;/p>&lt;p>&lt;/p>&lt;p>&lt;span>This form should take approximately 15 minutes to complete. Please provide thoughtful (but concise) answers and target two to three full sentences for each question. DON’T write a novel, provide only cryptic bullets, or overthink it. DO be honest and respectful. And save your feedback responses frequently to avoid losing them!  &lt;/span>&lt;/p>&lt;p>&lt;b>&lt;span>Important notes about anonymity: &lt;/span>&lt;/b>&lt;span>&lt;b>&lt;span>Feedback you provide to your manager or peers/stakeholders will be aggregated with feedback from other respondents and &lt;i>&lt;u>shared verbatim but anonymously&lt;/u> &lt;/i>with the recipient. The manager of the feedback recipient will, however, see your attributed feedback. This is to better understand and convey helpful context to the colleague (if needed), while maintaining the feedback provider’s confidentiality. If you are a people-manager, the feedback you provide to your direct reports will &lt;i>not&lt;/i> be anonymous. &lt;/span>&lt;/b>&lt;/span>&lt;/p>&lt;p>&lt;b>&lt;span>&lt;/span>&lt;/b>&lt;/p>&lt;p>&lt;b>&lt;span>Declining to provide feedback. &lt;/span>&lt;/b>&lt;span>Under certain circumstances, declining to submit feedback for a specific recipient may be warranted. If, for example, you feel that you don’t have enough experience with the person to provide minimally helpful feedback and would like to cancel the request, please reach out to your People Partner to discuss.&lt;/span>&lt;/p>&lt;p>&lt;/p>&lt;p>&lt;span>Feedback is an investment in each other, and peer accountability is a central tenet in Achieving Together. Thank you for giving this important responsibility the time and care it deserves! &lt;/span>&lt;/p>&lt;p>&lt;/p>&lt;p>&lt;span>This form should take approximately 15 minutes to complete. Please provide thoughtful (but concise) answers and target two to three full sentences for each question. DON’T write a novel, provide only cryptic bullets, or overthink it. DO be honest and respectful. And save your feedback responses frequently to avoid losing them!  &lt;/span>&lt;/p>&lt;p>&lt;b>&lt;span>Important notes about anonymity: &lt;/span>&lt;/b>&lt;span>&lt;b>&lt;span>Feedback you provide to your manager or peers/stakeholders will be aggregated with feedback from other respondents and &lt;i>&lt;u>shared verbatim but anonymously&lt;/u> &lt;/i>with the recipient. The manager of the feedback recipient will, however, see your attributed feedback. This is to better understand and convey helpful context to the colleague (if needed), while maintaining the feedback provider’s confidentiality. If you are a people-manager, the feedback you provide to your direct reports will &lt;i>not&lt;/i> be anonymous. &lt;/span>&lt;/b>&lt;/span>&lt;/p>&lt;p>&lt;b>&lt;span>&lt;/span>&lt;/b>&lt;/p>&lt;p>&lt;b>&lt;span>Declining to provide feedback. &lt;/span>&lt;/b>&lt;span>Under certain circumstances, declining to submit feedback for a specific recipient may be warranted. If, for example, you feel that you don’t have enough experience with the person to provide minimally helpful feedback and would like to cancel the request, please reach out to your People Partner to discuss.&lt;/span>&lt;/p>&lt;p>&lt;span>Feedback is an investment in each other, and peer accountability is a central tenet in Achieving Together. Thank you for giving this important responsibility the time and care it deserves! &lt;/span>&lt;/p>&lt;p>&lt;/p>&lt;p>&lt;span>This form should take approximately 15 minutes to complete. Please provide thoughtful (but concise) answers and target two to three full sentences for each question. DON’T write a novel, provide only cryptic bullets, or overthink it. DO be honest and respectful. And save your feedback responses frequently to avoid losing them!  &lt;/span>&lt;/p>&lt;p>&lt;b>&lt;span>Important notes about anonymity: &lt;/span>&lt;/b>&lt;span>&lt;b>&lt;span>Feedback you provide to your manager or peers/stakeholders will be aggregated with feedback from other respondents and &lt;i>&lt;u>shared verbatim but anonymously&lt;/u> &lt;/i>with the recipient. The manager of the feedback recipient will, however, see your attributed feedback. This is to better understand and convey helpful context to the colleague (if needed), while maintaining the feedback provider’s confidentiality. If you are a people-manager, the feedback you provide to your direct reports will &lt;i>not&lt;/i> be anonymous. &lt;/span>&lt;/b>&lt;/span>&lt;/p>&lt;p>&lt;b>&lt;span>&lt;/span>&lt;/b>&lt;/p>&lt;p>&lt;b>&lt;span>Declining to provide feedback. &lt;/span>&lt;/b>&lt;span>Under certain circumstances, declining to submit feedback for a specific recipient may be warranted. If, for example, you feel that you don’t have enough experience with the person to provide minimally helpful feedback and would like to cancel the request, please reach out to your People Partner to discuss.&lt;/span>&lt;/p>&lt;p>&lt;span>Feedback is an investment in each other, and peer accountability is a central tenet in Achieving Together. Thank you for giving this important responsibility the time and care it deserves! &lt;/span>&lt;/p>&lt;p>&lt;/p>&lt;p>&lt;span>This form should take approximately 15 minutes to complete. Please provide thoughtful (but concise) answers and target two to three full sentences for each question. DON’T write a novel, provide only cryptic bullets, or overthink it. DO be honest and respectful. And save your feedback responses frequently to avoid losing them!  &lt;/span>&lt;/p>&lt;p>&lt;b>&lt;span>Important notes about anonymity: &lt;/span>&lt;/b>&lt;span>&lt;b>&lt;span>Feedback you provide to your manager or peers/stakeholders will be aggregated with feedback from other respondents and &lt;i>&lt;u>shared verbatim but anonymously&lt;/u> &lt;/i>with the recipient. The manager of the feedback recipient will, however, see your attributed feedback. This is to better understand and convey helpful context to the colleague (if needed), while maintaining the feedback provider’s confidentiality. If you are a people-manager, the feedback you provide to your direct reports will &lt;i>not&lt;/i> be anonymous. &lt;/span>&lt;/b>&lt;/span>&lt;/p>&lt;p>&lt;b>&lt;span>&lt;/span>&lt;/b>&lt;/p>&lt;p>&lt;b>&lt;span>Declining to provide feedback. &lt;/span>&lt;/b>&lt;span>Under certain circumstances, declining to submit feedback for a specific recipient may be warranted. If, for example, you feel that you don’t have enough experience with the person to provide minimally helpful feedback and would like to cancel the request, please reach out to your People Partner to discuss.&lt;/span>&lt;/p>&lt;p>&lt;/p></wd:response>
      <wd:date>2023-11-21</wd:date>
      <wd:score>0</wd:score>
   </wd:Report_Entry>
   <wd:Report_Entry>
      <wd:empid>123</wd:empid>
      <wd:name>Buddi</wd:name>
      <wd:title>Executive, Call Center</wd:title>
      <wd:manager>Dimbu</wd:manager>
      <wd:tempno>1</wd:tempno>
      <wd:category>Peer/Stakeholder</wd:category>
      <wd:questionno>2</wd:questionno>
      <wd:response>&lt;p>test&lt;/p></wd:response>
      <wd:date>2023-11-21</wd:date>
      <wd:score>0</wd:score>
   </wd:Report_Entry>
   <wd:Report_Entry>
      <wd:empid>123</wd:empid>
      <wd:name>Buddi</wd:name>
      <wd:title>Executive, Call Center</wd:title>
      <wd:manager>Dimbu</wd:manager>
      <wd:tempno>1</wd:tempno>
      <wd:category>Direct Report</wd:category>
      <wd:questionno>1</wd:questionno>
      <wd:response>&lt;p>&lt;span>Effectively summarizes information and provides relevant updates to stakeholders. Demonstrates excellent organizational skills, keeping on top of multiple projects and responsibilities.&lt;/span>&lt;/p></wd:response>
      <wd:date>2023-11-20</wd:date>
      <wd:score>0</wd:score>
   </wd:Report_Entry>
   <wd:Report_Entry>
      <wd:empid>123</wd:empid>
      <wd:name>Buddi</wd:name>
      <wd:title>Executive, Call Center</wd:title>
      <wd:manager>Dimbu</wd:manager>
      <wd:tempno>1</wd:tempno>
      <wd:category>Direct Report</wd:category>
      <wd:questionno>2</wd:questionno>
      <wd:response>&lt;p>&lt;span>Has room for improvement in active listening skills and demonstrating empathy towards colleagues.&lt;/span>&lt;/p></wd:response>
      <wd:date>2023-11-20</wd:date>
      <wd:score>0</wd:score>
   </wd:Report_Entry>
   <wd:Report_Entry>
      <wd:empid>123</wd:empid>
      <wd:name>Buddi</wd:name>
      <wd:title>Executive, Call Center</wd:title>
      <wd:manager>Dimbu</wd:manager>
      <wd:tempno>1</wd:tempno>
      <wd:category>Peer/Stakeholder</wd:category>
      <wd:questionno>1</wd:questionno>
      <wd:response>&lt;p>&lt;span>Is a reliable team member, consistently meeting commitments and delivering high-quality work. Is committed to continuous improvement, regularly seeking feedback and making adjustments.&lt;/span>&lt;/p></wd:response>
      <wd:date>2023-11-20</wd:date>
      <wd:score>0</wd:score>
   </wd:Report_Entry>
   <wd:Report_Entry>
      <wd:empid>123</wd:empid>
      <wd:name>Buddi</wd:name>
      <wd:title>Executive, Call Center</wd:title>
      <wd:manager>Dimbu</wd:manager>
      <wd:tempno>1</wd:tempno>
      <wd:category>Peer/Stakeholder</wd:category>
      <wd:questionno>2</wd:questionno>
      <wd:response>&lt;p>&lt;span>Has a tendency to rush work, resulting in lower quality outcomes.&lt;/span>&lt;/p></wd:response>
      <wd:date>2023-11-20</wd:date>
      <wd:score>0</wd:score>
   </wd:Report_Entry>
   <wd:Report_Entry>
      <wd:empid>123</wd:empid>
      <wd:name>Buddi</wd:name>
      <wd:title>Executive, Call Center</wd:title>
      <wd:manager>Dimbu</wd:manager>
      <wd:tempno>1</wd:tempno>
      <wd:category>Direct Report</wd:category>
      <wd:questionno>1</wd:questionno>
      <wd:response>&lt;p>&lt;span>Shows pride in work, going above and beyond to ensure excellence. Takes responsibility for tasks and projects, ensuring they are completed on time and to the required standard.&lt;/span>&lt;/p></wd:response>
      <wd:date>2023-11-20</wd:date>
      <wd:score>0</wd:score>
   </wd:Report_Entry>
   <wd:Report_Entry>
      <wd:empid>123</wd:empid>
      <wd:name>Buddi</wd:name>
      <wd:title>Executive, Call Center</wd:title>
      <wd:manager>Dimbu</wd:manager>
      <wd:tempno>1</wd:tempno>
      <wd:category>Direct Report</wd:category>
      <wd:questionno>2</wd:questionno>
      <wd:response>&lt;p>&lt;span>Often requires a nudge to take the reins and identify opportunities for improvement.&lt;/span>&lt;/p></wd:response>
      <wd:date>2023-11-20</wd:date>
      <wd:score>0</wd:score>
   </wd:Report_Entry>
   <wd:Report_Entry>
      <wd:empid>123</wd:empid>
      <wd:name>Buddi</wd:name>
      <wd:title>Executive, Call Center</wd:title>
      <wd:manager>Dimbu</wd:manager>
      <wd:tempno>1</wd:tempno>
      <wd:category>Direct Report</wd:category>
      <wd:questionno>4</wd:questionno>
      <wd:response>6</wd:response>
      <wd:date>2023-11-20</wd:date>
      <wd:score>6</wd:score>
   </wd:Report_Entry>
</wd:Report_Data>

Here is xslt code, I tried it but not getting the dataresults for MRQ1, DRQ1,PSQ1,DRPSQ1,MRQ2, DRQ2,PSQ2,DRPSQ2.

<?xml version="1.0" encoding="UTF-8"?>
<xsl:stylesheet version="2.0"
    xmlns:xsl="http://www.w3.org/1999/XSL/Transform"
    xmlns:xsd="http://www.w3.org/2001/XMLSchema"
    xmlns:is="java:com.workday.esb.intsys.xpath.ParsedIntegrationSystemFunctions"
    xmlns:xdiff="urn:com.workday/esb/xdiff"
    xmlns:wd="urn:com.workday/bsvc">
    <xsl:output method="xml" indent="yes" omit-xml-declaration="no"/>
    <xsl:variable name="response" select="'Response'"/>
    <xsl:function name="wd:formatPSQ">
        <xsl:param name="psqValue"/>
        <xsl:param name="lastElement"/>
        <xsl:value-of select="concat('{\&quot;Response\&quot;:{\&quot;', $psqValue, '\&quot;}')"/>
        <xsl:if test="$lastElement = false()">
            <xsl:value-of select="','"/>
        </xsl:if>
    </xsl:function>
    <xsl:template match="/">
        <Report_Data>
            <xsl:apply-templates select="wd:Report_Data"/>
        </Report_Data>
    </xsl:template>
    <xsl:template match="wd:Report_Data">
        <xsl:for-each-group select="wd:Report_Entry" group-by="wd:empid">
            <Report_Entry>
                <empid>
                    <xsl:value-of select="wd:empid"/>
                </empid>
                <name>
                    <xsl:value-of select="wd:name"/>
                </name>
                <title>
                    <xsl:value-of select="wd:title"/>
                </title>
                <manager>
                    <xsl:value-of select="wd:manager"/>
                </manager>
                <tempno>
                    <xsl:value-of select="wd:tempno"/>
                </tempno>
                <MRQ1>
                    <xsl:if
                            test="(current-group()[wd:category = 'Manager' and wd:questionno = '1']/wd:response)">
                        <xsl:text>[</xsl:text>
                        <xsl:for-each
                                select="current-group()[wd:category = 'Manager' and wd:questionno = '1']">
                            <xsl:text>{"Response":"</xsl:text>
                            <xsl:value-of select="wd:response/*"/>
                            <xsl:text>"}</xsl:text>
                            <xsl:if test="position() != last()">,</xsl:if>
                        </xsl:for-each>
                        <xsl:text>]</xsl:text>
                    </xsl:if>
                </MRQ1>
                <DRQ1>
                    <xsl:if
                            test="(current-group()[wd:category = 'Direct Report' and wd:questionno = '1']/wd:response)">
                        <xsl:text>[</xsl:text>
                        <xsl:for-each
                                select="current-group()[wd:category = 'Direct Report' and wd:questionno = '1']">
                            <xsl:value-of
                                    select="wd:formatPSQ(wd:response/p, (position() = last()))"/>
                        </xsl:for-each>
                        <xsl:text>]</xsl:text>
                    </xsl:if>
                </DRQ1>
                <PSQ1>
                    <xsl:if
                            test="(current-group()[wd:category = 'Peer/Stakeholder' and wd:questionno = '1']/wd:response)">
                        <xsl:text>[</xsl:text>
                        <xsl:for-each
                                select="current-group()[wd:category = 'Peer/Stakeholder' and wd:questionno = '1']">
                            <xsl:text>{"Response":"</xsl:text>
                            <xsl:value-of select="wd:response/*"/>
                            <xsl:text>"}</xsl:text>
                            <xsl:if test="position() != last()">,</xsl:if>
                        </xsl:for-each>
                        <xsl:text>]</xsl:text>
                    </xsl:if>
                </PSQ1>
                <DRPSQ1>
                    <xsl:if
                            test="(current-group()[(wd:category = 'Peer/Stakeholder' or wd:category = 'Direct Report') and wd:questionno = '1']/wd:response)">
                        <xsl:text>[</xsl:text>
                        <xsl:for-each
                                select="current-group()[(wd:category = 'Peer/Stakeholder' or wd:category = 'Direct Report') and wd:questionno = '1']">
                            <xsl:text>{"Response":"</xsl:text>
                            <xsl:value-of select="wd:response/*"/>
                            <xsl:text>"}</xsl:text>
                            <xsl:if test="position() != last()">,</xsl:if>
                        </xsl:for-each>
                        <xsl:text>]</xsl:text>
                    </xsl:if>
                </DRPSQ1>
                <MRQ2>
                    <xsl:if
                            test="(current-group()[wd:category = 'Manager' and wd:questionno = '2']/wd:response)">
                        <xsl:text>[</xsl:text>
                        <xsl:for-each
                                select="current-group()[wd:category = 'Manager' and wd:questionno = '2']">
                            <xsl:text>{"Response":"</xsl:text>
                            <xsl:value-of select="wd:response/*"/>
                            <xsl:text>"}</xsl:text>
                            <xsl:if test="position() != last()">,</xsl:if>
                        </xsl:for-each>
                        <xsl:text>]</xsl:text>
                    </xsl:if>
                </MRQ2>
                <DRQ2>
                    <xsl:if
                            test="(current-group()[wd:category = 'Direct Report' and wd:questionno = '2']/wd:response)">
                        <xsl:text>[</xsl:text>
                        <xsl:for-each
                                select="current-group()[wd:category = 'Direct Report' and wd:questionno = '2']">
                            <xsl:value-of
                                    select="wd:formatPSQ(wd:response/p, (position() = last()))"/>
                        </xsl:for-each>
                        <xsl:text>]</xsl:text>
                    </xsl:if>
                </DRQ2>
                <PSQ2>
                    <xsl:if
                            test="(current-group()[wd:category = 'Peer/Stakeholder' and wd:questionno = '2']/wd:response)">
                        <xsl:text>[</xsl:text>
                        <xsl:for-each
                                select="current-group()[wd:category = 'Peer/Stakeholder' and wd:questionno = '2']">
                            <xsl:value-of
                                    select="wd:formatPSQ(wd:response/p, (position() = last()))"/>
                        </xsl:for-each>
                        <xsl:text>]</xsl:text>
                    </xsl:if>
                </PSQ2>
                <DRPSQ2>
                    <xsl:if
                            test="(current-group()[(wd:category = 'Peer/Stakeholder' or wd:category = 'Direct Report') and wd:questionno = '2']/wd:response)">
                        <xsl:text>[</xsl:text>
                        <xsl:for-each
                                select="current-group()[(wd:category = 'Peer/Stakeholder' or wd:category = 'Direct Report') and wd:questionno = '2']">
                            <xsl:value-of
                                    select="wd:formatPSQ(wd:response/p, (position() = last()))"/>
                        </xsl:for-each>
                        <xsl:text>]</xsl:text>
                    </xsl:if>
                </DRPSQ2>
            </Report_Entry>
        </xsl:for-each-group>
    </xsl:template>
</xsl:stylesheet>

Here is the sample expected results for an employee for PSQ1:

    <PSQ1>[
    {"Response": "You adopted a practical approach to problem-solving and building trust with others came easy to you"},
    {"Response": "Skillfully overcomes client objections. A loyal and trustworthy employee."},
    {"Response": "Takes initiative to identify and address challenges or opportunities withoutbeing prompted. Shows creativity and innovation in identifying new solutions or approaches to tasks and projects."}
]</PSQ1>

Solution

  • Try changing your code for PSQ1 to:

                <PSQ1>
                    <xsl:if
                            test="(current-group()[wd:category = 'Peer/Stakeholder' and wd:questionno = '1']/wd:response)">
                        <xsl:text>[</xsl:text>
                        <xsl:for-each
                                select="current-group()[wd:category = 'Peer/Stakeholder' and wd:questionno = '1']/parse-xml-fragment(wd:response)/p">
                            <xsl:text>{"Response":"</xsl:text>
                            <xsl:value-of select="."/>
                            <xsl:text>"}</xsl:text>
                            <xsl:if test="position() != last()">,</xsl:if>
                        </xsl:for-each>
                        <xsl:text>]</xsl:text>
                    </xsl:if>
                </PSQ1>
    

    and likewise for the other problematic areas.